babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197
  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. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17791. id: string;
  17792. /**
  17793. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17794. * @returns The render target texture if present otherwise, null
  17795. */
  17796. getShadowMap(): Nullable<RenderTargetTexture>;
  17797. /**
  17798. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17799. * @param subMesh The submesh we want to render in the shadow map
  17800. * @param useInstances Defines wether will draw in the map using instances
  17801. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17802. * @returns true if ready otherwise, false
  17803. */
  17804. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17805. /**
  17806. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17807. * @param defines Defines of the material we want to update
  17808. * @param lightIndex Index of the light in the enabled light list of the material
  17809. */
  17810. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17811. /**
  17812. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17813. * defined in the generator but impacting the effect).
  17814. * It implies the unifroms available on the materials are the standard BJS ones.
  17815. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17816. * @param effect The effect we are binfing the information for
  17817. */
  17818. bindShadowLight(lightIndex: string, effect: Effect): void;
  17819. /**
  17820. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17821. * (eq to shadow prjection matrix * light transform matrix)
  17822. * @returns The transform matrix used to create the shadow map
  17823. */
  17824. getTransformMatrix(): Matrix;
  17825. /**
  17826. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17827. * Cube and 2D textures for instance.
  17828. */
  17829. recreateShadowMap(): void;
  17830. /**
  17831. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17832. * @param onCompiled Callback triggered at the and of the effects compilation
  17833. * @param options Sets of optional options forcing the compilation with different modes
  17834. */
  17835. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17836. useInstances: boolean;
  17837. }>): void;
  17838. /**
  17839. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17840. * @param options Sets of optional options forcing the compilation with different modes
  17841. * @returns A promise that resolves when the compilation completes
  17842. */
  17843. forceCompilationAsync(options?: Partial<{
  17844. useInstances: boolean;
  17845. }>): Promise<void>;
  17846. /**
  17847. * Serializes the shadow generator setup to a json object.
  17848. * @returns The serialized JSON object
  17849. */
  17850. serialize(): any;
  17851. /**
  17852. * Disposes the Shadow map and related Textures and effects.
  17853. */
  17854. dispose(): void;
  17855. }
  17856. /**
  17857. * Default implementation IShadowGenerator.
  17858. * This is the main object responsible of generating shadows in the framework.
  17859. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17860. */
  17861. export class ShadowGenerator implements IShadowGenerator {
  17862. /**
  17863. * Name of the shadow generator class
  17864. */
  17865. static CLASSNAME: string;
  17866. /**
  17867. * Shadow generator mode None: no filtering applied.
  17868. */
  17869. static readonly FILTER_NONE: number;
  17870. /**
  17871. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17872. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17873. */
  17874. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17875. /**
  17876. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17877. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17878. */
  17879. static readonly FILTER_POISSONSAMPLING: number;
  17880. /**
  17881. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17882. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17883. */
  17884. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17885. /**
  17886. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17887. * edge artifacts on steep falloff.
  17888. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17889. */
  17890. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17891. /**
  17892. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17893. * edge artifacts on steep falloff.
  17894. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17895. */
  17896. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17897. /**
  17898. * Shadow generator mode PCF: Percentage Closer Filtering
  17899. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17900. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17901. */
  17902. static readonly FILTER_PCF: number;
  17903. /**
  17904. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17905. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17906. * Contact Hardening
  17907. */
  17908. static readonly FILTER_PCSS: number;
  17909. /**
  17910. * Reserved for PCF and PCSS
  17911. * Highest Quality.
  17912. *
  17913. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17914. *
  17915. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17916. */
  17917. static readonly QUALITY_HIGH: number;
  17918. /**
  17919. * Reserved for PCF and PCSS
  17920. * Good tradeoff for quality/perf cross devices
  17921. *
  17922. * Execute PCF on a 3*3 kernel.
  17923. *
  17924. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17925. */
  17926. static readonly QUALITY_MEDIUM: number;
  17927. /**
  17928. * Reserved for PCF and PCSS
  17929. * The lowest quality but the fastest.
  17930. *
  17931. * Execute PCF on a 1*1 kernel.
  17932. *
  17933. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17934. */
  17935. static readonly QUALITY_LOW: number;
  17936. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17937. id: string;
  17938. /** Gets or sets the custom shader name to use */
  17939. customShaderOptions: ICustomShaderOptions;
  17940. /**
  17941. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17942. */
  17943. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17944. /**
  17945. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17946. */
  17947. onAfterShadowMapRenderObservable: Observable<Effect>;
  17948. /**
  17949. * Observable triggered before a mesh is rendered in the shadow map.
  17950. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17951. */
  17952. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17953. /**
  17954. * Observable triggered after a mesh is rendered in the shadow map.
  17955. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17956. */
  17957. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17958. protected _bias: number;
  17959. /**
  17960. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17961. */
  17962. get bias(): number;
  17963. /**
  17964. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17965. */
  17966. set bias(bias: number);
  17967. protected _normalBias: number;
  17968. /**
  17969. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17970. */
  17971. get normalBias(): number;
  17972. /**
  17973. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17974. */
  17975. set normalBias(normalBias: number);
  17976. protected _blurBoxOffset: number;
  17977. /**
  17978. * Gets the blur box offset: offset applied during the blur pass.
  17979. * Only useful if useKernelBlur = false
  17980. */
  17981. get blurBoxOffset(): number;
  17982. /**
  17983. * Sets the blur box offset: offset applied during the blur pass.
  17984. * Only useful if useKernelBlur = false
  17985. */
  17986. set blurBoxOffset(value: number);
  17987. protected _blurScale: number;
  17988. /**
  17989. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17990. * 2 means half of the size.
  17991. */
  17992. get blurScale(): number;
  17993. /**
  17994. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17995. * 2 means half of the size.
  17996. */
  17997. set blurScale(value: number);
  17998. protected _blurKernel: number;
  17999. /**
  18000. * Gets the blur kernel: kernel size of the blur pass.
  18001. * Only useful if useKernelBlur = true
  18002. */
  18003. get blurKernel(): number;
  18004. /**
  18005. * Sets the blur kernel: kernel size of the blur pass.
  18006. * Only useful if useKernelBlur = true
  18007. */
  18008. set blurKernel(value: number);
  18009. protected _useKernelBlur: boolean;
  18010. /**
  18011. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18012. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18013. */
  18014. get useKernelBlur(): boolean;
  18015. /**
  18016. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18017. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18018. */
  18019. set useKernelBlur(value: boolean);
  18020. protected _depthScale: number;
  18021. /**
  18022. * Gets the depth scale used in ESM mode.
  18023. */
  18024. get depthScale(): number;
  18025. /**
  18026. * Sets the depth scale used in ESM mode.
  18027. * This can override the scale stored on the light.
  18028. */
  18029. set depthScale(value: number);
  18030. protected _validateFilter(filter: number): number;
  18031. protected _filter: number;
  18032. /**
  18033. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18034. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18035. */
  18036. get filter(): number;
  18037. /**
  18038. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18039. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18040. */
  18041. set filter(value: number);
  18042. /**
  18043. * Gets if the current filter is set to Poisson Sampling.
  18044. */
  18045. get usePoissonSampling(): boolean;
  18046. /**
  18047. * Sets the current filter to Poisson Sampling.
  18048. */
  18049. set usePoissonSampling(value: boolean);
  18050. /**
  18051. * Gets if the current filter is set to ESM.
  18052. */
  18053. get useExponentialShadowMap(): boolean;
  18054. /**
  18055. * Sets the current filter is to ESM.
  18056. */
  18057. set useExponentialShadowMap(value: boolean);
  18058. /**
  18059. * Gets if the current filter is set to filtered ESM.
  18060. */
  18061. get useBlurExponentialShadowMap(): boolean;
  18062. /**
  18063. * Gets if the current filter is set to filtered ESM.
  18064. */
  18065. set useBlurExponentialShadowMap(value: boolean);
  18066. /**
  18067. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18068. * exponential to prevent steep falloff artifacts).
  18069. */
  18070. get useCloseExponentialShadowMap(): boolean;
  18071. /**
  18072. * Sets the current filter to "close ESM" (using the inverse of the
  18073. * exponential to prevent steep falloff artifacts).
  18074. */
  18075. set useCloseExponentialShadowMap(value: boolean);
  18076. /**
  18077. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18078. * exponential to prevent steep falloff artifacts).
  18079. */
  18080. get useBlurCloseExponentialShadowMap(): boolean;
  18081. /**
  18082. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18083. * exponential to prevent steep falloff artifacts).
  18084. */
  18085. set useBlurCloseExponentialShadowMap(value: boolean);
  18086. /**
  18087. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18088. */
  18089. get usePercentageCloserFiltering(): boolean;
  18090. /**
  18091. * Sets the current filter to "PCF" (percentage closer filtering).
  18092. */
  18093. set usePercentageCloserFiltering(value: boolean);
  18094. protected _filteringQuality: number;
  18095. /**
  18096. * Gets the PCF or PCSS Quality.
  18097. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18098. */
  18099. get filteringQuality(): number;
  18100. /**
  18101. * Sets the PCF or PCSS Quality.
  18102. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18103. */
  18104. set filteringQuality(filteringQuality: number);
  18105. /**
  18106. * Gets if the current filter is set to "PCSS" (contact hardening).
  18107. */
  18108. get useContactHardeningShadow(): boolean;
  18109. /**
  18110. * Sets the current filter to "PCSS" (contact hardening).
  18111. */
  18112. set useContactHardeningShadow(value: boolean);
  18113. protected _contactHardeningLightSizeUVRatio: number;
  18114. /**
  18115. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18116. * Using a ratio helps keeping shape stability independently of the map size.
  18117. *
  18118. * It does not account for the light projection as it was having too much
  18119. * instability during the light setup or during light position changes.
  18120. *
  18121. * Only valid if useContactHardeningShadow is true.
  18122. */
  18123. get contactHardeningLightSizeUVRatio(): number;
  18124. /**
  18125. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18126. * Using a ratio helps keeping shape stability independently of the map size.
  18127. *
  18128. * It does not account for the light projection as it was having too much
  18129. * instability during the light setup or during light position changes.
  18130. *
  18131. * Only valid if useContactHardeningShadow is true.
  18132. */
  18133. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18134. protected _darkness: number;
  18135. /** Gets or sets the actual darkness of a shadow */
  18136. get darkness(): number;
  18137. set darkness(value: number);
  18138. /**
  18139. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18140. * 0 means strongest and 1 would means no shadow.
  18141. * @returns the darkness.
  18142. */
  18143. getDarkness(): number;
  18144. /**
  18145. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18146. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18147. * @returns the shadow generator allowing fluent coding.
  18148. */
  18149. setDarkness(darkness: number): ShadowGenerator;
  18150. protected _transparencyShadow: boolean;
  18151. /** Gets or sets the ability to have transparent shadow */
  18152. get transparencyShadow(): boolean;
  18153. set transparencyShadow(value: boolean);
  18154. /**
  18155. * Sets the ability to have transparent shadow (boolean).
  18156. * @param transparent True if transparent else False
  18157. * @returns the shadow generator allowing fluent coding
  18158. */
  18159. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18160. /**
  18161. * Enables or disables shadows with varying strength based on the transparency
  18162. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18163. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18164. * mesh.visibility * alphaTexture.a
  18165. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18166. */
  18167. enableSoftTransparentShadow: boolean;
  18168. protected _shadowMap: Nullable<RenderTargetTexture>;
  18169. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18170. /**
  18171. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18172. * @returns The render target texture if present otherwise, null
  18173. */
  18174. getShadowMap(): Nullable<RenderTargetTexture>;
  18175. /**
  18176. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18177. * @returns The render target texture if the shadow map is present otherwise, null
  18178. */
  18179. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18180. /**
  18181. * Gets the class name of that object
  18182. * @returns "ShadowGenerator"
  18183. */
  18184. getClassName(): string;
  18185. /**
  18186. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18187. * @param mesh Mesh to add
  18188. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18189. * @returns the Shadow Generator itself
  18190. */
  18191. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18192. /**
  18193. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18194. * @param mesh Mesh to remove
  18195. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18196. * @returns the Shadow Generator itself
  18197. */
  18198. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18199. /**
  18200. * Controls the extent to which the shadows fade out at the edge of the frustum
  18201. */
  18202. frustumEdgeFalloff: number;
  18203. protected _light: IShadowLight;
  18204. /**
  18205. * Returns the associated light object.
  18206. * @returns the light generating the shadow
  18207. */
  18208. getLight(): IShadowLight;
  18209. /**
  18210. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18211. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18212. * It might on the other hand introduce peter panning.
  18213. */
  18214. forceBackFacesOnly: boolean;
  18215. protected _scene: Scene;
  18216. protected _lightDirection: Vector3;
  18217. protected _effect: Effect;
  18218. protected _viewMatrix: Matrix;
  18219. protected _projectionMatrix: Matrix;
  18220. protected _transformMatrix: Matrix;
  18221. protected _cachedPosition: Vector3;
  18222. protected _cachedDirection: Vector3;
  18223. protected _cachedDefines: string;
  18224. protected _currentRenderID: number;
  18225. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18226. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18227. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18228. protected _blurPostProcesses: PostProcess[];
  18229. protected _mapSize: number;
  18230. protected _currentFaceIndex: number;
  18231. protected _currentFaceIndexCache: number;
  18232. protected _textureType: number;
  18233. protected _defaultTextureMatrix: Matrix;
  18234. protected _storedUniqueId: Nullable<number>;
  18235. /** @hidden */
  18236. static _SceneComponentInitialization: (scene: Scene) => void;
  18237. /**
  18238. * Creates a ShadowGenerator object.
  18239. * A ShadowGenerator is the required tool to use the shadows.
  18240. * Each light casting shadows needs to use its own ShadowGenerator.
  18241. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18242. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18243. * @param light The light object generating the shadows.
  18244. * @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.
  18245. */
  18246. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18247. protected _initializeGenerator(): void;
  18248. protected _createTargetRenderTexture(): void;
  18249. protected _initializeShadowMap(): void;
  18250. protected _initializeBlurRTTAndPostProcesses(): void;
  18251. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18252. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18253. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18254. protected _applyFilterValues(): void;
  18255. /**
  18256. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18257. * @param onCompiled Callback triggered at the and of the effects compilation
  18258. * @param options Sets of optional options forcing the compilation with different modes
  18259. */
  18260. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18261. useInstances: boolean;
  18262. }>): void;
  18263. /**
  18264. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18265. * @param options Sets of optional options forcing the compilation with different modes
  18266. * @returns A promise that resolves when the compilation completes
  18267. */
  18268. forceCompilationAsync(options?: Partial<{
  18269. useInstances: boolean;
  18270. }>): Promise<void>;
  18271. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18272. private _prepareShadowDefines;
  18273. /**
  18274. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18275. * @param subMesh The submesh we want to render in the shadow map
  18276. * @param useInstances Defines wether will draw in the map using instances
  18277. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18278. * @returns true if ready otherwise, false
  18279. */
  18280. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18281. /**
  18282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18283. * @param defines Defines of the material we want to update
  18284. * @param lightIndex Index of the light in the enabled light list of the material
  18285. */
  18286. prepareDefines(defines: any, lightIndex: number): void;
  18287. /**
  18288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18289. * defined in the generator but impacting the effect).
  18290. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18291. * @param effect The effect we are binfing the information for
  18292. */
  18293. bindShadowLight(lightIndex: string, effect: Effect): void;
  18294. /**
  18295. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18296. * (eq to shadow prjection matrix * light transform matrix)
  18297. * @returns The transform matrix used to create the shadow map
  18298. */
  18299. getTransformMatrix(): Matrix;
  18300. /**
  18301. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18302. * Cube and 2D textures for instance.
  18303. */
  18304. recreateShadowMap(): void;
  18305. protected _disposeBlurPostProcesses(): void;
  18306. protected _disposeRTTandPostProcesses(): void;
  18307. /**
  18308. * Disposes the ShadowGenerator.
  18309. * Returns nothing.
  18310. */
  18311. dispose(): void;
  18312. /**
  18313. * Serializes the shadow generator setup to a json object.
  18314. * @returns The serialized JSON object
  18315. */
  18316. serialize(): any;
  18317. /**
  18318. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18319. * @param parsedShadowGenerator The JSON object to parse
  18320. * @param scene The scene to create the shadow map for
  18321. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18322. * @returns The parsed shadow generator
  18323. */
  18324. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18325. }
  18326. }
  18327. declare module "babylonjs/Lights/light" {
  18328. import { Nullable } from "babylonjs/types";
  18329. import { Scene } from "babylonjs/scene";
  18330. import { Vector3 } from "babylonjs/Maths/math.vector";
  18331. import { Color3 } from "babylonjs/Maths/math.color";
  18332. import { Node } from "babylonjs/node";
  18333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18334. import { Effect } from "babylonjs/Materials/effect";
  18335. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18336. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18337. /**
  18338. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18339. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18340. * 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.
  18341. */
  18342. export abstract class Light extends Node {
  18343. /**
  18344. * Falloff Default: light is falling off following the material specification:
  18345. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18346. */
  18347. static readonly FALLOFF_DEFAULT: number;
  18348. /**
  18349. * Falloff Physical: light is falling off following the inverse squared distance law.
  18350. */
  18351. static readonly FALLOFF_PHYSICAL: number;
  18352. /**
  18353. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18354. * to enhance interoperability with other engines.
  18355. */
  18356. static readonly FALLOFF_GLTF: number;
  18357. /**
  18358. * Falloff Standard: light is falling off like in the standard material
  18359. * to enhance interoperability with other materials.
  18360. */
  18361. static readonly FALLOFF_STANDARD: number;
  18362. /**
  18363. * If every light affecting the material is in this lightmapMode,
  18364. * material.lightmapTexture adds or multiplies
  18365. * (depends on material.useLightmapAsShadowmap)
  18366. * after every other light calculations.
  18367. */
  18368. static readonly LIGHTMAP_DEFAULT: number;
  18369. /**
  18370. * material.lightmapTexture as only diffuse lighting from this light
  18371. * adds only specular lighting from this light
  18372. * adds dynamic shadows
  18373. */
  18374. static readonly LIGHTMAP_SPECULAR: number;
  18375. /**
  18376. * material.lightmapTexture as only lighting
  18377. * no light calculation from this light
  18378. * only adds dynamic shadows from this light
  18379. */
  18380. static readonly LIGHTMAP_SHADOWSONLY: number;
  18381. /**
  18382. * Each light type uses the default quantity according to its type:
  18383. * point/spot lights use luminous intensity
  18384. * directional lights use illuminance
  18385. */
  18386. static readonly INTENSITYMODE_AUTOMATIC: number;
  18387. /**
  18388. * lumen (lm)
  18389. */
  18390. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18391. /**
  18392. * candela (lm/sr)
  18393. */
  18394. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18395. /**
  18396. * lux (lm/m^2)
  18397. */
  18398. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18399. /**
  18400. * nit (cd/m^2)
  18401. */
  18402. static readonly INTENSITYMODE_LUMINANCE: number;
  18403. /**
  18404. * Light type const id of the point light.
  18405. */
  18406. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18407. /**
  18408. * Light type const id of the directional light.
  18409. */
  18410. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18411. /**
  18412. * Light type const id of the spot light.
  18413. */
  18414. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18415. /**
  18416. * Light type const id of the hemispheric light.
  18417. */
  18418. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18419. /**
  18420. * Diffuse gives the basic color to an object.
  18421. */
  18422. diffuse: Color3;
  18423. /**
  18424. * Specular produces a highlight color on an object.
  18425. * Note: This is note affecting PBR materials.
  18426. */
  18427. specular: Color3;
  18428. /**
  18429. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18430. * falling off base on range or angle.
  18431. * This can be set to any values in Light.FALLOFF_x.
  18432. *
  18433. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18434. * other types of materials.
  18435. */
  18436. falloffType: number;
  18437. /**
  18438. * Strength of the light.
  18439. * Note: By default it is define in the framework own unit.
  18440. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18441. */
  18442. intensity: number;
  18443. private _range;
  18444. protected _inverseSquaredRange: number;
  18445. /**
  18446. * Defines how far from the source the light is impacting in scene units.
  18447. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18448. */
  18449. get range(): number;
  18450. /**
  18451. * Defines how far from the source the light is impacting in scene units.
  18452. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18453. */
  18454. set range(value: number);
  18455. /**
  18456. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18457. * of light.
  18458. */
  18459. private _photometricScale;
  18460. private _intensityMode;
  18461. /**
  18462. * Gets the photometric scale used to interpret the intensity.
  18463. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18464. */
  18465. get intensityMode(): number;
  18466. /**
  18467. * Sets the photometric scale used to interpret the intensity.
  18468. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18469. */
  18470. set intensityMode(value: number);
  18471. private _radius;
  18472. /**
  18473. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18474. */
  18475. get radius(): number;
  18476. /**
  18477. * sets the light radius used by PBR Materials to simulate soft area lights.
  18478. */
  18479. set radius(value: number);
  18480. private _renderPriority;
  18481. /**
  18482. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18483. * exceeding the number allowed of the materials.
  18484. */
  18485. renderPriority: number;
  18486. private _shadowEnabled;
  18487. /**
  18488. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18489. * the current shadow generator.
  18490. */
  18491. get shadowEnabled(): boolean;
  18492. /**
  18493. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18494. * the current shadow generator.
  18495. */
  18496. set shadowEnabled(value: boolean);
  18497. private _includedOnlyMeshes;
  18498. /**
  18499. * Gets the only meshes impacted by this light.
  18500. */
  18501. get includedOnlyMeshes(): AbstractMesh[];
  18502. /**
  18503. * Sets the only meshes impacted by this light.
  18504. */
  18505. set includedOnlyMeshes(value: AbstractMesh[]);
  18506. private _excludedMeshes;
  18507. /**
  18508. * Gets the meshes not impacted by this light.
  18509. */
  18510. get excludedMeshes(): AbstractMesh[];
  18511. /**
  18512. * Sets the meshes not impacted by this light.
  18513. */
  18514. set excludedMeshes(value: AbstractMesh[]);
  18515. private _excludeWithLayerMask;
  18516. /**
  18517. * Gets the layer id use to find what meshes are not impacted by the light.
  18518. * Inactive if 0
  18519. */
  18520. get excludeWithLayerMask(): number;
  18521. /**
  18522. * Sets the layer id use to find what meshes are not impacted by the light.
  18523. * Inactive if 0
  18524. */
  18525. set excludeWithLayerMask(value: number);
  18526. private _includeOnlyWithLayerMask;
  18527. /**
  18528. * Gets the layer id use to find what meshes are impacted by the light.
  18529. * Inactive if 0
  18530. */
  18531. get includeOnlyWithLayerMask(): number;
  18532. /**
  18533. * Sets the layer id use to find what meshes are impacted by the light.
  18534. * Inactive if 0
  18535. */
  18536. set includeOnlyWithLayerMask(value: number);
  18537. private _lightmapMode;
  18538. /**
  18539. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18540. */
  18541. get lightmapMode(): number;
  18542. /**
  18543. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18544. */
  18545. set lightmapMode(value: number);
  18546. /**
  18547. * Shadow generator associted to the light.
  18548. * @hidden Internal use only.
  18549. */
  18550. _shadowGenerator: Nullable<IShadowGenerator>;
  18551. /**
  18552. * @hidden Internal use only.
  18553. */
  18554. _excludedMeshesIds: string[];
  18555. /**
  18556. * @hidden Internal use only.
  18557. */
  18558. _includedOnlyMeshesIds: string[];
  18559. /**
  18560. * The current light unifom buffer.
  18561. * @hidden Internal use only.
  18562. */
  18563. _uniformBuffer: UniformBuffer;
  18564. /** @hidden */
  18565. _renderId: number;
  18566. /**
  18567. * Creates a Light object in the scene.
  18568. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18569. * @param name The firendly name of the light
  18570. * @param scene The scene the light belongs too
  18571. */
  18572. constructor(name: string, scene: Scene);
  18573. protected abstract _buildUniformLayout(): void;
  18574. /**
  18575. * Sets the passed Effect "effect" with the Light information.
  18576. * @param effect The effect to update
  18577. * @param lightIndex The index of the light in the effect to update
  18578. * @returns The light
  18579. */
  18580. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18581. /**
  18582. * Sets the passed Effect "effect" with the Light textures.
  18583. * @param effect The effect to update
  18584. * @param lightIndex The index of the light in the effect to update
  18585. * @returns The light
  18586. */
  18587. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18588. /**
  18589. * Binds the lights information from the scene to the effect for the given mesh.
  18590. * @param lightIndex Light index
  18591. * @param scene The scene where the light belongs to
  18592. * @param effect The effect we are binding the data to
  18593. * @param useSpecular Defines if specular is supported
  18594. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18595. */
  18596. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18597. /**
  18598. * Sets the passed Effect "effect" with the Light information.
  18599. * @param effect The effect to update
  18600. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18601. * @returns The light
  18602. */
  18603. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18604. /**
  18605. * Returns the string "Light".
  18606. * @returns the class name
  18607. */
  18608. getClassName(): string;
  18609. /** @hidden */
  18610. readonly _isLight: boolean;
  18611. /**
  18612. * Converts the light information to a readable string for debug purpose.
  18613. * @param fullDetails Supports for multiple levels of logging within scene loading
  18614. * @returns the human readable light info
  18615. */
  18616. toString(fullDetails?: boolean): string;
  18617. /** @hidden */
  18618. protected _syncParentEnabledState(): void;
  18619. /**
  18620. * Set the enabled state of this node.
  18621. * @param value - the new enabled state
  18622. */
  18623. setEnabled(value: boolean): void;
  18624. /**
  18625. * Returns the Light associated shadow generator if any.
  18626. * @return the associated shadow generator.
  18627. */
  18628. getShadowGenerator(): Nullable<IShadowGenerator>;
  18629. /**
  18630. * Returns a Vector3, the absolute light position in the World.
  18631. * @returns the world space position of the light
  18632. */
  18633. getAbsolutePosition(): Vector3;
  18634. /**
  18635. * Specifies if the light will affect the passed mesh.
  18636. * @param mesh The mesh to test against the light
  18637. * @return true the mesh is affected otherwise, false.
  18638. */
  18639. canAffectMesh(mesh: AbstractMesh): boolean;
  18640. /**
  18641. * Sort function to order lights for rendering.
  18642. * @param a First Light object to compare to second.
  18643. * @param b Second Light object to compare first.
  18644. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18645. */
  18646. static CompareLightsPriority(a: Light, b: Light): number;
  18647. /**
  18648. * Releases resources associated with this node.
  18649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18651. */
  18652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18653. /**
  18654. * Returns the light type ID (integer).
  18655. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18656. */
  18657. getTypeID(): number;
  18658. /**
  18659. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18660. * @returns the scaled intensity in intensity mode unit
  18661. */
  18662. getScaledIntensity(): number;
  18663. /**
  18664. * Returns a new Light object, named "name", from the current one.
  18665. * @param name The name of the cloned light
  18666. * @param newParent The parent of this light, if it has one
  18667. * @returns the new created light
  18668. */
  18669. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18670. /**
  18671. * Serializes the current light into a Serialization object.
  18672. * @returns the serialized object.
  18673. */
  18674. serialize(): any;
  18675. /**
  18676. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18677. * This new light is named "name" and added to the passed scene.
  18678. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18679. * @param name The friendly name of the light
  18680. * @param scene The scene the new light will belong to
  18681. * @returns the constructor function
  18682. */
  18683. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18684. /**
  18685. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18686. * @param parsedLight The JSON representation of the light
  18687. * @param scene The scene to create the parsed light in
  18688. * @returns the created light after parsing
  18689. */
  18690. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18691. private _hookArrayForExcluded;
  18692. private _hookArrayForIncludedOnly;
  18693. private _resyncMeshes;
  18694. /**
  18695. * Forces the meshes to update their light related information in their rendering used effects
  18696. * @hidden Internal Use Only
  18697. */
  18698. _markMeshesAsLightDirty(): void;
  18699. /**
  18700. * Recomputes the cached photometric scale if needed.
  18701. */
  18702. private _computePhotometricScale;
  18703. /**
  18704. * Returns the Photometric Scale according to the light type and intensity mode.
  18705. */
  18706. private _getPhotometricScale;
  18707. /**
  18708. * Reorder the light in the scene according to their defined priority.
  18709. * @hidden Internal Use Only
  18710. */
  18711. _reorderLightsInScene(): void;
  18712. /**
  18713. * Prepares the list of defines specific to the light type.
  18714. * @param defines the list of defines
  18715. * @param lightIndex defines the index of the light for the effect
  18716. */
  18717. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18718. }
  18719. }
  18720. declare module "babylonjs/Cameras/targetCamera" {
  18721. import { Nullable } from "babylonjs/types";
  18722. import { Camera } from "babylonjs/Cameras/camera";
  18723. import { Scene } from "babylonjs/scene";
  18724. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18725. /**
  18726. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18727. * This is the base of the follow, arc rotate cameras and Free camera
  18728. * @see https://doc.babylonjs.com/features/cameras
  18729. */
  18730. export class TargetCamera extends Camera {
  18731. private static _RigCamTransformMatrix;
  18732. private static _TargetTransformMatrix;
  18733. private static _TargetFocalPoint;
  18734. private _tmpUpVector;
  18735. private _tmpTargetVector;
  18736. /**
  18737. * Define the current direction the camera is moving to
  18738. */
  18739. cameraDirection: Vector3;
  18740. /**
  18741. * Define the current rotation the camera is rotating to
  18742. */
  18743. cameraRotation: Vector2;
  18744. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18745. ignoreParentScaling: boolean;
  18746. /**
  18747. * When set, the up vector of the camera will be updated by the rotation of the camera
  18748. */
  18749. updateUpVectorFromRotation: boolean;
  18750. private _tmpQuaternion;
  18751. /**
  18752. * Define the current rotation of the camera
  18753. */
  18754. rotation: Vector3;
  18755. /**
  18756. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18757. */
  18758. rotationQuaternion: Quaternion;
  18759. /**
  18760. * Define the current speed of the camera
  18761. */
  18762. speed: number;
  18763. /**
  18764. * Add constraint to the camera to prevent it to move freely in all directions and
  18765. * around all axis.
  18766. */
  18767. noRotationConstraint: boolean;
  18768. /**
  18769. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18770. * panning
  18771. */
  18772. invertRotation: boolean;
  18773. /**
  18774. * Speed multiplier for inverse camera panning
  18775. */
  18776. inverseRotationSpeed: number;
  18777. /**
  18778. * Define the current target of the camera as an object or a position.
  18779. */
  18780. lockedTarget: any;
  18781. /** @hidden */
  18782. _currentTarget: Vector3;
  18783. /** @hidden */
  18784. _initialFocalDistance: number;
  18785. /** @hidden */
  18786. _viewMatrix: Matrix;
  18787. /** @hidden */
  18788. _camMatrix: Matrix;
  18789. /** @hidden */
  18790. _cameraTransformMatrix: Matrix;
  18791. /** @hidden */
  18792. _cameraRotationMatrix: Matrix;
  18793. /** @hidden */
  18794. _referencePoint: Vector3;
  18795. /** @hidden */
  18796. _transformedReferencePoint: Vector3;
  18797. /** @hidden */
  18798. _reset: () => void;
  18799. private _defaultUp;
  18800. /**
  18801. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18802. * This is the base of the follow, arc rotate cameras and Free camera
  18803. * @see https://doc.babylonjs.com/features/cameras
  18804. * @param name Defines the name of the camera in the scene
  18805. * @param position Defines the start position of the camera in the scene
  18806. * @param scene Defines the scene the camera belongs to
  18807. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18808. */
  18809. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18810. /**
  18811. * Gets the position in front of the camera at a given distance.
  18812. * @param distance The distance from the camera we want the position to be
  18813. * @returns the position
  18814. */
  18815. getFrontPosition(distance: number): Vector3;
  18816. /** @hidden */
  18817. _getLockedTargetPosition(): Nullable<Vector3>;
  18818. private _storedPosition;
  18819. private _storedRotation;
  18820. private _storedRotationQuaternion;
  18821. /**
  18822. * Store current camera state of the camera (fov, position, rotation, etc..)
  18823. * @returns the camera
  18824. */
  18825. storeState(): Camera;
  18826. /**
  18827. * Restored camera state. You must call storeState() first
  18828. * @returns whether it was successful or not
  18829. * @hidden
  18830. */
  18831. _restoreStateValues(): boolean;
  18832. /** @hidden */
  18833. _initCache(): void;
  18834. /** @hidden */
  18835. _updateCache(ignoreParentClass?: boolean): void;
  18836. /** @hidden */
  18837. _isSynchronizedViewMatrix(): boolean;
  18838. /** @hidden */
  18839. _computeLocalCameraSpeed(): number;
  18840. /**
  18841. * Defines the target the camera should look at.
  18842. * @param target Defines the new target as a Vector or a mesh
  18843. */
  18844. setTarget(target: Vector3): void;
  18845. /**
  18846. * Return the current target position of the camera. This value is expressed in local space.
  18847. * @returns the target position
  18848. */
  18849. getTarget(): Vector3;
  18850. /** @hidden */
  18851. _decideIfNeedsToMove(): boolean;
  18852. /** @hidden */
  18853. _updatePosition(): void;
  18854. /** @hidden */
  18855. _checkInputs(): void;
  18856. protected _updateCameraRotationMatrix(): void;
  18857. /**
  18858. * 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)
  18859. * @returns the current camera
  18860. */
  18861. private _rotateUpVectorWithCameraRotationMatrix;
  18862. private _cachedRotationZ;
  18863. private _cachedQuaternionRotationZ;
  18864. /** @hidden */
  18865. _getViewMatrix(): Matrix;
  18866. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18867. /**
  18868. * @hidden
  18869. */
  18870. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18871. /**
  18872. * @hidden
  18873. */
  18874. _updateRigCameras(): void;
  18875. private _getRigCamPositionAndTarget;
  18876. /**
  18877. * Gets the current object class name.
  18878. * @return the class name
  18879. */
  18880. getClassName(): string;
  18881. }
  18882. }
  18883. declare module "babylonjs/Events/keyboardEvents" {
  18884. /**
  18885. * Gather the list of keyboard event types as constants.
  18886. */
  18887. export class KeyboardEventTypes {
  18888. /**
  18889. * The keydown event is fired when a key becomes active (pressed).
  18890. */
  18891. static readonly KEYDOWN: number;
  18892. /**
  18893. * The keyup event is fired when a key has been released.
  18894. */
  18895. static readonly KEYUP: number;
  18896. }
  18897. /**
  18898. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18899. */
  18900. export class KeyboardInfo {
  18901. /**
  18902. * Defines the type of event (KeyboardEventTypes)
  18903. */
  18904. type: number;
  18905. /**
  18906. * Defines the related dom event
  18907. */
  18908. event: KeyboardEvent;
  18909. /**
  18910. * Instantiates a new keyboard info.
  18911. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18912. * @param type Defines the type of event (KeyboardEventTypes)
  18913. * @param event Defines the related dom event
  18914. */
  18915. constructor(
  18916. /**
  18917. * Defines the type of event (KeyboardEventTypes)
  18918. */
  18919. type: number,
  18920. /**
  18921. * Defines the related dom event
  18922. */
  18923. event: KeyboardEvent);
  18924. }
  18925. /**
  18926. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18927. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18928. */
  18929. export class KeyboardInfoPre extends KeyboardInfo {
  18930. /**
  18931. * Defines the type of event (KeyboardEventTypes)
  18932. */
  18933. type: number;
  18934. /**
  18935. * Defines the related dom event
  18936. */
  18937. event: KeyboardEvent;
  18938. /**
  18939. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18940. */
  18941. skipOnPointerObservable: boolean;
  18942. /**
  18943. * Instantiates a new keyboard pre info.
  18944. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18945. * @param type Defines the type of event (KeyboardEventTypes)
  18946. * @param event Defines the related dom event
  18947. */
  18948. constructor(
  18949. /**
  18950. * Defines the type of event (KeyboardEventTypes)
  18951. */
  18952. type: number,
  18953. /**
  18954. * Defines the related dom event
  18955. */
  18956. event: KeyboardEvent);
  18957. }
  18958. }
  18959. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18960. import { Nullable } from "babylonjs/types";
  18961. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18962. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18963. /**
  18964. * Manage the keyboard inputs to control the movement of a free camera.
  18965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18966. */
  18967. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18968. /**
  18969. * Defines the camera the input is attached to.
  18970. */
  18971. camera: FreeCamera;
  18972. /**
  18973. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18974. */
  18975. keysUp: number[];
  18976. /**
  18977. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18978. */
  18979. keysUpward: number[];
  18980. /**
  18981. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18982. */
  18983. keysDown: number[];
  18984. /**
  18985. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18986. */
  18987. keysDownward: number[];
  18988. /**
  18989. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18990. */
  18991. keysLeft: number[];
  18992. /**
  18993. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18994. */
  18995. keysRight: number[];
  18996. private _keys;
  18997. private _onCanvasBlurObserver;
  18998. private _onKeyboardObserver;
  18999. private _engine;
  19000. private _scene;
  19001. /**
  19002. * Attach the input controls to a specific dom element to get the input from.
  19003. * @param element Defines the element the controls should be listened from
  19004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19005. */
  19006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19007. /**
  19008. * Detach the current controls from the specified dom element.
  19009. * @param element Defines the element to stop listening the inputs from
  19010. */
  19011. detachControl(element: Nullable<HTMLElement>): void;
  19012. /**
  19013. * Update the current camera state depending on the inputs that have been used this frame.
  19014. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19015. */
  19016. checkInputs(): void;
  19017. /**
  19018. * Gets the class name of the current intput.
  19019. * @returns the class name
  19020. */
  19021. getClassName(): string;
  19022. /** @hidden */
  19023. _onLostFocus(): void;
  19024. /**
  19025. * Get the friendly name associated with the input class.
  19026. * @returns the input friendly name
  19027. */
  19028. getSimpleName(): string;
  19029. }
  19030. }
  19031. declare module "babylonjs/Events/pointerEvents" {
  19032. import { Nullable } from "babylonjs/types";
  19033. import { Vector2 } from "babylonjs/Maths/math.vector";
  19034. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19035. import { Ray } from "babylonjs/Culling/ray";
  19036. /**
  19037. * Gather the list of pointer event types as constants.
  19038. */
  19039. export class PointerEventTypes {
  19040. /**
  19041. * 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.
  19042. */
  19043. static readonly POINTERDOWN: number;
  19044. /**
  19045. * The pointerup event is fired when a pointer is no longer active.
  19046. */
  19047. static readonly POINTERUP: number;
  19048. /**
  19049. * The pointermove event is fired when a pointer changes coordinates.
  19050. */
  19051. static readonly POINTERMOVE: number;
  19052. /**
  19053. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19054. */
  19055. static readonly POINTERWHEEL: number;
  19056. /**
  19057. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19058. */
  19059. static readonly POINTERPICK: number;
  19060. /**
  19061. * The pointertap event is fired when a the object has been touched and released without drag.
  19062. */
  19063. static readonly POINTERTAP: number;
  19064. /**
  19065. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19066. */
  19067. static readonly POINTERDOUBLETAP: number;
  19068. }
  19069. /**
  19070. * Base class of pointer info types.
  19071. */
  19072. export class PointerInfoBase {
  19073. /**
  19074. * Defines the type of event (PointerEventTypes)
  19075. */
  19076. type: number;
  19077. /**
  19078. * Defines the related dom event
  19079. */
  19080. event: PointerEvent | MouseWheelEvent;
  19081. /**
  19082. * Instantiates the base class of pointers info.
  19083. * @param type Defines the type of event (PointerEventTypes)
  19084. * @param event Defines the related dom event
  19085. */
  19086. constructor(
  19087. /**
  19088. * Defines the type of event (PointerEventTypes)
  19089. */
  19090. type: number,
  19091. /**
  19092. * Defines the related dom event
  19093. */
  19094. event: PointerEvent | MouseWheelEvent);
  19095. }
  19096. /**
  19097. * This class is used to store pointer related info for the onPrePointerObservable event.
  19098. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19099. */
  19100. export class PointerInfoPre extends PointerInfoBase {
  19101. /**
  19102. * Ray from a pointer if availible (eg. 6dof controller)
  19103. */
  19104. ray: Nullable<Ray>;
  19105. /**
  19106. * Defines the local position of the pointer on the canvas.
  19107. */
  19108. localPosition: Vector2;
  19109. /**
  19110. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19111. */
  19112. skipOnPointerObservable: boolean;
  19113. /**
  19114. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19115. * @param type Defines the type of event (PointerEventTypes)
  19116. * @param event Defines the related dom event
  19117. * @param localX Defines the local x coordinates of the pointer when the event occured
  19118. * @param localY Defines the local y coordinates of the pointer when the event occured
  19119. */
  19120. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19121. }
  19122. /**
  19123. * This type contains all the data related to a pointer event in Babylon.js.
  19124. * 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.
  19125. */
  19126. export class PointerInfo extends PointerInfoBase {
  19127. /**
  19128. * Defines the picking info associated to the info (if any)\
  19129. */
  19130. pickInfo: Nullable<PickingInfo>;
  19131. /**
  19132. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19133. * @param type Defines the type of event (PointerEventTypes)
  19134. * @param event Defines the related dom event
  19135. * @param pickInfo Defines the picking info associated to the info (if any)\
  19136. */
  19137. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19138. /**
  19139. * Defines the picking info associated to the info (if any)\
  19140. */
  19141. pickInfo: Nullable<PickingInfo>);
  19142. }
  19143. /**
  19144. * Data relating to a touch event on the screen.
  19145. */
  19146. export interface PointerTouch {
  19147. /**
  19148. * X coordinate of touch.
  19149. */
  19150. x: number;
  19151. /**
  19152. * Y coordinate of touch.
  19153. */
  19154. y: number;
  19155. /**
  19156. * Id of touch. Unique for each finger.
  19157. */
  19158. pointerId: number;
  19159. /**
  19160. * Event type passed from DOM.
  19161. */
  19162. type: any;
  19163. }
  19164. }
  19165. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19166. import { Observable } from "babylonjs/Misc/observable";
  19167. import { Nullable } from "babylonjs/types";
  19168. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19169. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19170. /**
  19171. * Manage the mouse inputs to control the movement of a free camera.
  19172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19173. */
  19174. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19175. /**
  19176. * Define if touch is enabled in the mouse input
  19177. */
  19178. touchEnabled: boolean;
  19179. /**
  19180. * Defines the camera the input is attached to.
  19181. */
  19182. camera: FreeCamera;
  19183. /**
  19184. * Defines the buttons associated with the input to handle camera move.
  19185. */
  19186. buttons: number[];
  19187. /**
  19188. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19189. */
  19190. angularSensibility: number;
  19191. private _pointerInput;
  19192. private _onMouseMove;
  19193. private _observer;
  19194. private previousPosition;
  19195. /**
  19196. * Observable for when a pointer move event occurs containing the move offset
  19197. */
  19198. onPointerMovedObservable: Observable<{
  19199. offsetX: number;
  19200. offsetY: number;
  19201. }>;
  19202. /**
  19203. * @hidden
  19204. * If the camera should be rotated automatically based on pointer movement
  19205. */
  19206. _allowCameraRotation: boolean;
  19207. /**
  19208. * Manage the mouse inputs to control the movement of a free camera.
  19209. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19210. * @param touchEnabled Defines if touch is enabled or not
  19211. */
  19212. constructor(
  19213. /**
  19214. * Define if touch is enabled in the mouse input
  19215. */
  19216. touchEnabled?: boolean);
  19217. /**
  19218. * Attach the input controls to a specific dom element to get the input from.
  19219. * @param element Defines the element the controls should be listened from
  19220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19221. */
  19222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19223. /**
  19224. * Called on JS contextmenu event.
  19225. * Override this method to provide functionality.
  19226. */
  19227. protected onContextMenu(evt: PointerEvent): void;
  19228. /**
  19229. * Detach the current controls from the specified dom element.
  19230. * @param element Defines the element to stop listening the inputs from
  19231. */
  19232. detachControl(element: Nullable<HTMLElement>): void;
  19233. /**
  19234. * Gets the class name of the current intput.
  19235. * @returns the class name
  19236. */
  19237. getClassName(): string;
  19238. /**
  19239. * Get the friendly name associated with the input class.
  19240. * @returns the input friendly name
  19241. */
  19242. getSimpleName(): string;
  19243. }
  19244. }
  19245. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19246. import { Nullable } from "babylonjs/types";
  19247. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19248. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19249. /**
  19250. * Manage the touch inputs to control the movement of a free camera.
  19251. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19252. */
  19253. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19254. /**
  19255. * Defines the camera the input is attached to.
  19256. */
  19257. camera: FreeCamera;
  19258. /**
  19259. * Defines the touch sensibility for rotation.
  19260. * The higher the faster.
  19261. */
  19262. touchAngularSensibility: number;
  19263. /**
  19264. * Defines the touch sensibility for move.
  19265. * The higher the faster.
  19266. */
  19267. touchMoveSensibility: number;
  19268. private _offsetX;
  19269. private _offsetY;
  19270. private _pointerPressed;
  19271. private _pointerInput;
  19272. private _observer;
  19273. private _onLostFocus;
  19274. /**
  19275. * Attach the input controls to a specific dom element to get the input from.
  19276. * @param element Defines the element the controls should be listened from
  19277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19278. */
  19279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19280. /**
  19281. * Detach the current controls from the specified dom element.
  19282. * @param element Defines the element to stop listening the inputs from
  19283. */
  19284. detachControl(element: Nullable<HTMLElement>): void;
  19285. /**
  19286. * Update the current camera state depending on the inputs that have been used this frame.
  19287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19288. */
  19289. checkInputs(): void;
  19290. /**
  19291. * Gets the class name of the current intput.
  19292. * @returns the class name
  19293. */
  19294. getClassName(): string;
  19295. /**
  19296. * Get the friendly name associated with the input class.
  19297. * @returns the input friendly name
  19298. */
  19299. getSimpleName(): string;
  19300. }
  19301. }
  19302. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19303. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19304. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19305. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19306. import { Nullable } from "babylonjs/types";
  19307. /**
  19308. * Default Inputs manager for the FreeCamera.
  19309. * It groups all the default supported inputs for ease of use.
  19310. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19311. */
  19312. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19313. /**
  19314. * @hidden
  19315. */
  19316. _mouseInput: Nullable<FreeCameraMouseInput>;
  19317. /**
  19318. * Instantiates a new FreeCameraInputsManager.
  19319. * @param camera Defines the camera the inputs belong to
  19320. */
  19321. constructor(camera: FreeCamera);
  19322. /**
  19323. * Add keyboard input support to the input manager.
  19324. * @returns the current input manager
  19325. */
  19326. addKeyboard(): FreeCameraInputsManager;
  19327. /**
  19328. * Add mouse input support to the input manager.
  19329. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19330. * @returns the current input manager
  19331. */
  19332. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19333. /**
  19334. * Removes the mouse input support from the manager
  19335. * @returns the current input manager
  19336. */
  19337. removeMouse(): FreeCameraInputsManager;
  19338. /**
  19339. * Add touch input support to the input manager.
  19340. * @returns the current input manager
  19341. */
  19342. addTouch(): FreeCameraInputsManager;
  19343. /**
  19344. * Remove all attached input methods from a camera
  19345. */
  19346. clear(): void;
  19347. }
  19348. }
  19349. declare module "babylonjs/Cameras/freeCamera" {
  19350. import { Vector3 } from "babylonjs/Maths/math.vector";
  19351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19352. import { Scene } from "babylonjs/scene";
  19353. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19354. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19355. /**
  19356. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19357. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19358. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19359. */
  19360. export class FreeCamera extends TargetCamera {
  19361. /**
  19362. * Define the collision ellipsoid of the camera.
  19363. * This is helpful to simulate a camera body like the player body around the camera
  19364. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19365. */
  19366. ellipsoid: Vector3;
  19367. /**
  19368. * Define an offset for the position of the ellipsoid around the camera.
  19369. * This can be helpful to determine the center of the body near the gravity center of the body
  19370. * instead of its head.
  19371. */
  19372. ellipsoidOffset: Vector3;
  19373. /**
  19374. * Enable or disable collisions of the camera with the rest of the scene objects.
  19375. */
  19376. checkCollisions: boolean;
  19377. /**
  19378. * Enable or disable gravity on the camera.
  19379. */
  19380. applyGravity: boolean;
  19381. /**
  19382. * Define the input manager associated to the camera.
  19383. */
  19384. inputs: FreeCameraInputsManager;
  19385. /**
  19386. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19387. * Higher values reduce sensitivity.
  19388. */
  19389. get angularSensibility(): number;
  19390. /**
  19391. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19392. * Higher values reduce sensitivity.
  19393. */
  19394. set angularSensibility(value: number);
  19395. /**
  19396. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19397. */
  19398. get keysUp(): number[];
  19399. set keysUp(value: number[]);
  19400. /**
  19401. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19402. */
  19403. get keysUpward(): number[];
  19404. set keysUpward(value: number[]);
  19405. /**
  19406. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19407. */
  19408. get keysDown(): number[];
  19409. set keysDown(value: number[]);
  19410. /**
  19411. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19412. */
  19413. get keysDownward(): number[];
  19414. set keysDownward(value: number[]);
  19415. /**
  19416. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19417. */
  19418. get keysLeft(): number[];
  19419. set keysLeft(value: number[]);
  19420. /**
  19421. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19422. */
  19423. get keysRight(): number[];
  19424. set keysRight(value: number[]);
  19425. /**
  19426. * Event raised when the camera collide with a mesh in the scene.
  19427. */
  19428. onCollide: (collidedMesh: AbstractMesh) => void;
  19429. private _collider;
  19430. private _needMoveForGravity;
  19431. private _oldPosition;
  19432. private _diffPosition;
  19433. private _newPosition;
  19434. /** @hidden */
  19435. _localDirection: Vector3;
  19436. /** @hidden */
  19437. _transformedDirection: Vector3;
  19438. /**
  19439. * Instantiates a Free Camera.
  19440. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19441. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19442. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19443. * @param name Define the name of the camera in the scene
  19444. * @param position Define the start position of the camera in the scene
  19445. * @param scene Define the scene the camera belongs to
  19446. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19447. */
  19448. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19449. /**
  19450. * Attached controls to the current camera.
  19451. * @param element Defines the element the controls should be listened from
  19452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19453. */
  19454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19455. /**
  19456. * Detach the current controls from the camera.
  19457. * The camera will stop reacting to inputs.
  19458. * @param element Defines the element to stop listening the inputs from
  19459. */
  19460. detachControl(element: HTMLElement): void;
  19461. private _collisionMask;
  19462. /**
  19463. * Define a collision mask to limit the list of object the camera can collide with
  19464. */
  19465. get collisionMask(): number;
  19466. set collisionMask(mask: number);
  19467. /** @hidden */
  19468. _collideWithWorld(displacement: Vector3): void;
  19469. private _onCollisionPositionChange;
  19470. /** @hidden */
  19471. _checkInputs(): void;
  19472. /** @hidden */
  19473. _decideIfNeedsToMove(): boolean;
  19474. /** @hidden */
  19475. _updatePosition(): void;
  19476. /**
  19477. * Destroy the camera and release the current resources hold by it.
  19478. */
  19479. dispose(): void;
  19480. /**
  19481. * Gets the current object class name.
  19482. * @return the class name
  19483. */
  19484. getClassName(): string;
  19485. }
  19486. }
  19487. declare module "babylonjs/Gamepads/gamepad" {
  19488. import { Observable } from "babylonjs/Misc/observable";
  19489. /**
  19490. * Represents a gamepad control stick position
  19491. */
  19492. export class StickValues {
  19493. /**
  19494. * The x component of the control stick
  19495. */
  19496. x: number;
  19497. /**
  19498. * The y component of the control stick
  19499. */
  19500. y: number;
  19501. /**
  19502. * Initializes the gamepad x and y control stick values
  19503. * @param x The x component of the gamepad control stick value
  19504. * @param y The y component of the gamepad control stick value
  19505. */
  19506. constructor(
  19507. /**
  19508. * The x component of the control stick
  19509. */
  19510. x: number,
  19511. /**
  19512. * The y component of the control stick
  19513. */
  19514. y: number);
  19515. }
  19516. /**
  19517. * An interface which manages callbacks for gamepad button changes
  19518. */
  19519. export interface GamepadButtonChanges {
  19520. /**
  19521. * Called when a gamepad has been changed
  19522. */
  19523. changed: boolean;
  19524. /**
  19525. * Called when a gamepad press event has been triggered
  19526. */
  19527. pressChanged: boolean;
  19528. /**
  19529. * Called when a touch event has been triggered
  19530. */
  19531. touchChanged: boolean;
  19532. /**
  19533. * Called when a value has changed
  19534. */
  19535. valueChanged: boolean;
  19536. }
  19537. /**
  19538. * Represents a gamepad
  19539. */
  19540. export class Gamepad {
  19541. /**
  19542. * The id of the gamepad
  19543. */
  19544. id: string;
  19545. /**
  19546. * The index of the gamepad
  19547. */
  19548. index: number;
  19549. /**
  19550. * The browser gamepad
  19551. */
  19552. browserGamepad: any;
  19553. /**
  19554. * Specifies what type of gamepad this represents
  19555. */
  19556. type: number;
  19557. private _leftStick;
  19558. private _rightStick;
  19559. /** @hidden */
  19560. _isConnected: boolean;
  19561. private _leftStickAxisX;
  19562. private _leftStickAxisY;
  19563. private _rightStickAxisX;
  19564. private _rightStickAxisY;
  19565. /**
  19566. * Triggered when the left control stick has been changed
  19567. */
  19568. private _onleftstickchanged;
  19569. /**
  19570. * Triggered when the right control stick has been changed
  19571. */
  19572. private _onrightstickchanged;
  19573. /**
  19574. * Represents a gamepad controller
  19575. */
  19576. static GAMEPAD: number;
  19577. /**
  19578. * Represents a generic controller
  19579. */
  19580. static GENERIC: number;
  19581. /**
  19582. * Represents an XBox controller
  19583. */
  19584. static XBOX: number;
  19585. /**
  19586. * Represents a pose-enabled controller
  19587. */
  19588. static POSE_ENABLED: number;
  19589. /**
  19590. * Represents an Dual Shock controller
  19591. */
  19592. static DUALSHOCK: number;
  19593. /**
  19594. * Specifies whether the left control stick should be Y-inverted
  19595. */
  19596. protected _invertLeftStickY: boolean;
  19597. /**
  19598. * Specifies if the gamepad has been connected
  19599. */
  19600. get isConnected(): boolean;
  19601. /**
  19602. * Initializes the gamepad
  19603. * @param id The id of the gamepad
  19604. * @param index The index of the gamepad
  19605. * @param browserGamepad The browser gamepad
  19606. * @param leftStickX The x component of the left joystick
  19607. * @param leftStickY The y component of the left joystick
  19608. * @param rightStickX The x component of the right joystick
  19609. * @param rightStickY The y component of the right joystick
  19610. */
  19611. constructor(
  19612. /**
  19613. * The id of the gamepad
  19614. */
  19615. id: string,
  19616. /**
  19617. * The index of the gamepad
  19618. */
  19619. index: number,
  19620. /**
  19621. * The browser gamepad
  19622. */
  19623. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19624. /**
  19625. * Callback triggered when the left joystick has changed
  19626. * @param callback
  19627. */
  19628. onleftstickchanged(callback: (values: StickValues) => void): void;
  19629. /**
  19630. * Callback triggered when the right joystick has changed
  19631. * @param callback
  19632. */
  19633. onrightstickchanged(callback: (values: StickValues) => void): void;
  19634. /**
  19635. * Gets the left joystick
  19636. */
  19637. get leftStick(): StickValues;
  19638. /**
  19639. * Sets the left joystick values
  19640. */
  19641. set leftStick(newValues: StickValues);
  19642. /**
  19643. * Gets the right joystick
  19644. */
  19645. get rightStick(): StickValues;
  19646. /**
  19647. * Sets the right joystick value
  19648. */
  19649. set rightStick(newValues: StickValues);
  19650. /**
  19651. * Updates the gamepad joystick positions
  19652. */
  19653. update(): void;
  19654. /**
  19655. * Disposes the gamepad
  19656. */
  19657. dispose(): void;
  19658. }
  19659. /**
  19660. * Represents a generic gamepad
  19661. */
  19662. export class GenericPad extends Gamepad {
  19663. private _buttons;
  19664. private _onbuttondown;
  19665. private _onbuttonup;
  19666. /**
  19667. * Observable triggered when a button has been pressed
  19668. */
  19669. onButtonDownObservable: Observable<number>;
  19670. /**
  19671. * Observable triggered when a button has been released
  19672. */
  19673. onButtonUpObservable: Observable<number>;
  19674. /**
  19675. * Callback triggered when a button has been pressed
  19676. * @param callback Called when a button has been pressed
  19677. */
  19678. onbuttondown(callback: (buttonPressed: number) => void): void;
  19679. /**
  19680. * Callback triggered when a button has been released
  19681. * @param callback Called when a button has been released
  19682. */
  19683. onbuttonup(callback: (buttonReleased: number) => void): void;
  19684. /**
  19685. * Initializes the generic gamepad
  19686. * @param id The id of the generic gamepad
  19687. * @param index The index of the generic gamepad
  19688. * @param browserGamepad The browser gamepad
  19689. */
  19690. constructor(id: string, index: number, browserGamepad: any);
  19691. private _setButtonValue;
  19692. /**
  19693. * Updates the generic gamepad
  19694. */
  19695. update(): void;
  19696. /**
  19697. * Disposes the generic gamepad
  19698. */
  19699. dispose(): void;
  19700. }
  19701. }
  19702. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19703. import { Observable } from "babylonjs/Misc/observable";
  19704. import { Nullable } from "babylonjs/types";
  19705. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19706. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19708. import { Ray } from "babylonjs/Culling/ray";
  19709. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19710. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19711. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19712. /**
  19713. * Defines the types of pose enabled controllers that are supported
  19714. */
  19715. export enum PoseEnabledControllerType {
  19716. /**
  19717. * HTC Vive
  19718. */
  19719. VIVE = 0,
  19720. /**
  19721. * Oculus Rift
  19722. */
  19723. OCULUS = 1,
  19724. /**
  19725. * Windows mixed reality
  19726. */
  19727. WINDOWS = 2,
  19728. /**
  19729. * Samsung gear VR
  19730. */
  19731. GEAR_VR = 3,
  19732. /**
  19733. * Google Daydream
  19734. */
  19735. DAYDREAM = 4,
  19736. /**
  19737. * Generic
  19738. */
  19739. GENERIC = 5
  19740. }
  19741. /**
  19742. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19743. */
  19744. export interface MutableGamepadButton {
  19745. /**
  19746. * Value of the button/trigger
  19747. */
  19748. value: number;
  19749. /**
  19750. * If the button/trigger is currently touched
  19751. */
  19752. touched: boolean;
  19753. /**
  19754. * If the button/trigger is currently pressed
  19755. */
  19756. pressed: boolean;
  19757. }
  19758. /**
  19759. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19760. * @hidden
  19761. */
  19762. export interface ExtendedGamepadButton extends GamepadButton {
  19763. /**
  19764. * If the button/trigger is currently pressed
  19765. */
  19766. readonly pressed: boolean;
  19767. /**
  19768. * If the button/trigger is currently touched
  19769. */
  19770. readonly touched: boolean;
  19771. /**
  19772. * Value of the button/trigger
  19773. */
  19774. readonly value: number;
  19775. }
  19776. /** @hidden */
  19777. export interface _GamePadFactory {
  19778. /**
  19779. * Returns whether or not the current gamepad can be created for this type of controller.
  19780. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19781. * @returns true if it can be created, otherwise false
  19782. */
  19783. canCreate(gamepadInfo: any): boolean;
  19784. /**
  19785. * Creates a new instance of the Gamepad.
  19786. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19787. * @returns the new gamepad instance
  19788. */
  19789. create(gamepadInfo: any): Gamepad;
  19790. }
  19791. /**
  19792. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19793. */
  19794. export class PoseEnabledControllerHelper {
  19795. /** @hidden */
  19796. static _ControllerFactories: _GamePadFactory[];
  19797. /** @hidden */
  19798. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19799. /**
  19800. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19801. * @param vrGamepad the gamepad to initialized
  19802. * @returns a vr controller of the type the gamepad identified as
  19803. */
  19804. static InitiateController(vrGamepad: any): Gamepad;
  19805. }
  19806. /**
  19807. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19808. */
  19809. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19810. /**
  19811. * If the controller is used in a webXR session
  19812. */
  19813. isXR: boolean;
  19814. private _deviceRoomPosition;
  19815. private _deviceRoomRotationQuaternion;
  19816. /**
  19817. * The device position in babylon space
  19818. */
  19819. devicePosition: Vector3;
  19820. /**
  19821. * The device rotation in babylon space
  19822. */
  19823. deviceRotationQuaternion: Quaternion;
  19824. /**
  19825. * The scale factor of the device in babylon space
  19826. */
  19827. deviceScaleFactor: number;
  19828. /**
  19829. * (Likely devicePosition should be used instead) The device position in its room space
  19830. */
  19831. position: Vector3;
  19832. /**
  19833. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19834. */
  19835. rotationQuaternion: Quaternion;
  19836. /**
  19837. * The type of controller (Eg. Windows mixed reality)
  19838. */
  19839. controllerType: PoseEnabledControllerType;
  19840. protected _calculatedPosition: Vector3;
  19841. private _calculatedRotation;
  19842. /**
  19843. * The raw pose from the device
  19844. */
  19845. rawPose: DevicePose;
  19846. private _trackPosition;
  19847. private _maxRotationDistFromHeadset;
  19848. private _draggedRoomRotation;
  19849. /**
  19850. * @hidden
  19851. */
  19852. _disableTrackPosition(fixedPosition: Vector3): void;
  19853. /**
  19854. * Internal, the mesh attached to the controller
  19855. * @hidden
  19856. */
  19857. _mesh: Nullable<AbstractMesh>;
  19858. private _poseControlledCamera;
  19859. private _leftHandSystemQuaternion;
  19860. /**
  19861. * Internal, matrix used to convert room space to babylon space
  19862. * @hidden
  19863. */
  19864. _deviceToWorld: Matrix;
  19865. /**
  19866. * Node to be used when casting a ray from the controller
  19867. * @hidden
  19868. */
  19869. _pointingPoseNode: Nullable<TransformNode>;
  19870. /**
  19871. * Name of the child mesh that can be used to cast a ray from the controller
  19872. */
  19873. static readonly POINTING_POSE: string;
  19874. /**
  19875. * Creates a new PoseEnabledController from a gamepad
  19876. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19877. */
  19878. constructor(browserGamepad: any);
  19879. private _workingMatrix;
  19880. /**
  19881. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19882. */
  19883. update(): void;
  19884. /**
  19885. * Updates only the pose device and mesh without doing any button event checking
  19886. */
  19887. protected _updatePoseAndMesh(): void;
  19888. /**
  19889. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19890. * @param poseData raw pose fromthe device
  19891. */
  19892. updateFromDevice(poseData: DevicePose): void;
  19893. /**
  19894. * @hidden
  19895. */
  19896. _meshAttachedObservable: Observable<AbstractMesh>;
  19897. /**
  19898. * Attaches a mesh to the controller
  19899. * @param mesh the mesh to be attached
  19900. */
  19901. attachToMesh(mesh: AbstractMesh): void;
  19902. /**
  19903. * Attaches the controllers mesh to a camera
  19904. * @param camera the camera the mesh should be attached to
  19905. */
  19906. attachToPoseControlledCamera(camera: TargetCamera): void;
  19907. /**
  19908. * Disposes of the controller
  19909. */
  19910. dispose(): void;
  19911. /**
  19912. * The mesh that is attached to the controller
  19913. */
  19914. get mesh(): Nullable<AbstractMesh>;
  19915. /**
  19916. * Gets the ray of the controller in the direction the controller is pointing
  19917. * @param length the length the resulting ray should be
  19918. * @returns a ray in the direction the controller is pointing
  19919. */
  19920. getForwardRay(length?: number): Ray;
  19921. }
  19922. }
  19923. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19924. import { Observable } from "babylonjs/Misc/observable";
  19925. import { Scene } from "babylonjs/scene";
  19926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19927. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19928. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19929. import { Nullable } from "babylonjs/types";
  19930. /**
  19931. * Defines the WebVRController object that represents controllers tracked in 3D space
  19932. */
  19933. export abstract class WebVRController extends PoseEnabledController {
  19934. /**
  19935. * Internal, the default controller model for the controller
  19936. */
  19937. protected _defaultModel: Nullable<AbstractMesh>;
  19938. /**
  19939. * Fired when the trigger state has changed
  19940. */
  19941. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19942. /**
  19943. * Fired when the main button state has changed
  19944. */
  19945. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19946. /**
  19947. * Fired when the secondary button state has changed
  19948. */
  19949. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19950. /**
  19951. * Fired when the pad state has changed
  19952. */
  19953. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19954. /**
  19955. * Fired when controllers stick values have changed
  19956. */
  19957. onPadValuesChangedObservable: Observable<StickValues>;
  19958. /**
  19959. * Array of button availible on the controller
  19960. */
  19961. protected _buttons: Array<MutableGamepadButton>;
  19962. private _onButtonStateChange;
  19963. /**
  19964. * Fired when a controller button's state has changed
  19965. * @param callback the callback containing the button that was modified
  19966. */
  19967. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19968. /**
  19969. * X and Y axis corresponding to the controllers joystick
  19970. */
  19971. pad: StickValues;
  19972. /**
  19973. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19974. */
  19975. hand: string;
  19976. /**
  19977. * The default controller model for the controller
  19978. */
  19979. get defaultModel(): Nullable<AbstractMesh>;
  19980. /**
  19981. * Creates a new WebVRController from a gamepad
  19982. * @param vrGamepad the gamepad that the WebVRController should be created from
  19983. */
  19984. constructor(vrGamepad: any);
  19985. /**
  19986. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19987. */
  19988. update(): void;
  19989. /**
  19990. * Function to be called when a button is modified
  19991. */
  19992. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19993. /**
  19994. * Loads a mesh and attaches it to the controller
  19995. * @param scene the scene the mesh should be added to
  19996. * @param meshLoaded callback for when the mesh has been loaded
  19997. */
  19998. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19999. private _setButtonValue;
  20000. private _changes;
  20001. private _checkChanges;
  20002. /**
  20003. * Disposes of th webVRCOntroller
  20004. */
  20005. dispose(): void;
  20006. }
  20007. }
  20008. declare module "babylonjs/Lights/hemisphericLight" {
  20009. import { Nullable } from "babylonjs/types";
  20010. import { Scene } from "babylonjs/scene";
  20011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20012. import { Color3 } from "babylonjs/Maths/math.color";
  20013. import { Effect } from "babylonjs/Materials/effect";
  20014. import { Light } from "babylonjs/Lights/light";
  20015. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20016. /**
  20017. * The HemisphericLight simulates the ambient environment light,
  20018. * so the passed direction is the light reflection direction, not the incoming direction.
  20019. */
  20020. export class HemisphericLight extends Light {
  20021. /**
  20022. * The groundColor is the light in the opposite direction to the one specified during creation.
  20023. * 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.
  20024. */
  20025. groundColor: Color3;
  20026. /**
  20027. * The light reflection direction, not the incoming direction.
  20028. */
  20029. direction: Vector3;
  20030. /**
  20031. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20032. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20033. * The HemisphericLight can't cast shadows.
  20034. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20035. * @param name The friendly name of the light
  20036. * @param direction The direction of the light reflection
  20037. * @param scene The scene the light belongs to
  20038. */
  20039. constructor(name: string, direction: Vector3, scene: Scene);
  20040. protected _buildUniformLayout(): void;
  20041. /**
  20042. * Returns the string "HemisphericLight".
  20043. * @return The class name
  20044. */
  20045. getClassName(): string;
  20046. /**
  20047. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20048. * Returns the updated direction.
  20049. * @param target The target the direction should point to
  20050. * @return The computed direction
  20051. */
  20052. setDirectionToTarget(target: Vector3): Vector3;
  20053. /**
  20054. * Returns the shadow generator associated to the light.
  20055. * @returns Always null for hemispheric lights because it does not support shadows.
  20056. */
  20057. getShadowGenerator(): Nullable<IShadowGenerator>;
  20058. /**
  20059. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20060. * @param effect The effect to update
  20061. * @param lightIndex The index of the light in the effect to update
  20062. * @returns The hemispheric light
  20063. */
  20064. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20065. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20066. /**
  20067. * Computes the world matrix of the node
  20068. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20069. * @param useWasUpdatedFlag defines a reserved property
  20070. * @returns the world matrix
  20071. */
  20072. computeWorldMatrix(): Matrix;
  20073. /**
  20074. * Returns the integer 3.
  20075. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20076. */
  20077. getTypeID(): number;
  20078. /**
  20079. * Prepares the list of defines specific to the light type.
  20080. * @param defines the list of defines
  20081. * @param lightIndex defines the index of the light for the effect
  20082. */
  20083. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20084. }
  20085. }
  20086. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20087. /** @hidden */
  20088. export var vrMultiviewToSingleviewPixelShader: {
  20089. name: string;
  20090. shader: string;
  20091. };
  20092. }
  20093. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20094. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20095. import { Scene } from "babylonjs/scene";
  20096. /**
  20097. * Renders to multiple views with a single draw call
  20098. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20099. */
  20100. export class MultiviewRenderTarget extends RenderTargetTexture {
  20101. /**
  20102. * Creates a multiview render target
  20103. * @param scene scene used with the render target
  20104. * @param size the size of the render target (used for each view)
  20105. */
  20106. constructor(scene: Scene, size?: number | {
  20107. width: number;
  20108. height: number;
  20109. } | {
  20110. ratio: number;
  20111. });
  20112. /**
  20113. * @hidden
  20114. * @param faceIndex the face index, if its a cube texture
  20115. */
  20116. _bindFrameBuffer(faceIndex?: number): void;
  20117. /**
  20118. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20119. * @returns the view count
  20120. */
  20121. getViewCount(): number;
  20122. }
  20123. }
  20124. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20125. import { Camera } from "babylonjs/Cameras/camera";
  20126. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20127. import { Nullable } from "babylonjs/types";
  20128. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20129. import { Matrix } from "babylonjs/Maths/math.vector";
  20130. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20131. module "babylonjs/Engines/engine" {
  20132. interface Engine {
  20133. /**
  20134. * Creates a new multiview render target
  20135. * @param width defines the width of the texture
  20136. * @param height defines the height of the texture
  20137. * @returns the created multiview texture
  20138. */
  20139. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20140. /**
  20141. * Binds a multiview framebuffer to be drawn to
  20142. * @param multiviewTexture texture to bind
  20143. */
  20144. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20145. }
  20146. }
  20147. module "babylonjs/Cameras/camera" {
  20148. interface Camera {
  20149. /**
  20150. * @hidden
  20151. * 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)
  20152. */
  20153. _useMultiviewToSingleView: boolean;
  20154. /**
  20155. * @hidden
  20156. * 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)
  20157. */
  20158. _multiviewTexture: Nullable<RenderTargetTexture>;
  20159. /**
  20160. * @hidden
  20161. * ensures the multiview texture of the camera exists and has the specified width/height
  20162. * @param width height to set on the multiview texture
  20163. * @param height width to set on the multiview texture
  20164. */
  20165. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20166. }
  20167. }
  20168. module "babylonjs/scene" {
  20169. interface Scene {
  20170. /** @hidden */
  20171. _transformMatrixR: Matrix;
  20172. /** @hidden */
  20173. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20174. /** @hidden */
  20175. _createMultiviewUbo(): void;
  20176. /** @hidden */
  20177. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20178. /** @hidden */
  20179. _renderMultiviewToSingleView(camera: Camera): void;
  20180. }
  20181. }
  20182. }
  20183. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20184. import { Camera } from "babylonjs/Cameras/camera";
  20185. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20186. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20187. import "babylonjs/Engines/Extensions/engine.multiview";
  20188. /**
  20189. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20190. * This will not be used for webXR as it supports displaying texture arrays directly
  20191. */
  20192. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20193. /**
  20194. * Initializes a VRMultiviewToSingleview
  20195. * @param name name of the post process
  20196. * @param camera camera to be applied to
  20197. * @param scaleFactor scaling factor to the size of the output texture
  20198. */
  20199. constructor(name: string, camera: Camera, scaleFactor: number);
  20200. }
  20201. }
  20202. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20203. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20204. import { Nullable } from "babylonjs/types";
  20205. import { Size } from "babylonjs/Maths/math.size";
  20206. import { Observable } from "babylonjs/Misc/observable";
  20207. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20208. /**
  20209. * Interface used to define additional presentation attributes
  20210. */
  20211. export interface IVRPresentationAttributes {
  20212. /**
  20213. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20214. */
  20215. highRefreshRate: boolean;
  20216. /**
  20217. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20218. */
  20219. foveationLevel: number;
  20220. }
  20221. module "babylonjs/Engines/engine" {
  20222. interface Engine {
  20223. /** @hidden */
  20224. _vrDisplay: any;
  20225. /** @hidden */
  20226. _vrSupported: boolean;
  20227. /** @hidden */
  20228. _oldSize: Size;
  20229. /** @hidden */
  20230. _oldHardwareScaleFactor: number;
  20231. /** @hidden */
  20232. _vrExclusivePointerMode: boolean;
  20233. /** @hidden */
  20234. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20235. /** @hidden */
  20236. _onVRDisplayPointerRestricted: () => void;
  20237. /** @hidden */
  20238. _onVRDisplayPointerUnrestricted: () => void;
  20239. /** @hidden */
  20240. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20241. /** @hidden */
  20242. _onVrDisplayDisconnect: Nullable<() => void>;
  20243. /** @hidden */
  20244. _onVrDisplayPresentChange: Nullable<() => void>;
  20245. /**
  20246. * Observable signaled when VR display mode changes
  20247. */
  20248. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20249. /**
  20250. * Observable signaled when VR request present is complete
  20251. */
  20252. onVRRequestPresentComplete: Observable<boolean>;
  20253. /**
  20254. * Observable signaled when VR request present starts
  20255. */
  20256. onVRRequestPresentStart: Observable<Engine>;
  20257. /**
  20258. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20259. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20260. */
  20261. isInVRExclusivePointerMode: boolean;
  20262. /**
  20263. * Gets a boolean indicating if a webVR device was detected
  20264. * @returns true if a webVR device was detected
  20265. */
  20266. isVRDevicePresent(): boolean;
  20267. /**
  20268. * Gets the current webVR device
  20269. * @returns the current webVR device (or null)
  20270. */
  20271. getVRDevice(): any;
  20272. /**
  20273. * Initializes a webVR display and starts listening to display change events
  20274. * The onVRDisplayChangedObservable will be notified upon these changes
  20275. * @returns A promise containing a VRDisplay and if vr is supported
  20276. */
  20277. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20278. /** @hidden */
  20279. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20280. /**
  20281. * Gets or sets the presentation attributes used to configure VR rendering
  20282. */
  20283. vrPresentationAttributes?: IVRPresentationAttributes;
  20284. /**
  20285. * Call this function to switch to webVR mode
  20286. * Will do nothing if webVR is not supported or if there is no webVR device
  20287. * @param options the webvr options provided to the camera. mainly used for multiview
  20288. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20289. */
  20290. enableVR(options: WebVROptions): void;
  20291. /** @hidden */
  20292. _onVRFullScreenTriggered(): void;
  20293. }
  20294. }
  20295. }
  20296. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20297. import { Nullable } from "babylonjs/types";
  20298. import { Observable } from "babylonjs/Misc/observable";
  20299. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20300. import { Scene } from "babylonjs/scene";
  20301. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20302. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20303. import { Node } from "babylonjs/node";
  20304. import { Ray } from "babylonjs/Culling/ray";
  20305. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20306. import "babylonjs/Engines/Extensions/engine.webVR";
  20307. /**
  20308. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20309. * IMPORTANT!! The data is right-hand data.
  20310. * @export
  20311. * @interface DevicePose
  20312. */
  20313. export interface DevicePose {
  20314. /**
  20315. * The position of the device, values in array are [x,y,z].
  20316. */
  20317. readonly position: Nullable<Float32Array>;
  20318. /**
  20319. * The linearVelocity of the device, values in array are [x,y,z].
  20320. */
  20321. readonly linearVelocity: Nullable<Float32Array>;
  20322. /**
  20323. * The linearAcceleration of the device, values in array are [x,y,z].
  20324. */
  20325. readonly linearAcceleration: Nullable<Float32Array>;
  20326. /**
  20327. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20328. */
  20329. readonly orientation: Nullable<Float32Array>;
  20330. /**
  20331. * The angularVelocity of the device, values in array are [x,y,z].
  20332. */
  20333. readonly angularVelocity: Nullable<Float32Array>;
  20334. /**
  20335. * The angularAcceleration of the device, values in array are [x,y,z].
  20336. */
  20337. readonly angularAcceleration: Nullable<Float32Array>;
  20338. }
  20339. /**
  20340. * Interface representing a pose controlled object in Babylon.
  20341. * A pose controlled object has both regular pose values as well as pose values
  20342. * from an external device such as a VR head mounted display
  20343. */
  20344. export interface PoseControlled {
  20345. /**
  20346. * The position of the object in babylon space.
  20347. */
  20348. position: Vector3;
  20349. /**
  20350. * The rotation quaternion of the object in babylon space.
  20351. */
  20352. rotationQuaternion: Quaternion;
  20353. /**
  20354. * The position of the device in babylon space.
  20355. */
  20356. devicePosition?: Vector3;
  20357. /**
  20358. * The rotation quaternion of the device in babylon space.
  20359. */
  20360. deviceRotationQuaternion: Quaternion;
  20361. /**
  20362. * The raw pose coming from the device.
  20363. */
  20364. rawPose: Nullable<DevicePose>;
  20365. /**
  20366. * The scale of the device to be used when translating from device space to babylon space.
  20367. */
  20368. deviceScaleFactor: number;
  20369. /**
  20370. * Updates the poseControlled values based on the input device pose.
  20371. * @param poseData the pose data to update the object with
  20372. */
  20373. updateFromDevice(poseData: DevicePose): void;
  20374. }
  20375. /**
  20376. * Set of options to customize the webVRCamera
  20377. */
  20378. export interface WebVROptions {
  20379. /**
  20380. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20381. */
  20382. trackPosition?: boolean;
  20383. /**
  20384. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20385. */
  20386. positionScale?: number;
  20387. /**
  20388. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20389. */
  20390. displayName?: string;
  20391. /**
  20392. * Should the native controller meshes be initialized. (default: true)
  20393. */
  20394. controllerMeshes?: boolean;
  20395. /**
  20396. * Creating a default HemiLight only on controllers. (default: true)
  20397. */
  20398. defaultLightingOnControllers?: boolean;
  20399. /**
  20400. * If you don't want to use the default VR button of the helper. (default: false)
  20401. */
  20402. useCustomVRButton?: boolean;
  20403. /**
  20404. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20405. */
  20406. customVRButton?: HTMLButtonElement;
  20407. /**
  20408. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20409. */
  20410. rayLength?: number;
  20411. /**
  20412. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20413. */
  20414. defaultHeight?: number;
  20415. /**
  20416. * If multiview should be used if availible (default: false)
  20417. */
  20418. useMultiview?: boolean;
  20419. }
  20420. /**
  20421. * This represents a WebVR camera.
  20422. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20423. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20424. */
  20425. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20426. private webVROptions;
  20427. /**
  20428. * @hidden
  20429. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20430. */
  20431. _vrDevice: any;
  20432. /**
  20433. * The rawPose of the vrDevice.
  20434. */
  20435. rawPose: Nullable<DevicePose>;
  20436. private _onVREnabled;
  20437. private _specsVersion;
  20438. private _attached;
  20439. private _frameData;
  20440. protected _descendants: Array<Node>;
  20441. private _deviceRoomPosition;
  20442. /** @hidden */
  20443. _deviceRoomRotationQuaternion: Quaternion;
  20444. private _standingMatrix;
  20445. /**
  20446. * Represents device position in babylon space.
  20447. */
  20448. devicePosition: Vector3;
  20449. /**
  20450. * Represents device rotation in babylon space.
  20451. */
  20452. deviceRotationQuaternion: Quaternion;
  20453. /**
  20454. * The scale of the device to be used when translating from device space to babylon space.
  20455. */
  20456. deviceScaleFactor: number;
  20457. private _deviceToWorld;
  20458. private _worldToDevice;
  20459. /**
  20460. * References to the webVR controllers for the vrDevice.
  20461. */
  20462. controllers: Array<WebVRController>;
  20463. /**
  20464. * Emits an event when a controller is attached.
  20465. */
  20466. onControllersAttachedObservable: Observable<WebVRController[]>;
  20467. /**
  20468. * Emits an event when a controller's mesh has been loaded;
  20469. */
  20470. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20471. /**
  20472. * Emits an event when the HMD's pose has been updated.
  20473. */
  20474. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20475. private _poseSet;
  20476. /**
  20477. * If the rig cameras be used as parent instead of this camera.
  20478. */
  20479. rigParenting: boolean;
  20480. private _lightOnControllers;
  20481. private _defaultHeight?;
  20482. /**
  20483. * Instantiates a WebVRFreeCamera.
  20484. * @param name The name of the WebVRFreeCamera
  20485. * @param position The starting anchor position for the camera
  20486. * @param scene The scene the camera belongs to
  20487. * @param webVROptions a set of customizable options for the webVRCamera
  20488. */
  20489. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20490. /**
  20491. * Gets the device distance from the ground in meters.
  20492. * @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.
  20493. */
  20494. deviceDistanceToRoomGround(): number;
  20495. /**
  20496. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20497. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20498. */
  20499. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20500. /**
  20501. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20502. * @returns A promise with a boolean set to if the standing matrix is supported.
  20503. */
  20504. useStandingMatrixAsync(): Promise<boolean>;
  20505. /**
  20506. * Disposes the camera
  20507. */
  20508. dispose(): void;
  20509. /**
  20510. * Gets a vrController by name.
  20511. * @param name The name of the controller to retreive
  20512. * @returns the controller matching the name specified or null if not found
  20513. */
  20514. getControllerByName(name: string): Nullable<WebVRController>;
  20515. private _leftController;
  20516. /**
  20517. * The controller corresponding to the users left hand.
  20518. */
  20519. get leftController(): Nullable<WebVRController>;
  20520. private _rightController;
  20521. /**
  20522. * The controller corresponding to the users right hand.
  20523. */
  20524. get rightController(): Nullable<WebVRController>;
  20525. /**
  20526. * Casts a ray forward from the vrCamera's gaze.
  20527. * @param length Length of the ray (default: 100)
  20528. * @returns the ray corresponding to the gaze
  20529. */
  20530. getForwardRay(length?: number): Ray;
  20531. /**
  20532. * @hidden
  20533. * Updates the camera based on device's frame data
  20534. */
  20535. _checkInputs(): void;
  20536. /**
  20537. * Updates the poseControlled values based on the input device pose.
  20538. * @param poseData Pose coming from the device
  20539. */
  20540. updateFromDevice(poseData: DevicePose): void;
  20541. private _htmlElementAttached;
  20542. private _detachIfAttached;
  20543. /**
  20544. * WebVR's attach control will start broadcasting frames to the device.
  20545. * Note that in certain browsers (chrome for example) this function must be called
  20546. * within a user-interaction callback. Example:
  20547. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20548. *
  20549. * @param element html element to attach the vrDevice to
  20550. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20551. */
  20552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20553. /**
  20554. * Detaches the camera from the html element and disables VR
  20555. *
  20556. * @param element html element to detach from
  20557. */
  20558. detachControl(element: HTMLElement): void;
  20559. /**
  20560. * @returns the name of this class
  20561. */
  20562. getClassName(): string;
  20563. /**
  20564. * Calls resetPose on the vrDisplay
  20565. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20566. */
  20567. resetToCurrentRotation(): void;
  20568. /**
  20569. * @hidden
  20570. * Updates the rig cameras (left and right eye)
  20571. */
  20572. _updateRigCameras(): void;
  20573. private _workingVector;
  20574. private _oneVector;
  20575. private _workingMatrix;
  20576. private updateCacheCalled;
  20577. private _correctPositionIfNotTrackPosition;
  20578. /**
  20579. * @hidden
  20580. * Updates the cached values of the camera
  20581. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20582. */
  20583. _updateCache(ignoreParentClass?: boolean): void;
  20584. /**
  20585. * @hidden
  20586. * Get current device position in babylon world
  20587. */
  20588. _computeDevicePosition(): void;
  20589. /**
  20590. * Updates the current device position and rotation in the babylon world
  20591. */
  20592. update(): void;
  20593. /**
  20594. * @hidden
  20595. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20596. * @returns an identity matrix
  20597. */
  20598. _getViewMatrix(): Matrix;
  20599. private _tmpMatrix;
  20600. /**
  20601. * This function is called by the two RIG cameras.
  20602. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20603. * @hidden
  20604. */
  20605. _getWebVRViewMatrix(): Matrix;
  20606. /** @hidden */
  20607. _getWebVRProjectionMatrix(): Matrix;
  20608. private _onGamepadConnectedObserver;
  20609. private _onGamepadDisconnectedObserver;
  20610. private _updateCacheWhenTrackingDisabledObserver;
  20611. /**
  20612. * Initializes the controllers and their meshes
  20613. */
  20614. initControllers(): void;
  20615. }
  20616. }
  20617. declare module "babylonjs/Materials/materialHelper" {
  20618. import { Nullable } from "babylonjs/types";
  20619. import { Scene } from "babylonjs/scene";
  20620. import { Engine } from "babylonjs/Engines/engine";
  20621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20622. import { Light } from "babylonjs/Lights/light";
  20623. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20624. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20626. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20627. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20628. /**
  20629. * "Static Class" containing the most commonly used helper while dealing with material for
  20630. * rendering purpose.
  20631. *
  20632. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20633. *
  20634. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20635. */
  20636. export class MaterialHelper {
  20637. /**
  20638. * Bind the current view position to an effect.
  20639. * @param effect The effect to be bound
  20640. * @param scene The scene the eyes position is used from
  20641. * @param variableName name of the shader variable that will hold the eye position
  20642. */
  20643. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20644. /**
  20645. * Helps preparing the defines values about the UVs in used in the effect.
  20646. * UVs are shared as much as we can accross channels in the shaders.
  20647. * @param texture The texture we are preparing the UVs for
  20648. * @param defines The defines to update
  20649. * @param key The channel key "diffuse", "specular"... used in the shader
  20650. */
  20651. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20652. /**
  20653. * Binds a texture matrix value to its corrsponding uniform
  20654. * @param texture The texture to bind the matrix for
  20655. * @param uniformBuffer The uniform buffer receivin the data
  20656. * @param key The channel key "diffuse", "specular"... used in the shader
  20657. */
  20658. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20659. /**
  20660. * Gets the current status of the fog (should it be enabled?)
  20661. * @param mesh defines the mesh to evaluate for fog support
  20662. * @param scene defines the hosting scene
  20663. * @returns true if fog must be enabled
  20664. */
  20665. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20666. /**
  20667. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20668. * @param mesh defines the current mesh
  20669. * @param scene defines the current scene
  20670. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20671. * @param pointsCloud defines if point cloud rendering has to be turned on
  20672. * @param fogEnabled defines if fog has to be turned on
  20673. * @param alphaTest defines if alpha testing has to be turned on
  20674. * @param defines defines the current list of defines
  20675. */
  20676. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20677. /**
  20678. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20679. * @param scene defines the current scene
  20680. * @param engine defines the current engine
  20681. * @param defines specifies the list of active defines
  20682. * @param useInstances defines if instances have to be turned on
  20683. * @param useClipPlane defines if clip plane have to be turned on
  20684. * @param useInstances defines if instances have to be turned on
  20685. * @param useThinInstances defines if thin instances have to be turned on
  20686. */
  20687. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20688. /**
  20689. * Prepares the defines for bones
  20690. * @param mesh The mesh containing the geometry data we will draw
  20691. * @param defines The defines to update
  20692. */
  20693. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20694. /**
  20695. * Prepares the defines for morph targets
  20696. * @param mesh The mesh containing the geometry data we will draw
  20697. * @param defines The defines to update
  20698. */
  20699. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20700. /**
  20701. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20702. * @param mesh The mesh containing the geometry data we will draw
  20703. * @param defines The defines to update
  20704. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20705. * @param useBones Precise whether bones should be used or not (override mesh info)
  20706. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20707. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20708. * @returns false if defines are considered not dirty and have not been checked
  20709. */
  20710. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20711. /**
  20712. * Prepares the defines related to multiview
  20713. * @param scene The scene we are intending to draw
  20714. * @param defines The defines to update
  20715. */
  20716. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20717. /**
  20718. * Prepares the defines related to the prepass
  20719. * @param scene The scene we are intending to draw
  20720. * @param defines The defines to update
  20721. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20722. */
  20723. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20724. /**
  20725. * Prepares the defines related to the light information passed in parameter
  20726. * @param scene The scene we are intending to draw
  20727. * @param mesh The mesh the effect is compiling for
  20728. * @param light The light the effect is compiling for
  20729. * @param lightIndex The index of the light
  20730. * @param defines The defines to update
  20731. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20732. * @param state Defines the current state regarding what is needed (normals, etc...)
  20733. */
  20734. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20735. needNormals: boolean;
  20736. needRebuild: boolean;
  20737. shadowEnabled: boolean;
  20738. specularEnabled: boolean;
  20739. lightmapMode: boolean;
  20740. }): void;
  20741. /**
  20742. * Prepares the defines related to the light information passed in parameter
  20743. * @param scene The scene we are intending to draw
  20744. * @param mesh The mesh the effect is compiling for
  20745. * @param defines The defines to update
  20746. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20747. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20748. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20749. * @returns true if normals will be required for the rest of the effect
  20750. */
  20751. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20752. /**
  20753. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20754. * @param lightIndex defines the light index
  20755. * @param uniformsList The uniform list
  20756. * @param samplersList The sampler list
  20757. * @param projectedLightTexture defines if projected texture must be used
  20758. * @param uniformBuffersList defines an optional list of uniform buffers
  20759. */
  20760. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20761. /**
  20762. * Prepares the uniforms and samplers list to be used in the effect
  20763. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20764. * @param samplersList The sampler list
  20765. * @param defines The defines helping in the list generation
  20766. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20767. */
  20768. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20769. /**
  20770. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20771. * @param defines The defines to update while falling back
  20772. * @param fallbacks The authorized effect fallbacks
  20773. * @param maxSimultaneousLights The maximum number of lights allowed
  20774. * @param rank the current rank of the Effect
  20775. * @returns The newly affected rank
  20776. */
  20777. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20778. private static _TmpMorphInfluencers;
  20779. /**
  20780. * Prepares the list of attributes required for morph targets according to the effect defines.
  20781. * @param attribs The current list of supported attribs
  20782. * @param mesh The mesh to prepare the morph targets attributes for
  20783. * @param influencers The number of influencers
  20784. */
  20785. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20786. /**
  20787. * Prepares the list of attributes required for morph targets according to the effect defines.
  20788. * @param attribs The current list of supported attribs
  20789. * @param mesh The mesh to prepare the morph targets attributes for
  20790. * @param defines The current Defines of the effect
  20791. */
  20792. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20793. /**
  20794. * Prepares the list of attributes required for bones according to the effect defines.
  20795. * @param attribs The current list of supported attribs
  20796. * @param mesh The mesh to prepare the bones attributes for
  20797. * @param defines The current Defines of the effect
  20798. * @param fallbacks The current efffect fallback strategy
  20799. */
  20800. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20801. /**
  20802. * Check and prepare the list of attributes required for instances according to the effect defines.
  20803. * @param attribs The current list of supported attribs
  20804. * @param defines The current MaterialDefines of the effect
  20805. */
  20806. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20807. /**
  20808. * Add the list of attributes required for instances to the attribs array.
  20809. * @param attribs The current list of supported attribs
  20810. */
  20811. static PushAttributesForInstances(attribs: string[]): void;
  20812. /**
  20813. * Binds the light information to the effect.
  20814. * @param light The light containing the generator
  20815. * @param effect The effect we are binding the data to
  20816. * @param lightIndex The light index in the effect used to render
  20817. */
  20818. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20819. /**
  20820. * Binds the lights information from the scene to the effect for the given mesh.
  20821. * @param light Light to bind
  20822. * @param lightIndex Light index
  20823. * @param scene The scene where the light belongs to
  20824. * @param effect The effect we are binding the data to
  20825. * @param useSpecular Defines if specular is supported
  20826. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20827. */
  20828. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20829. /**
  20830. * Binds the lights information from the scene to the effect for the given mesh.
  20831. * @param scene The scene the lights belongs to
  20832. * @param mesh The mesh we are binding the information to render
  20833. * @param effect The effect we are binding the data to
  20834. * @param defines The generated defines for the effect
  20835. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20836. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20837. */
  20838. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20839. private static _tempFogColor;
  20840. /**
  20841. * Binds the fog information from the scene to the effect for the given mesh.
  20842. * @param scene The scene the lights belongs to
  20843. * @param mesh The mesh we are binding the information to render
  20844. * @param effect The effect we are binding the data to
  20845. * @param linearSpace Defines if the fog effect is applied in linear space
  20846. */
  20847. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20848. /**
  20849. * Binds the bones information from the mesh to the effect.
  20850. * @param mesh The mesh we are binding the information to render
  20851. * @param effect The effect we are binding the data to
  20852. */
  20853. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20854. /**
  20855. * Binds the morph targets information from the mesh to the effect.
  20856. * @param abstractMesh The mesh we are binding the information to render
  20857. * @param effect The effect we are binding the data to
  20858. */
  20859. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20860. /**
  20861. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20862. * @param defines The generated defines used in the effect
  20863. * @param effect The effect we are binding the data to
  20864. * @param scene The scene we are willing to render with logarithmic scale for
  20865. */
  20866. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20867. /**
  20868. * Binds the clip plane information from the scene to the effect.
  20869. * @param scene The scene the clip plane information are extracted from
  20870. * @param effect The effect we are binding the data to
  20871. */
  20872. static BindClipPlane(effect: Effect, scene: Scene): void;
  20873. }
  20874. }
  20875. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20877. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20878. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20879. import { Nullable } from "babylonjs/types";
  20880. import { Effect } from "babylonjs/Materials/effect";
  20881. import { Matrix } from "babylonjs/Maths/math.vector";
  20882. import { Scene } from "babylonjs/scene";
  20883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20885. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20886. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20887. import { Observable } from "babylonjs/Misc/observable";
  20888. /**
  20889. * Block used to expose an input value
  20890. */
  20891. export class InputBlock extends NodeMaterialBlock {
  20892. private _mode;
  20893. private _associatedVariableName;
  20894. private _storedValue;
  20895. private _valueCallback;
  20896. private _type;
  20897. private _animationType;
  20898. /** Gets or set a value used to limit the range of float values */
  20899. min: number;
  20900. /** Gets or set a value used to limit the range of float values */
  20901. max: number;
  20902. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20903. isBoolean: boolean;
  20904. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20905. matrixMode: number;
  20906. /** @hidden */
  20907. _systemValue: Nullable<NodeMaterialSystemValues>;
  20908. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20909. visibleInInspector: boolean;
  20910. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20911. isConstant: boolean;
  20912. /** Gets or sets the group to use to display this block in the Inspector */
  20913. groupInInspector: string;
  20914. /** Gets an observable raised when the value is changed */
  20915. onValueChangedObservable: Observable<InputBlock>;
  20916. /**
  20917. * Gets or sets the connection point type (default is float)
  20918. */
  20919. get type(): NodeMaterialBlockConnectionPointTypes;
  20920. /**
  20921. * Creates a new InputBlock
  20922. * @param name defines the block name
  20923. * @param target defines the target of that block (Vertex by default)
  20924. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20925. */
  20926. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20927. /**
  20928. * Validates if a name is a reserve word.
  20929. * @param newName the new name to be given to the node.
  20930. * @returns false if the name is a reserve word, else true.
  20931. */
  20932. validateBlockName(newName: string): boolean;
  20933. /**
  20934. * Gets the output component
  20935. */
  20936. get output(): NodeMaterialConnectionPoint;
  20937. /**
  20938. * Set the source of this connection point to a vertex attribute
  20939. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20940. * @returns the current connection point
  20941. */
  20942. setAsAttribute(attributeName?: string): InputBlock;
  20943. /**
  20944. * Set the source of this connection point to a system value
  20945. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20946. * @returns the current connection point
  20947. */
  20948. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20949. /**
  20950. * Gets or sets the value of that point.
  20951. * Please note that this value will be ignored if valueCallback is defined
  20952. */
  20953. get value(): any;
  20954. set value(value: any);
  20955. /**
  20956. * Gets or sets a callback used to get the value of that point.
  20957. * Please note that setting this value will force the connection point to ignore the value property
  20958. */
  20959. get valueCallback(): () => any;
  20960. set valueCallback(value: () => any);
  20961. /**
  20962. * Gets or sets the associated variable name in the shader
  20963. */
  20964. get associatedVariableName(): string;
  20965. set associatedVariableName(value: string);
  20966. /** Gets or sets the type of animation applied to the input */
  20967. get animationType(): AnimatedInputBlockTypes;
  20968. set animationType(value: AnimatedInputBlockTypes);
  20969. /**
  20970. * Gets a boolean indicating that this connection point not defined yet
  20971. */
  20972. get isUndefined(): boolean;
  20973. /**
  20974. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20975. * In this case the connection point name must be the name of the uniform to use.
  20976. * Can only be set on inputs
  20977. */
  20978. get isUniform(): boolean;
  20979. set isUniform(value: boolean);
  20980. /**
  20981. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20982. * In this case the connection point name must be the name of the attribute to use
  20983. * Can only be set on inputs
  20984. */
  20985. get isAttribute(): boolean;
  20986. set isAttribute(value: boolean);
  20987. /**
  20988. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20989. * Can only be set on exit points
  20990. */
  20991. get isVarying(): boolean;
  20992. set isVarying(value: boolean);
  20993. /**
  20994. * Gets a boolean indicating that the current connection point is a system value
  20995. */
  20996. get isSystemValue(): boolean;
  20997. /**
  20998. * Gets or sets the current well known value or null if not defined as a system value
  20999. */
  21000. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21001. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21002. /**
  21003. * Gets the current class name
  21004. * @returns the class name
  21005. */
  21006. getClassName(): string;
  21007. /**
  21008. * Animate the input if animationType !== None
  21009. * @param scene defines the rendering scene
  21010. */
  21011. animate(scene: Scene): void;
  21012. private _emitDefine;
  21013. initialize(state: NodeMaterialBuildState): void;
  21014. /**
  21015. * Set the input block to its default value (based on its type)
  21016. */
  21017. setDefaultValue(): void;
  21018. private _emitConstant;
  21019. /** @hidden */
  21020. get _noContextSwitch(): boolean;
  21021. private _emit;
  21022. /** @hidden */
  21023. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21024. /** @hidden */
  21025. _transmit(effect: Effect, scene: Scene): void;
  21026. protected _buildBlock(state: NodeMaterialBuildState): void;
  21027. protected _dumpPropertiesCode(): string;
  21028. dispose(): void;
  21029. serialize(): any;
  21030. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21031. }
  21032. }
  21033. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21034. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21035. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21036. import { Nullable } from "babylonjs/types";
  21037. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21038. import { Observable } from "babylonjs/Misc/observable";
  21039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21040. /**
  21041. * Enum used to define the compatibility state between two connection points
  21042. */
  21043. export enum NodeMaterialConnectionPointCompatibilityStates {
  21044. /** Points are compatibles */
  21045. Compatible = 0,
  21046. /** Points are incompatible because of their types */
  21047. TypeIncompatible = 1,
  21048. /** Points are incompatible because of their targets (vertex vs fragment) */
  21049. TargetIncompatible = 2
  21050. }
  21051. /**
  21052. * Defines the direction of a connection point
  21053. */
  21054. export enum NodeMaterialConnectionPointDirection {
  21055. /** Input */
  21056. Input = 0,
  21057. /** Output */
  21058. Output = 1
  21059. }
  21060. /**
  21061. * Defines a connection point for a block
  21062. */
  21063. export class NodeMaterialConnectionPoint {
  21064. /** @hidden */
  21065. _ownerBlock: NodeMaterialBlock;
  21066. /** @hidden */
  21067. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21068. private _endpoints;
  21069. private _associatedVariableName;
  21070. private _direction;
  21071. /** @hidden */
  21072. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21073. /** @hidden */
  21074. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21075. private _type;
  21076. /** @hidden */
  21077. _enforceAssociatedVariableName: boolean;
  21078. /** Gets the direction of the point */
  21079. get direction(): NodeMaterialConnectionPointDirection;
  21080. /** Indicates that this connection point needs dual validation before being connected to another point */
  21081. needDualDirectionValidation: boolean;
  21082. /**
  21083. * Gets or sets the additional types supported by this connection point
  21084. */
  21085. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21086. /**
  21087. * Gets or sets the additional types excluded by this connection point
  21088. */
  21089. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21090. /**
  21091. * Observable triggered when this point is connected
  21092. */
  21093. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21094. /**
  21095. * Gets or sets the associated variable name in the shader
  21096. */
  21097. get associatedVariableName(): string;
  21098. set associatedVariableName(value: string);
  21099. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21100. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21101. /**
  21102. * Gets or sets the connection point type (default is float)
  21103. */
  21104. get type(): NodeMaterialBlockConnectionPointTypes;
  21105. set type(value: NodeMaterialBlockConnectionPointTypes);
  21106. /**
  21107. * Gets or sets the connection point name
  21108. */
  21109. name: string;
  21110. /**
  21111. * Gets or sets the connection point name
  21112. */
  21113. displayName: string;
  21114. /**
  21115. * Gets or sets a boolean indicating that this connection point can be omitted
  21116. */
  21117. isOptional: boolean;
  21118. /**
  21119. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21120. */
  21121. isExposedOnFrame: boolean;
  21122. /**
  21123. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21124. */
  21125. define: string;
  21126. /** @hidden */
  21127. _prioritizeVertex: boolean;
  21128. private _target;
  21129. /** Gets or sets the target of that connection point */
  21130. get target(): NodeMaterialBlockTargets;
  21131. set target(value: NodeMaterialBlockTargets);
  21132. /**
  21133. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21134. */
  21135. get isConnected(): boolean;
  21136. /**
  21137. * Gets a boolean indicating that the current point is connected to an input block
  21138. */
  21139. get isConnectedToInputBlock(): boolean;
  21140. /**
  21141. * Gets a the connected input block (if any)
  21142. */
  21143. get connectInputBlock(): Nullable<InputBlock>;
  21144. /** Get the other side of the connection (if any) */
  21145. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21146. /** Get the block that owns this connection point */
  21147. get ownerBlock(): NodeMaterialBlock;
  21148. /** Get the block connected on the other side of this connection (if any) */
  21149. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21150. /** Get the block connected on the endpoints of this connection (if any) */
  21151. get connectedBlocks(): Array<NodeMaterialBlock>;
  21152. /** Gets the list of connected endpoints */
  21153. get endpoints(): NodeMaterialConnectionPoint[];
  21154. /** Gets a boolean indicating if that output point is connected to at least one input */
  21155. get hasEndpoints(): boolean;
  21156. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21157. get isConnectedInVertexShader(): boolean;
  21158. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21159. get isConnectedInFragmentShader(): boolean;
  21160. /**
  21161. * Creates a block suitable to be used as an input for this input point.
  21162. * If null is returned, a block based on the point type will be created.
  21163. * @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
  21164. */
  21165. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21166. /**
  21167. * Creates a new connection point
  21168. * @param name defines the connection point name
  21169. * @param ownerBlock defines the block hosting this connection point
  21170. * @param direction defines the direction of the connection point
  21171. */
  21172. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21173. /**
  21174. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21175. * @returns the class name
  21176. */
  21177. getClassName(): string;
  21178. /**
  21179. * Gets a boolean indicating if the current point can be connected to another point
  21180. * @param connectionPoint defines the other connection point
  21181. * @returns a boolean
  21182. */
  21183. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21184. /**
  21185. * Gets a number indicating if the current point can be connected to another point
  21186. * @param connectionPoint defines the other connection point
  21187. * @returns a number defining the compatibility state
  21188. */
  21189. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21190. /**
  21191. * Connect this point to another connection point
  21192. * @param connectionPoint defines the other connection point
  21193. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21194. * @returns the current connection point
  21195. */
  21196. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21197. /**
  21198. * Disconnect this point from one of his endpoint
  21199. * @param endpoint defines the other connection point
  21200. * @returns the current connection point
  21201. */
  21202. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21203. /**
  21204. * Serializes this point in a JSON representation
  21205. * @param isInput defines if the connection point is an input (default is true)
  21206. * @returns the serialized point object
  21207. */
  21208. serialize(isInput?: boolean): any;
  21209. /**
  21210. * Release resources
  21211. */
  21212. dispose(): void;
  21213. }
  21214. }
  21215. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21216. /**
  21217. * Enum used to define the material modes
  21218. */
  21219. export enum NodeMaterialModes {
  21220. /** Regular material */
  21221. Material = 0,
  21222. /** For post process */
  21223. PostProcess = 1,
  21224. /** For particle system */
  21225. Particle = 2
  21226. }
  21227. }
  21228. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21231. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21234. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21235. import { Effect } from "babylonjs/Materials/effect";
  21236. import { Mesh } from "babylonjs/Meshes/mesh";
  21237. import { Nullable } from "babylonjs/types";
  21238. import { Texture } from "babylonjs/Materials/Textures/texture";
  21239. import { Scene } from "babylonjs/scene";
  21240. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21241. /**
  21242. * Block used to read a texture from a sampler
  21243. */
  21244. export class TextureBlock extends NodeMaterialBlock {
  21245. private _defineName;
  21246. private _linearDefineName;
  21247. private _gammaDefineName;
  21248. private _tempTextureRead;
  21249. private _samplerName;
  21250. private _transformedUVName;
  21251. private _textureTransformName;
  21252. private _textureInfoName;
  21253. private _mainUVName;
  21254. private _mainUVDefineName;
  21255. private _fragmentOnly;
  21256. /**
  21257. * Gets or sets the texture associated with the node
  21258. */
  21259. texture: Nullable<Texture>;
  21260. /**
  21261. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21262. */
  21263. convertToGammaSpace: boolean;
  21264. /**
  21265. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21266. */
  21267. convertToLinearSpace: boolean;
  21268. /**
  21269. * Create a new TextureBlock
  21270. * @param name defines the block name
  21271. */
  21272. constructor(name: string, fragmentOnly?: boolean);
  21273. /**
  21274. * Gets the current class name
  21275. * @returns the class name
  21276. */
  21277. getClassName(): string;
  21278. /**
  21279. * Gets the uv input component
  21280. */
  21281. get uv(): NodeMaterialConnectionPoint;
  21282. /**
  21283. * Gets the rgba output component
  21284. */
  21285. get rgba(): NodeMaterialConnectionPoint;
  21286. /**
  21287. * Gets the rgb output component
  21288. */
  21289. get rgb(): NodeMaterialConnectionPoint;
  21290. /**
  21291. * Gets the r output component
  21292. */
  21293. get r(): NodeMaterialConnectionPoint;
  21294. /**
  21295. * Gets the g output component
  21296. */
  21297. get g(): NodeMaterialConnectionPoint;
  21298. /**
  21299. * Gets the b output component
  21300. */
  21301. get b(): NodeMaterialConnectionPoint;
  21302. /**
  21303. * Gets the a output component
  21304. */
  21305. get a(): NodeMaterialConnectionPoint;
  21306. get target(): NodeMaterialBlockTargets;
  21307. autoConfigure(material: NodeMaterial): void;
  21308. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21310. isReady(): boolean;
  21311. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21312. private get _isMixed();
  21313. private _injectVertexCode;
  21314. private _writeTextureRead;
  21315. private _writeOutput;
  21316. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21317. protected _dumpPropertiesCode(): string;
  21318. serialize(): any;
  21319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21320. }
  21321. }
  21322. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21323. /** @hidden */
  21324. export var reflectionFunction: {
  21325. name: string;
  21326. shader: string;
  21327. };
  21328. }
  21329. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21335. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21336. import { Effect } from "babylonjs/Materials/effect";
  21337. import { Mesh } from "babylonjs/Meshes/mesh";
  21338. import { Nullable } from "babylonjs/types";
  21339. import { Scene } from "babylonjs/scene";
  21340. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21341. /**
  21342. * Base block used to read a reflection texture from a sampler
  21343. */
  21344. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21345. /** @hidden */
  21346. _define3DName: string;
  21347. /** @hidden */
  21348. _defineCubicName: string;
  21349. /** @hidden */
  21350. _defineExplicitName: string;
  21351. /** @hidden */
  21352. _defineProjectionName: string;
  21353. /** @hidden */
  21354. _defineLocalCubicName: string;
  21355. /** @hidden */
  21356. _defineSphericalName: string;
  21357. /** @hidden */
  21358. _definePlanarName: string;
  21359. /** @hidden */
  21360. _defineEquirectangularName: string;
  21361. /** @hidden */
  21362. _defineMirroredEquirectangularFixedName: string;
  21363. /** @hidden */
  21364. _defineEquirectangularFixedName: string;
  21365. /** @hidden */
  21366. _defineSkyboxName: string;
  21367. /** @hidden */
  21368. _defineOppositeZ: string;
  21369. /** @hidden */
  21370. _cubeSamplerName: string;
  21371. /** @hidden */
  21372. _2DSamplerName: string;
  21373. protected _positionUVWName: string;
  21374. protected _directionWName: string;
  21375. protected _reflectionVectorName: string;
  21376. /** @hidden */
  21377. _reflectionCoordsName: string;
  21378. /** @hidden */
  21379. _reflectionMatrixName: string;
  21380. protected _reflectionColorName: string;
  21381. /**
  21382. * Gets or sets the texture associated with the node
  21383. */
  21384. texture: Nullable<BaseTexture>;
  21385. /**
  21386. * Create a new ReflectionTextureBaseBlock
  21387. * @param name defines the block name
  21388. */
  21389. constructor(name: string);
  21390. /**
  21391. * Gets the current class name
  21392. * @returns the class name
  21393. */
  21394. getClassName(): string;
  21395. /**
  21396. * Gets the world position input component
  21397. */
  21398. abstract get position(): NodeMaterialConnectionPoint;
  21399. /**
  21400. * Gets the world position input component
  21401. */
  21402. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21403. /**
  21404. * Gets the world normal input component
  21405. */
  21406. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21407. /**
  21408. * Gets the world input component
  21409. */
  21410. abstract get world(): NodeMaterialConnectionPoint;
  21411. /**
  21412. * Gets the camera (or eye) position component
  21413. */
  21414. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21415. /**
  21416. * Gets the view input component
  21417. */
  21418. abstract get view(): NodeMaterialConnectionPoint;
  21419. protected _getTexture(): Nullable<BaseTexture>;
  21420. autoConfigure(material: NodeMaterial): void;
  21421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21422. isReady(): boolean;
  21423. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21424. /**
  21425. * Gets the code to inject in the vertex shader
  21426. * @param state current state of the node material building
  21427. * @returns the shader code
  21428. */
  21429. handleVertexSide(state: NodeMaterialBuildState): string;
  21430. /**
  21431. * Handles the inits for the fragment code path
  21432. * @param state node material build state
  21433. */
  21434. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21435. /**
  21436. * Generates the reflection coords code for the fragment code path
  21437. * @param worldNormalVarName name of the world normal variable
  21438. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21439. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21440. * @returns the shader code
  21441. */
  21442. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21443. /**
  21444. * Generates the reflection color code for the fragment code path
  21445. * @param lodVarName name of the lod variable
  21446. * @param swizzleLookupTexture swizzle to use for the final color variable
  21447. * @returns the shader code
  21448. */
  21449. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21450. /**
  21451. * Generates the code corresponding to the connected output points
  21452. * @param state node material build state
  21453. * @param varName name of the variable to output
  21454. * @returns the shader code
  21455. */
  21456. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21457. protected _buildBlock(state: NodeMaterialBuildState): this;
  21458. protected _dumpPropertiesCode(): string;
  21459. serialize(): any;
  21460. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21461. }
  21462. }
  21463. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21465. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21466. import { Nullable } from "babylonjs/types";
  21467. /**
  21468. * Defines a connection point to be used for points with a custom object type
  21469. */
  21470. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21471. private _blockType;
  21472. private _blockName;
  21473. private _nameForCheking?;
  21474. /**
  21475. * Creates a new connection point
  21476. * @param name defines the connection point name
  21477. * @param ownerBlock defines the block hosting this connection point
  21478. * @param direction defines the direction of the connection point
  21479. */
  21480. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21481. /**
  21482. * Gets a number indicating if the current point can be connected to another point
  21483. * @param connectionPoint defines the other connection point
  21484. * @returns a number defining the compatibility state
  21485. */
  21486. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21487. /**
  21488. * Creates a block suitable to be used as an input for this input point.
  21489. * If null is returned, a block based on the point type will be created.
  21490. * @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
  21491. */
  21492. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21493. }
  21494. }
  21495. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21496. /**
  21497. * Enum defining the type of properties that can be edited in the property pages in the NME
  21498. */
  21499. export enum PropertyTypeForEdition {
  21500. /** property is a boolean */
  21501. Boolean = 0,
  21502. /** property is a float */
  21503. Float = 1,
  21504. /** property is a Vector2 */
  21505. Vector2 = 2,
  21506. /** property is a list of values */
  21507. List = 3
  21508. }
  21509. /**
  21510. * Interface that defines an option in a variable of type list
  21511. */
  21512. export interface IEditablePropertyListOption {
  21513. /** label of the option */
  21514. "label": string;
  21515. /** value of the option */
  21516. "value": number;
  21517. }
  21518. /**
  21519. * Interface that defines the options available for an editable property
  21520. */
  21521. export interface IEditablePropertyOption {
  21522. /** min value */
  21523. "min"?: number;
  21524. /** max value */
  21525. "max"?: number;
  21526. /** notifiers: indicates which actions to take when the property is changed */
  21527. "notifiers"?: {
  21528. /** the material should be rebuilt */
  21529. "rebuild"?: boolean;
  21530. /** the preview should be updated */
  21531. "update"?: boolean;
  21532. };
  21533. /** list of the options for a variable of type list */
  21534. "options"?: IEditablePropertyListOption[];
  21535. }
  21536. /**
  21537. * Interface that describes an editable property
  21538. */
  21539. export interface IPropertyDescriptionForEdition {
  21540. /** name of the property */
  21541. "propertyName": string;
  21542. /** display name of the property */
  21543. "displayName": string;
  21544. /** type of the property */
  21545. "type": PropertyTypeForEdition;
  21546. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21547. "groupName": string;
  21548. /** options for the property */
  21549. "options": IEditablePropertyOption;
  21550. }
  21551. /**
  21552. * Decorator that flags a property in a node material block as being editable
  21553. */
  21554. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21555. }
  21556. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21559. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21561. import { Nullable } from "babylonjs/types";
  21562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21563. import { Mesh } from "babylonjs/Meshes/mesh";
  21564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21565. import { Effect } from "babylonjs/Materials/effect";
  21566. import { Scene } from "babylonjs/scene";
  21567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21568. /**
  21569. * Block used to implement the refraction part of the sub surface module of the PBR material
  21570. */
  21571. export class RefractionBlock extends NodeMaterialBlock {
  21572. /** @hidden */
  21573. _define3DName: string;
  21574. /** @hidden */
  21575. _refractionMatrixName: string;
  21576. /** @hidden */
  21577. _defineLODRefractionAlpha: string;
  21578. /** @hidden */
  21579. _defineLinearSpecularRefraction: string;
  21580. /** @hidden */
  21581. _defineOppositeZ: string;
  21582. /** @hidden */
  21583. _cubeSamplerName: string;
  21584. /** @hidden */
  21585. _2DSamplerName: string;
  21586. /** @hidden */
  21587. _vRefractionMicrosurfaceInfosName: string;
  21588. /** @hidden */
  21589. _vRefractionInfosName: string;
  21590. private _scene;
  21591. /**
  21592. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21593. * Materials half opaque for instance using refraction could benefit from this control.
  21594. */
  21595. linkRefractionWithTransparency: boolean;
  21596. /**
  21597. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21598. */
  21599. invertRefractionY: boolean;
  21600. /**
  21601. * Gets or sets the texture associated with the node
  21602. */
  21603. texture: Nullable<BaseTexture>;
  21604. /**
  21605. * Create a new RefractionBlock
  21606. * @param name defines the block name
  21607. */
  21608. constructor(name: string);
  21609. /**
  21610. * Gets the current class name
  21611. * @returns the class name
  21612. */
  21613. getClassName(): string;
  21614. /**
  21615. * Gets the intensity input component
  21616. */
  21617. get intensity(): NodeMaterialConnectionPoint;
  21618. /**
  21619. * Gets the index of refraction input component
  21620. */
  21621. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21622. /**
  21623. * Gets the tint at distance input component
  21624. */
  21625. get tintAtDistance(): NodeMaterialConnectionPoint;
  21626. /**
  21627. * Gets the view input component
  21628. */
  21629. get view(): NodeMaterialConnectionPoint;
  21630. /**
  21631. * Gets the refraction object output component
  21632. */
  21633. get refraction(): NodeMaterialConnectionPoint;
  21634. /**
  21635. * Returns true if the block has a texture
  21636. */
  21637. get hasTexture(): boolean;
  21638. protected _getTexture(): Nullable<BaseTexture>;
  21639. autoConfigure(material: NodeMaterial): void;
  21640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21641. isReady(): boolean;
  21642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21643. /**
  21644. * Gets the main code of the block (fragment side)
  21645. * @param state current state of the node material building
  21646. * @returns the shader code
  21647. */
  21648. getCode(state: NodeMaterialBuildState): string;
  21649. protected _buildBlock(state: NodeMaterialBuildState): this;
  21650. protected _dumpPropertiesCode(): string;
  21651. serialize(): any;
  21652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21653. }
  21654. }
  21655. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21658. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21661. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21663. import { Nullable } from "babylonjs/types";
  21664. import { Scene } from "babylonjs/scene";
  21665. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21666. /**
  21667. * Base block used as input for post process
  21668. */
  21669. export class CurrentScreenBlock extends NodeMaterialBlock {
  21670. private _samplerName;
  21671. private _linearDefineName;
  21672. private _gammaDefineName;
  21673. private _mainUVName;
  21674. private _tempTextureRead;
  21675. /**
  21676. * Gets or sets the texture associated with the node
  21677. */
  21678. texture: Nullable<BaseTexture>;
  21679. /**
  21680. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21681. */
  21682. convertToGammaSpace: boolean;
  21683. /**
  21684. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21685. */
  21686. convertToLinearSpace: boolean;
  21687. /**
  21688. * Create a new CurrentScreenBlock
  21689. * @param name defines the block name
  21690. */
  21691. constructor(name: string);
  21692. /**
  21693. * Gets the current class name
  21694. * @returns the class name
  21695. */
  21696. getClassName(): string;
  21697. /**
  21698. * Gets the uv input component
  21699. */
  21700. get uv(): NodeMaterialConnectionPoint;
  21701. /**
  21702. * Gets the rgba output component
  21703. */
  21704. get rgba(): NodeMaterialConnectionPoint;
  21705. /**
  21706. * Gets the rgb output component
  21707. */
  21708. get rgb(): NodeMaterialConnectionPoint;
  21709. /**
  21710. * Gets the r output component
  21711. */
  21712. get r(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the g output component
  21715. */
  21716. get g(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the b output component
  21719. */
  21720. get b(): NodeMaterialConnectionPoint;
  21721. /**
  21722. * Gets the a output component
  21723. */
  21724. get a(): NodeMaterialConnectionPoint;
  21725. /**
  21726. * Initialize the block and prepare the context for build
  21727. * @param state defines the state that will be used for the build
  21728. */
  21729. initialize(state: NodeMaterialBuildState): void;
  21730. get target(): NodeMaterialBlockTargets;
  21731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21732. isReady(): boolean;
  21733. private _injectVertexCode;
  21734. private _writeTextureRead;
  21735. private _writeOutput;
  21736. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21737. serialize(): any;
  21738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21739. }
  21740. }
  21741. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21746. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21747. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21748. import { Nullable } from "babylonjs/types";
  21749. import { Scene } from "babylonjs/scene";
  21750. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21751. /**
  21752. * Base block used for the particle texture
  21753. */
  21754. export class ParticleTextureBlock extends NodeMaterialBlock {
  21755. private _samplerName;
  21756. private _linearDefineName;
  21757. private _gammaDefineName;
  21758. private _tempTextureRead;
  21759. /**
  21760. * Gets or sets the texture associated with the node
  21761. */
  21762. texture: Nullable<BaseTexture>;
  21763. /**
  21764. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21765. */
  21766. convertToGammaSpace: boolean;
  21767. /**
  21768. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21769. */
  21770. convertToLinearSpace: boolean;
  21771. /**
  21772. * Create a new ParticleTextureBlock
  21773. * @param name defines the block name
  21774. */
  21775. constructor(name: string);
  21776. /**
  21777. * Gets the current class name
  21778. * @returns the class name
  21779. */
  21780. getClassName(): string;
  21781. /**
  21782. * Gets the uv input component
  21783. */
  21784. get uv(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the rgba output component
  21787. */
  21788. get rgba(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the rgb output component
  21791. */
  21792. get rgb(): NodeMaterialConnectionPoint;
  21793. /**
  21794. * Gets the r output component
  21795. */
  21796. get r(): NodeMaterialConnectionPoint;
  21797. /**
  21798. * Gets the g output component
  21799. */
  21800. get g(): NodeMaterialConnectionPoint;
  21801. /**
  21802. * Gets the b output component
  21803. */
  21804. get b(): NodeMaterialConnectionPoint;
  21805. /**
  21806. * Gets the a output component
  21807. */
  21808. get a(): NodeMaterialConnectionPoint;
  21809. /**
  21810. * Initialize the block and prepare the context for build
  21811. * @param state defines the state that will be used for the build
  21812. */
  21813. initialize(state: NodeMaterialBuildState): void;
  21814. autoConfigure(material: NodeMaterial): void;
  21815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21816. isReady(): boolean;
  21817. private _writeOutput;
  21818. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21819. serialize(): any;
  21820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21821. }
  21822. }
  21823. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21826. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21827. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21828. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21829. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21830. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21831. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21832. import { Scene } from "babylonjs/scene";
  21833. /**
  21834. * Class used to store shared data between 2 NodeMaterialBuildState
  21835. */
  21836. export class NodeMaterialBuildStateSharedData {
  21837. /**
  21838. * Gets the list of emitted varyings
  21839. */
  21840. temps: string[];
  21841. /**
  21842. * Gets the list of emitted varyings
  21843. */
  21844. varyings: string[];
  21845. /**
  21846. * Gets the varying declaration string
  21847. */
  21848. varyingDeclaration: string;
  21849. /**
  21850. * Input blocks
  21851. */
  21852. inputBlocks: InputBlock[];
  21853. /**
  21854. * Input blocks
  21855. */
  21856. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21857. /**
  21858. * Bindable blocks (Blocks that need to set data to the effect)
  21859. */
  21860. bindableBlocks: NodeMaterialBlock[];
  21861. /**
  21862. * List of blocks that can provide a compilation fallback
  21863. */
  21864. blocksWithFallbacks: NodeMaterialBlock[];
  21865. /**
  21866. * List of blocks that can provide a define update
  21867. */
  21868. blocksWithDefines: NodeMaterialBlock[];
  21869. /**
  21870. * List of blocks that can provide a repeatable content
  21871. */
  21872. repeatableContentBlocks: NodeMaterialBlock[];
  21873. /**
  21874. * List of blocks that can provide a dynamic list of uniforms
  21875. */
  21876. dynamicUniformBlocks: NodeMaterialBlock[];
  21877. /**
  21878. * List of blocks that can block the isReady function for the material
  21879. */
  21880. blockingBlocks: NodeMaterialBlock[];
  21881. /**
  21882. * Gets the list of animated inputs
  21883. */
  21884. animatedInputs: InputBlock[];
  21885. /**
  21886. * Build Id used to avoid multiple recompilations
  21887. */
  21888. buildId: number;
  21889. /** List of emitted variables */
  21890. variableNames: {
  21891. [key: string]: number;
  21892. };
  21893. /** List of emitted defines */
  21894. defineNames: {
  21895. [key: string]: number;
  21896. };
  21897. /** Should emit comments? */
  21898. emitComments: boolean;
  21899. /** Emit build activity */
  21900. verbose: boolean;
  21901. /** Gets or sets the hosting scene */
  21902. scene: Scene;
  21903. /**
  21904. * Gets the compilation hints emitted at compilation time
  21905. */
  21906. hints: {
  21907. needWorldViewMatrix: boolean;
  21908. needWorldViewProjectionMatrix: boolean;
  21909. needAlphaBlending: boolean;
  21910. needAlphaTesting: boolean;
  21911. };
  21912. /**
  21913. * List of compilation checks
  21914. */
  21915. checks: {
  21916. emitVertex: boolean;
  21917. emitFragment: boolean;
  21918. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21919. };
  21920. /**
  21921. * Is vertex program allowed to be empty?
  21922. */
  21923. allowEmptyVertexProgram: boolean;
  21924. /** Creates a new shared data */
  21925. constructor();
  21926. /**
  21927. * Emits console errors and exceptions if there is a failing check
  21928. */
  21929. emitErrors(): void;
  21930. }
  21931. }
  21932. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21933. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21934. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21935. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21936. /**
  21937. * Class used to store node based material build state
  21938. */
  21939. export class NodeMaterialBuildState {
  21940. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21941. supportUniformBuffers: boolean;
  21942. /**
  21943. * Gets the list of emitted attributes
  21944. */
  21945. attributes: string[];
  21946. /**
  21947. * Gets the list of emitted uniforms
  21948. */
  21949. uniforms: string[];
  21950. /**
  21951. * Gets the list of emitted constants
  21952. */
  21953. constants: string[];
  21954. /**
  21955. * Gets the list of emitted samplers
  21956. */
  21957. samplers: string[];
  21958. /**
  21959. * Gets the list of emitted functions
  21960. */
  21961. functions: {
  21962. [key: string]: string;
  21963. };
  21964. /**
  21965. * Gets the list of emitted extensions
  21966. */
  21967. extensions: {
  21968. [key: string]: string;
  21969. };
  21970. /**
  21971. * Gets the target of the compilation state
  21972. */
  21973. target: NodeMaterialBlockTargets;
  21974. /**
  21975. * Gets the list of emitted counters
  21976. */
  21977. counters: {
  21978. [key: string]: number;
  21979. };
  21980. /**
  21981. * Shared data between multiple NodeMaterialBuildState instances
  21982. */
  21983. sharedData: NodeMaterialBuildStateSharedData;
  21984. /** @hidden */
  21985. _vertexState: NodeMaterialBuildState;
  21986. /** @hidden */
  21987. _attributeDeclaration: string;
  21988. /** @hidden */
  21989. _uniformDeclaration: string;
  21990. /** @hidden */
  21991. _constantDeclaration: string;
  21992. /** @hidden */
  21993. _samplerDeclaration: string;
  21994. /** @hidden */
  21995. _varyingTransfer: string;
  21996. /** @hidden */
  21997. _injectAtEnd: string;
  21998. private _repeatableContentAnchorIndex;
  21999. /** @hidden */
  22000. _builtCompilationString: string;
  22001. /**
  22002. * Gets the emitted compilation strings
  22003. */
  22004. compilationString: string;
  22005. /**
  22006. * Finalize the compilation strings
  22007. * @param state defines the current compilation state
  22008. */
  22009. finalize(state: NodeMaterialBuildState): void;
  22010. /** @hidden */
  22011. get _repeatableContentAnchor(): string;
  22012. /** @hidden */
  22013. _getFreeVariableName(prefix: string): string;
  22014. /** @hidden */
  22015. _getFreeDefineName(prefix: string): string;
  22016. /** @hidden */
  22017. _excludeVariableName(name: string): void;
  22018. /** @hidden */
  22019. _emit2DSampler(name: string): void;
  22020. /** @hidden */
  22021. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22022. /** @hidden */
  22023. _emitExtension(name: string, extension: string, define?: string): void;
  22024. /** @hidden */
  22025. _emitFunction(name: string, code: string, comments: string): void;
  22026. /** @hidden */
  22027. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22028. replaceStrings?: {
  22029. search: RegExp;
  22030. replace: string;
  22031. }[];
  22032. repeatKey?: string;
  22033. }): string;
  22034. /** @hidden */
  22035. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22036. repeatKey?: string;
  22037. removeAttributes?: boolean;
  22038. removeUniforms?: boolean;
  22039. removeVaryings?: boolean;
  22040. removeIfDef?: boolean;
  22041. replaceStrings?: {
  22042. search: RegExp;
  22043. replace: string;
  22044. }[];
  22045. }, storeKey?: string): void;
  22046. /** @hidden */
  22047. _registerTempVariable(name: string): boolean;
  22048. /** @hidden */
  22049. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22050. /** @hidden */
  22051. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22052. /** @hidden */
  22053. _emitFloat(value: number): string;
  22054. }
  22055. }
  22056. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22057. /**
  22058. * Helper class used to generate session unique ID
  22059. */
  22060. export class UniqueIdGenerator {
  22061. private static _UniqueIdCounter;
  22062. /**
  22063. * Gets an unique (relatively to the current scene) Id
  22064. */
  22065. static get UniqueId(): number;
  22066. }
  22067. }
  22068. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22069. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22071. import { Nullable } from "babylonjs/types";
  22072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22073. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22074. import { Effect } from "babylonjs/Materials/effect";
  22075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22076. import { Mesh } from "babylonjs/Meshes/mesh";
  22077. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22078. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22079. import { Scene } from "babylonjs/scene";
  22080. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22081. /**
  22082. * Defines a block that can be used inside a node based material
  22083. */
  22084. export class NodeMaterialBlock {
  22085. private _buildId;
  22086. private _buildTarget;
  22087. private _target;
  22088. private _isFinalMerger;
  22089. private _isInput;
  22090. private _name;
  22091. protected _isUnique: boolean;
  22092. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22093. inputsAreExclusive: boolean;
  22094. /** @hidden */
  22095. _codeVariableName: string;
  22096. /** @hidden */
  22097. _inputs: NodeMaterialConnectionPoint[];
  22098. /** @hidden */
  22099. _outputs: NodeMaterialConnectionPoint[];
  22100. /** @hidden */
  22101. _preparationId: number;
  22102. /**
  22103. * Gets the name of the block
  22104. */
  22105. get name(): string;
  22106. /**
  22107. * Sets the name of the block. Will check if the name is valid.
  22108. */
  22109. set name(newName: string);
  22110. /**
  22111. * Gets or sets the unique id of the node
  22112. */
  22113. uniqueId: number;
  22114. /**
  22115. * Gets or sets the comments associated with this block
  22116. */
  22117. comments: string;
  22118. /**
  22119. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22120. */
  22121. get isUnique(): boolean;
  22122. /**
  22123. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22124. */
  22125. get isFinalMerger(): boolean;
  22126. /**
  22127. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22128. */
  22129. get isInput(): boolean;
  22130. /**
  22131. * Gets or sets the build Id
  22132. */
  22133. get buildId(): number;
  22134. set buildId(value: number);
  22135. /**
  22136. * Gets or sets the target of the block
  22137. */
  22138. get target(): NodeMaterialBlockTargets;
  22139. set target(value: NodeMaterialBlockTargets);
  22140. /**
  22141. * Gets the list of input points
  22142. */
  22143. get inputs(): NodeMaterialConnectionPoint[];
  22144. /** Gets the list of output points */
  22145. get outputs(): NodeMaterialConnectionPoint[];
  22146. /**
  22147. * Find an input by its name
  22148. * @param name defines the name of the input to look for
  22149. * @returns the input or null if not found
  22150. */
  22151. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22152. /**
  22153. * Find an output by its name
  22154. * @param name defines the name of the outputto look for
  22155. * @returns the output or null if not found
  22156. */
  22157. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22158. /**
  22159. * Creates a new NodeMaterialBlock
  22160. * @param name defines the block name
  22161. * @param target defines the target of that block (Vertex by default)
  22162. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22163. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22164. */
  22165. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22166. /**
  22167. * Initialize the block and prepare the context for build
  22168. * @param state defines the state that will be used for the build
  22169. */
  22170. initialize(state: NodeMaterialBuildState): void;
  22171. /**
  22172. * Bind data to effect. Will only be called for blocks with isBindable === true
  22173. * @param effect defines the effect to bind data to
  22174. * @param nodeMaterial defines the hosting NodeMaterial
  22175. * @param mesh defines the mesh that will be rendered
  22176. * @param subMesh defines the submesh that will be rendered
  22177. */
  22178. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22179. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22180. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22181. protected _writeFloat(value: number): string;
  22182. /**
  22183. * Gets the current class name e.g. "NodeMaterialBlock"
  22184. * @returns the class name
  22185. */
  22186. getClassName(): string;
  22187. /**
  22188. * Register a new input. Must be called inside a block constructor
  22189. * @param name defines the connection point name
  22190. * @param type defines the connection point type
  22191. * @param isOptional defines a boolean indicating that this input can be omitted
  22192. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22193. * @param point an already created connection point. If not provided, create a new one
  22194. * @returns the current block
  22195. */
  22196. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22197. /**
  22198. * Register a new output. Must be called inside a block constructor
  22199. * @param name defines the connection point name
  22200. * @param type defines the connection point type
  22201. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22202. * @param point an already created connection point. If not provided, create a new one
  22203. * @returns the current block
  22204. */
  22205. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22206. /**
  22207. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22208. * @param forOutput defines an optional connection point to check compatibility with
  22209. * @returns the first available input or null
  22210. */
  22211. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22212. /**
  22213. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22214. * @param forBlock defines an optional block to check compatibility with
  22215. * @returns the first available input or null
  22216. */
  22217. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22218. /**
  22219. * Gets the sibling of the given output
  22220. * @param current defines the current output
  22221. * @returns the next output in the list or null
  22222. */
  22223. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22224. /**
  22225. * Connect current block with another block
  22226. * @param other defines the block to connect with
  22227. * @param options define the various options to help pick the right connections
  22228. * @returns the current block
  22229. */
  22230. connectTo(other: NodeMaterialBlock, options?: {
  22231. input?: string;
  22232. output?: string;
  22233. outputSwizzle?: string;
  22234. }): this | undefined;
  22235. protected _buildBlock(state: NodeMaterialBuildState): void;
  22236. /**
  22237. * Add uniforms, samplers and uniform buffers at compilation time
  22238. * @param state defines the state to update
  22239. * @param nodeMaterial defines the node material requesting the update
  22240. * @param defines defines the material defines to update
  22241. * @param uniformBuffers defines the list of uniform buffer names
  22242. */
  22243. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22244. /**
  22245. * Add potential fallbacks if shader compilation fails
  22246. * @param mesh defines the mesh to be rendered
  22247. * @param fallbacks defines the current prioritized list of fallbacks
  22248. */
  22249. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22250. /**
  22251. * Initialize defines for shader compilation
  22252. * @param mesh defines the mesh to be rendered
  22253. * @param nodeMaterial defines the node material requesting the update
  22254. * @param defines defines the material defines to update
  22255. * @param useInstances specifies that instances should be used
  22256. */
  22257. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22258. /**
  22259. * Update defines for shader compilation
  22260. * @param mesh defines the mesh to be rendered
  22261. * @param nodeMaterial defines the node material requesting the update
  22262. * @param defines defines the material defines to update
  22263. * @param useInstances specifies that instances should be used
  22264. * @param subMesh defines which submesh to render
  22265. */
  22266. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22267. /**
  22268. * Lets the block try to connect some inputs automatically
  22269. * @param material defines the hosting NodeMaterial
  22270. */
  22271. autoConfigure(material: NodeMaterial): void;
  22272. /**
  22273. * Function called when a block is declared as repeatable content generator
  22274. * @param vertexShaderState defines the current compilation state for the vertex shader
  22275. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22276. * @param mesh defines the mesh to be rendered
  22277. * @param defines defines the material defines to update
  22278. */
  22279. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22280. /**
  22281. * Checks if the block is ready
  22282. * @param mesh defines the mesh to be rendered
  22283. * @param nodeMaterial defines the node material requesting the update
  22284. * @param defines defines the material defines to update
  22285. * @param useInstances specifies that instances should be used
  22286. * @returns true if the block is ready
  22287. */
  22288. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22289. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22290. private _processBuild;
  22291. /**
  22292. * Validates the new name for the block node.
  22293. * @param newName the new name to be given to the node.
  22294. * @returns false if the name is a reserve word, else true.
  22295. */
  22296. validateBlockName(newName: string): boolean;
  22297. /**
  22298. * Compile the current node and generate the shader code
  22299. * @param state defines the current compilation state (uniforms, samplers, current string)
  22300. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22301. * @returns true if already built
  22302. */
  22303. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22304. protected _inputRename(name: string): string;
  22305. protected _outputRename(name: string): string;
  22306. protected _dumpPropertiesCode(): string;
  22307. /** @hidden */
  22308. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22309. /** @hidden */
  22310. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22311. /**
  22312. * Clone the current block to a new identical block
  22313. * @param scene defines the hosting scene
  22314. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22315. * @returns a copy of the current block
  22316. */
  22317. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22318. /**
  22319. * Serializes this block in a JSON representation
  22320. * @returns the serialized block object
  22321. */
  22322. serialize(): any;
  22323. /** @hidden */
  22324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22325. private _deserializePortDisplayNamesAndExposedOnFrame;
  22326. /**
  22327. * Release resources
  22328. */
  22329. dispose(): void;
  22330. }
  22331. }
  22332. declare module "babylonjs/Materials/pushMaterial" {
  22333. import { Nullable } from "babylonjs/types";
  22334. import { Scene } from "babylonjs/scene";
  22335. import { Matrix } from "babylonjs/Maths/math.vector";
  22336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22337. import { Mesh } from "babylonjs/Meshes/mesh";
  22338. import { Material } from "babylonjs/Materials/material";
  22339. import { Effect } from "babylonjs/Materials/effect";
  22340. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22341. /**
  22342. * Base class of materials working in push mode in babylon JS
  22343. * @hidden
  22344. */
  22345. export class PushMaterial extends Material {
  22346. protected _activeEffect: Effect;
  22347. protected _normalMatrix: Matrix;
  22348. constructor(name: string, scene: Scene);
  22349. getEffect(): Effect;
  22350. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22351. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22352. /**
  22353. * Binds the given world matrix to the active effect
  22354. *
  22355. * @param world the matrix to bind
  22356. */
  22357. bindOnlyWorldMatrix(world: Matrix): void;
  22358. /**
  22359. * Binds the given normal matrix to the active effect
  22360. *
  22361. * @param normalMatrix the matrix to bind
  22362. */
  22363. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22364. bind(world: Matrix, mesh?: Mesh): void;
  22365. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22366. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22367. }
  22368. }
  22369. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22371. /**
  22372. * Root class for all node material optimizers
  22373. */
  22374. export class NodeMaterialOptimizer {
  22375. /**
  22376. * Function used to optimize a NodeMaterial graph
  22377. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22378. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22379. */
  22380. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22381. }
  22382. }
  22383. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22384. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22385. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22386. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22387. import { Scene } from "babylonjs/scene";
  22388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22389. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22391. /**
  22392. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22393. */
  22394. export class TransformBlock extends NodeMaterialBlock {
  22395. /**
  22396. * Defines the value to use to complement W value to transform it to a Vector4
  22397. */
  22398. complementW: number;
  22399. /**
  22400. * Defines the value to use to complement z value to transform it to a Vector4
  22401. */
  22402. complementZ: number;
  22403. /**
  22404. * Creates a new TransformBlock
  22405. * @param name defines the block name
  22406. */
  22407. constructor(name: string);
  22408. /**
  22409. * Gets the current class name
  22410. * @returns the class name
  22411. */
  22412. getClassName(): string;
  22413. /**
  22414. * Gets the vector input
  22415. */
  22416. get vector(): NodeMaterialConnectionPoint;
  22417. /**
  22418. * Gets the output component
  22419. */
  22420. get output(): NodeMaterialConnectionPoint;
  22421. /**
  22422. * Gets the xyz output component
  22423. */
  22424. get xyz(): NodeMaterialConnectionPoint;
  22425. /**
  22426. * Gets the matrix transform input
  22427. */
  22428. get transform(): NodeMaterialConnectionPoint;
  22429. protected _buildBlock(state: NodeMaterialBuildState): this;
  22430. /**
  22431. * Update defines for shader compilation
  22432. * @param mesh defines the mesh to be rendered
  22433. * @param nodeMaterial defines the node material requesting the update
  22434. * @param defines defines the material defines to update
  22435. * @param useInstances specifies that instances should be used
  22436. * @param subMesh defines which submesh to render
  22437. */
  22438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22439. serialize(): any;
  22440. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22441. protected _dumpPropertiesCode(): string;
  22442. }
  22443. }
  22444. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22448. /**
  22449. * Block used to output the vertex position
  22450. */
  22451. export class VertexOutputBlock extends NodeMaterialBlock {
  22452. /**
  22453. * Creates a new VertexOutputBlock
  22454. * @param name defines the block name
  22455. */
  22456. constructor(name: string);
  22457. /**
  22458. * Gets the current class name
  22459. * @returns the class name
  22460. */
  22461. getClassName(): string;
  22462. /**
  22463. * Gets the vector input component
  22464. */
  22465. get vector(): NodeMaterialConnectionPoint;
  22466. protected _buildBlock(state: NodeMaterialBuildState): this;
  22467. }
  22468. }
  22469. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22473. /**
  22474. * Block used to output the final color
  22475. */
  22476. export class FragmentOutputBlock extends NodeMaterialBlock {
  22477. /**
  22478. * Create a new FragmentOutputBlock
  22479. * @param name defines the block name
  22480. */
  22481. constructor(name: string);
  22482. /**
  22483. * Gets the current class name
  22484. * @returns the class name
  22485. */
  22486. getClassName(): string;
  22487. /**
  22488. * Gets the rgba input component
  22489. */
  22490. get rgba(): NodeMaterialConnectionPoint;
  22491. /**
  22492. * Gets the rgb input component
  22493. */
  22494. get rgb(): NodeMaterialConnectionPoint;
  22495. /**
  22496. * Gets the a input component
  22497. */
  22498. get a(): NodeMaterialConnectionPoint;
  22499. protected _buildBlock(state: NodeMaterialBuildState): this;
  22500. }
  22501. }
  22502. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22506. /**
  22507. * Block used for the particle ramp gradient section
  22508. */
  22509. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22510. /**
  22511. * Create a new ParticleRampGradientBlock
  22512. * @param name defines the block name
  22513. */
  22514. constructor(name: string);
  22515. /**
  22516. * Gets the current class name
  22517. * @returns the class name
  22518. */
  22519. getClassName(): string;
  22520. /**
  22521. * Gets the color input component
  22522. */
  22523. get color(): NodeMaterialConnectionPoint;
  22524. /**
  22525. * Gets the rampColor output component
  22526. */
  22527. get rampColor(): NodeMaterialConnectionPoint;
  22528. /**
  22529. * Initialize the block and prepare the context for build
  22530. * @param state defines the state that will be used for the build
  22531. */
  22532. initialize(state: NodeMaterialBuildState): void;
  22533. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22534. }
  22535. }
  22536. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22540. /**
  22541. * Block used for the particle blend multiply section
  22542. */
  22543. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22544. /**
  22545. * Create a new ParticleBlendMultiplyBlock
  22546. * @param name defines the block name
  22547. */
  22548. constructor(name: string);
  22549. /**
  22550. * Gets the current class name
  22551. * @returns the class name
  22552. */
  22553. getClassName(): string;
  22554. /**
  22555. * Gets the color input component
  22556. */
  22557. get color(): NodeMaterialConnectionPoint;
  22558. /**
  22559. * Gets the alphaTexture input component
  22560. */
  22561. get alphaTexture(): NodeMaterialConnectionPoint;
  22562. /**
  22563. * Gets the alphaColor input component
  22564. */
  22565. get alphaColor(): NodeMaterialConnectionPoint;
  22566. /**
  22567. * Gets the blendColor output component
  22568. */
  22569. get blendColor(): NodeMaterialConnectionPoint;
  22570. /**
  22571. * Initialize the block and prepare the context for build
  22572. * @param state defines the state that will be used for the build
  22573. */
  22574. initialize(state: NodeMaterialBuildState): void;
  22575. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22576. }
  22577. }
  22578. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22582. /**
  22583. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22584. */
  22585. export class VectorMergerBlock extends NodeMaterialBlock {
  22586. /**
  22587. * Create a new VectorMergerBlock
  22588. * @param name defines the block name
  22589. */
  22590. constructor(name: string);
  22591. /**
  22592. * Gets the current class name
  22593. * @returns the class name
  22594. */
  22595. getClassName(): string;
  22596. /**
  22597. * Gets the xyz component (input)
  22598. */
  22599. get xyzIn(): NodeMaterialConnectionPoint;
  22600. /**
  22601. * Gets the xy component (input)
  22602. */
  22603. get xyIn(): NodeMaterialConnectionPoint;
  22604. /**
  22605. * Gets the x component (input)
  22606. */
  22607. get x(): NodeMaterialConnectionPoint;
  22608. /**
  22609. * Gets the y component (input)
  22610. */
  22611. get y(): NodeMaterialConnectionPoint;
  22612. /**
  22613. * Gets the z component (input)
  22614. */
  22615. get z(): NodeMaterialConnectionPoint;
  22616. /**
  22617. * Gets the w component (input)
  22618. */
  22619. get w(): NodeMaterialConnectionPoint;
  22620. /**
  22621. * Gets the xyzw component (output)
  22622. */
  22623. get xyzw(): NodeMaterialConnectionPoint;
  22624. /**
  22625. * Gets the xyz component (output)
  22626. */
  22627. get xyzOut(): NodeMaterialConnectionPoint;
  22628. /**
  22629. * Gets the xy component (output)
  22630. */
  22631. get xyOut(): NodeMaterialConnectionPoint;
  22632. /**
  22633. * Gets the xy component (output)
  22634. * @deprecated Please use xyOut instead.
  22635. */
  22636. get xy(): NodeMaterialConnectionPoint;
  22637. /**
  22638. * Gets the xyz component (output)
  22639. * @deprecated Please use xyzOut instead.
  22640. */
  22641. get xyz(): NodeMaterialConnectionPoint;
  22642. protected _buildBlock(state: NodeMaterialBuildState): this;
  22643. }
  22644. }
  22645. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22649. import { Vector2 } from "babylonjs/Maths/math.vector";
  22650. import { Scene } from "babylonjs/scene";
  22651. /**
  22652. * Block used to remap a float from a range to a new one
  22653. */
  22654. export class RemapBlock extends NodeMaterialBlock {
  22655. /**
  22656. * Gets or sets the source range
  22657. */
  22658. sourceRange: Vector2;
  22659. /**
  22660. * Gets or sets the target range
  22661. */
  22662. targetRange: Vector2;
  22663. /**
  22664. * Creates a new RemapBlock
  22665. * @param name defines the block name
  22666. */
  22667. constructor(name: string);
  22668. /**
  22669. * Gets the current class name
  22670. * @returns the class name
  22671. */
  22672. getClassName(): string;
  22673. /**
  22674. * Gets the input component
  22675. */
  22676. get input(): NodeMaterialConnectionPoint;
  22677. /**
  22678. * Gets the source min input component
  22679. */
  22680. get sourceMin(): NodeMaterialConnectionPoint;
  22681. /**
  22682. * Gets the source max input component
  22683. */
  22684. get sourceMax(): NodeMaterialConnectionPoint;
  22685. /**
  22686. * Gets the target min input component
  22687. */
  22688. get targetMin(): NodeMaterialConnectionPoint;
  22689. /**
  22690. * Gets the target max input component
  22691. */
  22692. get targetMax(): NodeMaterialConnectionPoint;
  22693. /**
  22694. * Gets the output component
  22695. */
  22696. get output(): NodeMaterialConnectionPoint;
  22697. protected _buildBlock(state: NodeMaterialBuildState): this;
  22698. protected _dumpPropertiesCode(): string;
  22699. serialize(): any;
  22700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22701. }
  22702. }
  22703. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22707. /**
  22708. * Block used to multiply 2 values
  22709. */
  22710. export class MultiplyBlock extends NodeMaterialBlock {
  22711. /**
  22712. * Creates a new MultiplyBlock
  22713. * @param name defines the block name
  22714. */
  22715. constructor(name: string);
  22716. /**
  22717. * Gets the current class name
  22718. * @returns the class name
  22719. */
  22720. getClassName(): string;
  22721. /**
  22722. * Gets the left operand input component
  22723. */
  22724. get left(): NodeMaterialConnectionPoint;
  22725. /**
  22726. * Gets the right operand input component
  22727. */
  22728. get right(): NodeMaterialConnectionPoint;
  22729. /**
  22730. * Gets the output component
  22731. */
  22732. get output(): NodeMaterialConnectionPoint;
  22733. protected _buildBlock(state: NodeMaterialBuildState): this;
  22734. }
  22735. }
  22736. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22740. /**
  22741. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22742. */
  22743. export class ColorSplitterBlock extends NodeMaterialBlock {
  22744. /**
  22745. * Create a new ColorSplitterBlock
  22746. * @param name defines the block name
  22747. */
  22748. constructor(name: string);
  22749. /**
  22750. * Gets the current class name
  22751. * @returns the class name
  22752. */
  22753. getClassName(): string;
  22754. /**
  22755. * Gets the rgba component (input)
  22756. */
  22757. get rgba(): NodeMaterialConnectionPoint;
  22758. /**
  22759. * Gets the rgb component (input)
  22760. */
  22761. get rgbIn(): NodeMaterialConnectionPoint;
  22762. /**
  22763. * Gets the rgb component (output)
  22764. */
  22765. get rgbOut(): NodeMaterialConnectionPoint;
  22766. /**
  22767. * Gets the r component (output)
  22768. */
  22769. get r(): NodeMaterialConnectionPoint;
  22770. /**
  22771. * Gets the g component (output)
  22772. */
  22773. get g(): NodeMaterialConnectionPoint;
  22774. /**
  22775. * Gets the b component (output)
  22776. */
  22777. get b(): NodeMaterialConnectionPoint;
  22778. /**
  22779. * Gets the a component (output)
  22780. */
  22781. get a(): NodeMaterialConnectionPoint;
  22782. protected _inputRename(name: string): string;
  22783. protected _outputRename(name: string): string;
  22784. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22785. }
  22786. }
  22787. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22789. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22790. import { Scene } from "babylonjs/scene";
  22791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22792. import { Matrix } from "babylonjs/Maths/math.vector";
  22793. import { Mesh } from "babylonjs/Meshes/mesh";
  22794. import { Engine } from "babylonjs/Engines/engine";
  22795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22796. import { Observable } from "babylonjs/Misc/observable";
  22797. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22798. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22799. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22800. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22801. import { Nullable } from "babylonjs/types";
  22802. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22803. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22804. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22805. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22806. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22807. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22808. import { Effect } from "babylonjs/Materials/effect";
  22809. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22810. import { Camera } from "babylonjs/Cameras/camera";
  22811. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22812. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22813. /**
  22814. * Interface used to configure the node material editor
  22815. */
  22816. export interface INodeMaterialEditorOptions {
  22817. /** Define the URl to load node editor script */
  22818. editorURL?: string;
  22819. }
  22820. /** @hidden */
  22821. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22822. NORMAL: boolean;
  22823. TANGENT: boolean;
  22824. UV1: boolean;
  22825. /** BONES */
  22826. NUM_BONE_INFLUENCERS: number;
  22827. BonesPerMesh: number;
  22828. BONETEXTURE: boolean;
  22829. /** MORPH TARGETS */
  22830. MORPHTARGETS: boolean;
  22831. MORPHTARGETS_NORMAL: boolean;
  22832. MORPHTARGETS_TANGENT: boolean;
  22833. MORPHTARGETS_UV: boolean;
  22834. NUM_MORPH_INFLUENCERS: number;
  22835. /** IMAGE PROCESSING */
  22836. IMAGEPROCESSING: boolean;
  22837. VIGNETTE: boolean;
  22838. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22839. VIGNETTEBLENDMODEOPAQUE: boolean;
  22840. TONEMAPPING: boolean;
  22841. TONEMAPPING_ACES: boolean;
  22842. CONTRAST: boolean;
  22843. EXPOSURE: boolean;
  22844. COLORCURVES: boolean;
  22845. COLORGRADING: boolean;
  22846. COLORGRADING3D: boolean;
  22847. SAMPLER3DGREENDEPTH: boolean;
  22848. SAMPLER3DBGRMAP: boolean;
  22849. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22850. /** MISC. */
  22851. BUMPDIRECTUV: number;
  22852. constructor();
  22853. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22854. }
  22855. /**
  22856. * Class used to configure NodeMaterial
  22857. */
  22858. export interface INodeMaterialOptions {
  22859. /**
  22860. * Defines if blocks should emit comments
  22861. */
  22862. emitComments: boolean;
  22863. }
  22864. /**
  22865. * Class used to create a node based material built by assembling shader blocks
  22866. */
  22867. export class NodeMaterial extends PushMaterial {
  22868. private static _BuildIdGenerator;
  22869. private _options;
  22870. private _vertexCompilationState;
  22871. private _fragmentCompilationState;
  22872. private _sharedData;
  22873. private _buildId;
  22874. private _buildWasSuccessful;
  22875. private _cachedWorldViewMatrix;
  22876. private _cachedWorldViewProjectionMatrix;
  22877. private _optimizers;
  22878. private _animationFrame;
  22879. /** Define the Url to load node editor script */
  22880. static EditorURL: string;
  22881. /** Define the Url to load snippets */
  22882. static SnippetUrl: string;
  22883. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22884. static IgnoreTexturesAtLoadTime: boolean;
  22885. private BJSNODEMATERIALEDITOR;
  22886. /** Get the inspector from bundle or global */
  22887. private _getGlobalNodeMaterialEditor;
  22888. /**
  22889. * Snippet ID if the material was created from the snippet server
  22890. */
  22891. snippetId: string;
  22892. /**
  22893. * Gets or sets data used by visual editor
  22894. * @see https://nme.babylonjs.com
  22895. */
  22896. editorData: any;
  22897. /**
  22898. * 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)
  22899. */
  22900. ignoreAlpha: boolean;
  22901. /**
  22902. * Defines the maximum number of lights that can be used in the material
  22903. */
  22904. maxSimultaneousLights: number;
  22905. /**
  22906. * Observable raised when the material is built
  22907. */
  22908. onBuildObservable: Observable<NodeMaterial>;
  22909. /**
  22910. * Gets or sets the root nodes of the material vertex shader
  22911. */
  22912. _vertexOutputNodes: NodeMaterialBlock[];
  22913. /**
  22914. * Gets or sets the root nodes of the material fragment (pixel) shader
  22915. */
  22916. _fragmentOutputNodes: NodeMaterialBlock[];
  22917. /** Gets or sets options to control the node material overall behavior */
  22918. get options(): INodeMaterialOptions;
  22919. set options(options: INodeMaterialOptions);
  22920. /**
  22921. * Default configuration related to image processing available in the standard Material.
  22922. */
  22923. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22924. /**
  22925. * Gets the image processing configuration used either in this material.
  22926. */
  22927. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22928. /**
  22929. * Sets the Default image processing configuration used either in the this material.
  22930. *
  22931. * If sets to null, the scene one is in use.
  22932. */
  22933. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22934. /**
  22935. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22936. */
  22937. attachedBlocks: NodeMaterialBlock[];
  22938. /**
  22939. * Specifies the mode of the node material
  22940. * @hidden
  22941. */
  22942. _mode: NodeMaterialModes;
  22943. /**
  22944. * Gets the mode property
  22945. */
  22946. get mode(): NodeMaterialModes;
  22947. /**
  22948. * Create a new node based material
  22949. * @param name defines the material name
  22950. * @param scene defines the hosting scene
  22951. * @param options defines creation option
  22952. */
  22953. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22954. /**
  22955. * Gets the current class name of the material e.g. "NodeMaterial"
  22956. * @returns the class name
  22957. */
  22958. getClassName(): string;
  22959. /**
  22960. * Keep track of the image processing observer to allow dispose and replace.
  22961. */
  22962. private _imageProcessingObserver;
  22963. /**
  22964. * Attaches a new image processing configuration to the Standard Material.
  22965. * @param configuration
  22966. */
  22967. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22968. /**
  22969. * Get a block by its name
  22970. * @param name defines the name of the block to retrieve
  22971. * @returns the required block or null if not found
  22972. */
  22973. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22974. /**
  22975. * Get a block by its name
  22976. * @param predicate defines the predicate used to find the good candidate
  22977. * @returns the required block or null if not found
  22978. */
  22979. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22980. /**
  22981. * Get an input block by its name
  22982. * @param predicate defines the predicate used to find the good candidate
  22983. * @returns the required input block or null if not found
  22984. */
  22985. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22986. /**
  22987. * Gets the list of input blocks attached to this material
  22988. * @returns an array of InputBlocks
  22989. */
  22990. getInputBlocks(): InputBlock[];
  22991. /**
  22992. * Adds a new optimizer to the list of optimizers
  22993. * @param optimizer defines the optimizers to add
  22994. * @returns the current material
  22995. */
  22996. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22997. /**
  22998. * Remove an optimizer from the list of optimizers
  22999. * @param optimizer defines the optimizers to remove
  23000. * @returns the current material
  23001. */
  23002. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23003. /**
  23004. * Add a new block to the list of output nodes
  23005. * @param node defines the node to add
  23006. * @returns the current material
  23007. */
  23008. addOutputNode(node: NodeMaterialBlock): this;
  23009. /**
  23010. * Remove a block from the list of root nodes
  23011. * @param node defines the node to remove
  23012. * @returns the current material
  23013. */
  23014. removeOutputNode(node: NodeMaterialBlock): this;
  23015. private _addVertexOutputNode;
  23016. private _removeVertexOutputNode;
  23017. private _addFragmentOutputNode;
  23018. private _removeFragmentOutputNode;
  23019. /**
  23020. * Specifies if the material will require alpha blending
  23021. * @returns a boolean specifying if alpha blending is needed
  23022. */
  23023. needAlphaBlending(): boolean;
  23024. /**
  23025. * Specifies if this material should be rendered in alpha test mode
  23026. * @returns a boolean specifying if an alpha test is needed.
  23027. */
  23028. needAlphaTesting(): boolean;
  23029. private _initializeBlock;
  23030. private _resetDualBlocks;
  23031. /**
  23032. * Remove a block from the current node material
  23033. * @param block defines the block to remove
  23034. */
  23035. removeBlock(block: NodeMaterialBlock): void;
  23036. /**
  23037. * Build the material and generates the inner effect
  23038. * @param verbose defines if the build should log activity
  23039. */
  23040. build(verbose?: boolean): void;
  23041. /**
  23042. * Runs an otpimization phase to try to improve the shader code
  23043. */
  23044. optimize(): void;
  23045. private _prepareDefinesForAttributes;
  23046. /**
  23047. * Create a post process from the material
  23048. * @param camera The camera to apply the render pass to.
  23049. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23051. * @param engine The engine which the post process will be applied. (default: current engine)
  23052. * @param reusable If the post process can be reused on the same frame. (default: false)
  23053. * @param textureType Type of textures used when performing the post process. (default: 0)
  23054. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23055. * @returns the post process created
  23056. */
  23057. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23058. /**
  23059. * Create the post process effect from the material
  23060. * @param postProcess The post process to create the effect for
  23061. */
  23062. createEffectForPostProcess(postProcess: PostProcess): void;
  23063. private _createEffectOrPostProcess;
  23064. private _createEffectForParticles;
  23065. /**
  23066. * Create the effect to be used as the custom effect for a particle system
  23067. * @param particleSystem Particle system to create the effect for
  23068. * @param onCompiled defines a function to call when the effect creation is successful
  23069. * @param onError defines a function to call when the effect creation has failed
  23070. */
  23071. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23072. private _processDefines;
  23073. /**
  23074. * Get if the submesh is ready to be used and all its information available.
  23075. * Child classes can use it to update shaders
  23076. * @param mesh defines the mesh to check
  23077. * @param subMesh defines which submesh to check
  23078. * @param useInstances specifies that instances should be used
  23079. * @returns a boolean indicating that the submesh is ready or not
  23080. */
  23081. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23082. /**
  23083. * Get a string representing the shaders built by the current node graph
  23084. */
  23085. get compiledShaders(): string;
  23086. /**
  23087. * Binds the world matrix to the material
  23088. * @param world defines the world transformation matrix
  23089. */
  23090. bindOnlyWorldMatrix(world: Matrix): void;
  23091. /**
  23092. * Binds the submesh to this material by preparing the effect and shader to draw
  23093. * @param world defines the world transformation matrix
  23094. * @param mesh defines the mesh containing the submesh
  23095. * @param subMesh defines the submesh to bind the material to
  23096. */
  23097. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23098. /**
  23099. * Gets the active textures from the material
  23100. * @returns an array of textures
  23101. */
  23102. getActiveTextures(): BaseTexture[];
  23103. /**
  23104. * Gets the list of texture blocks
  23105. * @returns an array of texture blocks
  23106. */
  23107. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23108. /**
  23109. * Specifies if the material uses a texture
  23110. * @param texture defines the texture to check against the material
  23111. * @returns a boolean specifying if the material uses the texture
  23112. */
  23113. hasTexture(texture: BaseTexture): boolean;
  23114. /**
  23115. * Disposes the material
  23116. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23117. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23118. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23119. */
  23120. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23121. /** Creates the node editor window. */
  23122. private _createNodeEditor;
  23123. /**
  23124. * Launch the node material editor
  23125. * @param config Define the configuration of the editor
  23126. * @return a promise fulfilled when the node editor is visible
  23127. */
  23128. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23129. /**
  23130. * Clear the current material
  23131. */
  23132. clear(): void;
  23133. /**
  23134. * Clear the current material and set it to a default state
  23135. */
  23136. setToDefault(): void;
  23137. /**
  23138. * Clear the current material and set it to a default state for post process
  23139. */
  23140. setToDefaultPostProcess(): void;
  23141. /**
  23142. * Clear the current material and set it to a default state for particle
  23143. */
  23144. setToDefaultParticle(): void;
  23145. /**
  23146. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23147. * @param url defines the url to load from
  23148. * @returns a promise that will fullfil when the material is fully loaded
  23149. */
  23150. loadAsync(url: string): Promise<void>;
  23151. private _gatherBlocks;
  23152. /**
  23153. * Generate a string containing the code declaration required to create an equivalent of this material
  23154. * @returns a string
  23155. */
  23156. generateCode(): string;
  23157. /**
  23158. * Serializes this material in a JSON representation
  23159. * @returns the serialized material object
  23160. */
  23161. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23162. private _restoreConnections;
  23163. /**
  23164. * Clear the current graph and load a new one from a serialization object
  23165. * @param source defines the JSON representation of the material
  23166. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23167. * @param merge defines whether or not the source must be merged or replace the current content
  23168. */
  23169. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23170. /**
  23171. * Makes a duplicate of the current material.
  23172. * @param name - name to use for the new material.
  23173. */
  23174. clone(name: string): NodeMaterial;
  23175. /**
  23176. * Creates a node material from parsed material data
  23177. * @param source defines the JSON representation of the material
  23178. * @param scene defines the hosting scene
  23179. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23180. * @returns a new node material
  23181. */
  23182. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23183. /**
  23184. * Creates a node material from a snippet saved in a remote file
  23185. * @param name defines the name of the material to create
  23186. * @param url defines the url to load from
  23187. * @param scene defines the hosting scene
  23188. * @returns a promise that will resolve to the new node material
  23189. */
  23190. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23191. /**
  23192. * Creates a node material from a snippet saved by the node material editor
  23193. * @param snippetId defines the snippet to load
  23194. * @param scene defines the hosting scene
  23195. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23196. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23197. * @returns a promise that will resolve to the new node material
  23198. */
  23199. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23200. /**
  23201. * Creates a new node material set to default basic configuration
  23202. * @param name defines the name of the material
  23203. * @param scene defines the hosting scene
  23204. * @returns a new NodeMaterial
  23205. */
  23206. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23207. }
  23208. }
  23209. declare module "babylonjs/PostProcesses/postProcess" {
  23210. import { Nullable } from "babylonjs/types";
  23211. import { SmartArray } from "babylonjs/Misc/smartArray";
  23212. import { Observable } from "babylonjs/Misc/observable";
  23213. import { Vector2 } from "babylonjs/Maths/math.vector";
  23214. import { Camera } from "babylonjs/Cameras/camera";
  23215. import { Effect } from "babylonjs/Materials/effect";
  23216. import "babylonjs/Shaders/postprocess.vertex";
  23217. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23218. import { Engine } from "babylonjs/Engines/engine";
  23219. import { Color4 } from "babylonjs/Maths/math.color";
  23220. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23221. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23222. import { Scene } from "babylonjs/scene";
  23223. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23224. /**
  23225. * Size options for a post process
  23226. */
  23227. export type PostProcessOptions = {
  23228. width: number;
  23229. height: number;
  23230. };
  23231. /**
  23232. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23233. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23234. */
  23235. export class PostProcess {
  23236. /** Name of the PostProcess. */
  23237. name: string;
  23238. /**
  23239. * Gets or sets the unique id of the post process
  23240. */
  23241. uniqueId: number;
  23242. /**
  23243. * Width of the texture to apply the post process on
  23244. */
  23245. width: number;
  23246. /**
  23247. * Height of the texture to apply the post process on
  23248. */
  23249. height: number;
  23250. /**
  23251. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23252. */
  23253. nodeMaterialSource: Nullable<NodeMaterial>;
  23254. /**
  23255. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23256. * @hidden
  23257. */
  23258. _outputTexture: Nullable<InternalTexture>;
  23259. /**
  23260. * Sampling mode used by the shader
  23261. * See https://doc.babylonjs.com/classes/3.1/texture
  23262. */
  23263. renderTargetSamplingMode: number;
  23264. /**
  23265. * Clear color to use when screen clearing
  23266. */
  23267. clearColor: Color4;
  23268. /**
  23269. * If the buffer needs to be cleared before applying the post process. (default: true)
  23270. * Should be set to false if shader will overwrite all previous pixels.
  23271. */
  23272. autoClear: boolean;
  23273. /**
  23274. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23275. */
  23276. alphaMode: number;
  23277. /**
  23278. * Sets the setAlphaBlendConstants of the babylon engine
  23279. */
  23280. alphaConstants: Color4;
  23281. /**
  23282. * Animations to be used for the post processing
  23283. */
  23284. animations: import("babylonjs/Animations/animation").Animation[];
  23285. /**
  23286. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23287. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23288. */
  23289. enablePixelPerfectMode: boolean;
  23290. /**
  23291. * Force the postprocess to be applied without taking in account viewport
  23292. */
  23293. forceFullscreenViewport: boolean;
  23294. /**
  23295. * List of inspectable custom properties (used by the Inspector)
  23296. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23297. */
  23298. inspectableCustomProperties: IInspectable[];
  23299. /**
  23300. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23301. *
  23302. * | Value | Type | Description |
  23303. * | ----- | ----------------------------------- | ----------- |
  23304. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23305. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23306. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23307. *
  23308. */
  23309. scaleMode: number;
  23310. /**
  23311. * Force textures to be a power of two (default: false)
  23312. */
  23313. alwaysForcePOT: boolean;
  23314. private _samples;
  23315. /**
  23316. * Number of sample textures (default: 1)
  23317. */
  23318. get samples(): number;
  23319. set samples(n: number);
  23320. /**
  23321. * Modify the scale of the post process to be the same as the viewport (default: false)
  23322. */
  23323. adaptScaleToCurrentViewport: boolean;
  23324. private _camera;
  23325. protected _scene: Scene;
  23326. private _engine;
  23327. private _options;
  23328. private _reusable;
  23329. private _textureType;
  23330. private _textureFormat;
  23331. /**
  23332. * Smart array of input and output textures for the post process.
  23333. * @hidden
  23334. */
  23335. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23336. /**
  23337. * The index in _textures that corresponds to the output texture.
  23338. * @hidden
  23339. */
  23340. _currentRenderTextureInd: number;
  23341. private _effect;
  23342. private _samplers;
  23343. private _fragmentUrl;
  23344. private _vertexUrl;
  23345. private _parameters;
  23346. private _scaleRatio;
  23347. protected _indexParameters: any;
  23348. private _shareOutputWithPostProcess;
  23349. private _texelSize;
  23350. private _forcedOutputTexture;
  23351. /**
  23352. * Returns the fragment url or shader name used in the post process.
  23353. * @returns the fragment url or name in the shader store.
  23354. */
  23355. getEffectName(): string;
  23356. /**
  23357. * An event triggered when the postprocess is activated.
  23358. */
  23359. onActivateObservable: Observable<Camera>;
  23360. private _onActivateObserver;
  23361. /**
  23362. * A function that is added to the onActivateObservable
  23363. */
  23364. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23365. /**
  23366. * An event triggered when the postprocess changes its size.
  23367. */
  23368. onSizeChangedObservable: Observable<PostProcess>;
  23369. private _onSizeChangedObserver;
  23370. /**
  23371. * A function that is added to the onSizeChangedObservable
  23372. */
  23373. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23374. /**
  23375. * An event triggered when the postprocess applies its effect.
  23376. */
  23377. onApplyObservable: Observable<Effect>;
  23378. private _onApplyObserver;
  23379. /**
  23380. * A function that is added to the onApplyObservable
  23381. */
  23382. set onApply(callback: (effect: Effect) => void);
  23383. /**
  23384. * An event triggered before rendering the postprocess
  23385. */
  23386. onBeforeRenderObservable: Observable<Effect>;
  23387. private _onBeforeRenderObserver;
  23388. /**
  23389. * A function that is added to the onBeforeRenderObservable
  23390. */
  23391. set onBeforeRender(callback: (effect: Effect) => void);
  23392. /**
  23393. * An event triggered after rendering the postprocess
  23394. */
  23395. onAfterRenderObservable: Observable<Effect>;
  23396. private _onAfterRenderObserver;
  23397. /**
  23398. * A function that is added to the onAfterRenderObservable
  23399. */
  23400. set onAfterRender(callback: (efect: Effect) => void);
  23401. /**
  23402. * 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
  23403. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23404. */
  23405. get inputTexture(): InternalTexture;
  23406. set inputTexture(value: InternalTexture);
  23407. /**
  23408. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23409. * the only way to unset it is to use this function to restore its internal state
  23410. */
  23411. restoreDefaultInputTexture(): void;
  23412. /**
  23413. * Gets the camera which post process is applied to.
  23414. * @returns The camera the post process is applied to.
  23415. */
  23416. getCamera(): Camera;
  23417. /**
  23418. * Gets the texel size of the postprocess.
  23419. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23420. */
  23421. get texelSize(): Vector2;
  23422. /**
  23423. * Creates a new instance PostProcess
  23424. * @param name The name of the PostProcess.
  23425. * @param fragmentUrl The url of the fragment shader to be used.
  23426. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23427. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23428. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23429. * @param camera The camera to apply the render pass to.
  23430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23431. * @param engine The engine which the post process will be applied. (default: current engine)
  23432. * @param reusable If the post process can be reused on the same frame. (default: false)
  23433. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23434. * @param textureType Type of textures used when performing the post process. (default: 0)
  23435. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23436. * @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
  23437. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23438. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23439. */
  23440. constructor(
  23441. /** Name of the PostProcess. */
  23442. 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);
  23443. /**
  23444. * Gets a string idenfifying the name of the class
  23445. * @returns "PostProcess" string
  23446. */
  23447. getClassName(): string;
  23448. /**
  23449. * Gets the engine which this post process belongs to.
  23450. * @returns The engine the post process was enabled with.
  23451. */
  23452. getEngine(): Engine;
  23453. /**
  23454. * The effect that is created when initializing the post process.
  23455. * @returns The created effect corresponding the the postprocess.
  23456. */
  23457. getEffect(): Effect;
  23458. /**
  23459. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23460. * @param postProcess The post process to share the output with.
  23461. * @returns This post process.
  23462. */
  23463. shareOutputWith(postProcess: PostProcess): PostProcess;
  23464. /**
  23465. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23466. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23467. */
  23468. useOwnOutput(): void;
  23469. /**
  23470. * Updates the effect with the current post process compile time values and recompiles the shader.
  23471. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23472. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23473. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23474. * @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
  23475. * @param onCompiled Called when the shader has been compiled.
  23476. * @param onError Called if there is an error when compiling a shader.
  23477. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23478. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23479. */
  23480. 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;
  23481. /**
  23482. * The post process is reusable if it can be used multiple times within one frame.
  23483. * @returns If the post process is reusable
  23484. */
  23485. isReusable(): boolean;
  23486. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23487. markTextureDirty(): void;
  23488. /**
  23489. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23490. * 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.
  23491. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23492. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23493. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23494. * @returns The target texture that was bound to be written to.
  23495. */
  23496. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23497. /**
  23498. * If the post process is supported.
  23499. */
  23500. get isSupported(): boolean;
  23501. /**
  23502. * The aspect ratio of the output texture.
  23503. */
  23504. get aspectRatio(): number;
  23505. /**
  23506. * Get a value indicating if the post-process is ready to be used
  23507. * @returns true if the post-process is ready (shader is compiled)
  23508. */
  23509. isReady(): boolean;
  23510. /**
  23511. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23512. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23513. */
  23514. apply(): Nullable<Effect>;
  23515. private _disposeTextures;
  23516. /**
  23517. * Disposes the post process.
  23518. * @param camera The camera to dispose the post process on.
  23519. */
  23520. dispose(camera?: Camera): void;
  23521. }
  23522. }
  23523. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23524. /** @hidden */
  23525. export var kernelBlurVaryingDeclaration: {
  23526. name: string;
  23527. shader: string;
  23528. };
  23529. }
  23530. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23531. /** @hidden */
  23532. export var kernelBlurFragment: {
  23533. name: string;
  23534. shader: string;
  23535. };
  23536. }
  23537. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23538. /** @hidden */
  23539. export var kernelBlurFragment2: {
  23540. name: string;
  23541. shader: string;
  23542. };
  23543. }
  23544. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23545. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23546. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23547. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23548. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23549. /** @hidden */
  23550. export var kernelBlurPixelShader: {
  23551. name: string;
  23552. shader: string;
  23553. };
  23554. }
  23555. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23556. /** @hidden */
  23557. export var kernelBlurVertex: {
  23558. name: string;
  23559. shader: string;
  23560. };
  23561. }
  23562. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23563. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23564. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23565. /** @hidden */
  23566. export var kernelBlurVertexShader: {
  23567. name: string;
  23568. shader: string;
  23569. };
  23570. }
  23571. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23572. import { Vector2 } from "babylonjs/Maths/math.vector";
  23573. import { Nullable } from "babylonjs/types";
  23574. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23575. import { Camera } from "babylonjs/Cameras/camera";
  23576. import { Effect } from "babylonjs/Materials/effect";
  23577. import { Engine } from "babylonjs/Engines/engine";
  23578. import "babylonjs/Shaders/kernelBlur.fragment";
  23579. import "babylonjs/Shaders/kernelBlur.vertex";
  23580. /**
  23581. * The Blur Post Process which blurs an image based on a kernel and direction.
  23582. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23583. */
  23584. export class BlurPostProcess extends PostProcess {
  23585. /** The direction in which to blur the image. */
  23586. direction: Vector2;
  23587. private blockCompilation;
  23588. protected _kernel: number;
  23589. protected _idealKernel: number;
  23590. protected _packedFloat: boolean;
  23591. private _staticDefines;
  23592. /**
  23593. * Sets the length in pixels of the blur sample region
  23594. */
  23595. set kernel(v: number);
  23596. /**
  23597. * Gets the length in pixels of the blur sample region
  23598. */
  23599. get kernel(): number;
  23600. /**
  23601. * Sets wether or not the blur needs to unpack/repack floats
  23602. */
  23603. set packedFloat(v: boolean);
  23604. /**
  23605. * Gets wether or not the blur is unpacking/repacking floats
  23606. */
  23607. get packedFloat(): boolean;
  23608. /**
  23609. * Creates a new instance BlurPostProcess
  23610. * @param name The name of the effect.
  23611. * @param direction The direction in which to blur the image.
  23612. * @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.
  23613. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23614. * @param camera The camera to apply the render pass to.
  23615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23616. * @param engine The engine which the post process will be applied. (default: current engine)
  23617. * @param reusable If the post process can be reused on the same frame. (default: false)
  23618. * @param textureType Type of textures used when performing the post process. (default: 0)
  23619. * @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)
  23620. */
  23621. constructor(name: string,
  23622. /** The direction in which to blur the image. */
  23623. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23624. /**
  23625. * Updates the effect with the current post process compile time values and recompiles the shader.
  23626. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23627. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23628. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23629. * @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
  23630. * @param onCompiled Called when the shader has been compiled.
  23631. * @param onError Called if there is an error when compiling a shader.
  23632. */
  23633. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23634. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23635. /**
  23636. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23637. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23638. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23639. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23640. * The gaps between physical kernels are compensated for in the weighting of the samples
  23641. * @param idealKernel Ideal blur kernel.
  23642. * @return Nearest best kernel.
  23643. */
  23644. protected _nearestBestKernel(idealKernel: number): number;
  23645. /**
  23646. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23647. * @param x The point on the Gaussian distribution to sample.
  23648. * @return the value of the Gaussian function at x.
  23649. */
  23650. protected _gaussianWeight(x: number): number;
  23651. /**
  23652. * Generates a string that can be used as a floating point number in GLSL.
  23653. * @param x Value to print.
  23654. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23655. * @return GLSL float string.
  23656. */
  23657. protected _glslFloat(x: number, decimalFigures?: number): string;
  23658. }
  23659. }
  23660. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23661. import { Scene } from "babylonjs/scene";
  23662. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23663. import { Plane } from "babylonjs/Maths/math.plane";
  23664. /**
  23665. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23666. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23667. * You can then easily use it as a reflectionTexture on a flat surface.
  23668. * In case the surface is not a plane, please consider relying on reflection probes.
  23669. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23670. */
  23671. export class MirrorTexture extends RenderTargetTexture {
  23672. private scene;
  23673. /**
  23674. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23675. * 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.
  23676. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23677. */
  23678. mirrorPlane: Plane;
  23679. /**
  23680. * Define the blur ratio used to blur the reflection if needed.
  23681. */
  23682. set blurRatio(value: number);
  23683. get blurRatio(): number;
  23684. /**
  23685. * Define the adaptive blur kernel used to blur the reflection if needed.
  23686. * This will autocompute the closest best match for the `blurKernel`
  23687. */
  23688. set adaptiveBlurKernel(value: number);
  23689. /**
  23690. * Define the blur kernel used to blur the reflection if needed.
  23691. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23692. */
  23693. set blurKernel(value: number);
  23694. /**
  23695. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23696. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23697. */
  23698. set blurKernelX(value: number);
  23699. get blurKernelX(): number;
  23700. /**
  23701. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23702. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23703. */
  23704. set blurKernelY(value: number);
  23705. get blurKernelY(): number;
  23706. private _autoComputeBlurKernel;
  23707. protected _onRatioRescale(): void;
  23708. private _updateGammaSpace;
  23709. private _imageProcessingConfigChangeObserver;
  23710. private _transformMatrix;
  23711. private _mirrorMatrix;
  23712. private _savedViewMatrix;
  23713. private _blurX;
  23714. private _blurY;
  23715. private _adaptiveBlurKernel;
  23716. private _blurKernelX;
  23717. private _blurKernelY;
  23718. private _blurRatio;
  23719. /**
  23720. * Instantiates a Mirror Texture.
  23721. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23722. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23723. * You can then easily use it as a reflectionTexture on a flat surface.
  23724. * In case the surface is not a plane, please consider relying on reflection probes.
  23725. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23726. * @param name
  23727. * @param size
  23728. * @param scene
  23729. * @param generateMipMaps
  23730. * @param type
  23731. * @param samplingMode
  23732. * @param generateDepthBuffer
  23733. */
  23734. constructor(name: string, size: number | {
  23735. width: number;
  23736. height: number;
  23737. } | {
  23738. ratio: number;
  23739. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23740. private _preparePostProcesses;
  23741. /**
  23742. * Clone the mirror texture.
  23743. * @returns the cloned texture
  23744. */
  23745. clone(): MirrorTexture;
  23746. /**
  23747. * Serialize the texture to a JSON representation you could use in Parse later on
  23748. * @returns the serialized JSON representation
  23749. */
  23750. serialize(): any;
  23751. /**
  23752. * Dispose the texture and release its associated resources.
  23753. */
  23754. dispose(): void;
  23755. }
  23756. }
  23757. declare module "babylonjs/Materials/Textures/texture" {
  23758. import { Observable } from "babylonjs/Misc/observable";
  23759. import { Nullable } from "babylonjs/types";
  23760. import { Matrix } from "babylonjs/Maths/math.vector";
  23761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23762. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23763. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23764. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23765. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23766. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23767. import { Scene } from "babylonjs/scene";
  23768. /**
  23769. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23770. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23771. */
  23772. export class Texture extends BaseTexture {
  23773. /**
  23774. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23775. */
  23776. static SerializeBuffers: boolean;
  23777. /** @hidden */
  23778. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23779. /** @hidden */
  23780. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23781. /** @hidden */
  23782. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23783. /** nearest is mag = nearest and min = nearest and mip = linear */
  23784. static readonly NEAREST_SAMPLINGMODE: number;
  23785. /** nearest is mag = nearest and min = nearest and mip = linear */
  23786. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23787. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23788. static readonly BILINEAR_SAMPLINGMODE: number;
  23789. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23790. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23791. /** Trilinear is mag = linear and min = linear and mip = linear */
  23792. static readonly TRILINEAR_SAMPLINGMODE: number;
  23793. /** Trilinear is mag = linear and min = linear and mip = linear */
  23794. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23795. /** mag = nearest and min = nearest and mip = nearest */
  23796. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23797. /** mag = nearest and min = linear and mip = nearest */
  23798. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23799. /** mag = nearest and min = linear and mip = linear */
  23800. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23801. /** mag = nearest and min = linear and mip = none */
  23802. static readonly NEAREST_LINEAR: number;
  23803. /** mag = nearest and min = nearest and mip = none */
  23804. static readonly NEAREST_NEAREST: number;
  23805. /** mag = linear and min = nearest and mip = nearest */
  23806. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23807. /** mag = linear and min = nearest and mip = linear */
  23808. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23809. /** mag = linear and min = linear and mip = none */
  23810. static readonly LINEAR_LINEAR: number;
  23811. /** mag = linear and min = nearest and mip = none */
  23812. static readonly LINEAR_NEAREST: number;
  23813. /** Explicit coordinates mode */
  23814. static readonly EXPLICIT_MODE: number;
  23815. /** Spherical coordinates mode */
  23816. static readonly SPHERICAL_MODE: number;
  23817. /** Planar coordinates mode */
  23818. static readonly PLANAR_MODE: number;
  23819. /** Cubic coordinates mode */
  23820. static readonly CUBIC_MODE: number;
  23821. /** Projection coordinates mode */
  23822. static readonly PROJECTION_MODE: number;
  23823. /** Inverse Cubic coordinates mode */
  23824. static readonly SKYBOX_MODE: number;
  23825. /** Inverse Cubic coordinates mode */
  23826. static readonly INVCUBIC_MODE: number;
  23827. /** Equirectangular coordinates mode */
  23828. static readonly EQUIRECTANGULAR_MODE: number;
  23829. /** Equirectangular Fixed coordinates mode */
  23830. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23831. /** Equirectangular Fixed Mirrored coordinates mode */
  23832. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23833. /** Texture is not repeating outside of 0..1 UVs */
  23834. static readonly CLAMP_ADDRESSMODE: number;
  23835. /** Texture is repeating outside of 0..1 UVs */
  23836. static readonly WRAP_ADDRESSMODE: number;
  23837. /** Texture is repeating and mirrored */
  23838. static readonly MIRROR_ADDRESSMODE: number;
  23839. /**
  23840. * 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
  23841. */
  23842. static UseSerializedUrlIfAny: boolean;
  23843. /**
  23844. * Define the url of the texture.
  23845. */
  23846. url: Nullable<string>;
  23847. /**
  23848. * Define an offset on the texture to offset the u coordinates of the UVs
  23849. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23850. */
  23851. uOffset: number;
  23852. /**
  23853. * Define an offset on the texture to offset the v coordinates of the UVs
  23854. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23855. */
  23856. vOffset: number;
  23857. /**
  23858. * Define an offset on the texture to scale the u coordinates of the UVs
  23859. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23860. */
  23861. uScale: number;
  23862. /**
  23863. * Define an offset on the texture to scale the v coordinates of the UVs
  23864. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23865. */
  23866. vScale: number;
  23867. /**
  23868. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23869. * @see https://doc.babylonjs.com/how_to/more_materials
  23870. */
  23871. uAng: number;
  23872. /**
  23873. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23874. * @see https://doc.babylonjs.com/how_to/more_materials
  23875. */
  23876. vAng: number;
  23877. /**
  23878. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23879. * @see https://doc.babylonjs.com/how_to/more_materials
  23880. */
  23881. wAng: number;
  23882. /**
  23883. * Defines the center of rotation (U)
  23884. */
  23885. uRotationCenter: number;
  23886. /**
  23887. * Defines the center of rotation (V)
  23888. */
  23889. vRotationCenter: number;
  23890. /**
  23891. * Defines the center of rotation (W)
  23892. */
  23893. wRotationCenter: number;
  23894. /**
  23895. * Are mip maps generated for this texture or not.
  23896. */
  23897. get noMipmap(): boolean;
  23898. /**
  23899. * List of inspectable custom properties (used by the Inspector)
  23900. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23901. */
  23902. inspectableCustomProperties: Nullable<IInspectable[]>;
  23903. private _noMipmap;
  23904. /** @hidden */
  23905. _invertY: boolean;
  23906. private _rowGenerationMatrix;
  23907. private _cachedTextureMatrix;
  23908. private _projectionModeMatrix;
  23909. private _t0;
  23910. private _t1;
  23911. private _t2;
  23912. private _cachedUOffset;
  23913. private _cachedVOffset;
  23914. private _cachedUScale;
  23915. private _cachedVScale;
  23916. private _cachedUAng;
  23917. private _cachedVAng;
  23918. private _cachedWAng;
  23919. private _cachedProjectionMatrixId;
  23920. private _cachedCoordinatesMode;
  23921. /** @hidden */
  23922. protected _initialSamplingMode: number;
  23923. /** @hidden */
  23924. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23925. private _deleteBuffer;
  23926. protected _format: Nullable<number>;
  23927. private _delayedOnLoad;
  23928. private _delayedOnError;
  23929. private _mimeType?;
  23930. /**
  23931. * Observable triggered once the texture has been loaded.
  23932. */
  23933. onLoadObservable: Observable<Texture>;
  23934. protected _isBlocking: boolean;
  23935. /**
  23936. * Is the texture preventing material to render while loading.
  23937. * If false, a default texture will be used instead of the loading one during the preparation step.
  23938. */
  23939. set isBlocking(value: boolean);
  23940. get isBlocking(): boolean;
  23941. /**
  23942. * Get the current sampling mode associated with the texture.
  23943. */
  23944. get samplingMode(): number;
  23945. /**
  23946. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23947. */
  23948. get invertY(): boolean;
  23949. /**
  23950. * Instantiates a new texture.
  23951. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23952. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23953. * @param url defines the url of the picture to load as a texture
  23954. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23955. * @param noMipmap defines if the texture will require mip maps or not
  23956. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23957. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23958. * @param onLoad defines a callback triggered when the texture has been loaded
  23959. * @param onError defines a callback triggered when an error occurred during the loading session
  23960. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23961. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23962. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23963. * @param mimeType defines an optional mime type information
  23964. */
  23965. 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);
  23966. /**
  23967. * Update the url (and optional buffer) of this texture if url was null during construction.
  23968. * @param url the url of the texture
  23969. * @param buffer the buffer of the texture (defaults to null)
  23970. * @param onLoad callback called when the texture is loaded (defaults to null)
  23971. */
  23972. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23973. /**
  23974. * Finish the loading sequence of a texture flagged as delayed load.
  23975. * @hidden
  23976. */
  23977. delayLoad(): void;
  23978. private _prepareRowForTextureGeneration;
  23979. /**
  23980. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23981. * @returns the transform matrix of the texture.
  23982. */
  23983. getTextureMatrix(uBase?: number): Matrix;
  23984. /**
  23985. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23986. * @returns The reflection texture transform
  23987. */
  23988. getReflectionTextureMatrix(): Matrix;
  23989. /**
  23990. * Clones the texture.
  23991. * @returns the cloned texture
  23992. */
  23993. clone(): Texture;
  23994. /**
  23995. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23996. * @returns The JSON representation of the texture
  23997. */
  23998. serialize(): any;
  23999. /**
  24000. * Get the current class name of the texture useful for serialization or dynamic coding.
  24001. * @returns "Texture"
  24002. */
  24003. getClassName(): string;
  24004. /**
  24005. * Dispose the texture and release its associated resources.
  24006. */
  24007. dispose(): void;
  24008. /**
  24009. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24010. * @param parsedTexture Define the JSON representation of the texture
  24011. * @param scene Define the scene the parsed texture should be instantiated in
  24012. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24013. * @returns The parsed texture if successful
  24014. */
  24015. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24016. /**
  24017. * Creates a texture from its base 64 representation.
  24018. * @param data Define the base64 payload without the data: prefix
  24019. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24020. * @param scene Define the scene the texture should belong to
  24021. * @param noMipmap Forces the texture to not create mip map information if true
  24022. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24023. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24024. * @param onLoad define a callback triggered when the texture has been loaded
  24025. * @param onError define a callback triggered when an error occurred during the loading session
  24026. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24027. * @returns the created texture
  24028. */
  24029. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24030. /**
  24031. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24032. * @param data Define the base64 payload without the data: prefix
  24033. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24034. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24035. * @param scene Define the scene the texture should belong to
  24036. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24037. * @param noMipmap Forces the texture to not create mip map information if true
  24038. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24039. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24040. * @param onLoad define a callback triggered when the texture has been loaded
  24041. * @param onError define a callback triggered when an error occurred during the loading session
  24042. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24043. * @returns the created texture
  24044. */
  24045. 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;
  24046. }
  24047. }
  24048. declare module "babylonjs/PostProcesses/postProcessManager" {
  24049. import { Nullable } from "babylonjs/types";
  24050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24051. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24052. import { Scene } from "babylonjs/scene";
  24053. /**
  24054. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24055. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24056. */
  24057. export class PostProcessManager {
  24058. private _scene;
  24059. private _indexBuffer;
  24060. private _vertexBuffers;
  24061. /**
  24062. * Creates a new instance PostProcess
  24063. * @param scene The scene that the post process is associated with.
  24064. */
  24065. constructor(scene: Scene);
  24066. private _prepareBuffers;
  24067. private _buildIndexBuffer;
  24068. /**
  24069. * Rebuilds the vertex buffers of the manager.
  24070. * @hidden
  24071. */
  24072. _rebuild(): void;
  24073. /**
  24074. * Prepares a frame to be run through a post process.
  24075. * @param sourceTexture The input texture to the post procesess. (default: null)
  24076. * @param postProcesses An array of post processes to be run. (default: null)
  24077. * @returns True if the post processes were able to be run.
  24078. * @hidden
  24079. */
  24080. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24081. /**
  24082. * Manually render a set of post processes to a texture.
  24083. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24084. * @param postProcesses An array of post processes to be run.
  24085. * @param targetTexture The target texture to render to.
  24086. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24087. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24088. * @param lodLevel defines which lod of the texture to render to
  24089. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24090. */
  24091. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24092. /**
  24093. * Finalize the result of the output of the postprocesses.
  24094. * @param doNotPresent If true the result will not be displayed to the screen.
  24095. * @param targetTexture The target texture to render to.
  24096. * @param faceIndex The index of the face to bind the target texture to.
  24097. * @param postProcesses The array of post processes to render.
  24098. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24099. * @hidden
  24100. */
  24101. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24102. /**
  24103. * Disposes of the post process manager.
  24104. */
  24105. dispose(): void;
  24106. }
  24107. }
  24108. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24109. import { Observable } from "babylonjs/Misc/observable";
  24110. import { SmartArray } from "babylonjs/Misc/smartArray";
  24111. import { Nullable, Immutable } from "babylonjs/types";
  24112. import { Camera } from "babylonjs/Cameras/camera";
  24113. import { Scene } from "babylonjs/scene";
  24114. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24115. import { Color4 } from "babylonjs/Maths/math.color";
  24116. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24118. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24119. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24120. import { Texture } from "babylonjs/Materials/Textures/texture";
  24121. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24122. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24123. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24124. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24125. import { Engine } from "babylonjs/Engines/engine";
  24126. /**
  24127. * This Helps creating a texture that will be created from a camera in your scene.
  24128. * It is basically a dynamic texture that could be used to create special effects for instance.
  24129. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24130. */
  24131. export class RenderTargetTexture extends Texture {
  24132. isCube: boolean;
  24133. /**
  24134. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24135. */
  24136. static readonly REFRESHRATE_RENDER_ONCE: number;
  24137. /**
  24138. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24139. */
  24140. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24141. /**
  24142. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24143. * the central point of your effect and can save a lot of performances.
  24144. */
  24145. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24146. /**
  24147. * Use this predicate to dynamically define the list of mesh you want to render.
  24148. * If set, the renderList property will be overwritten.
  24149. */
  24150. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24151. private _renderList;
  24152. /**
  24153. * Use this list to define the list of mesh you want to render.
  24154. */
  24155. get renderList(): Nullable<Array<AbstractMesh>>;
  24156. set renderList(value: Nullable<Array<AbstractMesh>>);
  24157. /**
  24158. * Use this function to overload the renderList array at rendering time.
  24159. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24160. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24161. * the cube (if the RTT is a cube, else layerOrFace=0).
  24162. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24163. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24164. * hold dummy elements!
  24165. */
  24166. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24167. private _hookArray;
  24168. /**
  24169. * Define if particles should be rendered in your texture.
  24170. */
  24171. renderParticles: boolean;
  24172. /**
  24173. * Define if sprites should be rendered in your texture.
  24174. */
  24175. renderSprites: boolean;
  24176. /**
  24177. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24178. */
  24179. coordinatesMode: number;
  24180. /**
  24181. * Define the camera used to render the texture.
  24182. */
  24183. activeCamera: Nullable<Camera>;
  24184. /**
  24185. * Override the mesh isReady function with your own one.
  24186. */
  24187. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24188. /**
  24189. * Override the render function of the texture with your own one.
  24190. */
  24191. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24192. /**
  24193. * Define if camera post processes should be use while rendering the texture.
  24194. */
  24195. useCameraPostProcesses: boolean;
  24196. /**
  24197. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24198. */
  24199. ignoreCameraViewport: boolean;
  24200. private _postProcessManager;
  24201. private _postProcesses;
  24202. private _resizeObserver;
  24203. /**
  24204. * An event triggered when the texture is unbind.
  24205. */
  24206. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24207. /**
  24208. * An event triggered when the texture is unbind.
  24209. */
  24210. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24211. private _onAfterUnbindObserver;
  24212. /**
  24213. * Set a after unbind callback in the texture.
  24214. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24215. */
  24216. set onAfterUnbind(callback: () => void);
  24217. /**
  24218. * An event triggered before rendering the texture
  24219. */
  24220. onBeforeRenderObservable: Observable<number>;
  24221. private _onBeforeRenderObserver;
  24222. /**
  24223. * Set a before render callback in the texture.
  24224. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24225. */
  24226. set onBeforeRender(callback: (faceIndex: number) => void);
  24227. /**
  24228. * An event triggered after rendering the texture
  24229. */
  24230. onAfterRenderObservable: Observable<number>;
  24231. private _onAfterRenderObserver;
  24232. /**
  24233. * Set a after render callback in the texture.
  24234. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24235. */
  24236. set onAfterRender(callback: (faceIndex: number) => void);
  24237. /**
  24238. * An event triggered after the texture clear
  24239. */
  24240. onClearObservable: Observable<Engine>;
  24241. private _onClearObserver;
  24242. /**
  24243. * Set a clear callback in the texture.
  24244. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24245. */
  24246. set onClear(callback: (Engine: Engine) => void);
  24247. /**
  24248. * An event triggered when the texture is resized.
  24249. */
  24250. onResizeObservable: Observable<RenderTargetTexture>;
  24251. /**
  24252. * Define the clear color of the Render Target if it should be different from the scene.
  24253. */
  24254. clearColor: Color4;
  24255. protected _size: number | {
  24256. width: number;
  24257. height: number;
  24258. layers?: number;
  24259. };
  24260. protected _initialSizeParameter: number | {
  24261. width: number;
  24262. height: number;
  24263. } | {
  24264. ratio: number;
  24265. };
  24266. protected _sizeRatio: Nullable<number>;
  24267. /** @hidden */
  24268. _generateMipMaps: boolean;
  24269. protected _renderingManager: RenderingManager;
  24270. /** @hidden */
  24271. _waitingRenderList: string[];
  24272. protected _doNotChangeAspectRatio: boolean;
  24273. protected _currentRefreshId: number;
  24274. protected _refreshRate: number;
  24275. protected _textureMatrix: Matrix;
  24276. protected _samples: number;
  24277. protected _renderTargetOptions: RenderTargetCreationOptions;
  24278. /**
  24279. * Gets render target creation options that were used.
  24280. */
  24281. get renderTargetOptions(): RenderTargetCreationOptions;
  24282. protected _onRatioRescale(): void;
  24283. /**
  24284. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24285. * It must define where the camera used to render the texture is set
  24286. */
  24287. boundingBoxPosition: Vector3;
  24288. private _boundingBoxSize;
  24289. /**
  24290. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24291. * When defined, the cubemap will switch to local mode
  24292. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24293. * @example https://www.babylonjs-playground.com/#RNASML
  24294. */
  24295. set boundingBoxSize(value: Vector3);
  24296. get boundingBoxSize(): Vector3;
  24297. /**
  24298. * In case the RTT has been created with a depth texture, get the associated
  24299. * depth texture.
  24300. * Otherwise, return null.
  24301. */
  24302. get depthStencilTexture(): Nullable<InternalTexture>;
  24303. /**
  24304. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24305. * or used a shadow, depth texture...
  24306. * @param name The friendly name of the texture
  24307. * @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)
  24308. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24309. * @param generateMipMaps True if mip maps need to be generated after render.
  24310. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24311. * @param type The type of the buffer in the RTT (int, half float, float...)
  24312. * @param isCube True if a cube texture needs to be created
  24313. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24314. * @param generateDepthBuffer True to generate a depth buffer
  24315. * @param generateStencilBuffer True to generate a stencil buffer
  24316. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24317. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24318. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24319. */
  24320. constructor(name: string, size: number | {
  24321. width: number;
  24322. height: number;
  24323. layers?: number;
  24324. } | {
  24325. ratio: number;
  24326. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24327. /**
  24328. * Creates a depth stencil texture.
  24329. * This is only available in WebGL 2 or with the depth texture extension available.
  24330. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24331. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24332. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24333. */
  24334. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24335. private _processSizeParameter;
  24336. /**
  24337. * Define the number of samples to use in case of MSAA.
  24338. * It defaults to one meaning no MSAA has been enabled.
  24339. */
  24340. get samples(): number;
  24341. set samples(value: number);
  24342. /**
  24343. * Resets the refresh counter of the texture and start bak from scratch.
  24344. * Could be useful to regenerate the texture if it is setup to render only once.
  24345. */
  24346. resetRefreshCounter(): void;
  24347. /**
  24348. * Define the refresh rate of the texture or the rendering frequency.
  24349. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24350. */
  24351. get refreshRate(): number;
  24352. set refreshRate(value: number);
  24353. /**
  24354. * Adds a post process to the render target rendering passes.
  24355. * @param postProcess define the post process to add
  24356. */
  24357. addPostProcess(postProcess: PostProcess): void;
  24358. /**
  24359. * Clear all the post processes attached to the render target
  24360. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24361. */
  24362. clearPostProcesses(dispose?: boolean): void;
  24363. /**
  24364. * Remove one of the post process from the list of attached post processes to the texture
  24365. * @param postProcess define the post process to remove from the list
  24366. */
  24367. removePostProcess(postProcess: PostProcess): void;
  24368. /** @hidden */
  24369. _shouldRender(): boolean;
  24370. /**
  24371. * Gets the actual render size of the texture.
  24372. * @returns the width of the render size
  24373. */
  24374. getRenderSize(): number;
  24375. /**
  24376. * Gets the actual render width of the texture.
  24377. * @returns the width of the render size
  24378. */
  24379. getRenderWidth(): number;
  24380. /**
  24381. * Gets the actual render height of the texture.
  24382. * @returns the height of the render size
  24383. */
  24384. getRenderHeight(): number;
  24385. /**
  24386. * Gets the actual number of layers of the texture.
  24387. * @returns the number of layers
  24388. */
  24389. getRenderLayers(): number;
  24390. /**
  24391. * Get if the texture can be rescaled or not.
  24392. */
  24393. get canRescale(): boolean;
  24394. /**
  24395. * Resize the texture using a ratio.
  24396. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24397. */
  24398. scale(ratio: number): void;
  24399. /**
  24400. * Get the texture reflection matrix used to rotate/transform the reflection.
  24401. * @returns the reflection matrix
  24402. */
  24403. getReflectionTextureMatrix(): Matrix;
  24404. /**
  24405. * Resize the texture to a new desired size.
  24406. * Be carrefull as it will recreate all the data in the new texture.
  24407. * @param size Define the new size. It can be:
  24408. * - a number for squared texture,
  24409. * - an object containing { width: number, height: number }
  24410. * - or an object containing a ratio { ratio: number }
  24411. */
  24412. resize(size: number | {
  24413. width: number;
  24414. height: number;
  24415. } | {
  24416. ratio: number;
  24417. }): void;
  24418. private _defaultRenderListPrepared;
  24419. /**
  24420. * Renders all the objects from the render list into the texture.
  24421. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24422. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24423. */
  24424. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24425. private _bestReflectionRenderTargetDimension;
  24426. private _prepareRenderingManager;
  24427. /**
  24428. * @hidden
  24429. * @param faceIndex face index to bind to if this is a cubetexture
  24430. * @param layer defines the index of the texture to bind in the array
  24431. */
  24432. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24433. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24434. private renderToTarget;
  24435. /**
  24436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24437. * This allowed control for front to back rendering or reversly depending of the special needs.
  24438. *
  24439. * @param renderingGroupId The rendering group id corresponding to its index
  24440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24443. */
  24444. 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;
  24445. /**
  24446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24447. *
  24448. * @param renderingGroupId The rendering group id corresponding to its index
  24449. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24450. */
  24451. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24452. /**
  24453. * Clones the texture.
  24454. * @returns the cloned texture
  24455. */
  24456. clone(): RenderTargetTexture;
  24457. /**
  24458. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24459. * @returns The JSON representation of the texture
  24460. */
  24461. serialize(): any;
  24462. /**
  24463. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24464. */
  24465. disposeFramebufferObjects(): void;
  24466. /**
  24467. * Dispose the texture and release its associated resources.
  24468. */
  24469. dispose(): void;
  24470. /** @hidden */
  24471. _rebuild(): void;
  24472. /**
  24473. * Clear the info related to rendering groups preventing retention point in material dispose.
  24474. */
  24475. freeRenderingGroups(): void;
  24476. /**
  24477. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24478. * @returns the view count
  24479. */
  24480. getViewCount(): number;
  24481. }
  24482. }
  24483. declare module "babylonjs/Misc/guid" {
  24484. /**
  24485. * Class used to manipulate GUIDs
  24486. */
  24487. export class GUID {
  24488. /**
  24489. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24490. * Be aware Math.random() could cause collisions, but:
  24491. * "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"
  24492. * @returns a pseudo random id
  24493. */
  24494. static RandomId(): string;
  24495. }
  24496. }
  24497. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24498. import { Nullable } from "babylonjs/types";
  24499. import { Scene } from "babylonjs/scene";
  24500. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24501. import { Material } from "babylonjs/Materials/material";
  24502. import { Effect } from "babylonjs/Materials/effect";
  24503. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24504. /**
  24505. * Options to be used when creating a shadow depth material
  24506. */
  24507. export interface IIOptionShadowDepthMaterial {
  24508. /** Variables in the vertex shader code that need to have their names remapped.
  24509. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24510. * "var_name" should be either: worldPos or vNormalW
  24511. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24512. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24513. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24514. */
  24515. remappedVariables?: string[];
  24516. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24517. standalone?: boolean;
  24518. }
  24519. /**
  24520. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24521. */
  24522. export class ShadowDepthWrapper {
  24523. private _scene;
  24524. private _options?;
  24525. private _baseMaterial;
  24526. private _onEffectCreatedObserver;
  24527. private _subMeshToEffect;
  24528. private _subMeshToDepthEffect;
  24529. private _meshes;
  24530. /** @hidden */
  24531. _matriceNames: any;
  24532. /** Gets the standalone status of the wrapper */
  24533. get standalone(): boolean;
  24534. /** Gets the base material the wrapper is built upon */
  24535. get baseMaterial(): Material;
  24536. /**
  24537. * Instantiate a new shadow depth wrapper.
  24538. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24539. * generate the shadow depth map. For more information, please refer to the documentation:
  24540. * https://doc.babylonjs.com/babylon101/shadows
  24541. * @param baseMaterial Material to wrap
  24542. * @param scene Define the scene the material belongs to
  24543. * @param options Options used to create the wrapper
  24544. */
  24545. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24546. /**
  24547. * Gets the effect to use to generate the depth map
  24548. * @param subMesh subMesh to get the effect for
  24549. * @param shadowGenerator shadow generator to get the effect for
  24550. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24551. */
  24552. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24553. /**
  24554. * Specifies that the submesh is ready to be used for depth rendering
  24555. * @param subMesh submesh to check
  24556. * @param defines the list of defines to take into account when checking the effect
  24557. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24558. * @param useInstances specifies that instances should be used
  24559. * @returns a boolean indicating that the submesh is ready or not
  24560. */
  24561. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24562. /**
  24563. * Disposes the resources
  24564. */
  24565. dispose(): void;
  24566. private _makeEffect;
  24567. }
  24568. }
  24569. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24571. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24572. import { Nullable } from "babylonjs/types";
  24573. module "babylonjs/Engines/thinEngine" {
  24574. interface ThinEngine {
  24575. /**
  24576. * Unbind a list of render target textures from the webGL context
  24577. * This is used only when drawBuffer extension or webGL2 are active
  24578. * @param textures defines the render target textures to unbind
  24579. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24580. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24581. */
  24582. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24583. /**
  24584. * Create a multi render target texture
  24585. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24586. * @param size defines the size of the texture
  24587. * @param options defines the creation options
  24588. * @returns the cube texture as an InternalTexture
  24589. */
  24590. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24591. /**
  24592. * Update the sample count for a given multiple render target texture
  24593. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24594. * @param textures defines the textures to update
  24595. * @param samples defines the sample count to set
  24596. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24597. */
  24598. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24599. /**
  24600. * Select a subsets of attachments to draw to.
  24601. * @param attachments gl attachments
  24602. */
  24603. bindAttachments(attachments: number[]): void;
  24604. }
  24605. }
  24606. }
  24607. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24608. import { Scene } from "babylonjs/scene";
  24609. import { Engine } from "babylonjs/Engines/engine";
  24610. import { Texture } from "babylonjs/Materials/Textures/texture";
  24611. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24612. import "babylonjs/Engines/Extensions/engine.multiRender";
  24613. /**
  24614. * Creation options of the multi render target texture.
  24615. */
  24616. export interface IMultiRenderTargetOptions {
  24617. /**
  24618. * Define if the texture needs to create mip maps after render.
  24619. */
  24620. generateMipMaps?: boolean;
  24621. /**
  24622. * Define the types of all the draw buffers we want to create
  24623. */
  24624. types?: number[];
  24625. /**
  24626. * Define the sampling modes of all the draw buffers we want to create
  24627. */
  24628. samplingModes?: number[];
  24629. /**
  24630. * Define if a depth buffer is required
  24631. */
  24632. generateDepthBuffer?: boolean;
  24633. /**
  24634. * Define if a stencil buffer is required
  24635. */
  24636. generateStencilBuffer?: boolean;
  24637. /**
  24638. * Define if a depth texture is required instead of a depth buffer
  24639. */
  24640. generateDepthTexture?: boolean;
  24641. /**
  24642. * Define the number of desired draw buffers
  24643. */
  24644. textureCount?: number;
  24645. /**
  24646. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24647. */
  24648. doNotChangeAspectRatio?: boolean;
  24649. /**
  24650. * Define the default type of the buffers we are creating
  24651. */
  24652. defaultType?: number;
  24653. }
  24654. /**
  24655. * A multi render target, like a render target provides the ability to render to a texture.
  24656. * Unlike the render target, it can render to several draw buffers in one draw.
  24657. * This is specially interesting in deferred rendering or for any effects requiring more than
  24658. * just one color from a single pass.
  24659. */
  24660. export class MultiRenderTarget extends RenderTargetTexture {
  24661. private _internalTextures;
  24662. private _textures;
  24663. private _multiRenderTargetOptions;
  24664. private _count;
  24665. /**
  24666. * Get if draw buffers are currently supported by the used hardware and browser.
  24667. */
  24668. get isSupported(): boolean;
  24669. /**
  24670. * Get the list of textures generated by the multi render target.
  24671. */
  24672. get textures(): Texture[];
  24673. /**
  24674. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24675. */
  24676. get count(): number;
  24677. /**
  24678. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24679. */
  24680. get depthTexture(): Texture;
  24681. /**
  24682. * Set the wrapping mode on U of all the textures we are rendering to.
  24683. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24684. */
  24685. set wrapU(wrap: number);
  24686. /**
  24687. * Set the wrapping mode on V of all the textures we are rendering to.
  24688. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24689. */
  24690. set wrapV(wrap: number);
  24691. /**
  24692. * Instantiate a new multi render target texture.
  24693. * A multi render target, like a render target provides the ability to render to a texture.
  24694. * Unlike the render target, it can render to several draw buffers in one draw.
  24695. * This is specially interesting in deferred rendering or for any effects requiring more than
  24696. * just one color from a single pass.
  24697. * @param name Define the name of the texture
  24698. * @param size Define the size of the buffers to render to
  24699. * @param count Define the number of target we are rendering into
  24700. * @param scene Define the scene the texture belongs to
  24701. * @param options Define the options used to create the multi render target
  24702. */
  24703. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24704. /** @hidden */
  24705. _rebuild(): void;
  24706. private _createInternalTextures;
  24707. private _createTextures;
  24708. /**
  24709. * Define the number of samples used if MSAA is enabled.
  24710. */
  24711. get samples(): number;
  24712. set samples(value: number);
  24713. /**
  24714. * Resize all the textures in the multi render target.
  24715. * Be carrefull as it will recreate all the data in the new texture.
  24716. * @param size Define the new size
  24717. */
  24718. resize(size: any): void;
  24719. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24720. /**
  24721. * Dispose the render targets and their associated resources
  24722. */
  24723. dispose(): void;
  24724. /**
  24725. * Release all the underlying texture used as draw buffers.
  24726. */
  24727. releaseInternalTextures(): void;
  24728. }
  24729. }
  24730. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24731. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24732. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24733. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24734. /** @hidden */
  24735. export var imageProcessingPixelShader: {
  24736. name: string;
  24737. shader: string;
  24738. };
  24739. }
  24740. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24741. import { Nullable } from "babylonjs/types";
  24742. import { Color4 } from "babylonjs/Maths/math.color";
  24743. import { Camera } from "babylonjs/Cameras/camera";
  24744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24745. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24746. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24747. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24748. import { Engine } from "babylonjs/Engines/engine";
  24749. import "babylonjs/Shaders/imageProcessing.fragment";
  24750. import "babylonjs/Shaders/postprocess.vertex";
  24751. /**
  24752. * ImageProcessingPostProcess
  24753. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24754. */
  24755. export class ImageProcessingPostProcess extends PostProcess {
  24756. /**
  24757. * Default configuration related to image processing available in the PBR Material.
  24758. */
  24759. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24760. /**
  24761. * Gets the image processing configuration used either in this material.
  24762. */
  24763. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24764. /**
  24765. * Sets the Default image processing configuration used either in the this material.
  24766. *
  24767. * If sets to null, the scene one is in use.
  24768. */
  24769. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24770. /**
  24771. * Keep track of the image processing observer to allow dispose and replace.
  24772. */
  24773. private _imageProcessingObserver;
  24774. /**
  24775. * Attaches a new image processing configuration to the PBR Material.
  24776. * @param configuration
  24777. */
  24778. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24779. /**
  24780. * If the post process is supported.
  24781. */
  24782. get isSupported(): boolean;
  24783. /**
  24784. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24785. */
  24786. get colorCurves(): Nullable<ColorCurves>;
  24787. /**
  24788. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24789. */
  24790. set colorCurves(value: Nullable<ColorCurves>);
  24791. /**
  24792. * Gets wether the color curves effect is enabled.
  24793. */
  24794. get colorCurvesEnabled(): boolean;
  24795. /**
  24796. * Sets wether the color curves effect is enabled.
  24797. */
  24798. set colorCurvesEnabled(value: boolean);
  24799. /**
  24800. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24801. */
  24802. get colorGradingTexture(): Nullable<BaseTexture>;
  24803. /**
  24804. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24805. */
  24806. set colorGradingTexture(value: Nullable<BaseTexture>);
  24807. /**
  24808. * Gets wether the color grading effect is enabled.
  24809. */
  24810. get colorGradingEnabled(): boolean;
  24811. /**
  24812. * Gets wether the color grading effect is enabled.
  24813. */
  24814. set colorGradingEnabled(value: boolean);
  24815. /**
  24816. * Gets exposure used in the effect.
  24817. */
  24818. get exposure(): number;
  24819. /**
  24820. * Sets exposure used in the effect.
  24821. */
  24822. set exposure(value: number);
  24823. /**
  24824. * Gets wether tonemapping is enabled or not.
  24825. */
  24826. get toneMappingEnabled(): boolean;
  24827. /**
  24828. * Sets wether tonemapping is enabled or not
  24829. */
  24830. set toneMappingEnabled(value: boolean);
  24831. /**
  24832. * Gets the type of tone mapping effect.
  24833. */
  24834. get toneMappingType(): number;
  24835. /**
  24836. * Sets the type of tone mapping effect.
  24837. */
  24838. set toneMappingType(value: number);
  24839. /**
  24840. * Gets contrast used in the effect.
  24841. */
  24842. get contrast(): number;
  24843. /**
  24844. * Sets contrast used in the effect.
  24845. */
  24846. set contrast(value: number);
  24847. /**
  24848. * Gets Vignette stretch size.
  24849. */
  24850. get vignetteStretch(): number;
  24851. /**
  24852. * Sets Vignette stretch size.
  24853. */
  24854. set vignetteStretch(value: number);
  24855. /**
  24856. * Gets Vignette centre X Offset.
  24857. */
  24858. get vignetteCentreX(): number;
  24859. /**
  24860. * Sets Vignette centre X Offset.
  24861. */
  24862. set vignetteCentreX(value: number);
  24863. /**
  24864. * Gets Vignette centre Y Offset.
  24865. */
  24866. get vignetteCentreY(): number;
  24867. /**
  24868. * Sets Vignette centre Y Offset.
  24869. */
  24870. set vignetteCentreY(value: number);
  24871. /**
  24872. * Gets Vignette weight or intensity of the vignette effect.
  24873. */
  24874. get vignetteWeight(): number;
  24875. /**
  24876. * Sets Vignette weight or intensity of the vignette effect.
  24877. */
  24878. set vignetteWeight(value: number);
  24879. /**
  24880. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24881. * if vignetteEnabled is set to true.
  24882. */
  24883. get vignetteColor(): Color4;
  24884. /**
  24885. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24886. * if vignetteEnabled is set to true.
  24887. */
  24888. set vignetteColor(value: Color4);
  24889. /**
  24890. * Gets Camera field of view used by the Vignette effect.
  24891. */
  24892. get vignetteCameraFov(): number;
  24893. /**
  24894. * Sets Camera field of view used by the Vignette effect.
  24895. */
  24896. set vignetteCameraFov(value: number);
  24897. /**
  24898. * Gets the vignette blend mode allowing different kind of effect.
  24899. */
  24900. get vignetteBlendMode(): number;
  24901. /**
  24902. * Sets the vignette blend mode allowing different kind of effect.
  24903. */
  24904. set vignetteBlendMode(value: number);
  24905. /**
  24906. * Gets wether the vignette effect is enabled.
  24907. */
  24908. get vignetteEnabled(): boolean;
  24909. /**
  24910. * Sets wether the vignette effect is enabled.
  24911. */
  24912. set vignetteEnabled(value: boolean);
  24913. private _fromLinearSpace;
  24914. /**
  24915. * Gets wether the input of the processing is in Gamma or Linear Space.
  24916. */
  24917. get fromLinearSpace(): boolean;
  24918. /**
  24919. * Sets wether the input of the processing is in Gamma or Linear Space.
  24920. */
  24921. set fromLinearSpace(value: boolean);
  24922. /**
  24923. * Defines cache preventing GC.
  24924. */
  24925. private _defines;
  24926. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24927. /**
  24928. * "ImageProcessingPostProcess"
  24929. * @returns "ImageProcessingPostProcess"
  24930. */
  24931. getClassName(): string;
  24932. /**
  24933. * @hidden
  24934. */
  24935. _updateParameters(): void;
  24936. dispose(camera?: Camera): void;
  24937. }
  24938. }
  24939. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  24940. /** @hidden */
  24941. export var fibonacci: {
  24942. name: string;
  24943. shader: string;
  24944. };
  24945. }
  24946. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  24947. /** @hidden */
  24948. export var subSurfaceScatteringFunctions: {
  24949. name: string;
  24950. shader: string;
  24951. };
  24952. }
  24953. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  24954. /** @hidden */
  24955. export var diffusionProfile: {
  24956. name: string;
  24957. shader: string;
  24958. };
  24959. }
  24960. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  24961. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  24962. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24963. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  24964. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  24965. /** @hidden */
  24966. export var subSurfaceScatteringPixelShader: {
  24967. name: string;
  24968. shader: string;
  24969. };
  24970. }
  24971. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  24972. import { Nullable } from "babylonjs/types";
  24973. import { Camera } from "babylonjs/Cameras/camera";
  24974. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24975. import { Engine } from "babylonjs/Engines/engine";
  24976. import { Scene } from "babylonjs/scene";
  24977. import "babylonjs/Shaders/imageProcessing.fragment";
  24978. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  24979. import "babylonjs/Shaders/postprocess.vertex";
  24980. /**
  24981. * Sub surface scattering post process
  24982. */
  24983. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24984. /** @hidden */
  24985. texelWidth: number;
  24986. /** @hidden */
  24987. texelHeight: number;
  24988. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24989. }
  24990. }
  24991. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24993. /**
  24994. * Interface for defining prepass effects in the prepass post-process pipeline
  24995. */
  24996. export interface PrePassEffectConfiguration {
  24997. /**
  24998. * Post process to attach for this effect
  24999. */
  25000. postProcess: PostProcess;
  25001. /**
  25002. * Is the effect enabled
  25003. */
  25004. enabled: boolean;
  25005. /**
  25006. * Disposes the effect configuration
  25007. */
  25008. dispose(): void;
  25009. /**
  25010. * Disposes the effect configuration
  25011. */
  25012. createPostProcess: () => PostProcess;
  25013. }
  25014. }
  25015. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25016. import { Scene } from "babylonjs/scene";
  25017. import { Color3 } from "babylonjs/Maths/math.color";
  25018. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25019. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25020. /**
  25021. * Contains all parameters needed for the prepass to perform
  25022. * screen space subsurface scattering
  25023. */
  25024. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25025. private _ssDiffusionS;
  25026. private _ssFilterRadii;
  25027. private _ssDiffusionD;
  25028. /**
  25029. * Post process to attach for screen space subsurface scattering
  25030. */
  25031. postProcess: SubSurfaceScatteringPostProcess;
  25032. /**
  25033. * Diffusion profile color for subsurface scattering
  25034. */
  25035. get ssDiffusionS(): number[];
  25036. /**
  25037. * Diffusion profile max color channel value for subsurface scattering
  25038. */
  25039. get ssDiffusionD(): number[];
  25040. /**
  25041. * Diffusion profile filter radius for subsurface scattering
  25042. */
  25043. get ssFilterRadii(): number[];
  25044. /**
  25045. * Is subsurface enabled
  25046. */
  25047. enabled: boolean;
  25048. /**
  25049. * Diffusion profile colors for subsurface scattering
  25050. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25051. * See ...
  25052. * Note that you can only store up to 5 of them
  25053. */
  25054. ssDiffusionProfileColors: Color3[];
  25055. /**
  25056. * Defines the ratio real world => scene units.
  25057. * Used for subsurface scattering
  25058. */
  25059. metersPerUnit: number;
  25060. private _scene;
  25061. /**
  25062. * Builds a subsurface configuration object
  25063. * @param scene The scene
  25064. */
  25065. constructor(scene: Scene);
  25066. /**
  25067. * Adds a new diffusion profile.
  25068. * Useful for more realistic subsurface scattering on diverse materials.
  25069. * @param color The color of the diffusion profile. Should be the average color of the material.
  25070. * @return The index of the diffusion profile for the material subsurface configuration
  25071. */
  25072. addDiffusionProfile(color: Color3): number;
  25073. /**
  25074. * Creates the sss post process
  25075. * @return The created post process
  25076. */
  25077. createPostProcess(): SubSurfaceScatteringPostProcess;
  25078. /**
  25079. * Deletes all diffusion profiles.
  25080. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25081. */
  25082. clearAllDiffusionProfiles(): void;
  25083. /**
  25084. * Disposes this object
  25085. */
  25086. dispose(): void;
  25087. /**
  25088. * @hidden
  25089. * https://zero-radiance.github.io/post/sampling-diffusion/
  25090. *
  25091. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25092. * ------------------------------------------------------------------------------------
  25093. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25094. * PDF[r, phi, s] = r * R[r, phi, s]
  25095. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25096. * ------------------------------------------------------------------------------------
  25097. * We importance sample the color channel with the widest scattering distance.
  25098. */
  25099. getDiffusionProfileParameters(color: Color3): number;
  25100. /**
  25101. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25102. * 'u' is the random number (the value of the CDF): [0, 1).
  25103. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25104. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25105. */
  25106. private _sampleBurleyDiffusionProfile;
  25107. }
  25108. }
  25109. declare module "babylonjs/Rendering/prePassRenderer" {
  25110. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25111. import { Scene } from "babylonjs/scene";
  25112. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25113. import { Effect } from "babylonjs/Materials/effect";
  25114. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25115. /**
  25116. * Renders a pre pass of the scene
  25117. * This means every mesh in the scene will be rendered to a render target texture
  25118. * And then this texture will be composited to the rendering canvas with post processes
  25119. * It is necessary for effects like subsurface scattering or deferred shading
  25120. */
  25121. export class PrePassRenderer {
  25122. /** @hidden */
  25123. static _SceneComponentInitialization: (scene: Scene) => void;
  25124. private _scene;
  25125. private _engine;
  25126. private _isDirty;
  25127. /**
  25128. * Number of textures in the multi render target texture where the scene is directly rendered
  25129. */
  25130. readonly mrtCount: number;
  25131. /**
  25132. * The render target where the scene is directly rendered
  25133. */
  25134. prePassRT: MultiRenderTarget;
  25135. private _mrtTypes;
  25136. private _multiRenderAttachments;
  25137. private _defaultAttachments;
  25138. private _clearAttachments;
  25139. private _postProcesses;
  25140. private readonly _clearColor;
  25141. /**
  25142. * Image processing post process for composition
  25143. */
  25144. imageProcessingPostProcess: ImageProcessingPostProcess;
  25145. /**
  25146. * Configuration for sub surface scattering post process
  25147. */
  25148. subSurfaceConfiguration: SubSurfaceConfiguration;
  25149. /**
  25150. * Should materials render their geometry on the MRT
  25151. */
  25152. materialsShouldRenderGeometry: boolean;
  25153. /**
  25154. * Should materials render the irradiance information on the MRT
  25155. */
  25156. materialsShouldRenderIrradiance: boolean;
  25157. private _enabled;
  25158. /**
  25159. * Indicates if the prepass is enabled
  25160. */
  25161. get enabled(): boolean;
  25162. /**
  25163. * How many samples are used for MSAA of the scene render target
  25164. */
  25165. get samples(): number;
  25166. set samples(n: number);
  25167. /**
  25168. * Instanciates a prepass renderer
  25169. * @param scene The scene
  25170. */
  25171. constructor(scene: Scene);
  25172. private _initializeAttachments;
  25173. private _createCompositionEffect;
  25174. /**
  25175. * Indicates if rendering a prepass is supported
  25176. */
  25177. get isSupported(): boolean;
  25178. /**
  25179. * Sets the proper output textures to draw in the engine.
  25180. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25181. */
  25182. bindAttachmentsForEffect(effect: Effect): void;
  25183. /**
  25184. * @hidden
  25185. */
  25186. _beforeCameraDraw(): void;
  25187. /**
  25188. * @hidden
  25189. */
  25190. _afterCameraDraw(): void;
  25191. private _checkRTSize;
  25192. private _bindFrameBuffer;
  25193. /**
  25194. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25195. */
  25196. clear(): void;
  25197. private _setState;
  25198. private _enable;
  25199. private _disable;
  25200. private _resetPostProcessChain;
  25201. private _bindPostProcessChain;
  25202. /**
  25203. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25204. */
  25205. markAsDirty(): void;
  25206. private _update;
  25207. /**
  25208. * Disposes the prepass renderer.
  25209. */
  25210. dispose(): void;
  25211. }
  25212. }
  25213. declare module "babylonjs/Materials/material" {
  25214. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25215. import { SmartArray } from "babylonjs/Misc/smartArray";
  25216. import { Observable } from "babylonjs/Misc/observable";
  25217. import { Nullable } from "babylonjs/types";
  25218. import { Scene } from "babylonjs/scene";
  25219. import { Matrix } from "babylonjs/Maths/math.vector";
  25220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25222. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25223. import { Effect } from "babylonjs/Materials/effect";
  25224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25226. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25227. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25228. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25229. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25230. import { Mesh } from "babylonjs/Meshes/mesh";
  25231. import { Animation } from "babylonjs/Animations/animation";
  25232. /**
  25233. * Options for compiling materials.
  25234. */
  25235. export interface IMaterialCompilationOptions {
  25236. /**
  25237. * Defines whether clip planes are enabled.
  25238. */
  25239. clipPlane: boolean;
  25240. /**
  25241. * Defines whether instances are enabled.
  25242. */
  25243. useInstances: boolean;
  25244. }
  25245. /**
  25246. * Options passed when calling customShaderNameResolve
  25247. */
  25248. export interface ICustomShaderNameResolveOptions {
  25249. /**
  25250. * 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
  25251. */
  25252. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25253. }
  25254. /**
  25255. * Base class for the main features of a material in Babylon.js
  25256. */
  25257. export class Material implements IAnimatable {
  25258. /**
  25259. * Returns the triangle fill mode
  25260. */
  25261. static readonly TriangleFillMode: number;
  25262. /**
  25263. * Returns the wireframe mode
  25264. */
  25265. static readonly WireFrameFillMode: number;
  25266. /**
  25267. * Returns the point fill mode
  25268. */
  25269. static readonly PointFillMode: number;
  25270. /**
  25271. * Returns the point list draw mode
  25272. */
  25273. static readonly PointListDrawMode: number;
  25274. /**
  25275. * Returns the line list draw mode
  25276. */
  25277. static readonly LineListDrawMode: number;
  25278. /**
  25279. * Returns the line loop draw mode
  25280. */
  25281. static readonly LineLoopDrawMode: number;
  25282. /**
  25283. * Returns the line strip draw mode
  25284. */
  25285. static readonly LineStripDrawMode: number;
  25286. /**
  25287. * Returns the triangle strip draw mode
  25288. */
  25289. static readonly TriangleStripDrawMode: number;
  25290. /**
  25291. * Returns the triangle fan draw mode
  25292. */
  25293. static readonly TriangleFanDrawMode: number;
  25294. /**
  25295. * Stores the clock-wise side orientation
  25296. */
  25297. static readonly ClockWiseSideOrientation: number;
  25298. /**
  25299. * Stores the counter clock-wise side orientation
  25300. */
  25301. static readonly CounterClockWiseSideOrientation: number;
  25302. /**
  25303. * The dirty texture flag value
  25304. */
  25305. static readonly TextureDirtyFlag: number;
  25306. /**
  25307. * The dirty light flag value
  25308. */
  25309. static readonly LightDirtyFlag: number;
  25310. /**
  25311. * The dirty fresnel flag value
  25312. */
  25313. static readonly FresnelDirtyFlag: number;
  25314. /**
  25315. * The dirty attribute flag value
  25316. */
  25317. static readonly AttributesDirtyFlag: number;
  25318. /**
  25319. * The dirty misc flag value
  25320. */
  25321. static readonly MiscDirtyFlag: number;
  25322. /**
  25323. * The all dirty flag value
  25324. */
  25325. static readonly AllDirtyFlag: number;
  25326. /**
  25327. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25328. */
  25329. static readonly MATERIAL_OPAQUE: number;
  25330. /**
  25331. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25332. */
  25333. static readonly MATERIAL_ALPHATEST: number;
  25334. /**
  25335. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25336. */
  25337. static readonly MATERIAL_ALPHABLEND: number;
  25338. /**
  25339. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25340. * They are also discarded below the alpha cutoff threshold to improve performances.
  25341. */
  25342. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25343. /**
  25344. * The Whiteout method is used to blend normals.
  25345. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25346. */
  25347. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25348. /**
  25349. * The Reoriented Normal Mapping method is used to blend normals.
  25350. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25351. */
  25352. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25353. /**
  25354. * Custom callback helping to override the default shader used in the material.
  25355. */
  25356. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25357. /**
  25358. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25359. */
  25360. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25361. /**
  25362. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25363. * This means that the material can keep using a previous shader while a new one is being compiled.
  25364. * This is mostly used when shader parallel compilation is supported (true by default)
  25365. */
  25366. allowShaderHotSwapping: boolean;
  25367. /**
  25368. * The ID of the material
  25369. */
  25370. id: string;
  25371. /**
  25372. * Gets or sets the unique id of the material
  25373. */
  25374. uniqueId: number;
  25375. /**
  25376. * The name of the material
  25377. */
  25378. name: string;
  25379. /**
  25380. * Gets or sets user defined metadata
  25381. */
  25382. metadata: any;
  25383. /**
  25384. * For internal use only. Please do not use.
  25385. */
  25386. reservedDataStore: any;
  25387. /**
  25388. * Specifies if the ready state should be checked on each call
  25389. */
  25390. checkReadyOnEveryCall: boolean;
  25391. /**
  25392. * Specifies if the ready state should be checked once
  25393. */
  25394. checkReadyOnlyOnce: boolean;
  25395. /**
  25396. * The state of the material
  25397. */
  25398. state: string;
  25399. /**
  25400. * If the material can be rendered to several textures with MRT extension
  25401. */
  25402. get canRenderToMRT(): boolean;
  25403. /**
  25404. * The alpha value of the material
  25405. */
  25406. protected _alpha: number;
  25407. /**
  25408. * List of inspectable custom properties (used by the Inspector)
  25409. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25410. */
  25411. inspectableCustomProperties: IInspectable[];
  25412. /**
  25413. * Sets the alpha value of the material
  25414. */
  25415. set alpha(value: number);
  25416. /**
  25417. * Gets the alpha value of the material
  25418. */
  25419. get alpha(): number;
  25420. /**
  25421. * Specifies if back face culling is enabled
  25422. */
  25423. protected _backFaceCulling: boolean;
  25424. /**
  25425. * Sets the back-face culling state
  25426. */
  25427. set backFaceCulling(value: boolean);
  25428. /**
  25429. * Gets the back-face culling state
  25430. */
  25431. get backFaceCulling(): boolean;
  25432. /**
  25433. * Stores the value for side orientation
  25434. */
  25435. sideOrientation: number;
  25436. /**
  25437. * Callback triggered when the material is compiled
  25438. */
  25439. onCompiled: Nullable<(effect: Effect) => void>;
  25440. /**
  25441. * Callback triggered when an error occurs
  25442. */
  25443. onError: Nullable<(effect: Effect, errors: string) => void>;
  25444. /**
  25445. * Callback triggered to get the render target textures
  25446. */
  25447. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25448. /**
  25449. * Gets a boolean indicating that current material needs to register RTT
  25450. */
  25451. get hasRenderTargetTextures(): boolean;
  25452. /**
  25453. * Specifies if the material should be serialized
  25454. */
  25455. doNotSerialize: boolean;
  25456. /**
  25457. * @hidden
  25458. */
  25459. _storeEffectOnSubMeshes: boolean;
  25460. /**
  25461. * Stores the animations for the material
  25462. */
  25463. animations: Nullable<Array<Animation>>;
  25464. /**
  25465. * An event triggered when the material is disposed
  25466. */
  25467. onDisposeObservable: Observable<Material>;
  25468. /**
  25469. * An observer which watches for dispose events
  25470. */
  25471. private _onDisposeObserver;
  25472. private _onUnBindObservable;
  25473. /**
  25474. * Called during a dispose event
  25475. */
  25476. set onDispose(callback: () => void);
  25477. private _onBindObservable;
  25478. /**
  25479. * An event triggered when the material is bound
  25480. */
  25481. get onBindObservable(): Observable<AbstractMesh>;
  25482. /**
  25483. * An observer which watches for bind events
  25484. */
  25485. private _onBindObserver;
  25486. /**
  25487. * Called during a bind event
  25488. */
  25489. set onBind(callback: (Mesh: AbstractMesh) => void);
  25490. /**
  25491. * An event triggered when the material is unbound
  25492. */
  25493. get onUnBindObservable(): Observable<Material>;
  25494. protected _onEffectCreatedObservable: Nullable<Observable<{
  25495. effect: Effect;
  25496. subMesh: Nullable<SubMesh>;
  25497. }>>;
  25498. /**
  25499. * An event triggered when the effect is (re)created
  25500. */
  25501. get onEffectCreatedObservable(): Observable<{
  25502. effect: Effect;
  25503. subMesh: Nullable<SubMesh>;
  25504. }>;
  25505. /**
  25506. * Stores the value of the alpha mode
  25507. */
  25508. private _alphaMode;
  25509. /**
  25510. * Sets the value of the alpha mode.
  25511. *
  25512. * | Value | Type | Description |
  25513. * | --- | --- | --- |
  25514. * | 0 | ALPHA_DISABLE | |
  25515. * | 1 | ALPHA_ADD | |
  25516. * | 2 | ALPHA_COMBINE | |
  25517. * | 3 | ALPHA_SUBTRACT | |
  25518. * | 4 | ALPHA_MULTIPLY | |
  25519. * | 5 | ALPHA_MAXIMIZED | |
  25520. * | 6 | ALPHA_ONEONE | |
  25521. * | 7 | ALPHA_PREMULTIPLIED | |
  25522. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25523. * | 9 | ALPHA_INTERPOLATE | |
  25524. * | 10 | ALPHA_SCREENMODE | |
  25525. *
  25526. */
  25527. set alphaMode(value: number);
  25528. /**
  25529. * Gets the value of the alpha mode
  25530. */
  25531. get alphaMode(): number;
  25532. /**
  25533. * Stores the state of the need depth pre-pass value
  25534. */
  25535. private _needDepthPrePass;
  25536. /**
  25537. * Sets the need depth pre-pass value
  25538. */
  25539. set needDepthPrePass(value: boolean);
  25540. /**
  25541. * Gets the depth pre-pass value
  25542. */
  25543. get needDepthPrePass(): boolean;
  25544. /**
  25545. * Specifies if depth writing should be disabled
  25546. */
  25547. disableDepthWrite: boolean;
  25548. /**
  25549. * Specifies if color writing should be disabled
  25550. */
  25551. disableColorWrite: boolean;
  25552. /**
  25553. * Specifies if depth writing should be forced
  25554. */
  25555. forceDepthWrite: boolean;
  25556. /**
  25557. * Specifies the depth function that should be used. 0 means the default engine function
  25558. */
  25559. depthFunction: number;
  25560. /**
  25561. * Specifies if there should be a separate pass for culling
  25562. */
  25563. separateCullingPass: boolean;
  25564. /**
  25565. * Stores the state specifing if fog should be enabled
  25566. */
  25567. private _fogEnabled;
  25568. /**
  25569. * Sets the state for enabling fog
  25570. */
  25571. set fogEnabled(value: boolean);
  25572. /**
  25573. * Gets the value of the fog enabled state
  25574. */
  25575. get fogEnabled(): boolean;
  25576. /**
  25577. * Stores the size of points
  25578. */
  25579. pointSize: number;
  25580. /**
  25581. * Stores the z offset value
  25582. */
  25583. zOffset: number;
  25584. get wireframe(): boolean;
  25585. /**
  25586. * Sets the state of wireframe mode
  25587. */
  25588. set wireframe(value: boolean);
  25589. /**
  25590. * Gets the value specifying if point clouds are enabled
  25591. */
  25592. get pointsCloud(): boolean;
  25593. /**
  25594. * Sets the state of point cloud mode
  25595. */
  25596. set pointsCloud(value: boolean);
  25597. /**
  25598. * Gets the material fill mode
  25599. */
  25600. get fillMode(): number;
  25601. /**
  25602. * Sets the material fill mode
  25603. */
  25604. set fillMode(value: number);
  25605. /**
  25606. * @hidden
  25607. * Stores the effects for the material
  25608. */
  25609. _effect: Nullable<Effect>;
  25610. /**
  25611. * Specifies if uniform buffers should be used
  25612. */
  25613. private _useUBO;
  25614. /**
  25615. * Stores a reference to the scene
  25616. */
  25617. private _scene;
  25618. /**
  25619. * Stores the fill mode state
  25620. */
  25621. private _fillMode;
  25622. /**
  25623. * Specifies if the depth write state should be cached
  25624. */
  25625. private _cachedDepthWriteState;
  25626. /**
  25627. * Specifies if the color write state should be cached
  25628. */
  25629. private _cachedColorWriteState;
  25630. /**
  25631. * Specifies if the depth function state should be cached
  25632. */
  25633. private _cachedDepthFunctionState;
  25634. /**
  25635. * Stores the uniform buffer
  25636. */
  25637. protected _uniformBuffer: UniformBuffer;
  25638. /** @hidden */
  25639. _indexInSceneMaterialArray: number;
  25640. /** @hidden */
  25641. meshMap: Nullable<{
  25642. [id: string]: AbstractMesh | undefined;
  25643. }>;
  25644. /**
  25645. * Creates a material instance
  25646. * @param name defines the name of the material
  25647. * @param scene defines the scene to reference
  25648. * @param doNotAdd specifies if the material should be added to the scene
  25649. */
  25650. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25651. /**
  25652. * Returns a string representation of the current material
  25653. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25654. * @returns a string with material information
  25655. */
  25656. toString(fullDetails?: boolean): string;
  25657. /**
  25658. * Gets the class name of the material
  25659. * @returns a string with the class name of the material
  25660. */
  25661. getClassName(): string;
  25662. /**
  25663. * Specifies if updates for the material been locked
  25664. */
  25665. get isFrozen(): boolean;
  25666. /**
  25667. * Locks updates for the material
  25668. */
  25669. freeze(): void;
  25670. /**
  25671. * Unlocks updates for the material
  25672. */
  25673. unfreeze(): void;
  25674. /**
  25675. * Specifies if the material is ready to be used
  25676. * @param mesh defines the mesh to check
  25677. * @param useInstances specifies if instances should be used
  25678. * @returns a boolean indicating if the material is ready to be used
  25679. */
  25680. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25681. /**
  25682. * Specifies that the submesh is ready to be used
  25683. * @param mesh defines the mesh to check
  25684. * @param subMesh defines which submesh to check
  25685. * @param useInstances specifies that instances should be used
  25686. * @returns a boolean indicating that the submesh is ready or not
  25687. */
  25688. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25689. /**
  25690. * Returns the material effect
  25691. * @returns the effect associated with the material
  25692. */
  25693. getEffect(): Nullable<Effect>;
  25694. /**
  25695. * Returns the current scene
  25696. * @returns a Scene
  25697. */
  25698. getScene(): Scene;
  25699. /**
  25700. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25701. */
  25702. protected _forceAlphaTest: boolean;
  25703. /**
  25704. * The transparency mode of the material.
  25705. */
  25706. protected _transparencyMode: Nullable<number>;
  25707. /**
  25708. * Gets the current transparency mode.
  25709. */
  25710. get transparencyMode(): Nullable<number>;
  25711. /**
  25712. * Sets the transparency mode of the material.
  25713. *
  25714. * | Value | Type | Description |
  25715. * | ----- | ----------------------------------- | ----------- |
  25716. * | 0 | OPAQUE | |
  25717. * | 1 | ALPHATEST | |
  25718. * | 2 | ALPHABLEND | |
  25719. * | 3 | ALPHATESTANDBLEND | |
  25720. *
  25721. */
  25722. set transparencyMode(value: Nullable<number>);
  25723. /**
  25724. * Returns true if alpha blending should be disabled.
  25725. */
  25726. protected get _disableAlphaBlending(): boolean;
  25727. /**
  25728. * Specifies whether or not this material should be rendered in alpha blend mode.
  25729. * @returns a boolean specifying if alpha blending is needed
  25730. */
  25731. needAlphaBlending(): boolean;
  25732. /**
  25733. * Specifies if the mesh will require alpha blending
  25734. * @param mesh defines the mesh to check
  25735. * @returns a boolean specifying if alpha blending is needed for the mesh
  25736. */
  25737. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25738. /**
  25739. * Specifies whether or not this material should be rendered in alpha test mode.
  25740. * @returns a boolean specifying if an alpha test is needed.
  25741. */
  25742. needAlphaTesting(): boolean;
  25743. /**
  25744. * Specifies if material alpha testing should be turned on for the mesh
  25745. * @param mesh defines the mesh to check
  25746. */
  25747. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25748. /**
  25749. * Gets the texture used for the alpha test
  25750. * @returns the texture to use for alpha testing
  25751. */
  25752. getAlphaTestTexture(): Nullable<BaseTexture>;
  25753. /**
  25754. * Marks the material to indicate that it needs to be re-calculated
  25755. */
  25756. markDirty(): void;
  25757. /** @hidden */
  25758. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25759. /**
  25760. * Binds the material to the mesh
  25761. * @param world defines the world transformation matrix
  25762. * @param mesh defines the mesh to bind the material to
  25763. */
  25764. bind(world: Matrix, mesh?: Mesh): void;
  25765. /**
  25766. * Binds the submesh to the material
  25767. * @param world defines the world transformation matrix
  25768. * @param mesh defines the mesh containing the submesh
  25769. * @param subMesh defines the submesh to bind the material to
  25770. */
  25771. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25772. /**
  25773. * Binds the world matrix to the material
  25774. * @param world defines the world transformation matrix
  25775. */
  25776. bindOnlyWorldMatrix(world: Matrix): void;
  25777. /**
  25778. * Binds the scene's uniform buffer to the effect.
  25779. * @param effect defines the effect to bind to the scene uniform buffer
  25780. * @param sceneUbo defines the uniform buffer storing scene data
  25781. */
  25782. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25783. /**
  25784. * Binds the view matrix to the effect
  25785. * @param effect defines the effect to bind the view matrix to
  25786. */
  25787. bindView(effect: Effect): void;
  25788. /**
  25789. * Binds the view projection matrix to the effect
  25790. * @param effect defines the effect to bind the view projection matrix to
  25791. */
  25792. bindViewProjection(effect: Effect): void;
  25793. /**
  25794. * Processes to execute after binding the material to a mesh
  25795. * @param mesh defines the rendered mesh
  25796. */
  25797. protected _afterBind(mesh?: Mesh): void;
  25798. /**
  25799. * Unbinds the material from the mesh
  25800. */
  25801. unbind(): void;
  25802. /**
  25803. * Gets the active textures from the material
  25804. * @returns an array of textures
  25805. */
  25806. getActiveTextures(): BaseTexture[];
  25807. /**
  25808. * Specifies if the material uses a texture
  25809. * @param texture defines the texture to check against the material
  25810. * @returns a boolean specifying if the material uses the texture
  25811. */
  25812. hasTexture(texture: BaseTexture): boolean;
  25813. /**
  25814. * Makes a duplicate of the material, and gives it a new name
  25815. * @param name defines the new name for the duplicated material
  25816. * @returns the cloned material
  25817. */
  25818. clone(name: string): Nullable<Material>;
  25819. /**
  25820. * Gets the meshes bound to the material
  25821. * @returns an array of meshes bound to the material
  25822. */
  25823. getBindedMeshes(): AbstractMesh[];
  25824. /**
  25825. * Force shader compilation
  25826. * @param mesh defines the mesh associated with this material
  25827. * @param onCompiled defines a function to execute once the material is compiled
  25828. * @param options defines the options to configure the compilation
  25829. * @param onError defines a function to execute if the material fails compiling
  25830. */
  25831. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25832. /**
  25833. * Force shader compilation
  25834. * @param mesh defines the mesh that will use this material
  25835. * @param options defines additional options for compiling the shaders
  25836. * @returns a promise that resolves when the compilation completes
  25837. */
  25838. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25839. private static readonly _AllDirtyCallBack;
  25840. private static readonly _ImageProcessingDirtyCallBack;
  25841. private static readonly _TextureDirtyCallBack;
  25842. private static readonly _FresnelDirtyCallBack;
  25843. private static readonly _MiscDirtyCallBack;
  25844. private static readonly _LightsDirtyCallBack;
  25845. private static readonly _AttributeDirtyCallBack;
  25846. private static _FresnelAndMiscDirtyCallBack;
  25847. private static _TextureAndMiscDirtyCallBack;
  25848. private static readonly _DirtyCallbackArray;
  25849. private static readonly _RunDirtyCallBacks;
  25850. /**
  25851. * Marks a define in the material to indicate that it needs to be re-computed
  25852. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25853. */
  25854. markAsDirty(flag: number): void;
  25855. /**
  25856. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25857. * @param func defines a function which checks material defines against the submeshes
  25858. */
  25859. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25860. /**
  25861. * Indicates that the scene should check if the rendering now needs a prepass
  25862. */
  25863. protected _markScenePrePassDirty(): void;
  25864. /**
  25865. * Indicates that we need to re-calculated for all submeshes
  25866. */
  25867. protected _markAllSubMeshesAsAllDirty(): void;
  25868. /**
  25869. * Indicates that image processing needs to be re-calculated for all submeshes
  25870. */
  25871. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25872. /**
  25873. * Indicates that textures need to be re-calculated for all submeshes
  25874. */
  25875. protected _markAllSubMeshesAsTexturesDirty(): void;
  25876. /**
  25877. * Indicates that fresnel needs to be re-calculated for all submeshes
  25878. */
  25879. protected _markAllSubMeshesAsFresnelDirty(): void;
  25880. /**
  25881. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25882. */
  25883. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25884. /**
  25885. * Indicates that lights need to be re-calculated for all submeshes
  25886. */
  25887. protected _markAllSubMeshesAsLightsDirty(): void;
  25888. /**
  25889. * Indicates that attributes need to be re-calculated for all submeshes
  25890. */
  25891. protected _markAllSubMeshesAsAttributesDirty(): void;
  25892. /**
  25893. * Indicates that misc needs to be re-calculated for all submeshes
  25894. */
  25895. protected _markAllSubMeshesAsMiscDirty(): void;
  25896. /**
  25897. * Indicates that textures and misc need to be re-calculated for all submeshes
  25898. */
  25899. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25900. /**
  25901. * Sets the required values to the prepass renderer.
  25902. * @param prePassRenderer defines the prepass renderer to setup.
  25903. * @returns true if the pre pass is needed.
  25904. */
  25905. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25906. /**
  25907. * Disposes the material
  25908. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25909. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25910. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25911. */
  25912. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25913. /** @hidden */
  25914. private releaseVertexArrayObject;
  25915. /**
  25916. * Serializes this material
  25917. * @returns the serialized material object
  25918. */
  25919. serialize(): any;
  25920. /**
  25921. * Creates a material from parsed material data
  25922. * @param parsedMaterial defines parsed material data
  25923. * @param scene defines the hosting scene
  25924. * @param rootUrl defines the root URL to use to load textures
  25925. * @returns a new material
  25926. */
  25927. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25928. }
  25929. }
  25930. declare module "babylonjs/Materials/multiMaterial" {
  25931. import { Nullable } from "babylonjs/types";
  25932. import { Scene } from "babylonjs/scene";
  25933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25934. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25936. import { Material } from "babylonjs/Materials/material";
  25937. /**
  25938. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25939. * separate meshes. This can be use to improve performances.
  25940. * @see https://doc.babylonjs.com/how_to/multi_materials
  25941. */
  25942. export class MultiMaterial extends Material {
  25943. private _subMaterials;
  25944. /**
  25945. * Gets or Sets the list of Materials used within the multi material.
  25946. * They need to be ordered according to the submeshes order in the associated mesh
  25947. */
  25948. get subMaterials(): Nullable<Material>[];
  25949. set subMaterials(value: Nullable<Material>[]);
  25950. /**
  25951. * Function used to align with Node.getChildren()
  25952. * @returns the list of Materials used within the multi material
  25953. */
  25954. getChildren(): Nullable<Material>[];
  25955. /**
  25956. * Instantiates a new Multi Material
  25957. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25958. * separate meshes. This can be use to improve performances.
  25959. * @see https://doc.babylonjs.com/how_to/multi_materials
  25960. * @param name Define the name in the scene
  25961. * @param scene Define the scene the material belongs to
  25962. */
  25963. constructor(name: string, scene: Scene);
  25964. private _hookArray;
  25965. /**
  25966. * Get one of the submaterial by its index in the submaterials array
  25967. * @param index The index to look the sub material at
  25968. * @returns The Material if the index has been defined
  25969. */
  25970. getSubMaterial(index: number): Nullable<Material>;
  25971. /**
  25972. * Get the list of active textures for the whole sub materials list.
  25973. * @returns All the textures that will be used during the rendering
  25974. */
  25975. getActiveTextures(): BaseTexture[];
  25976. /**
  25977. * Gets the current class name of the material e.g. "MultiMaterial"
  25978. * Mainly use in serialization.
  25979. * @returns the class name
  25980. */
  25981. getClassName(): string;
  25982. /**
  25983. * Checks if the material is ready to render the requested sub mesh
  25984. * @param mesh Define the mesh the submesh belongs to
  25985. * @param subMesh Define the sub mesh to look readyness for
  25986. * @param useInstances Define whether or not the material is used with instances
  25987. * @returns true if ready, otherwise false
  25988. */
  25989. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25990. /**
  25991. * Clones the current material and its related sub materials
  25992. * @param name Define the name of the newly cloned material
  25993. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25994. * @returns the cloned material
  25995. */
  25996. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25997. /**
  25998. * Serializes the materials into a JSON representation.
  25999. * @returns the JSON representation
  26000. */
  26001. serialize(): any;
  26002. /**
  26003. * Dispose the material and release its associated resources
  26004. * @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)
  26005. * @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)
  26006. * @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)
  26007. */
  26008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26009. /**
  26010. * Creates a MultiMaterial from parsed MultiMaterial data.
  26011. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26012. * @param scene defines the hosting scene
  26013. * @returns a new MultiMaterial
  26014. */
  26015. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26016. }
  26017. }
  26018. declare module "babylonjs/Meshes/subMesh" {
  26019. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26020. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26021. import { Engine } from "babylonjs/Engines/engine";
  26022. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26023. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26024. import { Effect } from "babylonjs/Materials/effect";
  26025. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26026. import { Plane } from "babylonjs/Maths/math.plane";
  26027. import { Collider } from "babylonjs/Collisions/collider";
  26028. import { Material } from "babylonjs/Materials/material";
  26029. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26031. import { Mesh } from "babylonjs/Meshes/mesh";
  26032. import { Ray } from "babylonjs/Culling/ray";
  26033. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26034. /**
  26035. * Defines a subdivision inside a mesh
  26036. */
  26037. export class SubMesh implements ICullable {
  26038. /** the material index to use */
  26039. materialIndex: number;
  26040. /** vertex index start */
  26041. verticesStart: number;
  26042. /** vertices count */
  26043. verticesCount: number;
  26044. /** index start */
  26045. indexStart: number;
  26046. /** indices count */
  26047. indexCount: number;
  26048. /** @hidden */
  26049. _materialDefines: Nullable<MaterialDefines>;
  26050. /** @hidden */
  26051. _materialEffect: Nullable<Effect>;
  26052. /** @hidden */
  26053. _effectOverride: Nullable<Effect>;
  26054. /**
  26055. * Gets material defines used by the effect associated to the sub mesh
  26056. */
  26057. get materialDefines(): Nullable<MaterialDefines>;
  26058. /**
  26059. * Sets material defines used by the effect associated to the sub mesh
  26060. */
  26061. set materialDefines(defines: Nullable<MaterialDefines>);
  26062. /**
  26063. * Gets associated effect
  26064. */
  26065. get effect(): Nullable<Effect>;
  26066. /**
  26067. * Sets associated effect (effect used to render this submesh)
  26068. * @param effect defines the effect to associate with
  26069. * @param defines defines the set of defines used to compile this effect
  26070. */
  26071. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26072. /** @hidden */
  26073. _linesIndexCount: number;
  26074. private _mesh;
  26075. private _renderingMesh;
  26076. private _boundingInfo;
  26077. private _linesIndexBuffer;
  26078. /** @hidden */
  26079. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26080. /** @hidden */
  26081. _trianglePlanes: Plane[];
  26082. /** @hidden */
  26083. _lastColliderTransformMatrix: Nullable<Matrix>;
  26084. /** @hidden */
  26085. _renderId: number;
  26086. /** @hidden */
  26087. _alphaIndex: number;
  26088. /** @hidden */
  26089. _distanceToCamera: number;
  26090. /** @hidden */
  26091. _id: number;
  26092. private _currentMaterial;
  26093. /**
  26094. * Add a new submesh to a mesh
  26095. * @param materialIndex defines the material index to use
  26096. * @param verticesStart defines vertex index start
  26097. * @param verticesCount defines vertices count
  26098. * @param indexStart defines index start
  26099. * @param indexCount defines indices count
  26100. * @param mesh defines the parent mesh
  26101. * @param renderingMesh defines an optional rendering mesh
  26102. * @param createBoundingBox defines if bounding box should be created for this submesh
  26103. * @returns the new submesh
  26104. */
  26105. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26106. /**
  26107. * Creates a new submesh
  26108. * @param materialIndex defines the material index to use
  26109. * @param verticesStart defines vertex index start
  26110. * @param verticesCount defines vertices count
  26111. * @param indexStart defines index start
  26112. * @param indexCount defines indices count
  26113. * @param mesh defines the parent mesh
  26114. * @param renderingMesh defines an optional rendering mesh
  26115. * @param createBoundingBox defines if bounding box should be created for this submesh
  26116. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26117. */
  26118. constructor(
  26119. /** the material index to use */
  26120. materialIndex: number,
  26121. /** vertex index start */
  26122. verticesStart: number,
  26123. /** vertices count */
  26124. verticesCount: number,
  26125. /** index start */
  26126. indexStart: number,
  26127. /** indices count */
  26128. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26129. /**
  26130. * Returns true if this submesh covers the entire parent mesh
  26131. * @ignorenaming
  26132. */
  26133. get IsGlobal(): boolean;
  26134. /**
  26135. * Returns the submesh BoudingInfo object
  26136. * @returns current bounding info (or mesh's one if the submesh is global)
  26137. */
  26138. getBoundingInfo(): BoundingInfo;
  26139. /**
  26140. * Sets the submesh BoundingInfo
  26141. * @param boundingInfo defines the new bounding info to use
  26142. * @returns the SubMesh
  26143. */
  26144. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26145. /**
  26146. * Returns the mesh of the current submesh
  26147. * @return the parent mesh
  26148. */
  26149. getMesh(): AbstractMesh;
  26150. /**
  26151. * Returns the rendering mesh of the submesh
  26152. * @returns the rendering mesh (could be different from parent mesh)
  26153. */
  26154. getRenderingMesh(): Mesh;
  26155. /**
  26156. * Returns the replacement mesh of the submesh
  26157. * @returns the replacement mesh (could be different from parent mesh)
  26158. */
  26159. getReplacementMesh(): Nullable<AbstractMesh>;
  26160. /**
  26161. * Returns the effective mesh of the submesh
  26162. * @returns the effective mesh (could be different from parent mesh)
  26163. */
  26164. getEffectiveMesh(): AbstractMesh;
  26165. /**
  26166. * Returns the submesh material
  26167. * @returns null or the current material
  26168. */
  26169. getMaterial(): Nullable<Material>;
  26170. private _IsMultiMaterial;
  26171. /**
  26172. * Sets a new updated BoundingInfo object to the submesh
  26173. * @param data defines an optional position array to use to determine the bounding info
  26174. * @returns the SubMesh
  26175. */
  26176. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26177. /** @hidden */
  26178. _checkCollision(collider: Collider): boolean;
  26179. /**
  26180. * Updates the submesh BoundingInfo
  26181. * @param world defines the world matrix to use to update the bounding info
  26182. * @returns the submesh
  26183. */
  26184. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26185. /**
  26186. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26187. * @param frustumPlanes defines the frustum planes
  26188. * @returns true if the submesh is intersecting with the frustum
  26189. */
  26190. isInFrustum(frustumPlanes: Plane[]): boolean;
  26191. /**
  26192. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26193. * @param frustumPlanes defines the frustum planes
  26194. * @returns true if the submesh is inside the frustum
  26195. */
  26196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26197. /**
  26198. * Renders the submesh
  26199. * @param enableAlphaMode defines if alpha needs to be used
  26200. * @returns the submesh
  26201. */
  26202. render(enableAlphaMode: boolean): SubMesh;
  26203. /**
  26204. * @hidden
  26205. */
  26206. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26207. /**
  26208. * Checks if the submesh intersects with a ray
  26209. * @param ray defines the ray to test
  26210. * @returns true is the passed ray intersects the submesh bounding box
  26211. */
  26212. canIntersects(ray: Ray): boolean;
  26213. /**
  26214. * Intersects current submesh with a ray
  26215. * @param ray defines the ray to test
  26216. * @param positions defines mesh's positions array
  26217. * @param indices defines mesh's indices array
  26218. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26219. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26220. * @returns intersection info or null if no intersection
  26221. */
  26222. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26223. /** @hidden */
  26224. private _intersectLines;
  26225. /** @hidden */
  26226. private _intersectUnIndexedLines;
  26227. /** @hidden */
  26228. private _intersectTriangles;
  26229. /** @hidden */
  26230. private _intersectUnIndexedTriangles;
  26231. /** @hidden */
  26232. _rebuild(): void;
  26233. /**
  26234. * Creates a new submesh from the passed mesh
  26235. * @param newMesh defines the new hosting mesh
  26236. * @param newRenderingMesh defines an optional rendering mesh
  26237. * @returns the new submesh
  26238. */
  26239. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26240. /**
  26241. * Release associated resources
  26242. */
  26243. dispose(): void;
  26244. /**
  26245. * Gets the class name
  26246. * @returns the string "SubMesh".
  26247. */
  26248. getClassName(): string;
  26249. /**
  26250. * Creates a new submesh from indices data
  26251. * @param materialIndex the index of the main mesh material
  26252. * @param startIndex the index where to start the copy in the mesh indices array
  26253. * @param indexCount the number of indices to copy then from the startIndex
  26254. * @param mesh the main mesh to create the submesh from
  26255. * @param renderingMesh the optional rendering mesh
  26256. * @returns a new submesh
  26257. */
  26258. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26259. }
  26260. }
  26261. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26262. /**
  26263. * Class used to represent data loading progression
  26264. */
  26265. export class SceneLoaderFlags {
  26266. private static _ForceFullSceneLoadingForIncremental;
  26267. private static _ShowLoadingScreen;
  26268. private static _CleanBoneMatrixWeights;
  26269. private static _loggingLevel;
  26270. /**
  26271. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26272. */
  26273. static get ForceFullSceneLoadingForIncremental(): boolean;
  26274. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26275. /**
  26276. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26277. */
  26278. static get ShowLoadingScreen(): boolean;
  26279. static set ShowLoadingScreen(value: boolean);
  26280. /**
  26281. * Defines the current logging level (while loading the scene)
  26282. * @ignorenaming
  26283. */
  26284. static get loggingLevel(): number;
  26285. static set loggingLevel(value: number);
  26286. /**
  26287. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26288. */
  26289. static get CleanBoneMatrixWeights(): boolean;
  26290. static set CleanBoneMatrixWeights(value: boolean);
  26291. }
  26292. }
  26293. declare module "babylonjs/Meshes/geometry" {
  26294. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26295. import { Scene } from "babylonjs/scene";
  26296. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26297. import { Engine } from "babylonjs/Engines/engine";
  26298. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26299. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26300. import { Effect } from "babylonjs/Materials/effect";
  26301. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26302. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26303. import { Mesh } from "babylonjs/Meshes/mesh";
  26304. /**
  26305. * Class used to store geometry data (vertex buffers + index buffer)
  26306. */
  26307. export class Geometry implements IGetSetVerticesData {
  26308. /**
  26309. * Gets or sets the ID of the geometry
  26310. */
  26311. id: string;
  26312. /**
  26313. * Gets or sets the unique ID of the geometry
  26314. */
  26315. uniqueId: number;
  26316. /**
  26317. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26318. */
  26319. delayLoadState: number;
  26320. /**
  26321. * Gets the file containing the data to load when running in delay load state
  26322. */
  26323. delayLoadingFile: Nullable<string>;
  26324. /**
  26325. * Callback called when the geometry is updated
  26326. */
  26327. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26328. private _scene;
  26329. private _engine;
  26330. private _meshes;
  26331. private _totalVertices;
  26332. /** @hidden */
  26333. _indices: IndicesArray;
  26334. /** @hidden */
  26335. _vertexBuffers: {
  26336. [key: string]: VertexBuffer;
  26337. };
  26338. private _isDisposed;
  26339. private _extend;
  26340. private _boundingBias;
  26341. /** @hidden */
  26342. _delayInfo: Array<string>;
  26343. private _indexBuffer;
  26344. private _indexBufferIsUpdatable;
  26345. /** @hidden */
  26346. _boundingInfo: Nullable<BoundingInfo>;
  26347. /** @hidden */
  26348. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26349. /** @hidden */
  26350. _softwareSkinningFrameId: number;
  26351. private _vertexArrayObjects;
  26352. private _updatable;
  26353. /** @hidden */
  26354. _positions: Nullable<Vector3[]>;
  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. get boundingBias(): Vector2;
  26359. /**
  26360. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  26361. */
  26362. set boundingBias(value: Vector2);
  26363. /**
  26364. * Static function used to attach a new empty geometry to a mesh
  26365. * @param mesh defines the mesh to attach the geometry to
  26366. * @returns the new Geometry
  26367. */
  26368. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26369. /** Get the list of meshes using this geometry */
  26370. get meshes(): Mesh[];
  26371. /**
  26372. * 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
  26373. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26374. */
  26375. useBoundingInfoFromGeometry: boolean;
  26376. /**
  26377. * Creates a new geometry
  26378. * @param id defines the unique ID
  26379. * @param scene defines the hosting scene
  26380. * @param vertexData defines the VertexData used to get geometry data
  26381. * @param updatable defines if geometry must be updatable (false by default)
  26382. * @param mesh defines the mesh that will be associated with the geometry
  26383. */
  26384. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26385. /**
  26386. * Gets the current extend of the geometry
  26387. */
  26388. get extend(): {
  26389. minimum: Vector3;
  26390. maximum: Vector3;
  26391. };
  26392. /**
  26393. * Gets the hosting scene
  26394. * @returns the hosting Scene
  26395. */
  26396. getScene(): Scene;
  26397. /**
  26398. * Gets the hosting engine
  26399. * @returns the hosting Engine
  26400. */
  26401. getEngine(): Engine;
  26402. /**
  26403. * Defines if the geometry is ready to use
  26404. * @returns true if the geometry is ready to be used
  26405. */
  26406. isReady(): boolean;
  26407. /**
  26408. * Gets a value indicating that the geometry should not be serialized
  26409. */
  26410. get doNotSerialize(): boolean;
  26411. /** @hidden */
  26412. _rebuild(): void;
  26413. /**
  26414. * Affects all geometry data in one call
  26415. * @param vertexData defines the geometry data
  26416. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26417. */
  26418. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26419. /**
  26420. * Set specific vertex data
  26421. * @param kind defines the data kind (Position, normal, etc...)
  26422. * @param data defines the vertex data to use
  26423. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26424. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26425. */
  26426. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26427. /**
  26428. * Removes a specific vertex data
  26429. * @param kind defines the data kind (Position, normal, etc...)
  26430. */
  26431. removeVerticesData(kind: string): void;
  26432. /**
  26433. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26434. * @param buffer defines the vertex buffer to use
  26435. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26436. */
  26437. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26438. /**
  26439. * Update a specific vertex buffer
  26440. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26441. * It will do nothing if the buffer is not updatable
  26442. * @param kind defines the data kind (Position, normal, etc...)
  26443. * @param data defines the data to use
  26444. * @param offset defines the offset in the target buffer where to store the data
  26445. * @param useBytes set to true if the offset is in bytes
  26446. */
  26447. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26448. /**
  26449. * Update a specific vertex buffer
  26450. * This function will create a new buffer if the current one is not updatable
  26451. * @param kind defines the data kind (Position, normal, etc...)
  26452. * @param data defines the data to use
  26453. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26454. */
  26455. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26456. private _updateBoundingInfo;
  26457. /** @hidden */
  26458. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26459. /**
  26460. * Gets total number of vertices
  26461. * @returns the total number of vertices
  26462. */
  26463. getTotalVertices(): number;
  26464. /**
  26465. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26466. * @param kind defines the data kind (Position, normal, etc...)
  26467. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26468. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26469. * @returns a float array containing vertex data
  26470. */
  26471. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26472. /**
  26473. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26474. * @param kind defines the data kind (Position, normal, etc...)
  26475. * @returns true if the vertex buffer with the specified kind is updatable
  26476. */
  26477. isVertexBufferUpdatable(kind: string): boolean;
  26478. /**
  26479. * Gets a specific vertex buffer
  26480. * @param kind defines the data kind (Position, normal, etc...)
  26481. * @returns a VertexBuffer
  26482. */
  26483. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26484. /**
  26485. * Returns all vertex buffers
  26486. * @return an object holding all vertex buffers indexed by kind
  26487. */
  26488. getVertexBuffers(): Nullable<{
  26489. [key: string]: VertexBuffer;
  26490. }>;
  26491. /**
  26492. * Gets a boolean indicating if specific vertex buffer is present
  26493. * @param kind defines the data kind (Position, normal, etc...)
  26494. * @returns true if data is present
  26495. */
  26496. isVerticesDataPresent(kind: string): boolean;
  26497. /**
  26498. * Gets a list of all attached data kinds (Position, normal, etc...)
  26499. * @returns a list of string containing all kinds
  26500. */
  26501. getVerticesDataKinds(): string[];
  26502. /**
  26503. * Update index buffer
  26504. * @param indices defines the indices to store in the index buffer
  26505. * @param offset defines the offset in the target buffer where to store the data
  26506. * @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)
  26507. */
  26508. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26509. /**
  26510. * Creates a new index buffer
  26511. * @param indices defines the indices to store in the index buffer
  26512. * @param totalVertices defines the total number of vertices (could be null)
  26513. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26514. */
  26515. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26516. /**
  26517. * Return the total number of indices
  26518. * @returns the total number of indices
  26519. */
  26520. getTotalIndices(): number;
  26521. /**
  26522. * Gets the index buffer array
  26523. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26524. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26525. * @returns the index buffer array
  26526. */
  26527. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26528. /**
  26529. * Gets the index buffer
  26530. * @return the index buffer
  26531. */
  26532. getIndexBuffer(): Nullable<DataBuffer>;
  26533. /** @hidden */
  26534. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26535. /**
  26536. * Release the associated resources for a specific mesh
  26537. * @param mesh defines the source mesh
  26538. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26539. */
  26540. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26541. /**
  26542. * Apply current geometry to a given mesh
  26543. * @param mesh defines the mesh to apply geometry to
  26544. */
  26545. applyToMesh(mesh: Mesh): void;
  26546. private _updateExtend;
  26547. private _applyToMesh;
  26548. private notifyUpdate;
  26549. /**
  26550. * Load the geometry if it was flagged as delay loaded
  26551. * @param scene defines the hosting scene
  26552. * @param onLoaded defines a callback called when the geometry is loaded
  26553. */
  26554. load(scene: Scene, onLoaded?: () => void): void;
  26555. private _queueLoad;
  26556. /**
  26557. * Invert the geometry to move from a right handed system to a left handed one.
  26558. */
  26559. toLeftHanded(): void;
  26560. /** @hidden */
  26561. _resetPointsArrayCache(): void;
  26562. /** @hidden */
  26563. _generatePointsArray(): boolean;
  26564. /**
  26565. * Gets a value indicating if the geometry is disposed
  26566. * @returns true if the geometry was disposed
  26567. */
  26568. isDisposed(): boolean;
  26569. private _disposeVertexArrayObjects;
  26570. /**
  26571. * Free all associated resources
  26572. */
  26573. dispose(): void;
  26574. /**
  26575. * Clone the current geometry into a new geometry
  26576. * @param id defines the unique ID of the new geometry
  26577. * @returns a new geometry object
  26578. */
  26579. copy(id: string): Geometry;
  26580. /**
  26581. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26582. * @return a JSON representation of the current geometry data (without the vertices data)
  26583. */
  26584. serialize(): any;
  26585. private toNumberArray;
  26586. /**
  26587. * Serialize all vertices data into a JSON oject
  26588. * @returns a JSON representation of the current geometry data
  26589. */
  26590. serializeVerticeData(): any;
  26591. /**
  26592. * Extracts a clone of a mesh geometry
  26593. * @param mesh defines the source mesh
  26594. * @param id defines the unique ID of the new geometry object
  26595. * @returns the new geometry object
  26596. */
  26597. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26598. /**
  26599. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26600. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26601. * Be aware Math.random() could cause collisions, but:
  26602. * "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"
  26603. * @returns a string containing a new GUID
  26604. */
  26605. static RandomId(): string;
  26606. /** @hidden */
  26607. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26608. private static _CleanMatricesWeights;
  26609. /**
  26610. * Create a new geometry from persisted data (Using .babylon file format)
  26611. * @param parsedVertexData defines the persisted data
  26612. * @param scene defines the hosting scene
  26613. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26614. * @returns the new geometry object
  26615. */
  26616. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26617. }
  26618. }
  26619. declare module "babylonjs/Meshes/mesh.vertexData" {
  26620. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26621. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26622. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26623. import { Geometry } from "babylonjs/Meshes/geometry";
  26624. import { Mesh } from "babylonjs/Meshes/mesh";
  26625. /**
  26626. * Define an interface for all classes that will get and set the data on vertices
  26627. */
  26628. export interface IGetSetVerticesData {
  26629. /**
  26630. * Gets a boolean indicating if specific vertex data is present
  26631. * @param kind defines the vertex data kind to use
  26632. * @returns true is data kind is present
  26633. */
  26634. isVerticesDataPresent(kind: string): boolean;
  26635. /**
  26636. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26637. * @param kind defines the data kind (Position, normal, etc...)
  26638. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26639. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26640. * @returns a float array containing vertex data
  26641. */
  26642. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26643. /**
  26644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26645. * @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.
  26646. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26647. * @returns the indices array or an empty array if the mesh has no geometry
  26648. */
  26649. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26650. /**
  26651. * Set specific vertex data
  26652. * @param kind defines the data kind (Position, normal, etc...)
  26653. * @param data defines the vertex data to use
  26654. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26655. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26656. */
  26657. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26658. /**
  26659. * Update a specific associated vertex buffer
  26660. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26661. * - VertexBuffer.PositionKind
  26662. * - VertexBuffer.UVKind
  26663. * - VertexBuffer.UV2Kind
  26664. * - VertexBuffer.UV3Kind
  26665. * - VertexBuffer.UV4Kind
  26666. * - VertexBuffer.UV5Kind
  26667. * - VertexBuffer.UV6Kind
  26668. * - VertexBuffer.ColorKind
  26669. * - VertexBuffer.MatricesIndicesKind
  26670. * - VertexBuffer.MatricesIndicesExtraKind
  26671. * - VertexBuffer.MatricesWeightsKind
  26672. * - VertexBuffer.MatricesWeightsExtraKind
  26673. * @param data defines the data source
  26674. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26675. * @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)
  26676. */
  26677. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26678. /**
  26679. * Creates a new index buffer
  26680. * @param indices defines the indices to store in the index buffer
  26681. * @param totalVertices defines the total number of vertices (could be null)
  26682. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26683. */
  26684. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26685. }
  26686. /**
  26687. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26688. */
  26689. export class VertexData {
  26690. /**
  26691. * Mesh side orientation : usually the external or front surface
  26692. */
  26693. static readonly FRONTSIDE: number;
  26694. /**
  26695. * Mesh side orientation : usually the internal or back surface
  26696. */
  26697. static readonly BACKSIDE: number;
  26698. /**
  26699. * Mesh side orientation : both internal and external or front and back surfaces
  26700. */
  26701. static readonly DOUBLESIDE: number;
  26702. /**
  26703. * Mesh side orientation : by default, `FRONTSIDE`
  26704. */
  26705. static readonly DEFAULTSIDE: number;
  26706. /**
  26707. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26708. */
  26709. positions: Nullable<FloatArray>;
  26710. /**
  26711. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26712. */
  26713. normals: Nullable<FloatArray>;
  26714. /**
  26715. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26716. */
  26717. tangents: Nullable<FloatArray>;
  26718. /**
  26719. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26720. */
  26721. uvs: Nullable<FloatArray>;
  26722. /**
  26723. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26724. */
  26725. uvs2: Nullable<FloatArray>;
  26726. /**
  26727. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26728. */
  26729. uvs3: Nullable<FloatArray>;
  26730. /**
  26731. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26732. */
  26733. uvs4: Nullable<FloatArray>;
  26734. /**
  26735. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26736. */
  26737. uvs5: Nullable<FloatArray>;
  26738. /**
  26739. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26740. */
  26741. uvs6: Nullable<FloatArray>;
  26742. /**
  26743. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26744. */
  26745. colors: Nullable<FloatArray>;
  26746. /**
  26747. * 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).
  26748. */
  26749. matricesIndices: Nullable<FloatArray>;
  26750. /**
  26751. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26752. */
  26753. matricesWeights: Nullable<FloatArray>;
  26754. /**
  26755. * An array extending the number of possible indices
  26756. */
  26757. matricesIndicesExtra: Nullable<FloatArray>;
  26758. /**
  26759. * An array extending the number of possible weights when the number of indices is extended
  26760. */
  26761. matricesWeightsExtra: Nullable<FloatArray>;
  26762. /**
  26763. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26764. */
  26765. indices: Nullable<IndicesArray>;
  26766. /**
  26767. * Uses the passed data array to set the set the values for the specified kind of data
  26768. * @param data a linear array of floating numbers
  26769. * @param kind the type of data that is being set, eg positions, colors etc
  26770. */
  26771. set(data: FloatArray, kind: string): void;
  26772. /**
  26773. * Associates the vertexData to the passed Mesh.
  26774. * Sets it as updatable or not (default `false`)
  26775. * @param mesh the mesh the vertexData is applied to
  26776. * @param updatable when used and having the value true allows new data to update the vertexData
  26777. * @returns the VertexData
  26778. */
  26779. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26780. /**
  26781. * Associates the vertexData to the passed Geometry.
  26782. * Sets it as updatable or not (default `false`)
  26783. * @param geometry the geometry the vertexData is applied to
  26784. * @param updatable when used and having the value true allows new data to update the vertexData
  26785. * @returns VertexData
  26786. */
  26787. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26788. /**
  26789. * Updates the associated mesh
  26790. * @param mesh the mesh to be updated
  26791. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26792. * @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
  26793. * @returns VertexData
  26794. */
  26795. updateMesh(mesh: Mesh): VertexData;
  26796. /**
  26797. * Updates the associated geometry
  26798. * @param geometry the geometry to be updated
  26799. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26800. * @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
  26801. * @returns VertexData.
  26802. */
  26803. updateGeometry(geometry: Geometry): VertexData;
  26804. private _applyTo;
  26805. private _update;
  26806. /**
  26807. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26808. * @param matrix the transforming matrix
  26809. * @returns the VertexData
  26810. */
  26811. transform(matrix: Matrix): VertexData;
  26812. /**
  26813. * Merges the passed VertexData into the current one
  26814. * @param other the VertexData to be merged into the current one
  26815. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26816. * @returns the modified VertexData
  26817. */
  26818. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26819. private _mergeElement;
  26820. private _validate;
  26821. /**
  26822. * Serializes the VertexData
  26823. * @returns a serialized object
  26824. */
  26825. serialize(): any;
  26826. /**
  26827. * Extracts the vertexData from a mesh
  26828. * @param mesh the mesh from which to extract the VertexData
  26829. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26830. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26831. * @returns the object VertexData associated to the passed mesh
  26832. */
  26833. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26834. /**
  26835. * Extracts the vertexData from the geometry
  26836. * @param geometry the geometry from which to extract the VertexData
  26837. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26838. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26839. * @returns the object VertexData associated to the passed mesh
  26840. */
  26841. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26842. private static _ExtractFrom;
  26843. /**
  26844. * Creates the VertexData for a Ribbon
  26845. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26846. * * pathArray array of paths, each of which an array of successive Vector3
  26847. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26848. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26849. * * 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
  26850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26851. * * 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)
  26852. * * 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)
  26853. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26854. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26855. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26856. * @returns the VertexData of the ribbon
  26857. */
  26858. static CreateRibbon(options: {
  26859. pathArray: Vector3[][];
  26860. closeArray?: boolean;
  26861. closePath?: boolean;
  26862. offset?: number;
  26863. sideOrientation?: number;
  26864. frontUVs?: Vector4;
  26865. backUVs?: Vector4;
  26866. invertUV?: boolean;
  26867. uvs?: Vector2[];
  26868. colors?: Color4[];
  26869. }): VertexData;
  26870. /**
  26871. * Creates the VertexData for a box
  26872. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26873. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26874. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26875. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26876. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26877. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26878. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26880. * * 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)
  26881. * * 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)
  26882. * @returns the VertexData of the box
  26883. */
  26884. static CreateBox(options: {
  26885. size?: number;
  26886. width?: number;
  26887. height?: number;
  26888. depth?: number;
  26889. faceUV?: Vector4[];
  26890. faceColors?: Color4[];
  26891. sideOrientation?: number;
  26892. frontUVs?: Vector4;
  26893. backUVs?: Vector4;
  26894. }): VertexData;
  26895. /**
  26896. * Creates the VertexData for a tiled box
  26897. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26898. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26899. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26900. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26901. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26902. * @returns the VertexData of the box
  26903. */
  26904. static CreateTiledBox(options: {
  26905. pattern?: number;
  26906. width?: number;
  26907. height?: number;
  26908. depth?: number;
  26909. tileSize?: number;
  26910. tileWidth?: number;
  26911. tileHeight?: number;
  26912. alignHorizontal?: number;
  26913. alignVertical?: number;
  26914. faceUV?: Vector4[];
  26915. faceColors?: Color4[];
  26916. sideOrientation?: number;
  26917. }): VertexData;
  26918. /**
  26919. * Creates the VertexData for a tiled plane
  26920. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26921. * * pattern a limited pattern arrangement depending on the number
  26922. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26923. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26924. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26926. * * 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)
  26927. * * 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)
  26928. * @returns the VertexData of the tiled plane
  26929. */
  26930. static CreateTiledPlane(options: {
  26931. pattern?: number;
  26932. tileSize?: number;
  26933. tileWidth?: number;
  26934. tileHeight?: number;
  26935. size?: number;
  26936. width?: number;
  26937. height?: number;
  26938. alignHorizontal?: number;
  26939. alignVertical?: number;
  26940. sideOrientation?: number;
  26941. frontUVs?: Vector4;
  26942. backUVs?: Vector4;
  26943. }): VertexData;
  26944. /**
  26945. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26946. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26947. * * segments sets the number of horizontal strips optional, default 32
  26948. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26949. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26950. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26951. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26952. * * 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
  26953. * * 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
  26954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26955. * * 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)
  26956. * * 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)
  26957. * @returns the VertexData of the ellipsoid
  26958. */
  26959. static CreateSphere(options: {
  26960. segments?: number;
  26961. diameter?: number;
  26962. diameterX?: number;
  26963. diameterY?: number;
  26964. diameterZ?: number;
  26965. arc?: number;
  26966. slice?: number;
  26967. sideOrientation?: number;
  26968. frontUVs?: Vector4;
  26969. backUVs?: Vector4;
  26970. }): VertexData;
  26971. /**
  26972. * Creates the VertexData for a cylinder, cone or prism
  26973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26974. * * height sets the height (y direction) of the cylinder, optional, default 2
  26975. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26976. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26977. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26978. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26979. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26980. * * 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
  26981. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26982. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26983. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26984. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26986. * * 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)
  26987. * * 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)
  26988. * @returns the VertexData of the cylinder, cone or prism
  26989. */
  26990. static CreateCylinder(options: {
  26991. height?: number;
  26992. diameterTop?: number;
  26993. diameterBottom?: number;
  26994. diameter?: number;
  26995. tessellation?: number;
  26996. subdivisions?: number;
  26997. arc?: number;
  26998. faceColors?: Color4[];
  26999. faceUV?: Vector4[];
  27000. hasRings?: boolean;
  27001. enclose?: boolean;
  27002. sideOrientation?: number;
  27003. frontUVs?: Vector4;
  27004. backUVs?: Vector4;
  27005. }): VertexData;
  27006. /**
  27007. * Creates the VertexData for a torus
  27008. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27009. * * diameter the diameter of the torus, optional default 1
  27010. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27011. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27013. * * 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)
  27014. * * 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)
  27015. * @returns the VertexData of the torus
  27016. */
  27017. static CreateTorus(options: {
  27018. diameter?: number;
  27019. thickness?: number;
  27020. tessellation?: number;
  27021. sideOrientation?: number;
  27022. frontUVs?: Vector4;
  27023. backUVs?: Vector4;
  27024. }): VertexData;
  27025. /**
  27026. * Creates the VertexData of the LineSystem
  27027. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27028. * - lines an array of lines, each line being an array of successive Vector3
  27029. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27030. * @returns the VertexData of the LineSystem
  27031. */
  27032. static CreateLineSystem(options: {
  27033. lines: Vector3[][];
  27034. colors?: Nullable<Color4[][]>;
  27035. }): VertexData;
  27036. /**
  27037. * Create the VertexData for a DashedLines
  27038. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27039. * - points an array successive Vector3
  27040. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27041. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27042. * - dashNb the intended total number of dashes, optional, default 200
  27043. * @returns the VertexData for the DashedLines
  27044. */
  27045. static CreateDashedLines(options: {
  27046. points: Vector3[];
  27047. dashSize?: number;
  27048. gapSize?: number;
  27049. dashNb?: number;
  27050. }): VertexData;
  27051. /**
  27052. * Creates the VertexData for a Ground
  27053. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27054. * - width the width (x direction) of the ground, optional, default 1
  27055. * - height the height (z direction) of the ground, optional, default 1
  27056. * - subdivisions the number of subdivisions per side, optional, default 1
  27057. * @returns the VertexData of the Ground
  27058. */
  27059. static CreateGround(options: {
  27060. width?: number;
  27061. height?: number;
  27062. subdivisions?: number;
  27063. subdivisionsX?: number;
  27064. subdivisionsY?: number;
  27065. }): VertexData;
  27066. /**
  27067. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27068. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27069. * * xmin the ground minimum X coordinate, optional, default -1
  27070. * * zmin the ground minimum Z coordinate, optional, default -1
  27071. * * xmax the ground maximum X coordinate, optional, default 1
  27072. * * zmax the ground maximum Z coordinate, optional, default 1
  27073. * * 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}
  27074. * * 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}
  27075. * @returns the VertexData of the TiledGround
  27076. */
  27077. static CreateTiledGround(options: {
  27078. xmin: number;
  27079. zmin: number;
  27080. xmax: number;
  27081. zmax: number;
  27082. subdivisions?: {
  27083. w: number;
  27084. h: number;
  27085. };
  27086. precision?: {
  27087. w: number;
  27088. h: number;
  27089. };
  27090. }): VertexData;
  27091. /**
  27092. * Creates the VertexData of the Ground designed from a heightmap
  27093. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27094. * * width the width (x direction) of the ground
  27095. * * height the height (z direction) of the ground
  27096. * * subdivisions the number of subdivisions per side
  27097. * * minHeight the minimum altitude on the ground, optional, default 0
  27098. * * maxHeight the maximum altitude on the ground, optional default 1
  27099. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27100. * * buffer the array holding the image color data
  27101. * * bufferWidth the width of image
  27102. * * bufferHeight the height of image
  27103. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27104. * @returns the VertexData of the Ground designed from a heightmap
  27105. */
  27106. static CreateGroundFromHeightMap(options: {
  27107. width: number;
  27108. height: number;
  27109. subdivisions: number;
  27110. minHeight: number;
  27111. maxHeight: number;
  27112. colorFilter: Color3;
  27113. buffer: Uint8Array;
  27114. bufferWidth: number;
  27115. bufferHeight: number;
  27116. alphaFilter: number;
  27117. }): VertexData;
  27118. /**
  27119. * Creates the VertexData for a Plane
  27120. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27121. * * size sets the width and height of the plane to the value of size, optional default 1
  27122. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27123. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27125. * * 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)
  27126. * * 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)
  27127. * @returns the VertexData of the box
  27128. */
  27129. static CreatePlane(options: {
  27130. size?: number;
  27131. width?: number;
  27132. height?: number;
  27133. sideOrientation?: number;
  27134. frontUVs?: Vector4;
  27135. backUVs?: Vector4;
  27136. }): VertexData;
  27137. /**
  27138. * Creates the VertexData of the Disc or regular Polygon
  27139. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27140. * * radius the radius of the disc, optional default 0.5
  27141. * * tessellation the number of polygon sides, optional, default 64
  27142. * * 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
  27143. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27144. * * 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)
  27145. * * 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)
  27146. * @returns the VertexData of the box
  27147. */
  27148. static CreateDisc(options: {
  27149. radius?: number;
  27150. tessellation?: number;
  27151. arc?: number;
  27152. sideOrientation?: number;
  27153. frontUVs?: Vector4;
  27154. backUVs?: Vector4;
  27155. }): VertexData;
  27156. /**
  27157. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27158. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27159. * @param polygon a mesh built from polygonTriangulation.build()
  27160. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27161. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27162. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27163. * @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)
  27164. * @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)
  27165. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27166. * @returns the VertexData of the Polygon
  27167. */
  27168. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27169. /**
  27170. * Creates the VertexData of the IcoSphere
  27171. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27172. * * radius the radius of the IcoSphere, optional default 1
  27173. * * radiusX allows stretching in the x direction, optional, default radius
  27174. * * radiusY allows stretching in the y direction, optional, default radius
  27175. * * radiusZ allows stretching in the z direction, optional, default radius
  27176. * * flat when true creates a flat shaded mesh, optional, default true
  27177. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27179. * * 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)
  27180. * * 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)
  27181. * @returns the VertexData of the IcoSphere
  27182. */
  27183. static CreateIcoSphere(options: {
  27184. radius?: number;
  27185. radiusX?: number;
  27186. radiusY?: number;
  27187. radiusZ?: number;
  27188. flat?: boolean;
  27189. subdivisions?: number;
  27190. sideOrientation?: number;
  27191. frontUVs?: Vector4;
  27192. backUVs?: Vector4;
  27193. }): VertexData;
  27194. /**
  27195. * Creates the VertexData for a Polyhedron
  27196. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27197. * * type provided types are:
  27198. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27199. * * 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)
  27200. * * size the size of the IcoSphere, optional default 1
  27201. * * sizeX allows stretching in the x direction, optional, default size
  27202. * * sizeY allows stretching in the y direction, optional, default size
  27203. * * sizeZ allows stretching in the z direction, optional, default size
  27204. * * 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
  27205. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27206. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27207. * * flat when true creates a flat shaded mesh, optional, default true
  27208. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27210. * * 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)
  27211. * * 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)
  27212. * @returns the VertexData of the Polyhedron
  27213. */
  27214. static CreatePolyhedron(options: {
  27215. type?: number;
  27216. size?: number;
  27217. sizeX?: number;
  27218. sizeY?: number;
  27219. sizeZ?: number;
  27220. custom?: any;
  27221. faceUV?: Vector4[];
  27222. faceColors?: Color4[];
  27223. flat?: boolean;
  27224. sideOrientation?: number;
  27225. frontUVs?: Vector4;
  27226. backUVs?: Vector4;
  27227. }): VertexData;
  27228. /**
  27229. * Creates the VertexData for a TorusKnot
  27230. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27231. * * radius the radius of the torus knot, optional, default 2
  27232. * * tube the thickness of the tube, optional, default 0.5
  27233. * * radialSegments the number of sides on each tube segments, optional, default 32
  27234. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27235. * * p the number of windings around the z axis, optional, default 2
  27236. * * q the number of windings around the x axis, optional, default 3
  27237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27238. * * 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)
  27239. * * 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)
  27240. * @returns the VertexData of the Torus Knot
  27241. */
  27242. static CreateTorusKnot(options: {
  27243. radius?: number;
  27244. tube?: number;
  27245. radialSegments?: number;
  27246. tubularSegments?: number;
  27247. p?: number;
  27248. q?: number;
  27249. sideOrientation?: number;
  27250. frontUVs?: Vector4;
  27251. backUVs?: Vector4;
  27252. }): VertexData;
  27253. /**
  27254. * Compute normals for given positions and indices
  27255. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27256. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27257. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27258. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27259. * * facetNormals : optional array of facet normals (vector3)
  27260. * * facetPositions : optional array of facet positions (vector3)
  27261. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27262. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27263. * * bInfo : optional bounding info, required for facetPartitioning computation
  27264. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27265. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27266. * * useRightHandedSystem: optional boolean to for right handed system computation
  27267. * * depthSort : optional boolean to enable the facet depth sort computation
  27268. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27269. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27270. */
  27271. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27272. facetNormals?: any;
  27273. facetPositions?: any;
  27274. facetPartitioning?: any;
  27275. ratio?: number;
  27276. bInfo?: any;
  27277. bbSize?: Vector3;
  27278. subDiv?: any;
  27279. useRightHandedSystem?: boolean;
  27280. depthSort?: boolean;
  27281. distanceTo?: Vector3;
  27282. depthSortedFacets?: any;
  27283. }): void;
  27284. /** @hidden */
  27285. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27286. /**
  27287. * Applies VertexData created from the imported parameters to the geometry
  27288. * @param parsedVertexData the parsed data from an imported file
  27289. * @param geometry the geometry to apply the VertexData to
  27290. */
  27291. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27292. }
  27293. }
  27294. declare module "babylonjs/Morph/morphTarget" {
  27295. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27296. import { Observable } from "babylonjs/Misc/observable";
  27297. import { Nullable, FloatArray } from "babylonjs/types";
  27298. import { Scene } from "babylonjs/scene";
  27299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27300. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27301. /**
  27302. * Defines a target to use with MorphTargetManager
  27303. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27304. */
  27305. export class MorphTarget implements IAnimatable {
  27306. /** defines the name of the target */
  27307. name: string;
  27308. /**
  27309. * Gets or sets the list of animations
  27310. */
  27311. animations: import("babylonjs/Animations/animation").Animation[];
  27312. private _scene;
  27313. private _positions;
  27314. private _normals;
  27315. private _tangents;
  27316. private _uvs;
  27317. private _influence;
  27318. private _uniqueId;
  27319. /**
  27320. * Observable raised when the influence changes
  27321. */
  27322. onInfluenceChanged: Observable<boolean>;
  27323. /** @hidden */
  27324. _onDataLayoutChanged: Observable<void>;
  27325. /**
  27326. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27327. */
  27328. get influence(): number;
  27329. set influence(influence: number);
  27330. /**
  27331. * Gets or sets the id of the morph Target
  27332. */
  27333. id: string;
  27334. private _animationPropertiesOverride;
  27335. /**
  27336. * Gets or sets the animation properties override
  27337. */
  27338. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27339. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27340. /**
  27341. * Creates a new MorphTarget
  27342. * @param name defines the name of the target
  27343. * @param influence defines the influence to use
  27344. * @param scene defines the scene the morphtarget belongs to
  27345. */
  27346. constructor(
  27347. /** defines the name of the target */
  27348. name: string, influence?: number, scene?: Nullable<Scene>);
  27349. /**
  27350. * Gets the unique ID of this manager
  27351. */
  27352. get uniqueId(): number;
  27353. /**
  27354. * Gets a boolean defining if the target contains position data
  27355. */
  27356. get hasPositions(): boolean;
  27357. /**
  27358. * Gets a boolean defining if the target contains normal data
  27359. */
  27360. get hasNormals(): boolean;
  27361. /**
  27362. * Gets a boolean defining if the target contains tangent data
  27363. */
  27364. get hasTangents(): boolean;
  27365. /**
  27366. * Gets a boolean defining if the target contains texture coordinates data
  27367. */
  27368. get hasUVs(): boolean;
  27369. /**
  27370. * Affects position data to this target
  27371. * @param data defines the position data to use
  27372. */
  27373. setPositions(data: Nullable<FloatArray>): void;
  27374. /**
  27375. * Gets the position data stored in this target
  27376. * @returns a FloatArray containing the position data (or null if not present)
  27377. */
  27378. getPositions(): Nullable<FloatArray>;
  27379. /**
  27380. * Affects normal data to this target
  27381. * @param data defines the normal data to use
  27382. */
  27383. setNormals(data: Nullable<FloatArray>): void;
  27384. /**
  27385. * Gets the normal data stored in this target
  27386. * @returns a FloatArray containing the normal data (or null if not present)
  27387. */
  27388. getNormals(): Nullable<FloatArray>;
  27389. /**
  27390. * Affects tangent data to this target
  27391. * @param data defines the tangent data to use
  27392. */
  27393. setTangents(data: Nullable<FloatArray>): void;
  27394. /**
  27395. * Gets the tangent data stored in this target
  27396. * @returns a FloatArray containing the tangent data (or null if not present)
  27397. */
  27398. getTangents(): Nullable<FloatArray>;
  27399. /**
  27400. * Affects texture coordinates data to this target
  27401. * @param data defines the texture coordinates data to use
  27402. */
  27403. setUVs(data: Nullable<FloatArray>): void;
  27404. /**
  27405. * Gets the texture coordinates data stored in this target
  27406. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27407. */
  27408. getUVs(): Nullable<FloatArray>;
  27409. /**
  27410. * Clone the current target
  27411. * @returns a new MorphTarget
  27412. */
  27413. clone(): MorphTarget;
  27414. /**
  27415. * Serializes the current target into a Serialization object
  27416. * @returns the serialized object
  27417. */
  27418. serialize(): any;
  27419. /**
  27420. * Returns the string "MorphTarget"
  27421. * @returns "MorphTarget"
  27422. */
  27423. getClassName(): string;
  27424. /**
  27425. * Creates a new target from serialized data
  27426. * @param serializationObject defines the serialized data to use
  27427. * @returns a new MorphTarget
  27428. */
  27429. static Parse(serializationObject: any): MorphTarget;
  27430. /**
  27431. * Creates a MorphTarget from mesh data
  27432. * @param mesh defines the source mesh
  27433. * @param name defines the name to use for the new target
  27434. * @param influence defines the influence to attach to the target
  27435. * @returns a new MorphTarget
  27436. */
  27437. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27438. }
  27439. }
  27440. declare module "babylonjs/Morph/morphTargetManager" {
  27441. import { Nullable } from "babylonjs/types";
  27442. import { Scene } from "babylonjs/scene";
  27443. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27444. /**
  27445. * This class is used to deform meshes using morphing between different targets
  27446. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27447. */
  27448. export class MorphTargetManager {
  27449. private _targets;
  27450. private _targetInfluenceChangedObservers;
  27451. private _targetDataLayoutChangedObservers;
  27452. private _activeTargets;
  27453. private _scene;
  27454. private _influences;
  27455. private _supportsNormals;
  27456. private _supportsTangents;
  27457. private _supportsUVs;
  27458. private _vertexCount;
  27459. private _uniqueId;
  27460. private _tempInfluences;
  27461. /**
  27462. * Gets or sets a boolean indicating if normals must be morphed
  27463. */
  27464. enableNormalMorphing: boolean;
  27465. /**
  27466. * Gets or sets a boolean indicating if tangents must be morphed
  27467. */
  27468. enableTangentMorphing: boolean;
  27469. /**
  27470. * Gets or sets a boolean indicating if UV must be morphed
  27471. */
  27472. enableUVMorphing: boolean;
  27473. /**
  27474. * Creates a new MorphTargetManager
  27475. * @param scene defines the current scene
  27476. */
  27477. constructor(scene?: Nullable<Scene>);
  27478. /**
  27479. * Gets the unique ID of this manager
  27480. */
  27481. get uniqueId(): number;
  27482. /**
  27483. * Gets the number of vertices handled by this manager
  27484. */
  27485. get vertexCount(): number;
  27486. /**
  27487. * Gets a boolean indicating if this manager supports morphing of normals
  27488. */
  27489. get supportsNormals(): boolean;
  27490. /**
  27491. * Gets a boolean indicating if this manager supports morphing of tangents
  27492. */
  27493. get supportsTangents(): boolean;
  27494. /**
  27495. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27496. */
  27497. get supportsUVs(): boolean;
  27498. /**
  27499. * Gets the number of targets stored in this manager
  27500. */
  27501. get numTargets(): number;
  27502. /**
  27503. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27504. */
  27505. get numInfluencers(): number;
  27506. /**
  27507. * Gets the list of influences (one per target)
  27508. */
  27509. get influences(): Float32Array;
  27510. /**
  27511. * Gets the active target at specified index. An active target is a target with an influence > 0
  27512. * @param index defines the index to check
  27513. * @returns the requested target
  27514. */
  27515. getActiveTarget(index: number): MorphTarget;
  27516. /**
  27517. * Gets the target at specified index
  27518. * @param index defines the index to check
  27519. * @returns the requested target
  27520. */
  27521. getTarget(index: number): MorphTarget;
  27522. /**
  27523. * Add a new target to this manager
  27524. * @param target defines the target to add
  27525. */
  27526. addTarget(target: MorphTarget): void;
  27527. /**
  27528. * Removes a target from the manager
  27529. * @param target defines the target to remove
  27530. */
  27531. removeTarget(target: MorphTarget): void;
  27532. /**
  27533. * Clone the current manager
  27534. * @returns a new MorphTargetManager
  27535. */
  27536. clone(): MorphTargetManager;
  27537. /**
  27538. * Serializes the current manager into a Serialization object
  27539. * @returns the serialized object
  27540. */
  27541. serialize(): any;
  27542. private _syncActiveTargets;
  27543. /**
  27544. * Syncrhonize the targets with all the meshes using this morph target manager
  27545. */
  27546. synchronize(): void;
  27547. /**
  27548. * Creates a new MorphTargetManager from serialized data
  27549. * @param serializationObject defines the serialized data
  27550. * @param scene defines the hosting scene
  27551. * @returns the new MorphTargetManager
  27552. */
  27553. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27554. }
  27555. }
  27556. declare module "babylonjs/Meshes/meshLODLevel" {
  27557. import { Mesh } from "babylonjs/Meshes/mesh";
  27558. import { Nullable } from "babylonjs/types";
  27559. /**
  27560. * Class used to represent a specific level of detail of a mesh
  27561. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27562. */
  27563. export class MeshLODLevel {
  27564. /** Defines the distance where this level should start being displayed */
  27565. distance: number;
  27566. /** Defines the mesh to use to render this level */
  27567. mesh: Nullable<Mesh>;
  27568. /**
  27569. * Creates a new LOD level
  27570. * @param distance defines the distance where this level should star being displayed
  27571. * @param mesh defines the mesh to use to render this level
  27572. */
  27573. constructor(
  27574. /** Defines the distance where this level should start being displayed */
  27575. distance: number,
  27576. /** Defines the mesh to use to render this level */
  27577. mesh: Nullable<Mesh>);
  27578. }
  27579. }
  27580. declare module "babylonjs/Misc/canvasGenerator" {
  27581. /**
  27582. * Helper class used to generate a canvas to manipulate images
  27583. */
  27584. export class CanvasGenerator {
  27585. /**
  27586. * Create a new canvas (or offscreen canvas depending on the context)
  27587. * @param width defines the expected width
  27588. * @param height defines the expected height
  27589. * @return a new canvas or offscreen canvas
  27590. */
  27591. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27592. }
  27593. }
  27594. declare module "babylonjs/Meshes/groundMesh" {
  27595. import { Scene } from "babylonjs/scene";
  27596. import { Vector3 } from "babylonjs/Maths/math.vector";
  27597. import { Mesh } from "babylonjs/Meshes/mesh";
  27598. /**
  27599. * Mesh representing the gorund
  27600. */
  27601. export class GroundMesh extends Mesh {
  27602. /** If octree should be generated */
  27603. generateOctree: boolean;
  27604. private _heightQuads;
  27605. /** @hidden */
  27606. _subdivisionsX: number;
  27607. /** @hidden */
  27608. _subdivisionsY: number;
  27609. /** @hidden */
  27610. _width: number;
  27611. /** @hidden */
  27612. _height: number;
  27613. /** @hidden */
  27614. _minX: number;
  27615. /** @hidden */
  27616. _maxX: number;
  27617. /** @hidden */
  27618. _minZ: number;
  27619. /** @hidden */
  27620. _maxZ: number;
  27621. constructor(name: string, scene: Scene);
  27622. /**
  27623. * "GroundMesh"
  27624. * @returns "GroundMesh"
  27625. */
  27626. getClassName(): string;
  27627. /**
  27628. * The minimum of x and y subdivisions
  27629. */
  27630. get subdivisions(): number;
  27631. /**
  27632. * X subdivisions
  27633. */
  27634. get subdivisionsX(): number;
  27635. /**
  27636. * Y subdivisions
  27637. */
  27638. get subdivisionsY(): number;
  27639. /**
  27640. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27641. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27642. * @param chunksCount the number of subdivisions for x and y
  27643. * @param octreeBlocksSize (Default: 32)
  27644. */
  27645. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27646. /**
  27647. * Returns a height (y) value in the Worl system :
  27648. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27649. * @param x x coordinate
  27650. * @param z z coordinate
  27651. * @returns the ground y position if (x, z) are outside the ground surface.
  27652. */
  27653. getHeightAtCoordinates(x: number, z: number): number;
  27654. /**
  27655. * Returns a normalized vector (Vector3) orthogonal to the ground
  27656. * at the ground coordinates (x, z) expressed in the World system.
  27657. * @param x x coordinate
  27658. * @param z z coordinate
  27659. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27660. */
  27661. getNormalAtCoordinates(x: number, z: number): Vector3;
  27662. /**
  27663. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27664. * at the ground coordinates (x, z) expressed in the World system.
  27665. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27666. * @param x x coordinate
  27667. * @param z z coordinate
  27668. * @param ref vector to store the result
  27669. * @returns the GroundMesh.
  27670. */
  27671. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27672. /**
  27673. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27674. * if the ground has been updated.
  27675. * This can be used in the render loop.
  27676. * @returns the GroundMesh.
  27677. */
  27678. updateCoordinateHeights(): GroundMesh;
  27679. private _getFacetAt;
  27680. private _initHeightQuads;
  27681. private _computeHeightQuads;
  27682. /**
  27683. * Serializes this ground mesh
  27684. * @param serializationObject object to write serialization to
  27685. */
  27686. serialize(serializationObject: any): void;
  27687. /**
  27688. * Parses a serialized ground mesh
  27689. * @param parsedMesh the serialized mesh
  27690. * @param scene the scene to create the ground mesh in
  27691. * @returns the created ground mesh
  27692. */
  27693. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27694. }
  27695. }
  27696. declare module "babylonjs/Physics/physicsJoint" {
  27697. import { Vector3 } from "babylonjs/Maths/math.vector";
  27698. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27699. /**
  27700. * Interface for Physics-Joint data
  27701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27702. */
  27703. export interface PhysicsJointData {
  27704. /**
  27705. * The main pivot of the joint
  27706. */
  27707. mainPivot?: Vector3;
  27708. /**
  27709. * The connected pivot of the joint
  27710. */
  27711. connectedPivot?: Vector3;
  27712. /**
  27713. * The main axis of the joint
  27714. */
  27715. mainAxis?: Vector3;
  27716. /**
  27717. * The connected axis of the joint
  27718. */
  27719. connectedAxis?: Vector3;
  27720. /**
  27721. * The collision of the joint
  27722. */
  27723. collision?: boolean;
  27724. /**
  27725. * Native Oimo/Cannon/Energy data
  27726. */
  27727. nativeParams?: any;
  27728. }
  27729. /**
  27730. * This is a holder class for the physics joint created by the physics plugin
  27731. * It holds a set of functions to control the underlying joint
  27732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27733. */
  27734. export class PhysicsJoint {
  27735. /**
  27736. * The type of the physics joint
  27737. */
  27738. type: number;
  27739. /**
  27740. * The data for the physics joint
  27741. */
  27742. jointData: PhysicsJointData;
  27743. private _physicsJoint;
  27744. protected _physicsPlugin: IPhysicsEnginePlugin;
  27745. /**
  27746. * Initializes the physics joint
  27747. * @param type The type of the physics joint
  27748. * @param jointData The data for the physics joint
  27749. */
  27750. constructor(
  27751. /**
  27752. * The type of the physics joint
  27753. */
  27754. type: number,
  27755. /**
  27756. * The data for the physics joint
  27757. */
  27758. jointData: PhysicsJointData);
  27759. /**
  27760. * Gets the physics joint
  27761. */
  27762. get physicsJoint(): any;
  27763. /**
  27764. * Sets the physics joint
  27765. */
  27766. set physicsJoint(newJoint: any);
  27767. /**
  27768. * Sets the physics plugin
  27769. */
  27770. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27771. /**
  27772. * Execute a function that is physics-plugin specific.
  27773. * @param {Function} func the function that will be executed.
  27774. * It accepts two parameters: the physics world and the physics joint
  27775. */
  27776. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27777. /**
  27778. * Distance-Joint type
  27779. */
  27780. static DistanceJoint: number;
  27781. /**
  27782. * Hinge-Joint type
  27783. */
  27784. static HingeJoint: number;
  27785. /**
  27786. * Ball-and-Socket joint type
  27787. */
  27788. static BallAndSocketJoint: number;
  27789. /**
  27790. * Wheel-Joint type
  27791. */
  27792. static WheelJoint: number;
  27793. /**
  27794. * Slider-Joint type
  27795. */
  27796. static SliderJoint: number;
  27797. /**
  27798. * Prismatic-Joint type
  27799. */
  27800. static PrismaticJoint: number;
  27801. /**
  27802. * Universal-Joint type
  27803. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27804. */
  27805. static UniversalJoint: number;
  27806. /**
  27807. * Hinge-Joint 2 type
  27808. */
  27809. static Hinge2Joint: number;
  27810. /**
  27811. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27812. */
  27813. static PointToPointJoint: number;
  27814. /**
  27815. * Spring-Joint type
  27816. */
  27817. static SpringJoint: number;
  27818. /**
  27819. * Lock-Joint type
  27820. */
  27821. static LockJoint: number;
  27822. }
  27823. /**
  27824. * A class representing a physics distance joint
  27825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27826. */
  27827. export class DistanceJoint extends PhysicsJoint {
  27828. /**
  27829. *
  27830. * @param jointData The data for the Distance-Joint
  27831. */
  27832. constructor(jointData: DistanceJointData);
  27833. /**
  27834. * Update the predefined distance.
  27835. * @param maxDistance The maximum preferred distance
  27836. * @param minDistance The minimum preferred distance
  27837. */
  27838. updateDistance(maxDistance: number, minDistance?: number): void;
  27839. }
  27840. /**
  27841. * Represents a Motor-Enabled Joint
  27842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27843. */
  27844. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27845. /**
  27846. * Initializes the Motor-Enabled Joint
  27847. * @param type The type of the joint
  27848. * @param jointData The physica joint data for the joint
  27849. */
  27850. constructor(type: number, jointData: PhysicsJointData);
  27851. /**
  27852. * Set the motor values.
  27853. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27854. * @param force the force to apply
  27855. * @param maxForce max force for this motor.
  27856. */
  27857. setMotor(force?: number, maxForce?: number): void;
  27858. /**
  27859. * Set the motor's limits.
  27860. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27861. * @param upperLimit The upper limit of the motor
  27862. * @param lowerLimit The lower limit of the motor
  27863. */
  27864. setLimit(upperLimit: number, lowerLimit?: number): void;
  27865. }
  27866. /**
  27867. * This class represents a single physics Hinge-Joint
  27868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27869. */
  27870. export class HingeJoint extends MotorEnabledJoint {
  27871. /**
  27872. * Initializes the Hinge-Joint
  27873. * @param jointData The joint data for the Hinge-Joint
  27874. */
  27875. constructor(jointData: PhysicsJointData);
  27876. /**
  27877. * Set the motor values.
  27878. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27879. * @param {number} force the force to apply
  27880. * @param {number} maxForce max force for this motor.
  27881. */
  27882. setMotor(force?: number, maxForce?: number): void;
  27883. /**
  27884. * Set the motor's limits.
  27885. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27886. * @param upperLimit The upper limit of the motor
  27887. * @param lowerLimit The lower limit of the motor
  27888. */
  27889. setLimit(upperLimit: number, lowerLimit?: number): void;
  27890. }
  27891. /**
  27892. * This class represents a dual hinge physics joint (same as wheel joint)
  27893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27894. */
  27895. export class Hinge2Joint extends MotorEnabledJoint {
  27896. /**
  27897. * Initializes the Hinge2-Joint
  27898. * @param jointData The joint data for the Hinge2-Joint
  27899. */
  27900. constructor(jointData: PhysicsJointData);
  27901. /**
  27902. * Set the motor values.
  27903. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27904. * @param {number} targetSpeed the speed the motor is to reach
  27905. * @param {number} maxForce max force for this motor.
  27906. * @param {motorIndex} the motor's index, 0 or 1.
  27907. */
  27908. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27909. /**
  27910. * Set the motor limits.
  27911. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27912. * @param {number} upperLimit the upper limit
  27913. * @param {number} lowerLimit lower limit
  27914. * @param {motorIndex} the motor's index, 0 or 1.
  27915. */
  27916. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27917. }
  27918. /**
  27919. * Interface for a motor enabled joint
  27920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27921. */
  27922. export interface IMotorEnabledJoint {
  27923. /**
  27924. * Physics joint
  27925. */
  27926. physicsJoint: any;
  27927. /**
  27928. * Sets the motor of the motor-enabled joint
  27929. * @param force The force of the motor
  27930. * @param maxForce The maximum force of the motor
  27931. * @param motorIndex The index of the motor
  27932. */
  27933. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27934. /**
  27935. * Sets the limit of the motor
  27936. * @param upperLimit The upper limit of the motor
  27937. * @param lowerLimit The lower limit of the motor
  27938. * @param motorIndex The index of the motor
  27939. */
  27940. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27941. }
  27942. /**
  27943. * Joint data for a Distance-Joint
  27944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27945. */
  27946. export interface DistanceJointData extends PhysicsJointData {
  27947. /**
  27948. * Max distance the 2 joint objects can be apart
  27949. */
  27950. maxDistance: number;
  27951. }
  27952. /**
  27953. * Joint data from a spring joint
  27954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27955. */
  27956. export interface SpringJointData extends PhysicsJointData {
  27957. /**
  27958. * Length of the spring
  27959. */
  27960. length: number;
  27961. /**
  27962. * Stiffness of the spring
  27963. */
  27964. stiffness: number;
  27965. /**
  27966. * Damping of the spring
  27967. */
  27968. damping: number;
  27969. /** this callback will be called when applying the force to the impostors. */
  27970. forceApplicationCallback: () => void;
  27971. }
  27972. }
  27973. declare module "babylonjs/Physics/physicsRaycastResult" {
  27974. import { Vector3 } from "babylonjs/Maths/math.vector";
  27975. /**
  27976. * Holds the data for the raycast result
  27977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27978. */
  27979. export class PhysicsRaycastResult {
  27980. private _hasHit;
  27981. private _hitDistance;
  27982. private _hitNormalWorld;
  27983. private _hitPointWorld;
  27984. private _rayFromWorld;
  27985. private _rayToWorld;
  27986. /**
  27987. * Gets if there was a hit
  27988. */
  27989. get hasHit(): boolean;
  27990. /**
  27991. * Gets the distance from the hit
  27992. */
  27993. get hitDistance(): number;
  27994. /**
  27995. * Gets the hit normal/direction in the world
  27996. */
  27997. get hitNormalWorld(): Vector3;
  27998. /**
  27999. * Gets the hit point in the world
  28000. */
  28001. get hitPointWorld(): Vector3;
  28002. /**
  28003. * Gets the ray "start point" of the ray in the world
  28004. */
  28005. get rayFromWorld(): Vector3;
  28006. /**
  28007. * Gets the ray "end point" of the ray in the world
  28008. */
  28009. get rayToWorld(): Vector3;
  28010. /**
  28011. * Sets the hit data (normal & point in world space)
  28012. * @param hitNormalWorld defines the normal in world space
  28013. * @param hitPointWorld defines the point in world space
  28014. */
  28015. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28016. /**
  28017. * Sets the distance from the start point to the hit point
  28018. * @param distance
  28019. */
  28020. setHitDistance(distance: number): void;
  28021. /**
  28022. * Calculates the distance manually
  28023. */
  28024. calculateHitDistance(): void;
  28025. /**
  28026. * Resets all the values to default
  28027. * @param from The from point on world space
  28028. * @param to The to point on world space
  28029. */
  28030. reset(from?: Vector3, to?: Vector3): void;
  28031. }
  28032. /**
  28033. * Interface for the size containing width and height
  28034. */
  28035. interface IXYZ {
  28036. /**
  28037. * X
  28038. */
  28039. x: number;
  28040. /**
  28041. * Y
  28042. */
  28043. y: number;
  28044. /**
  28045. * Z
  28046. */
  28047. z: number;
  28048. }
  28049. }
  28050. declare module "babylonjs/Physics/IPhysicsEngine" {
  28051. import { Nullable } from "babylonjs/types";
  28052. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28054. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28055. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28056. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28057. /**
  28058. * Interface used to describe a physics joint
  28059. */
  28060. export interface PhysicsImpostorJoint {
  28061. /** Defines the main impostor to which the joint is linked */
  28062. mainImpostor: PhysicsImpostor;
  28063. /** Defines the impostor that is connected to the main impostor using this joint */
  28064. connectedImpostor: PhysicsImpostor;
  28065. /** Defines the joint itself */
  28066. joint: PhysicsJoint;
  28067. }
  28068. /** @hidden */
  28069. export interface IPhysicsEnginePlugin {
  28070. world: any;
  28071. name: string;
  28072. setGravity(gravity: Vector3): void;
  28073. setTimeStep(timeStep: number): void;
  28074. getTimeStep(): number;
  28075. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28076. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28077. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28078. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28079. removePhysicsBody(impostor: PhysicsImpostor): void;
  28080. generateJoint(joint: PhysicsImpostorJoint): void;
  28081. removeJoint(joint: PhysicsImpostorJoint): void;
  28082. isSupported(): boolean;
  28083. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28084. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28085. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28086. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28087. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28089. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28090. getBodyMass(impostor: PhysicsImpostor): number;
  28091. getBodyFriction(impostor: PhysicsImpostor): number;
  28092. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28093. getBodyRestitution(impostor: PhysicsImpostor): number;
  28094. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28095. getBodyPressure?(impostor: PhysicsImpostor): number;
  28096. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28097. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28098. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28099. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28100. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28101. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28102. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28103. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28104. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28105. sleepBody(impostor: PhysicsImpostor): void;
  28106. wakeUpBody(impostor: PhysicsImpostor): void;
  28107. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28108. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28109. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28110. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28111. getRadius(impostor: PhysicsImpostor): number;
  28112. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28113. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28114. dispose(): void;
  28115. }
  28116. /**
  28117. * Interface used to define a physics engine
  28118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28119. */
  28120. export interface IPhysicsEngine {
  28121. /**
  28122. * Gets the gravity vector used by the simulation
  28123. */
  28124. gravity: Vector3;
  28125. /**
  28126. * Sets the gravity vector used by the simulation
  28127. * @param gravity defines the gravity vector to use
  28128. */
  28129. setGravity(gravity: Vector3): void;
  28130. /**
  28131. * Set the time step of the physics engine.
  28132. * Default is 1/60.
  28133. * To slow it down, enter 1/600 for example.
  28134. * To speed it up, 1/30
  28135. * @param newTimeStep the new timestep to apply to this world.
  28136. */
  28137. setTimeStep(newTimeStep: number): void;
  28138. /**
  28139. * Get the time step of the physics engine.
  28140. * @returns the current time step
  28141. */
  28142. getTimeStep(): number;
  28143. /**
  28144. * Set the sub time step of the physics engine.
  28145. * Default is 0 meaning there is no sub steps
  28146. * To increase physics resolution precision, set a small value (like 1 ms)
  28147. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28148. */
  28149. setSubTimeStep(subTimeStep: number): void;
  28150. /**
  28151. * Get the sub time step of the physics engine.
  28152. * @returns the current sub time step
  28153. */
  28154. getSubTimeStep(): number;
  28155. /**
  28156. * Release all resources
  28157. */
  28158. dispose(): void;
  28159. /**
  28160. * Gets the name of the current physics plugin
  28161. * @returns the name of the plugin
  28162. */
  28163. getPhysicsPluginName(): string;
  28164. /**
  28165. * Adding a new impostor for the impostor tracking.
  28166. * This will be done by the impostor itself.
  28167. * @param impostor the impostor to add
  28168. */
  28169. addImpostor(impostor: PhysicsImpostor): void;
  28170. /**
  28171. * Remove an impostor from the engine.
  28172. * This impostor and its mesh will not longer be updated by the physics engine.
  28173. * @param impostor the impostor to remove
  28174. */
  28175. removeImpostor(impostor: PhysicsImpostor): void;
  28176. /**
  28177. * Add a joint to the physics engine
  28178. * @param mainImpostor defines the main impostor to which the joint is added.
  28179. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28180. * @param joint defines the joint that will connect both impostors.
  28181. */
  28182. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28183. /**
  28184. * Removes a joint from the simulation
  28185. * @param mainImpostor defines the impostor used with the joint
  28186. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28187. * @param joint defines the joint to remove
  28188. */
  28189. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28190. /**
  28191. * Gets the current plugin used to run the simulation
  28192. * @returns current plugin
  28193. */
  28194. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28195. /**
  28196. * Gets the list of physic impostors
  28197. * @returns an array of PhysicsImpostor
  28198. */
  28199. getImpostors(): Array<PhysicsImpostor>;
  28200. /**
  28201. * Gets the impostor for a physics enabled object
  28202. * @param object defines the object impersonated by the impostor
  28203. * @returns the PhysicsImpostor or null if not found
  28204. */
  28205. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28206. /**
  28207. * Gets the impostor for a physics body object
  28208. * @param body defines physics body used by the impostor
  28209. * @returns the PhysicsImpostor or null if not found
  28210. */
  28211. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28212. /**
  28213. * Does a raycast in the physics world
  28214. * @param from when should the ray start?
  28215. * @param to when should the ray end?
  28216. * @returns PhysicsRaycastResult
  28217. */
  28218. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28219. /**
  28220. * Called by the scene. No need to call it.
  28221. * @param delta defines the timespam between frames
  28222. */
  28223. _step(delta: number): void;
  28224. }
  28225. }
  28226. declare module "babylonjs/Physics/physicsImpostor" {
  28227. import { Nullable, IndicesArray } from "babylonjs/types";
  28228. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28229. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28231. import { Scene } from "babylonjs/scene";
  28232. import { Bone } from "babylonjs/Bones/bone";
  28233. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28234. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28235. import { Space } from "babylonjs/Maths/math.axis";
  28236. /**
  28237. * The interface for the physics imposter parameters
  28238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28239. */
  28240. export interface PhysicsImpostorParameters {
  28241. /**
  28242. * The mass of the physics imposter
  28243. */
  28244. mass: number;
  28245. /**
  28246. * The friction of the physics imposter
  28247. */
  28248. friction?: number;
  28249. /**
  28250. * The coefficient of restitution of the physics imposter
  28251. */
  28252. restitution?: number;
  28253. /**
  28254. * The native options of the physics imposter
  28255. */
  28256. nativeOptions?: any;
  28257. /**
  28258. * Specifies if the parent should be ignored
  28259. */
  28260. ignoreParent?: boolean;
  28261. /**
  28262. * Specifies if bi-directional transformations should be disabled
  28263. */
  28264. disableBidirectionalTransformation?: boolean;
  28265. /**
  28266. * The pressure inside the physics imposter, soft object only
  28267. */
  28268. pressure?: number;
  28269. /**
  28270. * The stiffness the physics imposter, soft object only
  28271. */
  28272. stiffness?: number;
  28273. /**
  28274. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28275. */
  28276. velocityIterations?: number;
  28277. /**
  28278. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28279. */
  28280. positionIterations?: number;
  28281. /**
  28282. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28283. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28284. * Add to fix multiple points
  28285. */
  28286. fixedPoints?: number;
  28287. /**
  28288. * The collision margin around a soft object
  28289. */
  28290. margin?: number;
  28291. /**
  28292. * The collision margin around a soft object
  28293. */
  28294. damping?: number;
  28295. /**
  28296. * The path for a rope based on an extrusion
  28297. */
  28298. path?: any;
  28299. /**
  28300. * The shape of an extrusion used for a rope based on an extrusion
  28301. */
  28302. shape?: any;
  28303. }
  28304. /**
  28305. * Interface for a physics-enabled object
  28306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28307. */
  28308. export interface IPhysicsEnabledObject {
  28309. /**
  28310. * The position of the physics-enabled object
  28311. */
  28312. position: Vector3;
  28313. /**
  28314. * The rotation of the physics-enabled object
  28315. */
  28316. rotationQuaternion: Nullable<Quaternion>;
  28317. /**
  28318. * The scale of the physics-enabled object
  28319. */
  28320. scaling: Vector3;
  28321. /**
  28322. * The rotation of the physics-enabled object
  28323. */
  28324. rotation?: Vector3;
  28325. /**
  28326. * The parent of the physics-enabled object
  28327. */
  28328. parent?: any;
  28329. /**
  28330. * The bounding info of the physics-enabled object
  28331. * @returns The bounding info of the physics-enabled object
  28332. */
  28333. getBoundingInfo(): BoundingInfo;
  28334. /**
  28335. * Computes the world matrix
  28336. * @param force Specifies if the world matrix should be computed by force
  28337. * @returns A world matrix
  28338. */
  28339. computeWorldMatrix(force: boolean): Matrix;
  28340. /**
  28341. * Gets the world matrix
  28342. * @returns A world matrix
  28343. */
  28344. getWorldMatrix?(): Matrix;
  28345. /**
  28346. * Gets the child meshes
  28347. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28348. * @returns An array of abstract meshes
  28349. */
  28350. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28351. /**
  28352. * Gets the vertex data
  28353. * @param kind The type of vertex data
  28354. * @returns A nullable array of numbers, or a float32 array
  28355. */
  28356. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28357. /**
  28358. * Gets the indices from the mesh
  28359. * @returns A nullable array of index arrays
  28360. */
  28361. getIndices?(): Nullable<IndicesArray>;
  28362. /**
  28363. * Gets the scene from the mesh
  28364. * @returns the indices array or null
  28365. */
  28366. getScene?(): Scene;
  28367. /**
  28368. * Gets the absolute position from the mesh
  28369. * @returns the absolute position
  28370. */
  28371. getAbsolutePosition(): Vector3;
  28372. /**
  28373. * Gets the absolute pivot point from the mesh
  28374. * @returns the absolute pivot point
  28375. */
  28376. getAbsolutePivotPoint(): Vector3;
  28377. /**
  28378. * Rotates the mesh
  28379. * @param axis The axis of rotation
  28380. * @param amount The amount of rotation
  28381. * @param space The space of the rotation
  28382. * @returns The rotation transform node
  28383. */
  28384. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28385. /**
  28386. * Translates the mesh
  28387. * @param axis The axis of translation
  28388. * @param distance The distance of translation
  28389. * @param space The space of the translation
  28390. * @returns The transform node
  28391. */
  28392. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28393. /**
  28394. * Sets the absolute position of the mesh
  28395. * @param absolutePosition The absolute position of the mesh
  28396. * @returns The transform node
  28397. */
  28398. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28399. /**
  28400. * Gets the class name of the mesh
  28401. * @returns The class name
  28402. */
  28403. getClassName(): string;
  28404. }
  28405. /**
  28406. * Represents a physics imposter
  28407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28408. */
  28409. export class PhysicsImpostor {
  28410. /**
  28411. * The physics-enabled object used as the physics imposter
  28412. */
  28413. object: IPhysicsEnabledObject;
  28414. /**
  28415. * The type of the physics imposter
  28416. */
  28417. type: number;
  28418. private _options;
  28419. private _scene?;
  28420. /**
  28421. * The default object size of the imposter
  28422. */
  28423. static DEFAULT_OBJECT_SIZE: Vector3;
  28424. /**
  28425. * The identity quaternion of the imposter
  28426. */
  28427. static IDENTITY_QUATERNION: Quaternion;
  28428. /** @hidden */
  28429. _pluginData: any;
  28430. private _physicsEngine;
  28431. private _physicsBody;
  28432. private _bodyUpdateRequired;
  28433. private _onBeforePhysicsStepCallbacks;
  28434. private _onAfterPhysicsStepCallbacks;
  28435. /** @hidden */
  28436. _onPhysicsCollideCallbacks: Array<{
  28437. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28438. otherImpostors: Array<PhysicsImpostor>;
  28439. }>;
  28440. private _deltaPosition;
  28441. private _deltaRotation;
  28442. private _deltaRotationConjugated;
  28443. /** @hidden */
  28444. _isFromLine: boolean;
  28445. private _parent;
  28446. private _isDisposed;
  28447. private static _tmpVecs;
  28448. private static _tmpQuat;
  28449. /**
  28450. * Specifies if the physics imposter is disposed
  28451. */
  28452. get isDisposed(): boolean;
  28453. /**
  28454. * Gets the mass of the physics imposter
  28455. */
  28456. get mass(): number;
  28457. set mass(value: number);
  28458. /**
  28459. * Gets the coefficient of friction
  28460. */
  28461. get friction(): number;
  28462. /**
  28463. * Sets the coefficient of friction
  28464. */
  28465. set friction(value: number);
  28466. /**
  28467. * Gets the coefficient of restitution
  28468. */
  28469. get restitution(): number;
  28470. /**
  28471. * Sets the coefficient of restitution
  28472. */
  28473. set restitution(value: number);
  28474. /**
  28475. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28476. */
  28477. get pressure(): number;
  28478. /**
  28479. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28480. */
  28481. set pressure(value: number);
  28482. /**
  28483. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28484. */
  28485. get stiffness(): number;
  28486. /**
  28487. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28488. */
  28489. set stiffness(value: number);
  28490. /**
  28491. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28492. */
  28493. get velocityIterations(): number;
  28494. /**
  28495. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28496. */
  28497. set velocityIterations(value: number);
  28498. /**
  28499. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28500. */
  28501. get positionIterations(): number;
  28502. /**
  28503. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28504. */
  28505. set positionIterations(value: number);
  28506. /**
  28507. * The unique id of the physics imposter
  28508. * set by the physics engine when adding this impostor to the array
  28509. */
  28510. uniqueId: number;
  28511. /**
  28512. * @hidden
  28513. */
  28514. soft: boolean;
  28515. /**
  28516. * @hidden
  28517. */
  28518. segments: number;
  28519. private _joints;
  28520. /**
  28521. * Initializes the physics imposter
  28522. * @param object The physics-enabled object used as the physics imposter
  28523. * @param type The type of the physics imposter
  28524. * @param _options The options for the physics imposter
  28525. * @param _scene The Babylon scene
  28526. */
  28527. constructor(
  28528. /**
  28529. * The physics-enabled object used as the physics imposter
  28530. */
  28531. object: IPhysicsEnabledObject,
  28532. /**
  28533. * The type of the physics imposter
  28534. */
  28535. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28536. /**
  28537. * This function will completly initialize this impostor.
  28538. * It will create a new body - but only if this mesh has no parent.
  28539. * If it has, this impostor will not be used other than to define the impostor
  28540. * of the child mesh.
  28541. * @hidden
  28542. */
  28543. _init(): void;
  28544. private _getPhysicsParent;
  28545. /**
  28546. * Should a new body be generated.
  28547. * @returns boolean specifying if body initialization is required
  28548. */
  28549. isBodyInitRequired(): boolean;
  28550. /**
  28551. * Sets the updated scaling
  28552. * @param updated Specifies if the scaling is updated
  28553. */
  28554. setScalingUpdated(): void;
  28555. /**
  28556. * Force a regeneration of this or the parent's impostor's body.
  28557. * Use under cautious - This will remove all joints already implemented.
  28558. */
  28559. forceUpdate(): void;
  28560. /**
  28561. * Gets the body that holds this impostor. Either its own, or its parent.
  28562. */
  28563. get physicsBody(): any;
  28564. /**
  28565. * Get the parent of the physics imposter
  28566. * @returns Physics imposter or null
  28567. */
  28568. get parent(): Nullable<PhysicsImpostor>;
  28569. /**
  28570. * Sets the parent of the physics imposter
  28571. */
  28572. set parent(value: Nullable<PhysicsImpostor>);
  28573. /**
  28574. * Set the physics body. Used mainly by the physics engine/plugin
  28575. */
  28576. set physicsBody(physicsBody: any);
  28577. /**
  28578. * Resets the update flags
  28579. */
  28580. resetUpdateFlags(): void;
  28581. /**
  28582. * Gets the object extend size
  28583. * @returns the object extend size
  28584. */
  28585. getObjectExtendSize(): Vector3;
  28586. /**
  28587. * Gets the object center
  28588. * @returns The object center
  28589. */
  28590. getObjectCenter(): Vector3;
  28591. /**
  28592. * Get a specific parameter from the options parameters
  28593. * @param paramName The object parameter name
  28594. * @returns The object parameter
  28595. */
  28596. getParam(paramName: string): any;
  28597. /**
  28598. * Sets a specific parameter in the options given to the physics plugin
  28599. * @param paramName The parameter name
  28600. * @param value The value of the parameter
  28601. */
  28602. setParam(paramName: string, value: number): void;
  28603. /**
  28604. * Specifically change the body's mass option. Won't recreate the physics body object
  28605. * @param mass The mass of the physics imposter
  28606. */
  28607. setMass(mass: number): void;
  28608. /**
  28609. * Gets the linear velocity
  28610. * @returns linear velocity or null
  28611. */
  28612. getLinearVelocity(): Nullable<Vector3>;
  28613. /**
  28614. * Sets the linear velocity
  28615. * @param velocity linear velocity or null
  28616. */
  28617. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28618. /**
  28619. * Gets the angular velocity
  28620. * @returns angular velocity or null
  28621. */
  28622. getAngularVelocity(): Nullable<Vector3>;
  28623. /**
  28624. * Sets the angular velocity
  28625. * @param velocity The velocity or null
  28626. */
  28627. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28628. /**
  28629. * Execute a function with the physics plugin native code
  28630. * Provide a function the will have two variables - the world object and the physics body object
  28631. * @param func The function to execute with the physics plugin native code
  28632. */
  28633. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28634. /**
  28635. * Register a function that will be executed before the physics world is stepping forward
  28636. * @param func The function to execute before the physics world is stepped forward
  28637. */
  28638. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28639. /**
  28640. * Unregister a function that will be executed before the physics world is stepping forward
  28641. * @param func The function to execute before the physics world is stepped forward
  28642. */
  28643. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28644. /**
  28645. * Register a function that will be executed after the physics step
  28646. * @param func The function to execute after physics step
  28647. */
  28648. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28649. /**
  28650. * Unregisters a function that will be executed after the physics step
  28651. * @param func The function to execute after physics step
  28652. */
  28653. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28654. /**
  28655. * register a function that will be executed when this impostor collides against a different body
  28656. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28657. * @param func Callback that is executed on collision
  28658. */
  28659. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28660. /**
  28661. * Unregisters the physics imposter on contact
  28662. * @param collideAgainst The physics object to collide against
  28663. * @param func Callback to execute on collision
  28664. */
  28665. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28666. private _tmpQuat;
  28667. private _tmpQuat2;
  28668. /**
  28669. * Get the parent rotation
  28670. * @returns The parent rotation
  28671. */
  28672. getParentsRotation(): Quaternion;
  28673. /**
  28674. * this function is executed by the physics engine.
  28675. */
  28676. beforeStep: () => void;
  28677. /**
  28678. * this function is executed by the physics engine
  28679. */
  28680. afterStep: () => void;
  28681. /**
  28682. * Legacy collision detection event support
  28683. */
  28684. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28685. /**
  28686. * event and body object due to cannon's event-based architecture.
  28687. */
  28688. onCollide: (e: {
  28689. body: any;
  28690. }) => void;
  28691. /**
  28692. * Apply a force
  28693. * @param force The force to apply
  28694. * @param contactPoint The contact point for the force
  28695. * @returns The physics imposter
  28696. */
  28697. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28698. /**
  28699. * Apply an impulse
  28700. * @param force The impulse force
  28701. * @param contactPoint The contact point for the impulse force
  28702. * @returns The physics imposter
  28703. */
  28704. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28705. /**
  28706. * A help function to create a joint
  28707. * @param otherImpostor A physics imposter used to create a joint
  28708. * @param jointType The type of joint
  28709. * @param jointData The data for the joint
  28710. * @returns The physics imposter
  28711. */
  28712. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28713. /**
  28714. * Add a joint to this impostor with a different impostor
  28715. * @param otherImpostor A physics imposter used to add a joint
  28716. * @param joint The joint to add
  28717. * @returns The physics imposter
  28718. */
  28719. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28720. /**
  28721. * Add an anchor to a cloth impostor
  28722. * @param otherImpostor rigid impostor to anchor to
  28723. * @param width ratio across width from 0 to 1
  28724. * @param height ratio up height from 0 to 1
  28725. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28726. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28727. * @returns impostor the soft imposter
  28728. */
  28729. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28730. /**
  28731. * Add a hook to a rope impostor
  28732. * @param otherImpostor rigid impostor to anchor to
  28733. * @param length ratio across rope from 0 to 1
  28734. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28735. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28736. * @returns impostor the rope imposter
  28737. */
  28738. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28739. /**
  28740. * Will keep this body still, in a sleep mode.
  28741. * @returns the physics imposter
  28742. */
  28743. sleep(): PhysicsImpostor;
  28744. /**
  28745. * Wake the body up.
  28746. * @returns The physics imposter
  28747. */
  28748. wakeUp(): PhysicsImpostor;
  28749. /**
  28750. * Clones the physics imposter
  28751. * @param newObject The physics imposter clones to this physics-enabled object
  28752. * @returns A nullable physics imposter
  28753. */
  28754. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28755. /**
  28756. * Disposes the physics imposter
  28757. */
  28758. dispose(): void;
  28759. /**
  28760. * Sets the delta position
  28761. * @param position The delta position amount
  28762. */
  28763. setDeltaPosition(position: Vector3): void;
  28764. /**
  28765. * Sets the delta rotation
  28766. * @param rotation The delta rotation amount
  28767. */
  28768. setDeltaRotation(rotation: Quaternion): void;
  28769. /**
  28770. * Gets the box size of the physics imposter and stores the result in the input parameter
  28771. * @param result Stores the box size
  28772. * @returns The physics imposter
  28773. */
  28774. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28775. /**
  28776. * Gets the radius of the physics imposter
  28777. * @returns Radius of the physics imposter
  28778. */
  28779. getRadius(): number;
  28780. /**
  28781. * Sync a bone with this impostor
  28782. * @param bone The bone to sync to the impostor.
  28783. * @param boneMesh The mesh that the bone is influencing.
  28784. * @param jointPivot The pivot of the joint / bone in local space.
  28785. * @param distToJoint Optional distance from the impostor to the joint.
  28786. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28787. */
  28788. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28789. /**
  28790. * Sync impostor to a bone
  28791. * @param bone The bone that the impostor will be synced to.
  28792. * @param boneMesh The mesh that the bone is influencing.
  28793. * @param jointPivot The pivot of the joint / bone in local space.
  28794. * @param distToJoint Optional distance from the impostor to the joint.
  28795. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28796. * @param boneAxis Optional vector3 axis the bone is aligned with
  28797. */
  28798. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28799. /**
  28800. * No-Imposter type
  28801. */
  28802. static NoImpostor: number;
  28803. /**
  28804. * Sphere-Imposter type
  28805. */
  28806. static SphereImpostor: number;
  28807. /**
  28808. * Box-Imposter type
  28809. */
  28810. static BoxImpostor: number;
  28811. /**
  28812. * Plane-Imposter type
  28813. */
  28814. static PlaneImpostor: number;
  28815. /**
  28816. * Mesh-imposter type
  28817. */
  28818. static MeshImpostor: number;
  28819. /**
  28820. * Capsule-Impostor type (Ammo.js plugin only)
  28821. */
  28822. static CapsuleImpostor: number;
  28823. /**
  28824. * Cylinder-Imposter type
  28825. */
  28826. static CylinderImpostor: number;
  28827. /**
  28828. * Particle-Imposter type
  28829. */
  28830. static ParticleImpostor: number;
  28831. /**
  28832. * Heightmap-Imposter type
  28833. */
  28834. static HeightmapImpostor: number;
  28835. /**
  28836. * ConvexHull-Impostor type (Ammo.js plugin only)
  28837. */
  28838. static ConvexHullImpostor: number;
  28839. /**
  28840. * Custom-Imposter type (Ammo.js plugin only)
  28841. */
  28842. static CustomImpostor: number;
  28843. /**
  28844. * Rope-Imposter type
  28845. */
  28846. static RopeImpostor: number;
  28847. /**
  28848. * Cloth-Imposter type
  28849. */
  28850. static ClothImpostor: number;
  28851. /**
  28852. * Softbody-Imposter type
  28853. */
  28854. static SoftbodyImpostor: number;
  28855. }
  28856. }
  28857. declare module "babylonjs/Meshes/mesh" {
  28858. import { Observable } from "babylonjs/Misc/observable";
  28859. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28860. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28861. import { Camera } from "babylonjs/Cameras/camera";
  28862. import { Scene } from "babylonjs/scene";
  28863. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28864. import { Color4 } from "babylonjs/Maths/math.color";
  28865. import { Engine } from "babylonjs/Engines/engine";
  28866. import { Node } from "babylonjs/node";
  28867. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28868. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28869. import { Buffer } from "babylonjs/Meshes/buffer";
  28870. import { Geometry } from "babylonjs/Meshes/geometry";
  28871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28872. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28873. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28874. import { Effect } from "babylonjs/Materials/effect";
  28875. import { Material } from "babylonjs/Materials/material";
  28876. import { Skeleton } from "babylonjs/Bones/skeleton";
  28877. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28878. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28879. import { Path3D } from "babylonjs/Maths/math.path";
  28880. import { Plane } from "babylonjs/Maths/math.plane";
  28881. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28882. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28883. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28884. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28885. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28886. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28887. /**
  28888. * @hidden
  28889. **/
  28890. export class _CreationDataStorage {
  28891. closePath?: boolean;
  28892. closeArray?: boolean;
  28893. idx: number[];
  28894. dashSize: number;
  28895. gapSize: number;
  28896. path3D: Path3D;
  28897. pathArray: Vector3[][];
  28898. arc: number;
  28899. radius: number;
  28900. cap: number;
  28901. tessellation: number;
  28902. }
  28903. /**
  28904. * @hidden
  28905. **/
  28906. class _InstanceDataStorage {
  28907. visibleInstances: any;
  28908. batchCache: _InstancesBatch;
  28909. instancesBufferSize: number;
  28910. instancesBuffer: Nullable<Buffer>;
  28911. instancesData: Float32Array;
  28912. overridenInstanceCount: number;
  28913. isFrozen: boolean;
  28914. previousBatch: Nullable<_InstancesBatch>;
  28915. hardwareInstancedRendering: boolean;
  28916. sideOrientation: number;
  28917. manualUpdate: boolean;
  28918. }
  28919. /**
  28920. * @hidden
  28921. **/
  28922. export class _InstancesBatch {
  28923. mustReturn: boolean;
  28924. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28925. renderSelf: boolean[];
  28926. hardwareInstancedRendering: boolean[];
  28927. }
  28928. /**
  28929. * @hidden
  28930. **/
  28931. class _ThinInstanceDataStorage {
  28932. instancesCount: number;
  28933. matrixBuffer: Nullable<Buffer>;
  28934. matrixBufferSize: number;
  28935. matrixData: Nullable<Float32Array>;
  28936. boundingVectors: Array<Vector3>;
  28937. }
  28938. /**
  28939. * Class used to represent renderable models
  28940. */
  28941. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28942. /**
  28943. * Mesh side orientation : usually the external or front surface
  28944. */
  28945. static readonly FRONTSIDE: number;
  28946. /**
  28947. * Mesh side orientation : usually the internal or back surface
  28948. */
  28949. static readonly BACKSIDE: number;
  28950. /**
  28951. * Mesh side orientation : both internal and external or front and back surfaces
  28952. */
  28953. static readonly DOUBLESIDE: number;
  28954. /**
  28955. * Mesh side orientation : by default, `FRONTSIDE`
  28956. */
  28957. static readonly DEFAULTSIDE: number;
  28958. /**
  28959. * Mesh cap setting : no cap
  28960. */
  28961. static readonly NO_CAP: number;
  28962. /**
  28963. * Mesh cap setting : one cap at the beginning of the mesh
  28964. */
  28965. static readonly CAP_START: number;
  28966. /**
  28967. * Mesh cap setting : one cap at the end of the mesh
  28968. */
  28969. static readonly CAP_END: number;
  28970. /**
  28971. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28972. */
  28973. static readonly CAP_ALL: number;
  28974. /**
  28975. * Mesh pattern setting : no flip or rotate
  28976. */
  28977. static readonly NO_FLIP: number;
  28978. /**
  28979. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28980. */
  28981. static readonly FLIP_TILE: number;
  28982. /**
  28983. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28984. */
  28985. static readonly ROTATE_TILE: number;
  28986. /**
  28987. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28988. */
  28989. static readonly FLIP_ROW: number;
  28990. /**
  28991. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28992. */
  28993. static readonly ROTATE_ROW: number;
  28994. /**
  28995. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28996. */
  28997. static readonly FLIP_N_ROTATE_TILE: number;
  28998. /**
  28999. * Mesh pattern setting : rotate pattern and rotate
  29000. */
  29001. static readonly FLIP_N_ROTATE_ROW: number;
  29002. /**
  29003. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29004. */
  29005. static readonly CENTER: number;
  29006. /**
  29007. * Mesh tile positioning : part tiles on left
  29008. */
  29009. static readonly LEFT: number;
  29010. /**
  29011. * Mesh tile positioning : part tiles on right
  29012. */
  29013. static readonly RIGHT: number;
  29014. /**
  29015. * Mesh tile positioning : part tiles on top
  29016. */
  29017. static readonly TOP: number;
  29018. /**
  29019. * Mesh tile positioning : part tiles on bottom
  29020. */
  29021. static readonly BOTTOM: number;
  29022. /**
  29023. * Gets the default side orientation.
  29024. * @param orientation the orientation to value to attempt to get
  29025. * @returns the default orientation
  29026. * @hidden
  29027. */
  29028. static _GetDefaultSideOrientation(orientation?: number): number;
  29029. private _internalMeshDataInfo;
  29030. get computeBonesUsingShaders(): boolean;
  29031. set computeBonesUsingShaders(value: boolean);
  29032. /**
  29033. * An event triggered before rendering the mesh
  29034. */
  29035. get onBeforeRenderObservable(): Observable<Mesh>;
  29036. /**
  29037. * An event triggered before binding the mesh
  29038. */
  29039. get onBeforeBindObservable(): Observable<Mesh>;
  29040. /**
  29041. * An event triggered after rendering the mesh
  29042. */
  29043. get onAfterRenderObservable(): Observable<Mesh>;
  29044. /**
  29045. * An event triggered before drawing the mesh
  29046. */
  29047. get onBeforeDrawObservable(): Observable<Mesh>;
  29048. private _onBeforeDrawObserver;
  29049. /**
  29050. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29051. */
  29052. set onBeforeDraw(callback: () => void);
  29053. get hasInstances(): boolean;
  29054. get hasThinInstances(): boolean;
  29055. /**
  29056. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29057. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29058. */
  29059. delayLoadState: number;
  29060. /**
  29061. * Gets the list of instances created from this mesh
  29062. * it is not supposed to be modified manually.
  29063. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29064. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29065. */
  29066. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29067. /**
  29068. * Gets the file containing delay loading data for this mesh
  29069. */
  29070. delayLoadingFile: string;
  29071. /** @hidden */
  29072. _binaryInfo: any;
  29073. /**
  29074. * User defined function used to change how LOD level selection is done
  29075. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29076. */
  29077. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29078. /**
  29079. * Gets or sets the morph target manager
  29080. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29081. */
  29082. get morphTargetManager(): Nullable<MorphTargetManager>;
  29083. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29084. /** @hidden */
  29085. _creationDataStorage: Nullable<_CreationDataStorage>;
  29086. /** @hidden */
  29087. _geometry: Nullable<Geometry>;
  29088. /** @hidden */
  29089. _delayInfo: Array<string>;
  29090. /** @hidden */
  29091. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29092. /** @hidden */
  29093. _instanceDataStorage: _InstanceDataStorage;
  29094. /** @hidden */
  29095. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29096. private _effectiveMaterial;
  29097. /** @hidden */
  29098. _shouldGenerateFlatShading: boolean;
  29099. /** @hidden */
  29100. _originalBuilderSideOrientation: number;
  29101. /**
  29102. * Use this property to change the original side orientation defined at construction time
  29103. */
  29104. overrideMaterialSideOrientation: Nullable<number>;
  29105. /**
  29106. * Gets the source mesh (the one used to clone this one from)
  29107. */
  29108. get source(): Nullable<Mesh>;
  29109. /**
  29110. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29111. */
  29112. get isUnIndexed(): boolean;
  29113. set isUnIndexed(value: boolean);
  29114. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29115. get worldMatrixInstancedBuffer(): Float32Array;
  29116. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29117. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29118. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29119. /**
  29120. * @constructor
  29121. * @param name The value used by scene.getMeshByName() to do a lookup.
  29122. * @param scene The scene to add this mesh to.
  29123. * @param parent The parent of this mesh, if it has one
  29124. * @param source An optional Mesh from which geometry is shared, cloned.
  29125. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29126. * When false, achieved by calling a clone(), also passing False.
  29127. * This will make creation of children, recursive.
  29128. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29129. */
  29130. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29131. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29132. doNotInstantiate: boolean;
  29133. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29134. /**
  29135. * Gets the class name
  29136. * @returns the string "Mesh".
  29137. */
  29138. getClassName(): string;
  29139. /** @hidden */
  29140. get _isMesh(): boolean;
  29141. /**
  29142. * Returns a description of this mesh
  29143. * @param fullDetails define if full details about this mesh must be used
  29144. * @returns a descriptive string representing this mesh
  29145. */
  29146. toString(fullDetails?: boolean): string;
  29147. /** @hidden */
  29148. _unBindEffect(): void;
  29149. /**
  29150. * Gets a boolean indicating if this mesh has LOD
  29151. */
  29152. get hasLODLevels(): boolean;
  29153. /**
  29154. * Gets the list of MeshLODLevel associated with the current mesh
  29155. * @returns an array of MeshLODLevel
  29156. */
  29157. getLODLevels(): MeshLODLevel[];
  29158. private _sortLODLevels;
  29159. /**
  29160. * Add a mesh as LOD level triggered at the given distance.
  29161. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29162. * @param distance The distance from the center of the object to show this level
  29163. * @param mesh The mesh to be added as LOD level (can be null)
  29164. * @return This mesh (for chaining)
  29165. */
  29166. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29167. /**
  29168. * Returns the LOD level mesh at the passed distance or null if not found.
  29169. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29170. * @param distance The distance from the center of the object to show this level
  29171. * @returns a Mesh or `null`
  29172. */
  29173. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29174. /**
  29175. * Remove a mesh from the LOD array
  29176. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29177. * @param mesh defines the mesh to be removed
  29178. * @return This mesh (for chaining)
  29179. */
  29180. removeLODLevel(mesh: Mesh): Mesh;
  29181. /**
  29182. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29183. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29184. * @param camera defines the camera to use to compute distance
  29185. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29186. * @return This mesh (for chaining)
  29187. */
  29188. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29189. /**
  29190. * Gets the mesh internal Geometry object
  29191. */
  29192. get geometry(): Nullable<Geometry>;
  29193. /**
  29194. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29195. * @returns the total number of vertices
  29196. */
  29197. getTotalVertices(): number;
  29198. /**
  29199. * Returns the content of an associated vertex buffer
  29200. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29201. * - VertexBuffer.PositionKind
  29202. * - VertexBuffer.UVKind
  29203. * - VertexBuffer.UV2Kind
  29204. * - VertexBuffer.UV3Kind
  29205. * - VertexBuffer.UV4Kind
  29206. * - VertexBuffer.UV5Kind
  29207. * - VertexBuffer.UV6Kind
  29208. * - VertexBuffer.ColorKind
  29209. * - VertexBuffer.MatricesIndicesKind
  29210. * - VertexBuffer.MatricesIndicesExtraKind
  29211. * - VertexBuffer.MatricesWeightsKind
  29212. * - VertexBuffer.MatricesWeightsExtraKind
  29213. * @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
  29214. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29215. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29216. */
  29217. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29218. /**
  29219. * Returns the mesh VertexBuffer object from the requested `kind`
  29220. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29221. * - VertexBuffer.PositionKind
  29222. * - VertexBuffer.NormalKind
  29223. * - VertexBuffer.UVKind
  29224. * - VertexBuffer.UV2Kind
  29225. * - VertexBuffer.UV3Kind
  29226. * - VertexBuffer.UV4Kind
  29227. * - VertexBuffer.UV5Kind
  29228. * - VertexBuffer.UV6Kind
  29229. * - VertexBuffer.ColorKind
  29230. * - VertexBuffer.MatricesIndicesKind
  29231. * - VertexBuffer.MatricesIndicesExtraKind
  29232. * - VertexBuffer.MatricesWeightsKind
  29233. * - VertexBuffer.MatricesWeightsExtraKind
  29234. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29235. */
  29236. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29237. /**
  29238. * Tests if a specific vertex buffer is associated with this mesh
  29239. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29240. * - VertexBuffer.PositionKind
  29241. * - VertexBuffer.NormalKind
  29242. * - VertexBuffer.UVKind
  29243. * - VertexBuffer.UV2Kind
  29244. * - VertexBuffer.UV3Kind
  29245. * - VertexBuffer.UV4Kind
  29246. * - VertexBuffer.UV5Kind
  29247. * - VertexBuffer.UV6Kind
  29248. * - VertexBuffer.ColorKind
  29249. * - VertexBuffer.MatricesIndicesKind
  29250. * - VertexBuffer.MatricesIndicesExtraKind
  29251. * - VertexBuffer.MatricesWeightsKind
  29252. * - VertexBuffer.MatricesWeightsExtraKind
  29253. * @returns a boolean
  29254. */
  29255. isVerticesDataPresent(kind: string): boolean;
  29256. /**
  29257. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29258. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29259. * - VertexBuffer.PositionKind
  29260. * - VertexBuffer.UVKind
  29261. * - VertexBuffer.UV2Kind
  29262. * - VertexBuffer.UV3Kind
  29263. * - VertexBuffer.UV4Kind
  29264. * - VertexBuffer.UV5Kind
  29265. * - VertexBuffer.UV6Kind
  29266. * - VertexBuffer.ColorKind
  29267. * - VertexBuffer.MatricesIndicesKind
  29268. * - VertexBuffer.MatricesIndicesExtraKind
  29269. * - VertexBuffer.MatricesWeightsKind
  29270. * - VertexBuffer.MatricesWeightsExtraKind
  29271. * @returns a boolean
  29272. */
  29273. isVertexBufferUpdatable(kind: string): boolean;
  29274. /**
  29275. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29276. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29277. * - VertexBuffer.PositionKind
  29278. * - VertexBuffer.NormalKind
  29279. * - VertexBuffer.UVKind
  29280. * - VertexBuffer.UV2Kind
  29281. * - VertexBuffer.UV3Kind
  29282. * - VertexBuffer.UV4Kind
  29283. * - VertexBuffer.UV5Kind
  29284. * - VertexBuffer.UV6Kind
  29285. * - VertexBuffer.ColorKind
  29286. * - VertexBuffer.MatricesIndicesKind
  29287. * - VertexBuffer.MatricesIndicesExtraKind
  29288. * - VertexBuffer.MatricesWeightsKind
  29289. * - VertexBuffer.MatricesWeightsExtraKind
  29290. * @returns an array of strings
  29291. */
  29292. getVerticesDataKinds(): string[];
  29293. /**
  29294. * Returns a positive integer : the total number of indices in this mesh geometry.
  29295. * @returns the numner of indices or zero if the mesh has no geometry.
  29296. */
  29297. getTotalIndices(): number;
  29298. /**
  29299. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29300. * @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.
  29301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29302. * @returns the indices array or an empty array if the mesh has no geometry
  29303. */
  29304. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29305. get isBlocked(): boolean;
  29306. /**
  29307. * Determine if the current mesh is ready to be rendered
  29308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29309. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29310. * @returns true if all associated assets are ready (material, textures, shaders)
  29311. */
  29312. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29313. /**
  29314. * 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.
  29315. */
  29316. get areNormalsFrozen(): boolean;
  29317. /**
  29318. * 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.
  29319. * @returns the current mesh
  29320. */
  29321. freezeNormals(): Mesh;
  29322. /**
  29323. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  29324. * @returns the current mesh
  29325. */
  29326. unfreezeNormals(): Mesh;
  29327. /**
  29328. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29329. */
  29330. set overridenInstanceCount(count: number);
  29331. /** @hidden */
  29332. _preActivate(): Mesh;
  29333. /** @hidden */
  29334. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29335. /** @hidden */
  29336. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29337. protected _afterComputeWorldMatrix(): void;
  29338. /** @hidden */
  29339. _postActivate(): void;
  29340. /**
  29341. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29342. * This means the mesh underlying bounding box and sphere are recomputed.
  29343. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29344. * @returns the current mesh
  29345. */
  29346. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29347. /** @hidden */
  29348. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29349. /**
  29350. * This function will subdivide the mesh into multiple submeshes
  29351. * @param count defines the expected number of submeshes
  29352. */
  29353. subdivide(count: number): void;
  29354. /**
  29355. * Copy a FloatArray into a specific associated vertex buffer
  29356. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29357. * - VertexBuffer.PositionKind
  29358. * - VertexBuffer.UVKind
  29359. * - VertexBuffer.UV2Kind
  29360. * - VertexBuffer.UV3Kind
  29361. * - VertexBuffer.UV4Kind
  29362. * - VertexBuffer.UV5Kind
  29363. * - VertexBuffer.UV6Kind
  29364. * - VertexBuffer.ColorKind
  29365. * - VertexBuffer.MatricesIndicesKind
  29366. * - VertexBuffer.MatricesIndicesExtraKind
  29367. * - VertexBuffer.MatricesWeightsKind
  29368. * - VertexBuffer.MatricesWeightsExtraKind
  29369. * @param data defines the data source
  29370. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29371. * @param stride defines the data stride size (can be null)
  29372. * @returns the current mesh
  29373. */
  29374. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29375. /**
  29376. * Delete a vertex buffer associated with this mesh
  29377. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29378. * - VertexBuffer.PositionKind
  29379. * - VertexBuffer.UVKind
  29380. * - VertexBuffer.UV2Kind
  29381. * - VertexBuffer.UV3Kind
  29382. * - VertexBuffer.UV4Kind
  29383. * - VertexBuffer.UV5Kind
  29384. * - VertexBuffer.UV6Kind
  29385. * - VertexBuffer.ColorKind
  29386. * - VertexBuffer.MatricesIndicesKind
  29387. * - VertexBuffer.MatricesIndicesExtraKind
  29388. * - VertexBuffer.MatricesWeightsKind
  29389. * - VertexBuffer.MatricesWeightsExtraKind
  29390. */
  29391. removeVerticesData(kind: string): void;
  29392. /**
  29393. * Flags an associated vertex buffer as updatable
  29394. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29395. * - VertexBuffer.PositionKind
  29396. * - VertexBuffer.UVKind
  29397. * - VertexBuffer.UV2Kind
  29398. * - VertexBuffer.UV3Kind
  29399. * - VertexBuffer.UV4Kind
  29400. * - VertexBuffer.UV5Kind
  29401. * - VertexBuffer.UV6Kind
  29402. * - VertexBuffer.ColorKind
  29403. * - VertexBuffer.MatricesIndicesKind
  29404. * - VertexBuffer.MatricesIndicesExtraKind
  29405. * - VertexBuffer.MatricesWeightsKind
  29406. * - VertexBuffer.MatricesWeightsExtraKind
  29407. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29408. */
  29409. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29410. /**
  29411. * Sets the mesh global Vertex Buffer
  29412. * @param buffer defines the buffer to use
  29413. * @returns the current mesh
  29414. */
  29415. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29416. /**
  29417. * Update a specific associated vertex buffer
  29418. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29419. * - VertexBuffer.PositionKind
  29420. * - VertexBuffer.UVKind
  29421. * - VertexBuffer.UV2Kind
  29422. * - VertexBuffer.UV3Kind
  29423. * - VertexBuffer.UV4Kind
  29424. * - VertexBuffer.UV5Kind
  29425. * - VertexBuffer.UV6Kind
  29426. * - VertexBuffer.ColorKind
  29427. * - VertexBuffer.MatricesIndicesKind
  29428. * - VertexBuffer.MatricesIndicesExtraKind
  29429. * - VertexBuffer.MatricesWeightsKind
  29430. * - VertexBuffer.MatricesWeightsExtraKind
  29431. * @param data defines the data source
  29432. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29433. * @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)
  29434. * @returns the current mesh
  29435. */
  29436. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29437. /**
  29438. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29439. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29440. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29441. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29442. * @returns the current mesh
  29443. */
  29444. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29445. /**
  29446. * Creates a un-shared specific occurence of the geometry for the mesh.
  29447. * @returns the current mesh
  29448. */
  29449. makeGeometryUnique(): Mesh;
  29450. /**
  29451. * Set the index buffer of this mesh
  29452. * @param indices defines the source data
  29453. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29454. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29455. * @returns the current mesh
  29456. */
  29457. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29458. /**
  29459. * Update the current index buffer
  29460. * @param indices defines the source data
  29461. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29462. * @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)
  29463. * @returns the current mesh
  29464. */
  29465. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29466. /**
  29467. * Invert the geometry to move from a right handed system to a left handed one.
  29468. * @returns the current mesh
  29469. */
  29470. toLeftHanded(): Mesh;
  29471. /** @hidden */
  29472. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29473. /** @hidden */
  29474. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29475. /**
  29476. * Registers for this mesh a javascript function called just before the rendering process
  29477. * @param func defines the function to call before rendering this mesh
  29478. * @returns the current mesh
  29479. */
  29480. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29481. /**
  29482. * Disposes a previously registered javascript function called before the rendering
  29483. * @param func defines the function to remove
  29484. * @returns the current mesh
  29485. */
  29486. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29487. /**
  29488. * Registers for this mesh a javascript function called just after the rendering is complete
  29489. * @param func defines the function to call after rendering this mesh
  29490. * @returns the current mesh
  29491. */
  29492. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29493. /**
  29494. * Disposes a previously registered javascript function called after the rendering.
  29495. * @param func defines the function to remove
  29496. * @returns the current mesh
  29497. */
  29498. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29499. /** @hidden */
  29500. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29501. /** @hidden */
  29502. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29503. /** @hidden */
  29504. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29505. /** @hidden */
  29506. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29507. /** @hidden */
  29508. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29509. /** @hidden */
  29510. _rebuild(): void;
  29511. /** @hidden */
  29512. _freeze(): void;
  29513. /** @hidden */
  29514. _unFreeze(): void;
  29515. /**
  29516. * 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
  29517. * @param subMesh defines the subMesh to render
  29518. * @param enableAlphaMode defines if alpha mode can be changed
  29519. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29520. * @returns the current mesh
  29521. */
  29522. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29523. private _onBeforeDraw;
  29524. /**
  29525. * Renormalize the mesh and patch it up if there are no weights
  29526. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29527. * However in the case of zero weights then we set just a single influence to 1.
  29528. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29529. */
  29530. cleanMatrixWeights(): void;
  29531. private normalizeSkinFourWeights;
  29532. private normalizeSkinWeightsAndExtra;
  29533. /**
  29534. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29535. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29536. * the user know there was an issue with importing the mesh
  29537. * @returns a validation object with skinned, valid and report string
  29538. */
  29539. validateSkinning(): {
  29540. skinned: boolean;
  29541. valid: boolean;
  29542. report: string;
  29543. };
  29544. /** @hidden */
  29545. _checkDelayState(): Mesh;
  29546. private _queueLoad;
  29547. /**
  29548. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29549. * A mesh is in the frustum if its bounding box intersects the frustum
  29550. * @param frustumPlanes defines the frustum to test
  29551. * @returns true if the mesh is in the frustum planes
  29552. */
  29553. isInFrustum(frustumPlanes: Plane[]): boolean;
  29554. /**
  29555. * Sets the mesh material by the material or multiMaterial `id` property
  29556. * @param id is a string identifying the material or the multiMaterial
  29557. * @returns the current mesh
  29558. */
  29559. setMaterialByID(id: string): Mesh;
  29560. /**
  29561. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29562. * @returns an array of IAnimatable
  29563. */
  29564. getAnimatables(): IAnimatable[];
  29565. /**
  29566. * Modifies the mesh geometry according to the passed transformation matrix.
  29567. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29568. * The mesh normals are modified using the same transformation.
  29569. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29570. * @param transform defines the transform matrix to use
  29571. * @see https://doc.babylonjs.com/resources/baking_transformations
  29572. * @returns the current mesh
  29573. */
  29574. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29575. /**
  29576. * Modifies the mesh geometry according to its own current World Matrix.
  29577. * The mesh World Matrix is then reset.
  29578. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29579. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29580. * @see https://doc.babylonjs.com/resources/baking_transformations
  29581. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29582. * @returns the current mesh
  29583. */
  29584. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29585. /** @hidden */
  29586. get _positions(): Nullable<Vector3[]>;
  29587. /** @hidden */
  29588. _resetPointsArrayCache(): Mesh;
  29589. /** @hidden */
  29590. _generatePointsArray(): boolean;
  29591. /**
  29592. * Returns a new Mesh object generated from the current mesh properties.
  29593. * This method must not get confused with createInstance()
  29594. * @param name is a string, the name given to the new mesh
  29595. * @param newParent can be any Node object (default `null`)
  29596. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29597. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29598. * @returns a new mesh
  29599. */
  29600. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29601. /**
  29602. * Releases resources associated with this mesh.
  29603. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29604. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29605. */
  29606. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29607. /** @hidden */
  29608. _disposeInstanceSpecificData(): void;
  29609. /** @hidden */
  29610. _disposeThinInstanceSpecificData(): void;
  29611. /**
  29612. * Modifies the mesh geometry according to a displacement map.
  29613. * 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.
  29614. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29615. * @param url is a string, the URL from the image file is to be downloaded.
  29616. * @param minHeight is the lower limit of the displacement.
  29617. * @param maxHeight is the upper limit of the displacement.
  29618. * @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.
  29619. * @param uvOffset is an optional vector2 used to offset UV.
  29620. * @param uvScale is an optional vector2 used to scale UV.
  29621. * @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.
  29622. * @returns the Mesh.
  29623. */
  29624. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29625. /**
  29626. * Modifies the mesh geometry according to a displacementMap buffer.
  29627. * 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.
  29628. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29629. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29630. * @param heightMapWidth is the width of the buffer image.
  29631. * @param heightMapHeight is the height of the buffer image.
  29632. * @param minHeight is the lower limit of the displacement.
  29633. * @param maxHeight is the upper limit of the displacement.
  29634. * @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.
  29635. * @param uvOffset is an optional vector2 used to offset UV.
  29636. * @param uvScale is an optional vector2 used to scale UV.
  29637. * @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.
  29638. * @returns the Mesh.
  29639. */
  29640. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29641. /**
  29642. * Modify the mesh to get a flat shading rendering.
  29643. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29644. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29645. * @returns current mesh
  29646. */
  29647. convertToFlatShadedMesh(): Mesh;
  29648. /**
  29649. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29650. * In other words, more vertices, no more indices and a single bigger VBO.
  29651. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29652. * @returns current mesh
  29653. */
  29654. convertToUnIndexedMesh(): Mesh;
  29655. /**
  29656. * Inverses facet orientations.
  29657. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29658. * @param flipNormals will also inverts the normals
  29659. * @returns current mesh
  29660. */
  29661. flipFaces(flipNormals?: boolean): Mesh;
  29662. /**
  29663. * Increase the number of facets and hence vertices in a mesh
  29664. * Vertex normals are interpolated from existing vertex normals
  29665. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29666. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29667. */
  29668. increaseVertices(numberPerEdge: number): void;
  29669. /**
  29670. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29671. * This will undo any application of covertToFlatShadedMesh
  29672. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29673. */
  29674. forceSharedVertices(): void;
  29675. /** @hidden */
  29676. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29677. /** @hidden */
  29678. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29679. /**
  29680. * Creates a new InstancedMesh object from the mesh model.
  29681. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29682. * @param name defines the name of the new instance
  29683. * @returns a new InstancedMesh
  29684. */
  29685. createInstance(name: string): InstancedMesh;
  29686. /**
  29687. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29688. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29689. * @returns the current mesh
  29690. */
  29691. synchronizeInstances(): Mesh;
  29692. /**
  29693. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29694. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29695. * This should be used together with the simplification to avoid disappearing triangles.
  29696. * @param successCallback an optional success callback to be called after the optimization finished.
  29697. * @returns the current mesh
  29698. */
  29699. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29700. /**
  29701. * Serialize current mesh
  29702. * @param serializationObject defines the object which will receive the serialization data
  29703. */
  29704. serialize(serializationObject: any): void;
  29705. /** @hidden */
  29706. _syncGeometryWithMorphTargetManager(): void;
  29707. /** @hidden */
  29708. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29709. /**
  29710. * Returns a new Mesh object parsed from the source provided.
  29711. * @param parsedMesh is the source
  29712. * @param scene defines the hosting scene
  29713. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29714. * @returns a new Mesh
  29715. */
  29716. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29717. /**
  29718. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29720. * @param name defines the name of the mesh to create
  29721. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29722. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29723. * @param closePath creates a seam between the first and the last points of each path of the path array
  29724. * @param offset is taken in account only if the `pathArray` is containing a single path
  29725. * @param scene defines the hosting scene
  29726. * @param updatable defines if the mesh must be flagged as updatable
  29727. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29728. * @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)
  29729. * @returns a new Mesh
  29730. */
  29731. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29732. /**
  29733. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29734. * @param name defines the name of the mesh to create
  29735. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29736. * @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
  29737. * @param scene defines the hosting scene
  29738. * @param updatable defines if the mesh must be flagged as updatable
  29739. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29740. * @returns a new Mesh
  29741. */
  29742. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29743. /**
  29744. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29745. * @param name defines the name of the mesh to create
  29746. * @param size sets the size (float) of each box side (default 1)
  29747. * @param scene defines the hosting scene
  29748. * @param updatable defines if the mesh must be flagged as updatable
  29749. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29750. * @returns a new Mesh
  29751. */
  29752. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29753. /**
  29754. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29755. * @param name defines the name of the mesh to create
  29756. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29757. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29758. * @param scene defines the hosting scene
  29759. * @param updatable defines if the mesh must be flagged as updatable
  29760. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29761. * @returns a new Mesh
  29762. */
  29763. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29764. /**
  29765. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29766. * @param name defines the name of the mesh to create
  29767. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29768. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29769. * @param scene defines the hosting scene
  29770. * @returns a new Mesh
  29771. */
  29772. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29773. /**
  29774. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29775. * @param name defines the name of the mesh to create
  29776. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29777. * @param diameterTop set the top cap diameter (floats, default 1)
  29778. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29779. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29780. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29781. * @param scene defines the hosting scene
  29782. * @param updatable defines if the mesh must be flagged as updatable
  29783. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29784. * @returns a new Mesh
  29785. */
  29786. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29787. /**
  29788. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29789. * @param name defines the name of the mesh to create
  29790. * @param diameter sets the diameter size (float) of the torus (default 1)
  29791. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29792. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29793. * @param scene defines the hosting scene
  29794. * @param updatable defines if the mesh must be flagged as updatable
  29795. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29796. * @returns a new Mesh
  29797. */
  29798. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29799. /**
  29800. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29801. * @param name defines the name of the mesh to create
  29802. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29803. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29804. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29805. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29806. * @param p the number of windings on X axis (positive integers, default 2)
  29807. * @param q the number of windings on Y axis (positive integers, default 3)
  29808. * @param scene defines the hosting scene
  29809. * @param updatable defines if the mesh must be flagged as updatable
  29810. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29811. * @returns a new Mesh
  29812. */
  29813. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29814. /**
  29815. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29816. * @param name defines the name of the mesh to create
  29817. * @param points is an array successive Vector3
  29818. * @param scene defines the hosting scene
  29819. * @param updatable defines if the mesh must be flagged as updatable
  29820. * @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).
  29821. * @returns a new Mesh
  29822. */
  29823. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29824. /**
  29825. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29826. * @param name defines the name of the mesh to create
  29827. * @param points is an array successive Vector3
  29828. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29829. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29830. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29831. * @param scene defines the hosting scene
  29832. * @param updatable defines if the mesh must be flagged as updatable
  29833. * @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)
  29834. * @returns a new Mesh
  29835. */
  29836. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29837. /**
  29838. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29839. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29840. * 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.
  29841. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29842. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29843. * Remember you can only change the shape positions, not their number when updating a polygon.
  29844. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29845. * @param name defines the name of the mesh to create
  29846. * @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
  29847. * @param scene defines the hosting scene
  29848. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29849. * @param updatable defines if the mesh must be flagged as updatable
  29850. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29851. * @param earcutInjection can be used to inject your own earcut reference
  29852. * @returns a new Mesh
  29853. */
  29854. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29855. /**
  29856. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29858. * @param name defines the name of the mesh to create
  29859. * @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
  29860. * @param depth defines the height of extrusion
  29861. * @param scene defines the hosting scene
  29862. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29863. * @param updatable defines if the mesh must be flagged as updatable
  29864. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29865. * @param earcutInjection can be used to inject your own earcut reference
  29866. * @returns a new Mesh
  29867. */
  29868. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29869. /**
  29870. * Creates an extruded shape mesh.
  29871. * 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
  29872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29874. * @param name defines the name of the mesh to create
  29875. * @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
  29876. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29877. * @param scale is the value to scale the shape
  29878. * @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
  29879. * @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
  29880. * @param scene defines the hosting scene
  29881. * @param updatable defines if the mesh must be flagged as updatable
  29882. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29883. * @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)
  29884. * @returns a new Mesh
  29885. */
  29886. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29887. /**
  29888. * Creates an custom extruded shape mesh.
  29889. * The custom extrusion is a parametric shape.
  29890. * It has no predefined shape. Its final shape will depend on the input parameters.
  29891. * Please consider using the same method from the MeshBuilder class instead
  29892. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29893. * @param name defines the name of the mesh to create
  29894. * @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
  29895. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29896. * @param scaleFunction is a custom Javascript function called on each path point
  29897. * @param rotationFunction is a custom Javascript function called on each path point
  29898. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29899. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29900. * @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
  29901. * @param scene defines the hosting scene
  29902. * @param updatable defines if the mesh must be flagged as updatable
  29903. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29904. * @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)
  29905. * @returns a new Mesh
  29906. */
  29907. 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;
  29908. /**
  29909. * Creates lathe mesh.
  29910. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29911. * Please consider using the same method from the MeshBuilder class instead
  29912. * @param name defines the name of the mesh to create
  29913. * @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
  29914. * @param radius is the radius value of the lathe
  29915. * @param tessellation is the side number of the lathe.
  29916. * @param scene defines the hosting scene
  29917. * @param updatable defines if the mesh must be flagged as updatable
  29918. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29919. * @returns a new Mesh
  29920. */
  29921. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29922. /**
  29923. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29924. * @param name defines the name of the mesh to create
  29925. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29926. * @param scene defines the hosting scene
  29927. * @param updatable defines if the mesh must be flagged as updatable
  29928. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29929. * @returns a new Mesh
  29930. */
  29931. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29932. /**
  29933. * Creates a ground mesh.
  29934. * Please consider using the same method from the MeshBuilder class instead
  29935. * @param name defines the name of the mesh to create
  29936. * @param width set the width of the ground
  29937. * @param height set the height of the ground
  29938. * @param subdivisions sets the number of subdivisions per side
  29939. * @param scene defines the hosting scene
  29940. * @param updatable defines if the mesh must be flagged as updatable
  29941. * @returns a new Mesh
  29942. */
  29943. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29944. /**
  29945. * Creates a tiled ground mesh.
  29946. * Please consider using the same method from the MeshBuilder class instead
  29947. * @param name defines the name of the mesh to create
  29948. * @param xmin set the ground minimum X coordinate
  29949. * @param zmin set the ground minimum Y coordinate
  29950. * @param xmax set the ground maximum X coordinate
  29951. * @param zmax set the ground maximum Z coordinate
  29952. * @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
  29953. * @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
  29954. * @param scene defines the hosting scene
  29955. * @param updatable defines if the mesh must be flagged as updatable
  29956. * @returns a new Mesh
  29957. */
  29958. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29959. w: number;
  29960. h: number;
  29961. }, precision: {
  29962. w: number;
  29963. h: number;
  29964. }, scene: Scene, updatable?: boolean): Mesh;
  29965. /**
  29966. * Creates a ground mesh from a height map.
  29967. * Please consider using the same method from the MeshBuilder class instead
  29968. * @see https://doc.babylonjs.com/babylon101/height_map
  29969. * @param name defines the name of the mesh to create
  29970. * @param url sets the URL of the height map image resource
  29971. * @param width set the ground width size
  29972. * @param height set the ground height size
  29973. * @param subdivisions sets the number of subdivision per side
  29974. * @param minHeight is the minimum altitude on the ground
  29975. * @param maxHeight is the maximum altitude on the ground
  29976. * @param scene defines the hosting scene
  29977. * @param updatable defines if the mesh must be flagged as updatable
  29978. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29979. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29980. * @returns a new Mesh
  29981. */
  29982. 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;
  29983. /**
  29984. * Creates a tube mesh.
  29985. * The tube is a parametric shape.
  29986. * It has no predefined shape. Its final shape will depend on the input parameters.
  29987. * Please consider using the same method from the MeshBuilder class instead
  29988. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29989. * @param name defines the name of the mesh to create
  29990. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29991. * @param radius sets the tube radius size
  29992. * @param tessellation is the number of sides on the tubular surface
  29993. * @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
  29994. * @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
  29995. * @param scene defines the hosting scene
  29996. * @param updatable defines if the mesh must be flagged as updatable
  29997. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29998. * @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)
  29999. * @returns a new Mesh
  30000. */
  30001. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30002. (i: number, distance: number): number;
  30003. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30004. /**
  30005. * Creates a polyhedron mesh.
  30006. * Please consider using the same method from the MeshBuilder class instead.
  30007. * * 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
  30008. * * The parameter `size` (positive float, default 1) sets the polygon size
  30009. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30010. * * 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`
  30011. * * 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
  30012. * * 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)`)
  30013. * * 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
  30014. * * 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
  30015. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30018. * @param name defines the name of the mesh to create
  30019. * @param options defines the options used to create the mesh
  30020. * @param scene defines the hosting scene
  30021. * @returns a new Mesh
  30022. */
  30023. static CreatePolyhedron(name: string, options: {
  30024. type?: number;
  30025. size?: number;
  30026. sizeX?: number;
  30027. sizeY?: number;
  30028. sizeZ?: number;
  30029. custom?: any;
  30030. faceUV?: Vector4[];
  30031. faceColors?: Color4[];
  30032. updatable?: boolean;
  30033. sideOrientation?: number;
  30034. }, scene: Scene): Mesh;
  30035. /**
  30036. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30037. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30038. * * 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`)
  30039. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30040. * * 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
  30041. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30044. * @param name defines the name of the mesh
  30045. * @param options defines the options used to create the mesh
  30046. * @param scene defines the hosting scene
  30047. * @returns a new Mesh
  30048. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30049. */
  30050. static CreateIcoSphere(name: string, options: {
  30051. radius?: number;
  30052. flat?: boolean;
  30053. subdivisions?: number;
  30054. sideOrientation?: number;
  30055. updatable?: boolean;
  30056. }, scene: Scene): Mesh;
  30057. /**
  30058. * Creates a decal mesh.
  30059. * Please consider using the same method from the MeshBuilder class instead.
  30060. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30061. * @param name defines the name of the mesh
  30062. * @param sourceMesh defines the mesh receiving the decal
  30063. * @param position sets the position of the decal in world coordinates
  30064. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30065. * @param size sets the decal scaling
  30066. * @param angle sets the angle to rotate the decal
  30067. * @returns a new Mesh
  30068. */
  30069. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30070. /**
  30071. * Prepare internal position array for software CPU skinning
  30072. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30073. */
  30074. setPositionsForCPUSkinning(): Float32Array;
  30075. /**
  30076. * Prepare internal normal array for software CPU skinning
  30077. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30078. */
  30079. setNormalsForCPUSkinning(): Float32Array;
  30080. /**
  30081. * Updates the vertex buffer by applying transformation from the bones
  30082. * @param skeleton defines the skeleton to apply to current mesh
  30083. * @returns the current mesh
  30084. */
  30085. applySkeleton(skeleton: Skeleton): Mesh;
  30086. /**
  30087. * 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
  30088. * @param meshes defines the list of meshes to scan
  30089. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30090. */
  30091. static MinMax(meshes: AbstractMesh[]): {
  30092. min: Vector3;
  30093. max: Vector3;
  30094. };
  30095. /**
  30096. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30097. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30098. * @returns a vector3
  30099. */
  30100. static Center(meshesOrMinMaxVector: {
  30101. min: Vector3;
  30102. max: Vector3;
  30103. } | AbstractMesh[]): Vector3;
  30104. /**
  30105. * Merge the array of meshes into a single mesh for performance reasons.
  30106. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30107. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30108. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30109. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30110. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30111. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30112. * @returns a new mesh
  30113. */
  30114. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30115. /** @hidden */
  30116. addInstance(instance: InstancedMesh): void;
  30117. /** @hidden */
  30118. removeInstance(instance: InstancedMesh): void;
  30119. }
  30120. }
  30121. declare module "babylonjs/Cameras/camera" {
  30122. import { SmartArray } from "babylonjs/Misc/smartArray";
  30123. import { Observable } from "babylonjs/Misc/observable";
  30124. import { Nullable } from "babylonjs/types";
  30125. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30126. import { Scene } from "babylonjs/scene";
  30127. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30128. import { Node } from "babylonjs/node";
  30129. import { Mesh } from "babylonjs/Meshes/mesh";
  30130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30131. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30132. import { Viewport } from "babylonjs/Maths/math.viewport";
  30133. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30134. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30135. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30136. import { Ray } from "babylonjs/Culling/ray";
  30137. /**
  30138. * This is the base class of all the camera used in the application.
  30139. * @see https://doc.babylonjs.com/features/cameras
  30140. */
  30141. export class Camera extends Node {
  30142. /** @hidden */
  30143. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30144. /**
  30145. * This is the default projection mode used by the cameras.
  30146. * It helps recreating a feeling of perspective and better appreciate depth.
  30147. * This is the best way to simulate real life cameras.
  30148. */
  30149. static readonly PERSPECTIVE_CAMERA: number;
  30150. /**
  30151. * This helps creating camera with an orthographic mode.
  30152. * 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.
  30153. */
  30154. static readonly ORTHOGRAPHIC_CAMERA: number;
  30155. /**
  30156. * This is the default FOV mode for perspective cameras.
  30157. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30158. */
  30159. static readonly FOVMODE_VERTICAL_FIXED: number;
  30160. /**
  30161. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30162. */
  30163. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30164. /**
  30165. * This specifies ther is no need for a camera rig.
  30166. * Basically only one eye is rendered corresponding to the camera.
  30167. */
  30168. static readonly RIG_MODE_NONE: number;
  30169. /**
  30170. * Simulates a camera Rig with one blue eye and one red eye.
  30171. * This can be use with 3d blue and red glasses.
  30172. */
  30173. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30174. /**
  30175. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30176. */
  30177. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30178. /**
  30179. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30180. */
  30181. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30182. /**
  30183. * Defines that both eyes of the camera will be rendered over under each other.
  30184. */
  30185. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30186. /**
  30187. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30188. */
  30189. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30190. /**
  30191. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30192. */
  30193. static readonly RIG_MODE_VR: number;
  30194. /**
  30195. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30196. */
  30197. static readonly RIG_MODE_WEBVR: number;
  30198. /**
  30199. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30200. */
  30201. static readonly RIG_MODE_CUSTOM: number;
  30202. /**
  30203. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30204. */
  30205. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30206. /**
  30207. * Define the input manager associated with the camera.
  30208. */
  30209. inputs: CameraInputsManager<Camera>;
  30210. /** @hidden */
  30211. _position: Vector3;
  30212. /**
  30213. * Define the current local position of the camera in the scene
  30214. */
  30215. get position(): Vector3;
  30216. set position(newPosition: Vector3);
  30217. /**
  30218. * The vector the camera should consider as up.
  30219. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30220. */
  30221. upVector: Vector3;
  30222. /**
  30223. * Define the current limit on the left side for an orthographic camera
  30224. * In scene unit
  30225. */
  30226. orthoLeft: Nullable<number>;
  30227. /**
  30228. * Define the current limit on the right side for an orthographic camera
  30229. * In scene unit
  30230. */
  30231. orthoRight: Nullable<number>;
  30232. /**
  30233. * Define the current limit on the bottom side for an orthographic camera
  30234. * In scene unit
  30235. */
  30236. orthoBottom: Nullable<number>;
  30237. /**
  30238. * Define the current limit on the top side for an orthographic camera
  30239. * In scene unit
  30240. */
  30241. orthoTop: Nullable<number>;
  30242. /**
  30243. * Field Of View is set in Radians. (default is 0.8)
  30244. */
  30245. fov: number;
  30246. /**
  30247. * Define the minimum distance the camera can see from.
  30248. * This is important to note that the depth buffer are not infinite and the closer it starts
  30249. * the more your scene might encounter depth fighting issue.
  30250. */
  30251. minZ: number;
  30252. /**
  30253. * Define the maximum distance the camera can see to.
  30254. * This is important to note that the depth buffer are not infinite and the further it end
  30255. * the more your scene might encounter depth fighting issue.
  30256. */
  30257. maxZ: number;
  30258. /**
  30259. * Define the default inertia of the camera.
  30260. * This helps giving a smooth feeling to the camera movement.
  30261. */
  30262. inertia: number;
  30263. /**
  30264. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30265. */
  30266. mode: number;
  30267. /**
  30268. * Define whether the camera is intermediate.
  30269. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30270. */
  30271. isIntermediate: boolean;
  30272. /**
  30273. * Define the viewport of the camera.
  30274. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30275. */
  30276. viewport: Viewport;
  30277. /**
  30278. * Restricts the camera to viewing objects with the same layerMask.
  30279. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30280. */
  30281. layerMask: number;
  30282. /**
  30283. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30284. */
  30285. fovMode: number;
  30286. /**
  30287. * Rig mode of the camera.
  30288. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30289. * This is normally controlled byt the camera themselves as internal use.
  30290. */
  30291. cameraRigMode: number;
  30292. /**
  30293. * Defines the distance between both "eyes" in case of a RIG
  30294. */
  30295. interaxialDistance: number;
  30296. /**
  30297. * Defines if stereoscopic rendering is done side by side or over under.
  30298. */
  30299. isStereoscopicSideBySide: boolean;
  30300. /**
  30301. * 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
  30302. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30303. * else in the scene. (Eg. security camera)
  30304. *
  30305. * 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)
  30306. */
  30307. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30308. /**
  30309. * When set, the camera will render to this render target instead of the default canvas
  30310. *
  30311. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30312. */
  30313. outputRenderTarget: Nullable<RenderTargetTexture>;
  30314. /**
  30315. * Observable triggered when the camera view matrix has changed.
  30316. */
  30317. onViewMatrixChangedObservable: Observable<Camera>;
  30318. /**
  30319. * Observable triggered when the camera Projection matrix has changed.
  30320. */
  30321. onProjectionMatrixChangedObservable: Observable<Camera>;
  30322. /**
  30323. * Observable triggered when the inputs have been processed.
  30324. */
  30325. onAfterCheckInputsObservable: Observable<Camera>;
  30326. /**
  30327. * Observable triggered when reset has been called and applied to the camera.
  30328. */
  30329. onRestoreStateObservable: Observable<Camera>;
  30330. /**
  30331. * Is this camera a part of a rig system?
  30332. */
  30333. isRigCamera: boolean;
  30334. /**
  30335. * If isRigCamera set to true this will be set with the parent camera.
  30336. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30337. */
  30338. rigParent?: Camera;
  30339. /** @hidden */
  30340. _cameraRigParams: any;
  30341. /** @hidden */
  30342. _rigCameras: Camera[];
  30343. /** @hidden */
  30344. _rigPostProcess: Nullable<PostProcess>;
  30345. protected _webvrViewMatrix: Matrix;
  30346. /** @hidden */
  30347. _skipRendering: boolean;
  30348. /** @hidden */
  30349. _projectionMatrix: Matrix;
  30350. /** @hidden */
  30351. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30352. /** @hidden */
  30353. _activeMeshes: SmartArray<AbstractMesh>;
  30354. protected _globalPosition: Vector3;
  30355. /** @hidden */
  30356. _computedViewMatrix: Matrix;
  30357. private _doNotComputeProjectionMatrix;
  30358. private _transformMatrix;
  30359. private _frustumPlanes;
  30360. private _refreshFrustumPlanes;
  30361. private _storedFov;
  30362. private _stateStored;
  30363. /**
  30364. * Instantiates a new camera object.
  30365. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30366. * @see https://doc.babylonjs.com/features/cameras
  30367. * @param name Defines the name of the camera in the scene
  30368. * @param position Defines the position of the camera
  30369. * @param scene Defines the scene the camera belongs too
  30370. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30371. */
  30372. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30373. /**
  30374. * Store current camera state (fov, position, etc..)
  30375. * @returns the camera
  30376. */
  30377. storeState(): Camera;
  30378. /**
  30379. * Restores the camera state values if it has been stored. You must call storeState() first
  30380. */
  30381. protected _restoreStateValues(): boolean;
  30382. /**
  30383. * Restored camera state. You must call storeState() first.
  30384. * @returns true if restored and false otherwise
  30385. */
  30386. restoreState(): boolean;
  30387. /**
  30388. * Gets the class name of the camera.
  30389. * @returns the class name
  30390. */
  30391. getClassName(): string;
  30392. /** @hidden */
  30393. readonly _isCamera: boolean;
  30394. /**
  30395. * Gets a string representation of the camera useful for debug purpose.
  30396. * @param fullDetails Defines that a more verboe level of logging is required
  30397. * @returns the string representation
  30398. */
  30399. toString(fullDetails?: boolean): string;
  30400. /**
  30401. * Gets the current world space position of the camera.
  30402. */
  30403. get globalPosition(): Vector3;
  30404. /**
  30405. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30406. * @returns the active meshe list
  30407. */
  30408. getActiveMeshes(): SmartArray<AbstractMesh>;
  30409. /**
  30410. * Check whether a mesh is part of the current active mesh list of the camera
  30411. * @param mesh Defines the mesh to check
  30412. * @returns true if active, false otherwise
  30413. */
  30414. isActiveMesh(mesh: Mesh): boolean;
  30415. /**
  30416. * Is this camera ready to be used/rendered
  30417. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30418. * @return true if the camera is ready
  30419. */
  30420. isReady(completeCheck?: boolean): boolean;
  30421. /** @hidden */
  30422. _initCache(): void;
  30423. /** @hidden */
  30424. _updateCache(ignoreParentClass?: boolean): void;
  30425. /** @hidden */
  30426. _isSynchronized(): boolean;
  30427. /** @hidden */
  30428. _isSynchronizedViewMatrix(): boolean;
  30429. /** @hidden */
  30430. _isSynchronizedProjectionMatrix(): boolean;
  30431. /**
  30432. * Attach the input controls to a specific dom element to get the input from.
  30433. * @param element Defines the element the controls should be listened from
  30434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30435. */
  30436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30437. /**
  30438. * Detach the current controls from the specified dom element.
  30439. * @param element Defines the element to stop listening the inputs from
  30440. */
  30441. detachControl(element: HTMLElement): void;
  30442. /**
  30443. * Update the camera state according to the different inputs gathered during the frame.
  30444. */
  30445. update(): void;
  30446. /** @hidden */
  30447. _checkInputs(): void;
  30448. /** @hidden */
  30449. get rigCameras(): Camera[];
  30450. /**
  30451. * Gets the post process used by the rig cameras
  30452. */
  30453. get rigPostProcess(): Nullable<PostProcess>;
  30454. /**
  30455. * Internal, gets the first post proces.
  30456. * @returns the first post process to be run on this camera.
  30457. */
  30458. _getFirstPostProcess(): Nullable<PostProcess>;
  30459. private _cascadePostProcessesToRigCams;
  30460. /**
  30461. * Attach a post process to the camera.
  30462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30463. * @param postProcess The post process to attach to the camera
  30464. * @param insertAt The position of the post process in case several of them are in use in the scene
  30465. * @returns the position the post process has been inserted at
  30466. */
  30467. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30468. /**
  30469. * Detach a post process to the camera.
  30470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30471. * @param postProcess The post process to detach from the camera
  30472. */
  30473. detachPostProcess(postProcess: PostProcess): void;
  30474. /**
  30475. * Gets the current world matrix of the camera
  30476. */
  30477. getWorldMatrix(): Matrix;
  30478. /** @hidden */
  30479. _getViewMatrix(): Matrix;
  30480. /**
  30481. * Gets the current view matrix of the camera.
  30482. * @param force forces the camera to recompute the matrix without looking at the cached state
  30483. * @returns the view matrix
  30484. */
  30485. getViewMatrix(force?: boolean): Matrix;
  30486. /**
  30487. * Freeze the projection matrix.
  30488. * It will prevent the cache check of the camera projection compute and can speed up perf
  30489. * if no parameter of the camera are meant to change
  30490. * @param projection Defines manually a projection if necessary
  30491. */
  30492. freezeProjectionMatrix(projection?: Matrix): void;
  30493. /**
  30494. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30495. */
  30496. unfreezeProjectionMatrix(): void;
  30497. /**
  30498. * Gets the current projection matrix of the camera.
  30499. * @param force forces the camera to recompute the matrix without looking at the cached state
  30500. * @returns the projection matrix
  30501. */
  30502. getProjectionMatrix(force?: boolean): Matrix;
  30503. /**
  30504. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30505. * @returns a Matrix
  30506. */
  30507. getTransformationMatrix(): Matrix;
  30508. private _updateFrustumPlanes;
  30509. /**
  30510. * Checks if a cullable object (mesh...) is in the camera frustum
  30511. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30512. * @param target The object to check
  30513. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30514. * @returns true if the object is in frustum otherwise false
  30515. */
  30516. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30517. /**
  30518. * Checks if a cullable object (mesh...) is in the camera frustum
  30519. * Unlike isInFrustum this cheks the full bounding box
  30520. * @param target The object to check
  30521. * @returns true if the object is in frustum otherwise false
  30522. */
  30523. isCompletelyInFrustum(target: ICullable): boolean;
  30524. /**
  30525. * Gets a ray in the forward direction from the camera.
  30526. * @param length Defines the length of the ray to create
  30527. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30528. * @param origin Defines the start point of the ray which defaults to the camera position
  30529. * @returns the forward ray
  30530. */
  30531. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30532. /**
  30533. * Gets a ray in the forward direction from the camera.
  30534. * @param refRay the ray to (re)use when setting the values
  30535. * @param length Defines the length of the ray to create
  30536. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30537. * @param origin Defines the start point of the ray which defaults to the camera position
  30538. * @returns the forward ray
  30539. */
  30540. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30541. /**
  30542. * Releases resources associated with this node.
  30543. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30544. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30545. */
  30546. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30547. /** @hidden */
  30548. _isLeftCamera: boolean;
  30549. /**
  30550. * Gets the left camera of a rig setup in case of Rigged Camera
  30551. */
  30552. get isLeftCamera(): boolean;
  30553. /** @hidden */
  30554. _isRightCamera: boolean;
  30555. /**
  30556. * Gets the right camera of a rig setup in case of Rigged Camera
  30557. */
  30558. get isRightCamera(): boolean;
  30559. /**
  30560. * Gets the left camera of a rig setup in case of Rigged Camera
  30561. */
  30562. get leftCamera(): Nullable<FreeCamera>;
  30563. /**
  30564. * Gets the right camera of a rig setup in case of Rigged Camera
  30565. */
  30566. get rightCamera(): Nullable<FreeCamera>;
  30567. /**
  30568. * Gets the left camera target of a rig setup in case of Rigged Camera
  30569. * @returns the target position
  30570. */
  30571. getLeftTarget(): Nullable<Vector3>;
  30572. /**
  30573. * Gets the right camera target of a rig setup in case of Rigged Camera
  30574. * @returns the target position
  30575. */
  30576. getRightTarget(): Nullable<Vector3>;
  30577. /**
  30578. * @hidden
  30579. */
  30580. setCameraRigMode(mode: number, rigParams: any): void;
  30581. /** @hidden */
  30582. static _setStereoscopicRigMode(camera: Camera): void;
  30583. /** @hidden */
  30584. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30585. /** @hidden */
  30586. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30587. /** @hidden */
  30588. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30589. /** @hidden */
  30590. _getVRProjectionMatrix(): Matrix;
  30591. protected _updateCameraRotationMatrix(): void;
  30592. protected _updateWebVRCameraRotationMatrix(): void;
  30593. /**
  30594. * This function MUST be overwritten by the different WebVR cameras available.
  30595. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30596. * @hidden
  30597. */
  30598. _getWebVRProjectionMatrix(): Matrix;
  30599. /**
  30600. * This function MUST be overwritten by the different WebVR cameras available.
  30601. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30602. * @hidden
  30603. */
  30604. _getWebVRViewMatrix(): Matrix;
  30605. /** @hidden */
  30606. setCameraRigParameter(name: string, value: any): void;
  30607. /**
  30608. * needs to be overridden by children so sub has required properties to be copied
  30609. * @hidden
  30610. */
  30611. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30612. /**
  30613. * May need to be overridden by children
  30614. * @hidden
  30615. */
  30616. _updateRigCameras(): void;
  30617. /** @hidden */
  30618. _setupInputs(): void;
  30619. /**
  30620. * Serialiaze the camera setup to a json represention
  30621. * @returns the JSON representation
  30622. */
  30623. serialize(): any;
  30624. /**
  30625. * Clones the current camera.
  30626. * @param name The cloned camera name
  30627. * @returns the cloned camera
  30628. */
  30629. clone(name: string): Camera;
  30630. /**
  30631. * Gets the direction of the camera relative to a given local axis.
  30632. * @param localAxis Defines the reference axis to provide a relative direction.
  30633. * @return the direction
  30634. */
  30635. getDirection(localAxis: Vector3): Vector3;
  30636. /**
  30637. * Returns the current camera absolute rotation
  30638. */
  30639. get absoluteRotation(): Quaternion;
  30640. /**
  30641. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30642. * @param localAxis Defines the reference axis to provide a relative direction.
  30643. * @param result Defines the vector to store the result in
  30644. */
  30645. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30646. /**
  30647. * Gets a camera constructor for a given camera type
  30648. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30649. * @param name The name of the camera the result will be able to instantiate
  30650. * @param scene The scene the result will construct the camera in
  30651. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30652. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30653. * @returns a factory method to construc the camera
  30654. */
  30655. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30656. /**
  30657. * Compute the world matrix of the camera.
  30658. * @returns the camera world matrix
  30659. */
  30660. computeWorldMatrix(): Matrix;
  30661. /**
  30662. * Parse a JSON and creates the camera from the parsed information
  30663. * @param parsedCamera The JSON to parse
  30664. * @param scene The scene to instantiate the camera in
  30665. * @returns the newly constructed camera
  30666. */
  30667. static Parse(parsedCamera: any, scene: Scene): Camera;
  30668. }
  30669. }
  30670. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30671. import { Nullable } from "babylonjs/types";
  30672. import { Scene } from "babylonjs/scene";
  30673. import { Vector4 } from "babylonjs/Maths/math.vector";
  30674. import { Mesh } from "babylonjs/Meshes/mesh";
  30675. /**
  30676. * Class containing static functions to help procedurally build meshes
  30677. */
  30678. export class DiscBuilder {
  30679. /**
  30680. * Creates a plane polygonal mesh. By default, this is a disc
  30681. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30682. * * 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
  30683. * * 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
  30684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30687. * @param name defines the name of the mesh
  30688. * @param options defines the options used to create the mesh
  30689. * @param scene defines the hosting scene
  30690. * @returns the plane polygonal mesh
  30691. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30692. */
  30693. static CreateDisc(name: string, options: {
  30694. radius?: number;
  30695. tessellation?: number;
  30696. arc?: number;
  30697. updatable?: boolean;
  30698. sideOrientation?: number;
  30699. frontUVs?: Vector4;
  30700. backUVs?: Vector4;
  30701. }, scene?: Nullable<Scene>): Mesh;
  30702. }
  30703. }
  30704. declare module "babylonjs/Materials/fresnelParameters" {
  30705. import { DeepImmutable } from "babylonjs/types";
  30706. import { Color3 } from "babylonjs/Maths/math.color";
  30707. /**
  30708. * Options to be used when creating a FresnelParameters.
  30709. */
  30710. export type IFresnelParametersCreationOptions = {
  30711. /**
  30712. * Define the color used on edges (grazing angle)
  30713. */
  30714. leftColor?: Color3;
  30715. /**
  30716. * Define the color used on center
  30717. */
  30718. rightColor?: Color3;
  30719. /**
  30720. * Define bias applied to computed fresnel term
  30721. */
  30722. bias?: number;
  30723. /**
  30724. * Defined the power exponent applied to fresnel term
  30725. */
  30726. power?: number;
  30727. /**
  30728. * Define if the fresnel effect is enable or not.
  30729. */
  30730. isEnabled?: boolean;
  30731. };
  30732. /**
  30733. * Serialized format for FresnelParameters.
  30734. */
  30735. export type IFresnelParametersSerialized = {
  30736. /**
  30737. * Define the color used on edges (grazing angle) [as an array]
  30738. */
  30739. leftColor: number[];
  30740. /**
  30741. * Define the color used on center [as an array]
  30742. */
  30743. rightColor: number[];
  30744. /**
  30745. * Define bias applied to computed fresnel term
  30746. */
  30747. bias: number;
  30748. /**
  30749. * Defined the power exponent applied to fresnel term
  30750. */
  30751. power?: number;
  30752. /**
  30753. * Define if the fresnel effect is enable or not.
  30754. */
  30755. isEnabled: boolean;
  30756. };
  30757. /**
  30758. * This represents all the required information to add a fresnel effect on a material:
  30759. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30760. */
  30761. export class FresnelParameters {
  30762. private _isEnabled;
  30763. /**
  30764. * Define if the fresnel effect is enable or not.
  30765. */
  30766. get isEnabled(): boolean;
  30767. set isEnabled(value: boolean);
  30768. /**
  30769. * Define the color used on edges (grazing angle)
  30770. */
  30771. leftColor: Color3;
  30772. /**
  30773. * Define the color used on center
  30774. */
  30775. rightColor: Color3;
  30776. /**
  30777. * Define bias applied to computed fresnel term
  30778. */
  30779. bias: number;
  30780. /**
  30781. * Defined the power exponent applied to fresnel term
  30782. */
  30783. power: number;
  30784. /**
  30785. * Creates a new FresnelParameters object.
  30786. *
  30787. * @param options provide your own settings to optionally to override defaults
  30788. */
  30789. constructor(options?: IFresnelParametersCreationOptions);
  30790. /**
  30791. * Clones the current fresnel and its valuues
  30792. * @returns a clone fresnel configuration
  30793. */
  30794. clone(): FresnelParameters;
  30795. /**
  30796. * Determines equality between FresnelParameters objects
  30797. * @param otherFresnelParameters defines the second operand
  30798. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30799. */
  30800. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30801. /**
  30802. * Serializes the current fresnel parameters to a JSON representation.
  30803. * @return the JSON serialization
  30804. */
  30805. serialize(): IFresnelParametersSerialized;
  30806. /**
  30807. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30808. * @param parsedFresnelParameters Define the JSON representation
  30809. * @returns the parsed parameters
  30810. */
  30811. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30812. }
  30813. }
  30814. declare module "babylonjs/Materials/materialFlags" {
  30815. /**
  30816. * This groups all the flags used to control the materials channel.
  30817. */
  30818. export class MaterialFlags {
  30819. private static _DiffuseTextureEnabled;
  30820. /**
  30821. * Are diffuse textures enabled in the application.
  30822. */
  30823. static get DiffuseTextureEnabled(): boolean;
  30824. static set DiffuseTextureEnabled(value: boolean);
  30825. private static _DetailTextureEnabled;
  30826. /**
  30827. * Are detail textures enabled in the application.
  30828. */
  30829. static get DetailTextureEnabled(): boolean;
  30830. static set DetailTextureEnabled(value: boolean);
  30831. private static _AmbientTextureEnabled;
  30832. /**
  30833. * Are ambient textures enabled in the application.
  30834. */
  30835. static get AmbientTextureEnabled(): boolean;
  30836. static set AmbientTextureEnabled(value: boolean);
  30837. private static _OpacityTextureEnabled;
  30838. /**
  30839. * Are opacity textures enabled in the application.
  30840. */
  30841. static get OpacityTextureEnabled(): boolean;
  30842. static set OpacityTextureEnabled(value: boolean);
  30843. private static _ReflectionTextureEnabled;
  30844. /**
  30845. * Are reflection textures enabled in the application.
  30846. */
  30847. static get ReflectionTextureEnabled(): boolean;
  30848. static set ReflectionTextureEnabled(value: boolean);
  30849. private static _EmissiveTextureEnabled;
  30850. /**
  30851. * Are emissive textures enabled in the application.
  30852. */
  30853. static get EmissiveTextureEnabled(): boolean;
  30854. static set EmissiveTextureEnabled(value: boolean);
  30855. private static _SpecularTextureEnabled;
  30856. /**
  30857. * Are specular textures enabled in the application.
  30858. */
  30859. static get SpecularTextureEnabled(): boolean;
  30860. static set SpecularTextureEnabled(value: boolean);
  30861. private static _BumpTextureEnabled;
  30862. /**
  30863. * Are bump textures enabled in the application.
  30864. */
  30865. static get BumpTextureEnabled(): boolean;
  30866. static set BumpTextureEnabled(value: boolean);
  30867. private static _LightmapTextureEnabled;
  30868. /**
  30869. * Are lightmap textures enabled in the application.
  30870. */
  30871. static get LightmapTextureEnabled(): boolean;
  30872. static set LightmapTextureEnabled(value: boolean);
  30873. private static _RefractionTextureEnabled;
  30874. /**
  30875. * Are refraction textures enabled in the application.
  30876. */
  30877. static get RefractionTextureEnabled(): boolean;
  30878. static set RefractionTextureEnabled(value: boolean);
  30879. private static _ColorGradingTextureEnabled;
  30880. /**
  30881. * Are color grading textures enabled in the application.
  30882. */
  30883. static get ColorGradingTextureEnabled(): boolean;
  30884. static set ColorGradingTextureEnabled(value: boolean);
  30885. private static _FresnelEnabled;
  30886. /**
  30887. * Are fresnels enabled in the application.
  30888. */
  30889. static get FresnelEnabled(): boolean;
  30890. static set FresnelEnabled(value: boolean);
  30891. private static _ClearCoatTextureEnabled;
  30892. /**
  30893. * Are clear coat textures enabled in the application.
  30894. */
  30895. static get ClearCoatTextureEnabled(): boolean;
  30896. static set ClearCoatTextureEnabled(value: boolean);
  30897. private static _ClearCoatBumpTextureEnabled;
  30898. /**
  30899. * Are clear coat bump textures enabled in the application.
  30900. */
  30901. static get ClearCoatBumpTextureEnabled(): boolean;
  30902. static set ClearCoatBumpTextureEnabled(value: boolean);
  30903. private static _ClearCoatTintTextureEnabled;
  30904. /**
  30905. * Are clear coat tint textures enabled in the application.
  30906. */
  30907. static get ClearCoatTintTextureEnabled(): boolean;
  30908. static set ClearCoatTintTextureEnabled(value: boolean);
  30909. private static _SheenTextureEnabled;
  30910. /**
  30911. * Are sheen textures enabled in the application.
  30912. */
  30913. static get SheenTextureEnabled(): boolean;
  30914. static set SheenTextureEnabled(value: boolean);
  30915. private static _AnisotropicTextureEnabled;
  30916. /**
  30917. * Are anisotropic textures enabled in the application.
  30918. */
  30919. static get AnisotropicTextureEnabled(): boolean;
  30920. static set AnisotropicTextureEnabled(value: boolean);
  30921. private static _ThicknessTextureEnabled;
  30922. /**
  30923. * Are thickness textures enabled in the application.
  30924. */
  30925. static get ThicknessTextureEnabled(): boolean;
  30926. static set ThicknessTextureEnabled(value: boolean);
  30927. }
  30928. }
  30929. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30930. /** @hidden */
  30931. export var defaultFragmentDeclaration: {
  30932. name: string;
  30933. shader: string;
  30934. };
  30935. }
  30936. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30937. /** @hidden */
  30938. export var defaultUboDeclaration: {
  30939. name: string;
  30940. shader: string;
  30941. };
  30942. }
  30943. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  30944. /** @hidden */
  30945. export var prePassDeclaration: {
  30946. name: string;
  30947. shader: string;
  30948. };
  30949. }
  30950. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30951. /** @hidden */
  30952. export var lightFragmentDeclaration: {
  30953. name: string;
  30954. shader: string;
  30955. };
  30956. }
  30957. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30958. /** @hidden */
  30959. export var lightUboDeclaration: {
  30960. name: string;
  30961. shader: string;
  30962. };
  30963. }
  30964. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30965. /** @hidden */
  30966. export var lightsFragmentFunctions: {
  30967. name: string;
  30968. shader: string;
  30969. };
  30970. }
  30971. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30972. /** @hidden */
  30973. export var shadowsFragmentFunctions: {
  30974. name: string;
  30975. shader: string;
  30976. };
  30977. }
  30978. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30979. /** @hidden */
  30980. export var fresnelFunction: {
  30981. name: string;
  30982. shader: string;
  30983. };
  30984. }
  30985. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30986. /** @hidden */
  30987. export var bumpFragmentMainFunctions: {
  30988. name: string;
  30989. shader: string;
  30990. };
  30991. }
  30992. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30993. /** @hidden */
  30994. export var bumpFragmentFunctions: {
  30995. name: string;
  30996. shader: string;
  30997. };
  30998. }
  30999. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31000. /** @hidden */
  31001. export var logDepthDeclaration: {
  31002. name: string;
  31003. shader: string;
  31004. };
  31005. }
  31006. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31007. /** @hidden */
  31008. export var bumpFragment: {
  31009. name: string;
  31010. shader: string;
  31011. };
  31012. }
  31013. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31014. /** @hidden */
  31015. export var depthPrePass: {
  31016. name: string;
  31017. shader: string;
  31018. };
  31019. }
  31020. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31021. /** @hidden */
  31022. export var lightFragment: {
  31023. name: string;
  31024. shader: string;
  31025. };
  31026. }
  31027. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31028. /** @hidden */
  31029. export var logDepthFragment: {
  31030. name: string;
  31031. shader: string;
  31032. };
  31033. }
  31034. declare module "babylonjs/Shaders/default.fragment" {
  31035. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31036. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31037. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31038. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31039. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31040. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31041. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31042. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31043. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31044. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31045. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31046. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31047. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31048. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31049. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31050. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31051. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31052. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31053. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31054. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31055. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31056. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31057. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31058. /** @hidden */
  31059. export var defaultPixelShader: {
  31060. name: string;
  31061. shader: string;
  31062. };
  31063. }
  31064. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31065. /** @hidden */
  31066. export var defaultVertexDeclaration: {
  31067. name: string;
  31068. shader: string;
  31069. };
  31070. }
  31071. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31072. /** @hidden */
  31073. export var bumpVertexDeclaration: {
  31074. name: string;
  31075. shader: string;
  31076. };
  31077. }
  31078. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31079. /** @hidden */
  31080. export var bumpVertex: {
  31081. name: string;
  31082. shader: string;
  31083. };
  31084. }
  31085. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31086. /** @hidden */
  31087. export var fogVertex: {
  31088. name: string;
  31089. shader: string;
  31090. };
  31091. }
  31092. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31093. /** @hidden */
  31094. export var shadowsVertex: {
  31095. name: string;
  31096. shader: string;
  31097. };
  31098. }
  31099. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31100. /** @hidden */
  31101. export var pointCloudVertex: {
  31102. name: string;
  31103. shader: string;
  31104. };
  31105. }
  31106. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31107. /** @hidden */
  31108. export var logDepthVertex: {
  31109. name: string;
  31110. shader: string;
  31111. };
  31112. }
  31113. declare module "babylonjs/Shaders/default.vertex" {
  31114. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31115. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31116. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31117. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31118. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31119. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31120. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31121. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31122. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31123. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31124. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31125. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31126. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31127. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31128. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31129. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31130. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31131. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31132. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31133. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31134. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31135. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31136. /** @hidden */
  31137. export var defaultVertexShader: {
  31138. name: string;
  31139. shader: string;
  31140. };
  31141. }
  31142. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31143. import { Nullable } from "babylonjs/types";
  31144. import { Scene } from "babylonjs/scene";
  31145. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31146. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31147. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31148. /**
  31149. * @hidden
  31150. */
  31151. export interface IMaterialDetailMapDefines {
  31152. DETAIL: boolean;
  31153. DETAILDIRECTUV: number;
  31154. DETAIL_NORMALBLENDMETHOD: number;
  31155. /** @hidden */
  31156. _areTexturesDirty: boolean;
  31157. }
  31158. /**
  31159. * Define the code related to the detail map parameters of a material
  31160. *
  31161. * Inspired from:
  31162. * 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
  31163. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31164. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31165. */
  31166. export class DetailMapConfiguration {
  31167. private _texture;
  31168. /**
  31169. * The detail texture of the material.
  31170. */
  31171. texture: Nullable<BaseTexture>;
  31172. /**
  31173. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31174. * Bigger values mean stronger blending
  31175. */
  31176. diffuseBlendLevel: number;
  31177. /**
  31178. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31179. * Bigger values mean stronger blending. Only used with PBR materials
  31180. */
  31181. roughnessBlendLevel: number;
  31182. /**
  31183. * Defines how strong the bump effect from the detail map is
  31184. * Bigger values mean stronger effect
  31185. */
  31186. bumpLevel: number;
  31187. private _normalBlendMethod;
  31188. /**
  31189. * The method used to blend the bump and detail normals together
  31190. */
  31191. normalBlendMethod: number;
  31192. private _isEnabled;
  31193. /**
  31194. * Enable or disable the detail map on this material
  31195. */
  31196. isEnabled: boolean;
  31197. /** @hidden */
  31198. private _internalMarkAllSubMeshesAsTexturesDirty;
  31199. /** @hidden */
  31200. _markAllSubMeshesAsTexturesDirty(): void;
  31201. /**
  31202. * Instantiate a new detail map
  31203. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31204. */
  31205. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31206. /**
  31207. * Gets whether the submesh is ready to be used or not.
  31208. * @param defines the list of "defines" to update.
  31209. * @param scene defines the scene the material belongs to.
  31210. * @returns - boolean indicating that the submesh is ready or not.
  31211. */
  31212. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31213. /**
  31214. * Update the defines for detail map usage
  31215. * @param defines the list of "defines" to update.
  31216. * @param scene defines the scene the material belongs to.
  31217. */
  31218. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31219. /**
  31220. * Binds the material data.
  31221. * @param uniformBuffer defines the Uniform buffer to fill in.
  31222. * @param scene defines the scene the material belongs to.
  31223. * @param isFrozen defines whether the material is frozen or not.
  31224. */
  31225. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31226. /**
  31227. * Checks to see if a texture is used in the material.
  31228. * @param texture - Base texture to use.
  31229. * @returns - Boolean specifying if a texture is used in the material.
  31230. */
  31231. hasTexture(texture: BaseTexture): boolean;
  31232. /**
  31233. * Returns an array of the actively used textures.
  31234. * @param activeTextures Array of BaseTextures
  31235. */
  31236. getActiveTextures(activeTextures: BaseTexture[]): void;
  31237. /**
  31238. * Returns the animatable textures.
  31239. * @param animatables Array of animatable textures.
  31240. */
  31241. getAnimatables(animatables: IAnimatable[]): void;
  31242. /**
  31243. * Disposes the resources of the material.
  31244. * @param forceDisposeTextures - Forces the disposal of all textures.
  31245. */
  31246. dispose(forceDisposeTextures?: boolean): void;
  31247. /**
  31248. * Get the current class name useful for serialization or dynamic coding.
  31249. * @returns "DetailMap"
  31250. */
  31251. getClassName(): string;
  31252. /**
  31253. * Add the required uniforms to the current list.
  31254. * @param uniforms defines the current uniform list.
  31255. */
  31256. static AddUniforms(uniforms: string[]): void;
  31257. /**
  31258. * Add the required samplers to the current list.
  31259. * @param samplers defines the current sampler list.
  31260. */
  31261. static AddSamplers(samplers: string[]): void;
  31262. /**
  31263. * Add the required uniforms to the current buffer.
  31264. * @param uniformBuffer defines the current uniform buffer.
  31265. */
  31266. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31267. /**
  31268. * Makes a duplicate of the current instance into another one.
  31269. * @param detailMap define the instance where to copy the info
  31270. */
  31271. copyTo(detailMap: DetailMapConfiguration): void;
  31272. /**
  31273. * Serializes this detail map instance
  31274. * @returns - An object with the serialized instance.
  31275. */
  31276. serialize(): any;
  31277. /**
  31278. * Parses a detail map setting from a serialized object.
  31279. * @param source - Serialized object.
  31280. * @param scene Defines the scene we are parsing for
  31281. * @param rootUrl Defines the rootUrl to load from
  31282. */
  31283. parse(source: any, scene: Scene, rootUrl: string): void;
  31284. }
  31285. }
  31286. declare module "babylonjs/Materials/standardMaterial" {
  31287. import { SmartArray } from "babylonjs/Misc/smartArray";
  31288. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31289. import { Nullable } from "babylonjs/types";
  31290. import { Scene } from "babylonjs/scene";
  31291. import { Matrix } from "babylonjs/Maths/math.vector";
  31292. import { Color3 } from "babylonjs/Maths/math.color";
  31293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31295. import { Mesh } from "babylonjs/Meshes/mesh";
  31296. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31297. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31298. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31299. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31300. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31302. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31303. import "babylonjs/Shaders/default.fragment";
  31304. import "babylonjs/Shaders/default.vertex";
  31305. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31306. /** @hidden */
  31307. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31308. MAINUV1: boolean;
  31309. MAINUV2: boolean;
  31310. DIFFUSE: boolean;
  31311. DIFFUSEDIRECTUV: number;
  31312. DETAIL: boolean;
  31313. DETAILDIRECTUV: number;
  31314. DETAIL_NORMALBLENDMETHOD: number;
  31315. AMBIENT: boolean;
  31316. AMBIENTDIRECTUV: number;
  31317. OPACITY: boolean;
  31318. OPACITYDIRECTUV: number;
  31319. OPACITYRGB: boolean;
  31320. REFLECTION: boolean;
  31321. EMISSIVE: boolean;
  31322. EMISSIVEDIRECTUV: number;
  31323. SPECULAR: boolean;
  31324. SPECULARDIRECTUV: number;
  31325. BUMP: boolean;
  31326. BUMPDIRECTUV: number;
  31327. PARALLAX: boolean;
  31328. PARALLAXOCCLUSION: boolean;
  31329. SPECULAROVERALPHA: boolean;
  31330. CLIPPLANE: boolean;
  31331. CLIPPLANE2: boolean;
  31332. CLIPPLANE3: boolean;
  31333. CLIPPLANE4: boolean;
  31334. CLIPPLANE5: boolean;
  31335. CLIPPLANE6: boolean;
  31336. ALPHATEST: boolean;
  31337. DEPTHPREPASS: boolean;
  31338. ALPHAFROMDIFFUSE: boolean;
  31339. POINTSIZE: boolean;
  31340. FOG: boolean;
  31341. SPECULARTERM: boolean;
  31342. DIFFUSEFRESNEL: boolean;
  31343. OPACITYFRESNEL: boolean;
  31344. REFLECTIONFRESNEL: boolean;
  31345. REFRACTIONFRESNEL: boolean;
  31346. EMISSIVEFRESNEL: boolean;
  31347. FRESNEL: boolean;
  31348. NORMAL: boolean;
  31349. UV1: boolean;
  31350. UV2: boolean;
  31351. VERTEXCOLOR: boolean;
  31352. VERTEXALPHA: boolean;
  31353. NUM_BONE_INFLUENCERS: number;
  31354. BonesPerMesh: number;
  31355. BONETEXTURE: boolean;
  31356. INSTANCES: boolean;
  31357. THIN_INSTANCES: boolean;
  31358. GLOSSINESS: boolean;
  31359. ROUGHNESS: boolean;
  31360. EMISSIVEASILLUMINATION: boolean;
  31361. LINKEMISSIVEWITHDIFFUSE: boolean;
  31362. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31363. LIGHTMAP: boolean;
  31364. LIGHTMAPDIRECTUV: number;
  31365. OBJECTSPACE_NORMALMAP: boolean;
  31366. USELIGHTMAPASSHADOWMAP: boolean;
  31367. REFLECTIONMAP_3D: boolean;
  31368. REFLECTIONMAP_SPHERICAL: boolean;
  31369. REFLECTIONMAP_PLANAR: boolean;
  31370. REFLECTIONMAP_CUBIC: boolean;
  31371. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31372. REFLECTIONMAP_PROJECTION: boolean;
  31373. REFLECTIONMAP_SKYBOX: boolean;
  31374. REFLECTIONMAP_EXPLICIT: boolean;
  31375. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31376. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31377. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31378. INVERTCUBICMAP: boolean;
  31379. LOGARITHMICDEPTH: boolean;
  31380. REFRACTION: boolean;
  31381. REFRACTIONMAP_3D: boolean;
  31382. REFLECTIONOVERALPHA: boolean;
  31383. TWOSIDEDLIGHTING: boolean;
  31384. SHADOWFLOAT: boolean;
  31385. MORPHTARGETS: boolean;
  31386. MORPHTARGETS_NORMAL: boolean;
  31387. MORPHTARGETS_TANGENT: boolean;
  31388. MORPHTARGETS_UV: boolean;
  31389. NUM_MORPH_INFLUENCERS: number;
  31390. NONUNIFORMSCALING: boolean;
  31391. PREMULTIPLYALPHA: boolean;
  31392. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31393. ALPHABLEND: boolean;
  31394. PREPASS: boolean;
  31395. SCENE_MRT_COUNT: number;
  31396. RGBDLIGHTMAP: boolean;
  31397. RGBDREFLECTION: boolean;
  31398. RGBDREFRACTION: boolean;
  31399. IMAGEPROCESSING: boolean;
  31400. VIGNETTE: boolean;
  31401. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31402. VIGNETTEBLENDMODEOPAQUE: boolean;
  31403. TONEMAPPING: boolean;
  31404. TONEMAPPING_ACES: boolean;
  31405. CONTRAST: boolean;
  31406. COLORCURVES: boolean;
  31407. COLORGRADING: boolean;
  31408. COLORGRADING3D: boolean;
  31409. SAMPLER3DGREENDEPTH: boolean;
  31410. SAMPLER3DBGRMAP: boolean;
  31411. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31412. MULTIVIEW: boolean;
  31413. /**
  31414. * If the reflection texture on this material is in linear color space
  31415. * @hidden
  31416. */
  31417. IS_REFLECTION_LINEAR: boolean;
  31418. /**
  31419. * If the refraction texture on this material is in linear color space
  31420. * @hidden
  31421. */
  31422. IS_REFRACTION_LINEAR: boolean;
  31423. EXPOSURE: boolean;
  31424. constructor();
  31425. setReflectionMode(modeToEnable: string): void;
  31426. }
  31427. /**
  31428. * This is the default material used in Babylon. It is the best trade off between quality
  31429. * and performances.
  31430. * @see https://doc.babylonjs.com/babylon101/materials
  31431. */
  31432. export class StandardMaterial extends PushMaterial {
  31433. private _diffuseTexture;
  31434. /**
  31435. * The basic texture of the material as viewed under a light.
  31436. */
  31437. diffuseTexture: Nullable<BaseTexture>;
  31438. private _ambientTexture;
  31439. /**
  31440. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31441. */
  31442. ambientTexture: Nullable<BaseTexture>;
  31443. private _opacityTexture;
  31444. /**
  31445. * Define the transparency of the material from a texture.
  31446. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31447. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31448. */
  31449. opacityTexture: Nullable<BaseTexture>;
  31450. private _reflectionTexture;
  31451. /**
  31452. * Define the texture used to display the reflection.
  31453. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31454. */
  31455. reflectionTexture: Nullable<BaseTexture>;
  31456. private _emissiveTexture;
  31457. /**
  31458. * Define texture of the material as if self lit.
  31459. * This will be mixed in the final result even in the absence of light.
  31460. */
  31461. emissiveTexture: Nullable<BaseTexture>;
  31462. private _specularTexture;
  31463. /**
  31464. * Define how the color and intensity of the highlight given by the light in the material.
  31465. */
  31466. specularTexture: Nullable<BaseTexture>;
  31467. private _bumpTexture;
  31468. /**
  31469. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31470. * 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.
  31471. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31472. */
  31473. bumpTexture: Nullable<BaseTexture>;
  31474. private _lightmapTexture;
  31475. /**
  31476. * Complex lighting can be computationally expensive to compute at runtime.
  31477. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31478. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31479. */
  31480. lightmapTexture: Nullable<BaseTexture>;
  31481. private _refractionTexture;
  31482. /**
  31483. * Define the texture used to display the refraction.
  31484. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31485. */
  31486. refractionTexture: Nullable<BaseTexture>;
  31487. /**
  31488. * The color of the material lit by the environmental background lighting.
  31489. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31490. */
  31491. ambientColor: Color3;
  31492. /**
  31493. * The basic color of the material as viewed under a light.
  31494. */
  31495. diffuseColor: Color3;
  31496. /**
  31497. * Define how the color and intensity of the highlight given by the light in the material.
  31498. */
  31499. specularColor: Color3;
  31500. /**
  31501. * Define the color of the material as if self lit.
  31502. * This will be mixed in the final result even in the absence of light.
  31503. */
  31504. emissiveColor: Color3;
  31505. /**
  31506. * Defines how sharp are the highlights in the material.
  31507. * The bigger the value the sharper giving a more glossy feeling to the result.
  31508. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31509. */
  31510. specularPower: number;
  31511. private _useAlphaFromDiffuseTexture;
  31512. /**
  31513. * Does the transparency come from the diffuse texture alpha channel.
  31514. */
  31515. useAlphaFromDiffuseTexture: boolean;
  31516. private _useEmissiveAsIllumination;
  31517. /**
  31518. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31519. */
  31520. useEmissiveAsIllumination: boolean;
  31521. private _linkEmissiveWithDiffuse;
  31522. /**
  31523. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31524. * the emissive level when the final color is close to one.
  31525. */
  31526. linkEmissiveWithDiffuse: boolean;
  31527. private _useSpecularOverAlpha;
  31528. /**
  31529. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31530. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31531. */
  31532. useSpecularOverAlpha: boolean;
  31533. private _useReflectionOverAlpha;
  31534. /**
  31535. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31536. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31537. */
  31538. useReflectionOverAlpha: boolean;
  31539. private _disableLighting;
  31540. /**
  31541. * Does lights from the scene impacts this material.
  31542. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31543. */
  31544. disableLighting: boolean;
  31545. private _useObjectSpaceNormalMap;
  31546. /**
  31547. * Allows using an object space normal map (instead of tangent space).
  31548. */
  31549. useObjectSpaceNormalMap: boolean;
  31550. private _useParallax;
  31551. /**
  31552. * Is parallax enabled or not.
  31553. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31554. */
  31555. useParallax: boolean;
  31556. private _useParallaxOcclusion;
  31557. /**
  31558. * Is parallax occlusion enabled or not.
  31559. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31560. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31561. */
  31562. useParallaxOcclusion: boolean;
  31563. /**
  31564. * 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.
  31565. */
  31566. parallaxScaleBias: number;
  31567. private _roughness;
  31568. /**
  31569. * Helps to define how blurry the reflections should appears in the material.
  31570. */
  31571. roughness: number;
  31572. /**
  31573. * In case of refraction, define the value of the index of refraction.
  31574. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31575. */
  31576. indexOfRefraction: number;
  31577. /**
  31578. * Invert the refraction texture alongside the y axis.
  31579. * It can be useful with procedural textures or probe for instance.
  31580. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31581. */
  31582. invertRefractionY: boolean;
  31583. /**
  31584. * Defines the alpha limits in alpha test mode.
  31585. */
  31586. alphaCutOff: number;
  31587. private _useLightmapAsShadowmap;
  31588. /**
  31589. * In case of light mapping, define whether the map contains light or shadow informations.
  31590. */
  31591. useLightmapAsShadowmap: boolean;
  31592. private _diffuseFresnelParameters;
  31593. /**
  31594. * Define the diffuse fresnel parameters of the material.
  31595. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31596. */
  31597. diffuseFresnelParameters: FresnelParameters;
  31598. private _opacityFresnelParameters;
  31599. /**
  31600. * Define the opacity fresnel parameters of the material.
  31601. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31602. */
  31603. opacityFresnelParameters: FresnelParameters;
  31604. private _reflectionFresnelParameters;
  31605. /**
  31606. * Define the reflection fresnel parameters of the material.
  31607. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31608. */
  31609. reflectionFresnelParameters: FresnelParameters;
  31610. private _refractionFresnelParameters;
  31611. /**
  31612. * Define the refraction fresnel parameters of the material.
  31613. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31614. */
  31615. refractionFresnelParameters: FresnelParameters;
  31616. private _emissiveFresnelParameters;
  31617. /**
  31618. * Define the emissive fresnel parameters of the material.
  31619. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31620. */
  31621. emissiveFresnelParameters: FresnelParameters;
  31622. private _useReflectionFresnelFromSpecular;
  31623. /**
  31624. * If true automatically deducts the fresnels values from the material specularity.
  31625. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31626. */
  31627. useReflectionFresnelFromSpecular: boolean;
  31628. private _useGlossinessFromSpecularMapAlpha;
  31629. /**
  31630. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31631. */
  31632. useGlossinessFromSpecularMapAlpha: boolean;
  31633. private _maxSimultaneousLights;
  31634. /**
  31635. * Defines the maximum number of lights that can be used in the material
  31636. */
  31637. maxSimultaneousLights: number;
  31638. private _invertNormalMapX;
  31639. /**
  31640. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31641. */
  31642. invertNormalMapX: boolean;
  31643. private _invertNormalMapY;
  31644. /**
  31645. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31646. */
  31647. invertNormalMapY: boolean;
  31648. private _twoSidedLighting;
  31649. /**
  31650. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31651. */
  31652. twoSidedLighting: boolean;
  31653. /**
  31654. * Default configuration related to image processing available in the standard Material.
  31655. */
  31656. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31657. /**
  31658. * Gets the image processing configuration used either in this material.
  31659. */
  31660. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31661. /**
  31662. * Sets the Default image processing configuration used either in the this material.
  31663. *
  31664. * If sets to null, the scene one is in use.
  31665. */
  31666. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31667. /**
  31668. * Keep track of the image processing observer to allow dispose and replace.
  31669. */
  31670. private _imageProcessingObserver;
  31671. /**
  31672. * Attaches a new image processing configuration to the Standard Material.
  31673. * @param configuration
  31674. */
  31675. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31676. /**
  31677. * Gets wether the color curves effect is enabled.
  31678. */
  31679. get cameraColorCurvesEnabled(): boolean;
  31680. /**
  31681. * Sets wether the color curves effect is enabled.
  31682. */
  31683. set cameraColorCurvesEnabled(value: boolean);
  31684. /**
  31685. * Gets wether the color grading effect is enabled.
  31686. */
  31687. get cameraColorGradingEnabled(): boolean;
  31688. /**
  31689. * Gets wether the color grading effect is enabled.
  31690. */
  31691. set cameraColorGradingEnabled(value: boolean);
  31692. /**
  31693. * Gets wether tonemapping is enabled or not.
  31694. */
  31695. get cameraToneMappingEnabled(): boolean;
  31696. /**
  31697. * Sets wether tonemapping is enabled or not
  31698. */
  31699. set cameraToneMappingEnabled(value: boolean);
  31700. /**
  31701. * The camera exposure used on this material.
  31702. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31703. * This corresponds to a photographic exposure.
  31704. */
  31705. get cameraExposure(): number;
  31706. /**
  31707. * The camera exposure used on this material.
  31708. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31709. * This corresponds to a photographic exposure.
  31710. */
  31711. set cameraExposure(value: number);
  31712. /**
  31713. * Gets The camera contrast used on this material.
  31714. */
  31715. get cameraContrast(): number;
  31716. /**
  31717. * Sets The camera contrast used on this material.
  31718. */
  31719. set cameraContrast(value: number);
  31720. /**
  31721. * Gets the Color Grading 2D Lookup Texture.
  31722. */
  31723. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31724. /**
  31725. * Sets the Color Grading 2D Lookup Texture.
  31726. */
  31727. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31728. /**
  31729. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31730. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31731. * 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;
  31732. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31733. */
  31734. get cameraColorCurves(): Nullable<ColorCurves>;
  31735. /**
  31736. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31737. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31738. * 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;
  31739. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31740. */
  31741. set cameraColorCurves(value: Nullable<ColorCurves>);
  31742. /**
  31743. * Can this material render to several textures at once
  31744. */
  31745. get canRenderToMRT(): boolean;
  31746. /**
  31747. * Defines the detail map parameters for the material.
  31748. */
  31749. readonly detailMap: DetailMapConfiguration;
  31750. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31751. protected _worldViewProjectionMatrix: Matrix;
  31752. protected _globalAmbientColor: Color3;
  31753. protected _useLogarithmicDepth: boolean;
  31754. protected _rebuildInParallel: boolean;
  31755. /**
  31756. * Instantiates a new standard material.
  31757. * This is the default material used in Babylon. It is the best trade off between quality
  31758. * and performances.
  31759. * @see https://doc.babylonjs.com/babylon101/materials
  31760. * @param name Define the name of the material in the scene
  31761. * @param scene Define the scene the material belong to
  31762. */
  31763. constructor(name: string, scene: Scene);
  31764. /**
  31765. * Gets a boolean indicating that current material needs to register RTT
  31766. */
  31767. get hasRenderTargetTextures(): boolean;
  31768. /**
  31769. * Gets the current class name of the material e.g. "StandardMaterial"
  31770. * Mainly use in serialization.
  31771. * @returns the class name
  31772. */
  31773. getClassName(): string;
  31774. /**
  31775. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31776. * You can try switching to logarithmic depth.
  31777. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31778. */
  31779. get useLogarithmicDepth(): boolean;
  31780. set useLogarithmicDepth(value: boolean);
  31781. /**
  31782. * Specifies if the material will require alpha blending
  31783. * @returns a boolean specifying if alpha blending is needed
  31784. */
  31785. needAlphaBlending(): boolean;
  31786. /**
  31787. * Specifies if this material should be rendered in alpha test mode
  31788. * @returns a boolean specifying if an alpha test is needed.
  31789. */
  31790. needAlphaTesting(): boolean;
  31791. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31792. /**
  31793. * Get the texture used for alpha test purpose.
  31794. * @returns the diffuse texture in case of the standard material.
  31795. */
  31796. getAlphaTestTexture(): Nullable<BaseTexture>;
  31797. /**
  31798. * Get if the submesh is ready to be used and all its information available.
  31799. * Child classes can use it to update shaders
  31800. * @param mesh defines the mesh to check
  31801. * @param subMesh defines which submesh to check
  31802. * @param useInstances specifies that instances should be used
  31803. * @returns a boolean indicating that the submesh is ready or not
  31804. */
  31805. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31806. /**
  31807. * Builds the material UBO layouts.
  31808. * Used internally during the effect preparation.
  31809. */
  31810. buildUniformLayout(): void;
  31811. /**
  31812. * Unbinds the material from the mesh
  31813. */
  31814. unbind(): void;
  31815. /**
  31816. * Binds the submesh to this material by preparing the effect and shader to draw
  31817. * @param world defines the world transformation matrix
  31818. * @param mesh defines the mesh containing the submesh
  31819. * @param subMesh defines the submesh to bind the material to
  31820. */
  31821. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31822. /**
  31823. * Get the list of animatables in the material.
  31824. * @returns the list of animatables object used in the material
  31825. */
  31826. getAnimatables(): IAnimatable[];
  31827. /**
  31828. * Gets the active textures from the material
  31829. * @returns an array of textures
  31830. */
  31831. getActiveTextures(): BaseTexture[];
  31832. /**
  31833. * Specifies if the material uses a texture
  31834. * @param texture defines the texture to check against the material
  31835. * @returns a boolean specifying if the material uses the texture
  31836. */
  31837. hasTexture(texture: BaseTexture): boolean;
  31838. /**
  31839. * Disposes the material
  31840. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31841. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31842. */
  31843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31844. /**
  31845. * Makes a duplicate of the material, and gives it a new name
  31846. * @param name defines the new name for the duplicated material
  31847. * @returns the cloned material
  31848. */
  31849. clone(name: string): StandardMaterial;
  31850. /**
  31851. * Serializes this material in a JSON representation
  31852. * @returns the serialized material object
  31853. */
  31854. serialize(): any;
  31855. /**
  31856. * Creates a standard material from parsed material data
  31857. * @param source defines the JSON representation of the material
  31858. * @param scene defines the hosting scene
  31859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31860. * @returns a new standard material
  31861. */
  31862. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31863. /**
  31864. * Are diffuse textures enabled in the application.
  31865. */
  31866. static get DiffuseTextureEnabled(): boolean;
  31867. static set DiffuseTextureEnabled(value: boolean);
  31868. /**
  31869. * Are detail textures enabled in the application.
  31870. */
  31871. static get DetailTextureEnabled(): boolean;
  31872. static set DetailTextureEnabled(value: boolean);
  31873. /**
  31874. * Are ambient textures enabled in the application.
  31875. */
  31876. static get AmbientTextureEnabled(): boolean;
  31877. static set AmbientTextureEnabled(value: boolean);
  31878. /**
  31879. * Are opacity textures enabled in the application.
  31880. */
  31881. static get OpacityTextureEnabled(): boolean;
  31882. static set OpacityTextureEnabled(value: boolean);
  31883. /**
  31884. * Are reflection textures enabled in the application.
  31885. */
  31886. static get ReflectionTextureEnabled(): boolean;
  31887. static set ReflectionTextureEnabled(value: boolean);
  31888. /**
  31889. * Are emissive textures enabled in the application.
  31890. */
  31891. static get EmissiveTextureEnabled(): boolean;
  31892. static set EmissiveTextureEnabled(value: boolean);
  31893. /**
  31894. * Are specular textures enabled in the application.
  31895. */
  31896. static get SpecularTextureEnabled(): boolean;
  31897. static set SpecularTextureEnabled(value: boolean);
  31898. /**
  31899. * Are bump textures enabled in the application.
  31900. */
  31901. static get BumpTextureEnabled(): boolean;
  31902. static set BumpTextureEnabled(value: boolean);
  31903. /**
  31904. * Are lightmap textures enabled in the application.
  31905. */
  31906. static get LightmapTextureEnabled(): boolean;
  31907. static set LightmapTextureEnabled(value: boolean);
  31908. /**
  31909. * Are refraction textures enabled in the application.
  31910. */
  31911. static get RefractionTextureEnabled(): boolean;
  31912. static set RefractionTextureEnabled(value: boolean);
  31913. /**
  31914. * Are color grading textures enabled in the application.
  31915. */
  31916. static get ColorGradingTextureEnabled(): boolean;
  31917. static set ColorGradingTextureEnabled(value: boolean);
  31918. /**
  31919. * Are fresnels enabled in the application.
  31920. */
  31921. static get FresnelEnabled(): boolean;
  31922. static set FresnelEnabled(value: boolean);
  31923. }
  31924. }
  31925. declare module "babylonjs/Particles/solidParticleSystem" {
  31926. import { Nullable } from "babylonjs/types";
  31927. import { Mesh } from "babylonjs/Meshes/mesh";
  31928. import { Scene, IDisposable } from "babylonjs/scene";
  31929. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31930. import { Material } from "babylonjs/Materials/material";
  31931. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31932. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31933. /**
  31934. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31935. *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.
  31936. * The SPS is also a particle system. It provides some methods to manage the particles.
  31937. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31938. *
  31939. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31940. */
  31941. export class SolidParticleSystem implements IDisposable {
  31942. /**
  31943. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31944. * Example : var p = SPS.particles[i];
  31945. */
  31946. particles: SolidParticle[];
  31947. /**
  31948. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31949. */
  31950. nbParticles: number;
  31951. /**
  31952. * If the particles must ever face the camera (default false). Useful for planar particles.
  31953. */
  31954. billboard: boolean;
  31955. /**
  31956. * Recompute normals when adding a shape
  31957. */
  31958. recomputeNormals: boolean;
  31959. /**
  31960. * This a counter ofr your own usage. It's not set by any SPS functions.
  31961. */
  31962. counter: number;
  31963. /**
  31964. * The SPS name. This name is also given to the underlying mesh.
  31965. */
  31966. name: string;
  31967. /**
  31968. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31969. */
  31970. mesh: Mesh;
  31971. /**
  31972. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31973. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31974. */
  31975. vars: any;
  31976. /**
  31977. * This array is populated when the SPS is set as 'pickable'.
  31978. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31979. * Each element of this array is an object `{idx: int, faceId: int}`.
  31980. * `idx` is the picked particle index in the `SPS.particles` array
  31981. * `faceId` is the picked face index counted within this particle.
  31982. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31983. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31984. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31985. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31986. */
  31987. pickedParticles: {
  31988. idx: number;
  31989. faceId: number;
  31990. }[];
  31991. /**
  31992. * This array is populated when the SPS is set as 'pickable'
  31993. * Each key of this array is a submesh index.
  31994. * Each element of this array is a second array defined like this :
  31995. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31996. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31997. * `idx` is the picked particle index in the `SPS.particles` array
  31998. * `faceId` is the picked face index counted within this particle.
  31999. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32000. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32001. */
  32002. pickedBySubMesh: {
  32003. idx: number;
  32004. faceId: number;
  32005. }[][];
  32006. /**
  32007. * This array is populated when `enableDepthSort` is set to true.
  32008. * Each element of this array is an instance of the class DepthSortedParticle.
  32009. */
  32010. depthSortedParticles: DepthSortedParticle[];
  32011. /**
  32012. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32013. * @hidden
  32014. */
  32015. _bSphereOnly: boolean;
  32016. /**
  32017. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32018. * @hidden
  32019. */
  32020. _bSphereRadiusFactor: number;
  32021. private _scene;
  32022. private _positions;
  32023. private _indices;
  32024. private _normals;
  32025. private _colors;
  32026. private _uvs;
  32027. private _indices32;
  32028. private _positions32;
  32029. private _normals32;
  32030. private _fixedNormal32;
  32031. private _colors32;
  32032. private _uvs32;
  32033. private _index;
  32034. private _updatable;
  32035. private _pickable;
  32036. private _isVisibilityBoxLocked;
  32037. private _alwaysVisible;
  32038. private _depthSort;
  32039. private _expandable;
  32040. private _shapeCounter;
  32041. private _copy;
  32042. private _color;
  32043. private _computeParticleColor;
  32044. private _computeParticleTexture;
  32045. private _computeParticleRotation;
  32046. private _computeParticleVertex;
  32047. private _computeBoundingBox;
  32048. private _depthSortParticles;
  32049. private _camera;
  32050. private _mustUnrotateFixedNormals;
  32051. private _particlesIntersect;
  32052. private _needs32Bits;
  32053. private _isNotBuilt;
  32054. private _lastParticleId;
  32055. private _idxOfId;
  32056. private _multimaterialEnabled;
  32057. private _useModelMaterial;
  32058. private _indicesByMaterial;
  32059. private _materialIndexes;
  32060. private _depthSortFunction;
  32061. private _materialSortFunction;
  32062. private _materials;
  32063. private _multimaterial;
  32064. private _materialIndexesById;
  32065. private _defaultMaterial;
  32066. private _autoUpdateSubMeshes;
  32067. private _tmpVertex;
  32068. /**
  32069. * Creates a SPS (Solid Particle System) object.
  32070. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32071. * @param scene (Scene) is the scene in which the SPS is added.
  32072. * @param options defines the options of the sps e.g.
  32073. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32074. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32075. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32076. * * 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.
  32077. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32078. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32079. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32080. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32081. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32082. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32083. */
  32084. constructor(name: string, scene: Scene, options?: {
  32085. updatable?: boolean;
  32086. isPickable?: boolean;
  32087. enableDepthSort?: boolean;
  32088. particleIntersection?: boolean;
  32089. boundingSphereOnly?: boolean;
  32090. bSphereRadiusFactor?: number;
  32091. expandable?: boolean;
  32092. useModelMaterial?: boolean;
  32093. enableMultiMaterial?: boolean;
  32094. });
  32095. /**
  32096. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32097. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32098. * @returns the created mesh
  32099. */
  32100. buildMesh(): Mesh;
  32101. /**
  32102. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32103. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32104. * Thus the particles generated from `digest()` have their property `position` set yet.
  32105. * @param mesh ( Mesh ) is the mesh to be digested
  32106. * @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
  32107. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32108. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32109. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32110. * @returns the current SPS
  32111. */
  32112. digest(mesh: Mesh, options?: {
  32113. facetNb?: number;
  32114. number?: number;
  32115. delta?: number;
  32116. storage?: [];
  32117. }): SolidParticleSystem;
  32118. /**
  32119. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32120. * @hidden
  32121. */
  32122. private _unrotateFixedNormals;
  32123. /**
  32124. * Resets the temporary working copy particle
  32125. * @hidden
  32126. */
  32127. private _resetCopy;
  32128. /**
  32129. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32130. * @param p the current index in the positions array to be updated
  32131. * @param ind the current index in the indices array
  32132. * @param shape a Vector3 array, the shape geometry
  32133. * @param positions the positions array to be updated
  32134. * @param meshInd the shape indices array
  32135. * @param indices the indices array to be updated
  32136. * @param meshUV the shape uv array
  32137. * @param uvs the uv array to be updated
  32138. * @param meshCol the shape color array
  32139. * @param colors the color array to be updated
  32140. * @param meshNor the shape normals array
  32141. * @param normals the normals array to be updated
  32142. * @param idx the particle index
  32143. * @param idxInShape the particle index in its shape
  32144. * @param options the addShape() method passed options
  32145. * @model the particle model
  32146. * @hidden
  32147. */
  32148. private _meshBuilder;
  32149. /**
  32150. * Returns a shape Vector3 array from positions float array
  32151. * @param positions float array
  32152. * @returns a vector3 array
  32153. * @hidden
  32154. */
  32155. private _posToShape;
  32156. /**
  32157. * Returns a shapeUV array from a float uvs (array deep copy)
  32158. * @param uvs as a float array
  32159. * @returns a shapeUV array
  32160. * @hidden
  32161. */
  32162. private _uvsToShapeUV;
  32163. /**
  32164. * Adds a new particle object in the particles array
  32165. * @param idx particle index in particles array
  32166. * @param id particle id
  32167. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32168. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32169. * @param model particle ModelShape object
  32170. * @param shapeId model shape identifier
  32171. * @param idxInShape index of the particle in the current model
  32172. * @param bInfo model bounding info object
  32173. * @param storage target storage array, if any
  32174. * @hidden
  32175. */
  32176. private _addParticle;
  32177. /**
  32178. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32179. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32180. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32181. * @param nb (positive integer) the number of particles to be created from this model
  32182. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32183. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32184. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32185. * @returns the number of shapes in the system
  32186. */
  32187. addShape(mesh: Mesh, nb: number, options?: {
  32188. positionFunction?: any;
  32189. vertexFunction?: any;
  32190. storage?: [];
  32191. }): number;
  32192. /**
  32193. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32194. * @hidden
  32195. */
  32196. private _rebuildParticle;
  32197. /**
  32198. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32199. * @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.
  32200. * @returns the SPS.
  32201. */
  32202. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32203. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32204. * Returns an array with the removed particles.
  32205. * 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.
  32206. * The SPS can't be empty so at least one particle needs to remain in place.
  32207. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32208. * @param start index of the first particle to remove
  32209. * @param end index of the last particle to remove (included)
  32210. * @returns an array populated with the removed particles
  32211. */
  32212. removeParticles(start: number, end: number): SolidParticle[];
  32213. /**
  32214. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32215. * @param solidParticleArray an array populated with Solid Particles objects
  32216. * @returns the SPS
  32217. */
  32218. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32219. /**
  32220. * Creates a new particle and modifies the SPS mesh geometry :
  32221. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32222. * - calls _addParticle() to populate the particle array
  32223. * factorized code from addShape() and insertParticlesFromArray()
  32224. * @param idx particle index in the particles array
  32225. * @param i particle index in its shape
  32226. * @param modelShape particle ModelShape object
  32227. * @param shape shape vertex array
  32228. * @param meshInd shape indices array
  32229. * @param meshUV shape uv array
  32230. * @param meshCol shape color array
  32231. * @param meshNor shape normals array
  32232. * @param bbInfo shape bounding info
  32233. * @param storage target particle storage
  32234. * @options addShape() passed options
  32235. * @hidden
  32236. */
  32237. private _insertNewParticle;
  32238. /**
  32239. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32240. * This method calls `updateParticle()` for each particle of the SPS.
  32241. * For an animated SPS, it is usually called within the render loop.
  32242. * 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.
  32243. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32244. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32245. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32246. * @returns the SPS.
  32247. */
  32248. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32249. /**
  32250. * Disposes the SPS.
  32251. */
  32252. dispose(): void;
  32253. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32254. * idx is the particle index in the SPS
  32255. * faceId is the picked face index counted within this particle.
  32256. * Returns null if the pickInfo can't identify a picked particle.
  32257. * @param pickingInfo (PickingInfo object)
  32258. * @returns {idx: number, faceId: number} or null
  32259. */
  32260. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32261. idx: number;
  32262. faceId: number;
  32263. }>;
  32264. /**
  32265. * Returns a SolidParticle object from its identifier : particle.id
  32266. * @param id (integer) the particle Id
  32267. * @returns the searched particle or null if not found in the SPS.
  32268. */
  32269. getParticleById(id: number): Nullable<SolidParticle>;
  32270. /**
  32271. * Returns a new array populated with the particles having the passed shapeId.
  32272. * @param shapeId (integer) the shape identifier
  32273. * @returns a new solid particle array
  32274. */
  32275. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32276. /**
  32277. * Populates the passed array "ref" with the particles having the passed shapeId.
  32278. * @param shapeId the shape identifier
  32279. * @returns the SPS
  32280. * @param ref
  32281. */
  32282. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32283. /**
  32284. * Computes the required SubMeshes according the materials assigned to the particles.
  32285. * @returns the solid particle system.
  32286. * Does nothing if called before the SPS mesh is built.
  32287. */
  32288. computeSubMeshes(): SolidParticleSystem;
  32289. /**
  32290. * Sorts the solid particles by material when MultiMaterial is enabled.
  32291. * Updates the indices32 array.
  32292. * Updates the indicesByMaterial array.
  32293. * Updates the mesh indices array.
  32294. * @returns the SPS
  32295. * @hidden
  32296. */
  32297. private _sortParticlesByMaterial;
  32298. /**
  32299. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32300. * @hidden
  32301. */
  32302. private _setMaterialIndexesById;
  32303. /**
  32304. * Returns an array with unique values of Materials from the passed array
  32305. * @param array the material array to be checked and filtered
  32306. * @hidden
  32307. */
  32308. private _filterUniqueMaterialId;
  32309. /**
  32310. * Sets a new Standard Material as _defaultMaterial if not already set.
  32311. * @hidden
  32312. */
  32313. private _setDefaultMaterial;
  32314. /**
  32315. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32316. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32317. * @returns the SPS.
  32318. */
  32319. refreshVisibleSize(): SolidParticleSystem;
  32320. /**
  32321. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32322. * @param size the size (float) of the visibility box
  32323. * note : this doesn't lock the SPS mesh bounding box.
  32324. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32325. */
  32326. setVisibilityBox(size: number): void;
  32327. /**
  32328. * Gets whether the SPS as always visible or not
  32329. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32330. */
  32331. get isAlwaysVisible(): boolean;
  32332. /**
  32333. * Sets the SPS as always visible or not
  32334. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32335. */
  32336. set isAlwaysVisible(val: boolean);
  32337. /**
  32338. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32339. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32340. */
  32341. set isVisibilityBoxLocked(val: boolean);
  32342. /**
  32343. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32344. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32345. */
  32346. get isVisibilityBoxLocked(): boolean;
  32347. /**
  32348. * Tells to `setParticles()` to compute the particle rotations or not.
  32349. * Default value : true. The SPS is faster when it's set to false.
  32350. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32351. */
  32352. set computeParticleRotation(val: boolean);
  32353. /**
  32354. * Tells to `setParticles()` to compute the particle colors or not.
  32355. * Default value : true. The SPS is faster when it's set to false.
  32356. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32357. */
  32358. set computeParticleColor(val: boolean);
  32359. set computeParticleTexture(val: boolean);
  32360. /**
  32361. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32362. * Default value : false. The SPS is faster when it's set to false.
  32363. * Note : the particle custom vertex positions aren't stored values.
  32364. */
  32365. set computeParticleVertex(val: boolean);
  32366. /**
  32367. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32368. */
  32369. set computeBoundingBox(val: boolean);
  32370. /**
  32371. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32372. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32373. * Default : `true`
  32374. */
  32375. set depthSortParticles(val: boolean);
  32376. /**
  32377. * Gets if `setParticles()` computes the particle rotations or not.
  32378. * Default value : true. The SPS is faster when it's set to false.
  32379. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32380. */
  32381. get computeParticleRotation(): boolean;
  32382. /**
  32383. * Gets if `setParticles()` computes the particle colors or not.
  32384. * Default value : true. The SPS is faster when it's set to false.
  32385. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32386. */
  32387. get computeParticleColor(): boolean;
  32388. /**
  32389. * Gets if `setParticles()` computes the particle textures or not.
  32390. * Default value : true. The SPS is faster when it's set to false.
  32391. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32392. */
  32393. get computeParticleTexture(): boolean;
  32394. /**
  32395. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32396. * Default value : false. The SPS is faster when it's set to false.
  32397. * Note : the particle custom vertex positions aren't stored values.
  32398. */
  32399. get computeParticleVertex(): boolean;
  32400. /**
  32401. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32402. */
  32403. get computeBoundingBox(): boolean;
  32404. /**
  32405. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32406. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32407. * Default : `true`
  32408. */
  32409. get depthSortParticles(): boolean;
  32410. /**
  32411. * Gets if the SPS is created as expandable at construction time.
  32412. * Default : `false`
  32413. */
  32414. get expandable(): boolean;
  32415. /**
  32416. * Gets if the SPS supports the Multi Materials
  32417. */
  32418. get multimaterialEnabled(): boolean;
  32419. /**
  32420. * Gets if the SPS uses the model materials for its own multimaterial.
  32421. */
  32422. get useModelMaterial(): boolean;
  32423. /**
  32424. * The SPS used material array.
  32425. */
  32426. get materials(): Material[];
  32427. /**
  32428. * Sets the SPS MultiMaterial from the passed materials.
  32429. * Note : the passed array is internally copied and not used then by reference.
  32430. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32431. */
  32432. setMultiMaterial(materials: Material[]): void;
  32433. /**
  32434. * The SPS computed multimaterial object
  32435. */
  32436. get multimaterial(): MultiMaterial;
  32437. set multimaterial(mm: MultiMaterial);
  32438. /**
  32439. * If the subMeshes must be updated on the next call to setParticles()
  32440. */
  32441. get autoUpdateSubMeshes(): boolean;
  32442. set autoUpdateSubMeshes(val: boolean);
  32443. /**
  32444. * This function does nothing. It may be overwritten to set all the particle first values.
  32445. * The SPS doesn't call this function, you may have to call it by your own.
  32446. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32447. */
  32448. initParticles(): void;
  32449. /**
  32450. * This function does nothing. It may be overwritten to recycle a particle.
  32451. * The SPS doesn't call this function, you may have to call it by your own.
  32452. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32453. * @param particle The particle to recycle
  32454. * @returns the recycled particle
  32455. */
  32456. recycleParticle(particle: SolidParticle): SolidParticle;
  32457. /**
  32458. * Updates a particle : this function should be overwritten by the user.
  32459. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32460. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32461. * @example : just set a particle position or velocity and recycle conditions
  32462. * @param particle The particle to update
  32463. * @returns the updated particle
  32464. */
  32465. updateParticle(particle: SolidParticle): SolidParticle;
  32466. /**
  32467. * Updates a vertex of a particle : it can be overwritten by the user.
  32468. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32469. * @param particle the current particle
  32470. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32471. * @param pt the index of the current vertex in the particle shape
  32472. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32473. * @example : just set a vertex particle position or color
  32474. * @returns the sps
  32475. */
  32476. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32477. /**
  32478. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32479. * This does nothing and may be overwritten by the user.
  32480. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32481. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32482. * @param update the boolean update value actually passed to setParticles()
  32483. */
  32484. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32485. /**
  32486. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32487. * This will be passed three parameters.
  32488. * This does nothing and may be overwritten by the user.
  32489. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32490. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32491. * @param update the boolean update value actually passed to setParticles()
  32492. */
  32493. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32494. }
  32495. }
  32496. declare module "babylonjs/Particles/solidParticle" {
  32497. import { Nullable } from "babylonjs/types";
  32498. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32499. import { Color4 } from "babylonjs/Maths/math.color";
  32500. import { Mesh } from "babylonjs/Meshes/mesh";
  32501. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32502. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32503. import { Plane } from "babylonjs/Maths/math.plane";
  32504. import { Material } from "babylonjs/Materials/material";
  32505. /**
  32506. * Represents one particle of a solid particle system.
  32507. */
  32508. export class SolidParticle {
  32509. /**
  32510. * particle global index
  32511. */
  32512. idx: number;
  32513. /**
  32514. * particle identifier
  32515. */
  32516. id: number;
  32517. /**
  32518. * The color of the particle
  32519. */
  32520. color: Nullable<Color4>;
  32521. /**
  32522. * The world space position of the particle.
  32523. */
  32524. position: Vector3;
  32525. /**
  32526. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32527. */
  32528. rotation: Vector3;
  32529. /**
  32530. * The world space rotation quaternion of the particle.
  32531. */
  32532. rotationQuaternion: Nullable<Quaternion>;
  32533. /**
  32534. * The scaling of the particle.
  32535. */
  32536. scaling: Vector3;
  32537. /**
  32538. * The uvs of the particle.
  32539. */
  32540. uvs: Vector4;
  32541. /**
  32542. * The current speed of the particle.
  32543. */
  32544. velocity: Vector3;
  32545. /**
  32546. * The pivot point in the particle local space.
  32547. */
  32548. pivot: Vector3;
  32549. /**
  32550. * Must the particle be translated from its pivot point in its local space ?
  32551. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32552. * Default : false
  32553. */
  32554. translateFromPivot: boolean;
  32555. /**
  32556. * Is the particle active or not ?
  32557. */
  32558. alive: boolean;
  32559. /**
  32560. * Is the particle visible or not ?
  32561. */
  32562. isVisible: boolean;
  32563. /**
  32564. * Index of this particle in the global "positions" array (Internal use)
  32565. * @hidden
  32566. */
  32567. _pos: number;
  32568. /**
  32569. * @hidden Index of this particle in the global "indices" array (Internal use)
  32570. */
  32571. _ind: number;
  32572. /**
  32573. * @hidden ModelShape of this particle (Internal use)
  32574. */
  32575. _model: ModelShape;
  32576. /**
  32577. * ModelShape id of this particle
  32578. */
  32579. shapeId: number;
  32580. /**
  32581. * Index of the particle in its shape id
  32582. */
  32583. idxInShape: number;
  32584. /**
  32585. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32586. */
  32587. _modelBoundingInfo: BoundingInfo;
  32588. /**
  32589. * @hidden Particle BoundingInfo object (Internal use)
  32590. */
  32591. _boundingInfo: BoundingInfo;
  32592. /**
  32593. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32594. */
  32595. _sps: SolidParticleSystem;
  32596. /**
  32597. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32598. */
  32599. _stillInvisible: boolean;
  32600. /**
  32601. * @hidden Last computed particle rotation matrix
  32602. */
  32603. _rotationMatrix: number[];
  32604. /**
  32605. * Parent particle Id, if any.
  32606. * Default null.
  32607. */
  32608. parentId: Nullable<number>;
  32609. /**
  32610. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32611. */
  32612. materialIndex: Nullable<number>;
  32613. /**
  32614. * Custom object or properties.
  32615. */
  32616. props: Nullable<any>;
  32617. /**
  32618. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32619. * The possible values are :
  32620. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32621. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32622. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32623. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32624. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32625. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32626. * */
  32627. cullingStrategy: number;
  32628. /**
  32629. * @hidden Internal global position in the SPS.
  32630. */
  32631. _globalPosition: Vector3;
  32632. /**
  32633. * Creates a Solid Particle object.
  32634. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32635. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32636. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32637. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32638. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32639. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32640. * @param shapeId (integer) is the model shape identifier in the SPS.
  32641. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32642. * @param sps defines the sps it is associated to
  32643. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32644. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32645. */
  32646. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32647. /**
  32648. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32649. * @param target the particle target
  32650. * @returns the current particle
  32651. */
  32652. copyToRef(target: SolidParticle): SolidParticle;
  32653. /**
  32654. * Legacy support, changed scale to scaling
  32655. */
  32656. get scale(): Vector3;
  32657. /**
  32658. * Legacy support, changed scale to scaling
  32659. */
  32660. set scale(scale: Vector3);
  32661. /**
  32662. * Legacy support, changed quaternion to rotationQuaternion
  32663. */
  32664. get quaternion(): Nullable<Quaternion>;
  32665. /**
  32666. * Legacy support, changed quaternion to rotationQuaternion
  32667. */
  32668. set quaternion(q: Nullable<Quaternion>);
  32669. /**
  32670. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32671. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32672. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32673. * @returns true if it intersects
  32674. */
  32675. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32676. /**
  32677. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32678. * A particle is in the frustum if its bounding box intersects the frustum
  32679. * @param frustumPlanes defines the frustum to test
  32680. * @returns true if the particle is in the frustum planes
  32681. */
  32682. isInFrustum(frustumPlanes: Plane[]): boolean;
  32683. /**
  32684. * get the rotation matrix of the particle
  32685. * @hidden
  32686. */
  32687. getRotationMatrix(m: Matrix): void;
  32688. }
  32689. /**
  32690. * Represents the shape of the model used by one particle of a solid particle system.
  32691. * SPS internal tool, don't use it manually.
  32692. */
  32693. export class ModelShape {
  32694. /**
  32695. * The shape id
  32696. * @hidden
  32697. */
  32698. shapeID: number;
  32699. /**
  32700. * flat array of model positions (internal use)
  32701. * @hidden
  32702. */
  32703. _shape: Vector3[];
  32704. /**
  32705. * flat array of model UVs (internal use)
  32706. * @hidden
  32707. */
  32708. _shapeUV: number[];
  32709. /**
  32710. * color array of the model
  32711. * @hidden
  32712. */
  32713. _shapeColors: number[];
  32714. /**
  32715. * indices array of the model
  32716. * @hidden
  32717. */
  32718. _indices: number[];
  32719. /**
  32720. * normals array of the model
  32721. * @hidden
  32722. */
  32723. _normals: number[];
  32724. /**
  32725. * length of the shape in the model indices array (internal use)
  32726. * @hidden
  32727. */
  32728. _indicesLength: number;
  32729. /**
  32730. * Custom position function (internal use)
  32731. * @hidden
  32732. */
  32733. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32734. /**
  32735. * Custom vertex function (internal use)
  32736. * @hidden
  32737. */
  32738. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32739. /**
  32740. * Model material (internal use)
  32741. * @hidden
  32742. */
  32743. _material: Nullable<Material>;
  32744. /**
  32745. * 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.
  32746. * SPS internal tool, don't use it manually.
  32747. * @hidden
  32748. */
  32749. 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>);
  32750. }
  32751. /**
  32752. * Represents a Depth Sorted Particle in the solid particle system.
  32753. * @hidden
  32754. */
  32755. export class DepthSortedParticle {
  32756. /**
  32757. * Particle index
  32758. */
  32759. idx: number;
  32760. /**
  32761. * Index of the particle in the "indices" array
  32762. */
  32763. ind: number;
  32764. /**
  32765. * Length of the particle shape in the "indices" array
  32766. */
  32767. indicesLength: number;
  32768. /**
  32769. * Squared distance from the particle to the camera
  32770. */
  32771. sqDistance: number;
  32772. /**
  32773. * Material index when used with MultiMaterials
  32774. */
  32775. materialIndex: number;
  32776. /**
  32777. * Creates a new sorted particle
  32778. * @param materialIndex
  32779. */
  32780. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32781. }
  32782. /**
  32783. * Represents a solid particle vertex
  32784. */
  32785. export class SolidParticleVertex {
  32786. /**
  32787. * Vertex position
  32788. */
  32789. position: Vector3;
  32790. /**
  32791. * Vertex color
  32792. */
  32793. color: Color4;
  32794. /**
  32795. * Vertex UV
  32796. */
  32797. uv: Vector2;
  32798. /**
  32799. * Creates a new solid particle vertex
  32800. */
  32801. constructor();
  32802. /** Vertex x coordinate */
  32803. get x(): number;
  32804. set x(val: number);
  32805. /** Vertex y coordinate */
  32806. get y(): number;
  32807. set y(val: number);
  32808. /** Vertex z coordinate */
  32809. get z(): number;
  32810. set z(val: number);
  32811. }
  32812. }
  32813. declare module "babylonjs/Collisions/meshCollisionData" {
  32814. import { Collider } from "babylonjs/Collisions/collider";
  32815. import { Vector3 } from "babylonjs/Maths/math.vector";
  32816. import { Nullable } from "babylonjs/types";
  32817. import { Observer } from "babylonjs/Misc/observable";
  32818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32819. /**
  32820. * @hidden
  32821. */
  32822. export class _MeshCollisionData {
  32823. _checkCollisions: boolean;
  32824. _collisionMask: number;
  32825. _collisionGroup: number;
  32826. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32827. _collider: Nullable<Collider>;
  32828. _oldPositionForCollisions: Vector3;
  32829. _diffPositionForCollisions: Vector3;
  32830. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32831. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32832. }
  32833. }
  32834. declare module "babylonjs/Meshes/abstractMesh" {
  32835. import { Observable } from "babylonjs/Misc/observable";
  32836. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32837. import { Camera } from "babylonjs/Cameras/camera";
  32838. import { Scene, IDisposable } from "babylonjs/scene";
  32839. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32840. import { Node } from "babylonjs/node";
  32841. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32842. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32843. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32845. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32846. import { Material } from "babylonjs/Materials/material";
  32847. import { Light } from "babylonjs/Lights/light";
  32848. import { Skeleton } from "babylonjs/Bones/skeleton";
  32849. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32850. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32852. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32853. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32854. import { Plane } from "babylonjs/Maths/math.plane";
  32855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32856. import { Ray } from "babylonjs/Culling/ray";
  32857. import { Collider } from "babylonjs/Collisions/collider";
  32858. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32859. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32860. /** @hidden */
  32861. class _FacetDataStorage {
  32862. facetPositions: Vector3[];
  32863. facetNormals: Vector3[];
  32864. facetPartitioning: number[][];
  32865. facetNb: number;
  32866. partitioningSubdivisions: number;
  32867. partitioningBBoxRatio: number;
  32868. facetDataEnabled: boolean;
  32869. facetParameters: any;
  32870. bbSize: Vector3;
  32871. subDiv: {
  32872. max: number;
  32873. X: number;
  32874. Y: number;
  32875. Z: number;
  32876. };
  32877. facetDepthSort: boolean;
  32878. facetDepthSortEnabled: boolean;
  32879. depthSortedIndices: IndicesArray;
  32880. depthSortedFacets: {
  32881. ind: number;
  32882. sqDistance: number;
  32883. }[];
  32884. facetDepthSortFunction: (f1: {
  32885. ind: number;
  32886. sqDistance: number;
  32887. }, f2: {
  32888. ind: number;
  32889. sqDistance: number;
  32890. }) => number;
  32891. facetDepthSortFrom: Vector3;
  32892. facetDepthSortOrigin: Vector3;
  32893. invertedMatrix: Matrix;
  32894. }
  32895. /**
  32896. * @hidden
  32897. **/
  32898. class _InternalAbstractMeshDataInfo {
  32899. _hasVertexAlpha: boolean;
  32900. _useVertexColors: boolean;
  32901. _numBoneInfluencers: number;
  32902. _applyFog: boolean;
  32903. _receiveShadows: boolean;
  32904. _facetData: _FacetDataStorage;
  32905. _visibility: number;
  32906. _skeleton: Nullable<Skeleton>;
  32907. _layerMask: number;
  32908. _computeBonesUsingShaders: boolean;
  32909. _isActive: boolean;
  32910. _onlyForInstances: boolean;
  32911. _isActiveIntermediate: boolean;
  32912. _onlyForInstancesIntermediate: boolean;
  32913. _actAsRegularMesh: boolean;
  32914. }
  32915. /**
  32916. * Class used to store all common mesh properties
  32917. */
  32918. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32919. /** No occlusion */
  32920. static OCCLUSION_TYPE_NONE: number;
  32921. /** Occlusion set to optimisitic */
  32922. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32923. /** Occlusion set to strict */
  32924. static OCCLUSION_TYPE_STRICT: number;
  32925. /** Use an accurante occlusion algorithm */
  32926. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32927. /** Use a conservative occlusion algorithm */
  32928. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32929. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32930. * Test order :
  32931. * Is the bounding sphere outside the frustum ?
  32932. * If not, are the bounding box vertices outside the frustum ?
  32933. * It not, then the cullable object is in the frustum.
  32934. */
  32935. static readonly CULLINGSTRATEGY_STANDARD: number;
  32936. /** Culling strategy : Bounding Sphere Only.
  32937. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32938. * It's also less accurate than the standard because some not visible objects can still be selected.
  32939. * Test : is the bounding sphere outside the frustum ?
  32940. * If not, then the cullable object is in the frustum.
  32941. */
  32942. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32943. /** Culling strategy : Optimistic Inclusion.
  32944. * This in an inclusion test first, then the standard exclusion test.
  32945. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32946. * 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.
  32947. * Anyway, it's as accurate as the standard strategy.
  32948. * Test :
  32949. * Is the cullable object bounding sphere center in the frustum ?
  32950. * If not, apply the default culling strategy.
  32951. */
  32952. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32953. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32954. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32955. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32956. * 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.
  32957. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32958. * Test :
  32959. * Is the cullable object bounding sphere center in the frustum ?
  32960. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32961. */
  32962. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32963. /**
  32964. * No billboard
  32965. */
  32966. static get BILLBOARDMODE_NONE(): number;
  32967. /** Billboard on X axis */
  32968. static get BILLBOARDMODE_X(): number;
  32969. /** Billboard on Y axis */
  32970. static get BILLBOARDMODE_Y(): number;
  32971. /** Billboard on Z axis */
  32972. static get BILLBOARDMODE_Z(): number;
  32973. /** Billboard on all axes */
  32974. static get BILLBOARDMODE_ALL(): number;
  32975. /** Billboard on using position instead of orientation */
  32976. static get BILLBOARDMODE_USE_POSITION(): number;
  32977. /** @hidden */
  32978. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32979. /**
  32980. * The culling strategy to use to check whether the mesh must be rendered or not.
  32981. * This value can be changed at any time and will be used on the next render mesh selection.
  32982. * The possible values are :
  32983. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32984. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32985. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32986. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32987. * Please read each static variable documentation to get details about the culling process.
  32988. * */
  32989. cullingStrategy: number;
  32990. /**
  32991. * Gets the number of facets in the mesh
  32992. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32993. */
  32994. get facetNb(): number;
  32995. /**
  32996. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32997. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32998. */
  32999. get partitioningSubdivisions(): number;
  33000. set partitioningSubdivisions(nb: number);
  33001. /**
  33002. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33003. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33004. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33005. */
  33006. get partitioningBBoxRatio(): number;
  33007. set partitioningBBoxRatio(ratio: number);
  33008. /**
  33009. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33010. * Works only for updatable meshes.
  33011. * Doesn't work with multi-materials
  33012. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33013. */
  33014. get mustDepthSortFacets(): boolean;
  33015. set mustDepthSortFacets(sort: boolean);
  33016. /**
  33017. * The location (Vector3) where the facet depth sort must be computed from.
  33018. * By default, the active camera position.
  33019. * Used only when facet depth sort is enabled
  33020. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33021. */
  33022. get facetDepthSortFrom(): Vector3;
  33023. set facetDepthSortFrom(location: Vector3);
  33024. /**
  33025. * gets a boolean indicating if facetData is enabled
  33026. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33027. */
  33028. get isFacetDataEnabled(): boolean;
  33029. /** @hidden */
  33030. _updateNonUniformScalingState(value: boolean): boolean;
  33031. /**
  33032. * An event triggered when this mesh collides with another one
  33033. */
  33034. onCollideObservable: Observable<AbstractMesh>;
  33035. /** Set a function to call when this mesh collides with another one */
  33036. set onCollide(callback: () => void);
  33037. /**
  33038. * An event triggered when the collision's position changes
  33039. */
  33040. onCollisionPositionChangeObservable: Observable<Vector3>;
  33041. /** Set a function to call when the collision's position changes */
  33042. set onCollisionPositionChange(callback: () => void);
  33043. /**
  33044. * An event triggered when material is changed
  33045. */
  33046. onMaterialChangedObservable: Observable<AbstractMesh>;
  33047. /**
  33048. * Gets or sets the orientation for POV movement & rotation
  33049. */
  33050. definedFacingForward: boolean;
  33051. /** @hidden */
  33052. _occlusionQuery: Nullable<WebGLQuery>;
  33053. /** @hidden */
  33054. _renderingGroup: Nullable<RenderingGroup>;
  33055. /**
  33056. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33057. */
  33058. get visibility(): number;
  33059. /**
  33060. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33061. */
  33062. set visibility(value: number);
  33063. /** Gets or sets the alpha index used to sort transparent meshes
  33064. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33065. */
  33066. alphaIndex: number;
  33067. /**
  33068. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33069. */
  33070. isVisible: boolean;
  33071. /**
  33072. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33073. */
  33074. isPickable: boolean;
  33075. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33076. showSubMeshesBoundingBox: boolean;
  33077. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33078. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33079. */
  33080. isBlocker: boolean;
  33081. /**
  33082. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33083. */
  33084. enablePointerMoveEvents: boolean;
  33085. /**
  33086. * Specifies the rendering group id for this mesh (0 by default)
  33087. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33088. */
  33089. renderingGroupId: number;
  33090. private _material;
  33091. /** Gets or sets current material */
  33092. get material(): Nullable<Material>;
  33093. set material(value: Nullable<Material>);
  33094. /**
  33095. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33096. * @see https://doc.babylonjs.com/babylon101/shadows
  33097. */
  33098. get receiveShadows(): boolean;
  33099. set receiveShadows(value: boolean);
  33100. /** Defines color to use when rendering outline */
  33101. outlineColor: Color3;
  33102. /** Define width to use when rendering outline */
  33103. outlineWidth: number;
  33104. /** Defines color to use when rendering overlay */
  33105. overlayColor: Color3;
  33106. /** Defines alpha to use when rendering overlay */
  33107. overlayAlpha: number;
  33108. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33109. get hasVertexAlpha(): boolean;
  33110. set hasVertexAlpha(value: boolean);
  33111. /** 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) */
  33112. get useVertexColors(): boolean;
  33113. set useVertexColors(value: boolean);
  33114. /**
  33115. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33116. */
  33117. get computeBonesUsingShaders(): boolean;
  33118. set computeBonesUsingShaders(value: boolean);
  33119. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33120. get numBoneInfluencers(): number;
  33121. set numBoneInfluencers(value: number);
  33122. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33123. get applyFog(): boolean;
  33124. set applyFog(value: boolean);
  33125. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33126. useOctreeForRenderingSelection: boolean;
  33127. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33128. useOctreeForPicking: boolean;
  33129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33130. useOctreeForCollisions: boolean;
  33131. /**
  33132. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33133. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33134. */
  33135. get layerMask(): number;
  33136. set layerMask(value: number);
  33137. /**
  33138. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33139. */
  33140. alwaysSelectAsActiveMesh: boolean;
  33141. /**
  33142. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33143. */
  33144. doNotSyncBoundingInfo: boolean;
  33145. /**
  33146. * Gets or sets the current action manager
  33147. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33148. */
  33149. actionManager: Nullable<AbstractActionManager>;
  33150. private _meshCollisionData;
  33151. /**
  33152. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33153. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33154. */
  33155. ellipsoid: Vector3;
  33156. /**
  33157. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33158. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33159. */
  33160. ellipsoidOffset: Vector3;
  33161. /**
  33162. * Gets or sets a collision mask used to mask collisions (default is -1).
  33163. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33164. */
  33165. get collisionMask(): number;
  33166. set collisionMask(mask: number);
  33167. /**
  33168. * Gets or sets the current collision group mask (-1 by default).
  33169. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33170. */
  33171. get collisionGroup(): number;
  33172. set collisionGroup(mask: number);
  33173. /**
  33174. * Gets or sets current surrounding meshes (null by default).
  33175. *
  33176. * By default collision detection is tested against every mesh in the scene.
  33177. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33178. * meshes will be tested for the collision.
  33179. *
  33180. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33181. */
  33182. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33183. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33184. /**
  33185. * Defines edge width used when edgesRenderer is enabled
  33186. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33187. */
  33188. edgesWidth: number;
  33189. /**
  33190. * Defines edge color used when edgesRenderer is enabled
  33191. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33192. */
  33193. edgesColor: Color4;
  33194. /** @hidden */
  33195. _edgesRenderer: Nullable<IEdgesRenderer>;
  33196. /** @hidden */
  33197. _masterMesh: Nullable<AbstractMesh>;
  33198. /** @hidden */
  33199. _boundingInfo: Nullable<BoundingInfo>;
  33200. /** @hidden */
  33201. _renderId: number;
  33202. /**
  33203. * Gets or sets the list of subMeshes
  33204. * @see https://doc.babylonjs.com/how_to/multi_materials
  33205. */
  33206. subMeshes: SubMesh[];
  33207. /** @hidden */
  33208. _intersectionsInProgress: AbstractMesh[];
  33209. /** @hidden */
  33210. _unIndexed: boolean;
  33211. /** @hidden */
  33212. _lightSources: Light[];
  33213. /** Gets the list of lights affecting that mesh */
  33214. get lightSources(): Light[];
  33215. /** @hidden */
  33216. get _positions(): Nullable<Vector3[]>;
  33217. /** @hidden */
  33218. _waitingData: {
  33219. lods: Nullable<any>;
  33220. actions: Nullable<any>;
  33221. freezeWorldMatrix: Nullable<boolean>;
  33222. };
  33223. /** @hidden */
  33224. _bonesTransformMatrices: Nullable<Float32Array>;
  33225. /** @hidden */
  33226. _transformMatrixTexture: Nullable<RawTexture>;
  33227. /**
  33228. * Gets or sets a skeleton to apply skining transformations
  33229. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33230. */
  33231. set skeleton(value: Nullable<Skeleton>);
  33232. get skeleton(): Nullable<Skeleton>;
  33233. /**
  33234. * An event triggered when the mesh is rebuilt.
  33235. */
  33236. onRebuildObservable: Observable<AbstractMesh>;
  33237. /**
  33238. * Creates a new AbstractMesh
  33239. * @param name defines the name of the mesh
  33240. * @param scene defines the hosting scene
  33241. */
  33242. constructor(name: string, scene?: Nullable<Scene>);
  33243. /**
  33244. * Returns the string "AbstractMesh"
  33245. * @returns "AbstractMesh"
  33246. */
  33247. getClassName(): string;
  33248. /**
  33249. * Gets a string representation of the current mesh
  33250. * @param fullDetails defines a boolean indicating if full details must be included
  33251. * @returns a string representation of the current mesh
  33252. */
  33253. toString(fullDetails?: boolean): string;
  33254. /**
  33255. * @hidden
  33256. */
  33257. protected _getEffectiveParent(): Nullable<Node>;
  33258. /** @hidden */
  33259. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33260. /** @hidden */
  33261. _rebuild(): void;
  33262. /** @hidden */
  33263. _resyncLightSources(): void;
  33264. /** @hidden */
  33265. _resyncLightSource(light: Light): void;
  33266. /** @hidden */
  33267. _unBindEffect(): void;
  33268. /** @hidden */
  33269. _removeLightSource(light: Light, dispose: boolean): void;
  33270. private _markSubMeshesAsDirty;
  33271. /** @hidden */
  33272. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33273. /** @hidden */
  33274. _markSubMeshesAsAttributesDirty(): void;
  33275. /** @hidden */
  33276. _markSubMeshesAsMiscDirty(): void;
  33277. /**
  33278. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33279. */
  33280. get scaling(): Vector3;
  33281. set scaling(newScaling: Vector3);
  33282. /**
  33283. * Returns true if the mesh is blocked. Implemented by child classes
  33284. */
  33285. get isBlocked(): boolean;
  33286. /**
  33287. * Returns the mesh itself by default. Implemented by child classes
  33288. * @param camera defines the camera to use to pick the right LOD level
  33289. * @returns the currentAbstractMesh
  33290. */
  33291. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33292. /**
  33293. * Returns 0 by default. Implemented by child classes
  33294. * @returns an integer
  33295. */
  33296. getTotalVertices(): number;
  33297. /**
  33298. * Returns a positive integer : the total number of indices in this mesh geometry.
  33299. * @returns the numner of indices or zero if the mesh has no geometry.
  33300. */
  33301. getTotalIndices(): number;
  33302. /**
  33303. * Returns null by default. Implemented by child classes
  33304. * @returns null
  33305. */
  33306. getIndices(): Nullable<IndicesArray>;
  33307. /**
  33308. * Returns the array of the requested vertex data kind. Implemented by child classes
  33309. * @param kind defines the vertex data kind to use
  33310. * @returns null
  33311. */
  33312. getVerticesData(kind: string): Nullable<FloatArray>;
  33313. /**
  33314. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33315. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33316. * Note that a new underlying VertexBuffer object is created each call.
  33317. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33318. * @param kind defines vertex data kind:
  33319. * * VertexBuffer.PositionKind
  33320. * * VertexBuffer.UVKind
  33321. * * VertexBuffer.UV2Kind
  33322. * * VertexBuffer.UV3Kind
  33323. * * VertexBuffer.UV4Kind
  33324. * * VertexBuffer.UV5Kind
  33325. * * VertexBuffer.UV6Kind
  33326. * * VertexBuffer.ColorKind
  33327. * * VertexBuffer.MatricesIndicesKind
  33328. * * VertexBuffer.MatricesIndicesExtraKind
  33329. * * VertexBuffer.MatricesWeightsKind
  33330. * * VertexBuffer.MatricesWeightsExtraKind
  33331. * @param data defines the data source
  33332. * @param updatable defines if the data must be flagged as updatable (or static)
  33333. * @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
  33334. * @returns the current mesh
  33335. */
  33336. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33337. /**
  33338. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33339. * If the mesh has no geometry, it is simply returned as it is.
  33340. * @param kind defines vertex data kind:
  33341. * * VertexBuffer.PositionKind
  33342. * * VertexBuffer.UVKind
  33343. * * VertexBuffer.UV2Kind
  33344. * * VertexBuffer.UV3Kind
  33345. * * VertexBuffer.UV4Kind
  33346. * * VertexBuffer.UV5Kind
  33347. * * VertexBuffer.UV6Kind
  33348. * * VertexBuffer.ColorKind
  33349. * * VertexBuffer.MatricesIndicesKind
  33350. * * VertexBuffer.MatricesIndicesExtraKind
  33351. * * VertexBuffer.MatricesWeightsKind
  33352. * * VertexBuffer.MatricesWeightsExtraKind
  33353. * @param data defines the data source
  33354. * @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
  33355. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33356. * @returns the current mesh
  33357. */
  33358. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33359. /**
  33360. * Sets the mesh indices,
  33361. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33362. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33363. * @param totalVertices Defines the total number of vertices
  33364. * @returns the current mesh
  33365. */
  33366. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33367. /**
  33368. * Gets a boolean indicating if specific vertex data is present
  33369. * @param kind defines the vertex data kind to use
  33370. * @returns true is data kind is present
  33371. */
  33372. isVerticesDataPresent(kind: string): boolean;
  33373. /**
  33374. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33375. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33376. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33377. * @returns a BoundingInfo
  33378. */
  33379. getBoundingInfo(): BoundingInfo;
  33380. /**
  33381. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33382. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33383. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33384. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33385. * @returns the current mesh
  33386. */
  33387. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33388. /**
  33389. * Overwrite the current bounding info
  33390. * @param boundingInfo defines the new bounding info
  33391. * @returns the current mesh
  33392. */
  33393. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33394. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33395. get useBones(): boolean;
  33396. /** @hidden */
  33397. _preActivate(): void;
  33398. /** @hidden */
  33399. _preActivateForIntermediateRendering(renderId: number): void;
  33400. /** @hidden */
  33401. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33402. /** @hidden */
  33403. _postActivate(): void;
  33404. /** @hidden */
  33405. _freeze(): void;
  33406. /** @hidden */
  33407. _unFreeze(): void;
  33408. /**
  33409. * Gets the current world matrix
  33410. * @returns a Matrix
  33411. */
  33412. getWorldMatrix(): Matrix;
  33413. /** @hidden */
  33414. _getWorldMatrixDeterminant(): number;
  33415. /**
  33416. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33417. */
  33418. get isAnInstance(): boolean;
  33419. /**
  33420. * Gets a boolean indicating if this mesh has instances
  33421. */
  33422. get hasInstances(): boolean;
  33423. /**
  33424. * Gets a boolean indicating if this mesh has thin instances
  33425. */
  33426. get hasThinInstances(): boolean;
  33427. /**
  33428. * Perform relative position change from the point of view of behind the front of the mesh.
  33429. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33430. * Supports definition of mesh facing forward or backward
  33431. * @param amountRight defines the distance on the right axis
  33432. * @param amountUp defines the distance on the up axis
  33433. * @param amountForward defines the distance on the forward axis
  33434. * @returns the current mesh
  33435. */
  33436. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33437. /**
  33438. * Calculate relative position change from the point of view of behind the front of the mesh.
  33439. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33440. * Supports definition of mesh facing forward or backward
  33441. * @param amountRight defines the distance on the right axis
  33442. * @param amountUp defines the distance on the up axis
  33443. * @param amountForward defines the distance on the forward axis
  33444. * @returns the new displacement vector
  33445. */
  33446. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33447. /**
  33448. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33449. * Supports definition of mesh facing forward or backward
  33450. * @param flipBack defines the flip
  33451. * @param twirlClockwise defines the twirl
  33452. * @param tiltRight defines the tilt
  33453. * @returns the current mesh
  33454. */
  33455. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33456. /**
  33457. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33458. * Supports definition of mesh facing forward or backward.
  33459. * @param flipBack defines the flip
  33460. * @param twirlClockwise defines the twirl
  33461. * @param tiltRight defines the tilt
  33462. * @returns the new rotation vector
  33463. */
  33464. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33465. /**
  33466. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33467. * This means the mesh underlying bounding box and sphere are recomputed.
  33468. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33469. * @returns the current mesh
  33470. */
  33471. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33472. /** @hidden */
  33473. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33474. /** @hidden */
  33475. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33476. /** @hidden */
  33477. _updateBoundingInfo(): AbstractMesh;
  33478. /** @hidden */
  33479. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33480. /** @hidden */
  33481. protected _afterComputeWorldMatrix(): void;
  33482. /** @hidden */
  33483. get _effectiveMesh(): AbstractMesh;
  33484. /**
  33485. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33486. * A mesh is in the frustum if its bounding box intersects the frustum
  33487. * @param frustumPlanes defines the frustum to test
  33488. * @returns true if the mesh is in the frustum planes
  33489. */
  33490. isInFrustum(frustumPlanes: Plane[]): boolean;
  33491. /**
  33492. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33493. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33494. * @param frustumPlanes defines the frustum to test
  33495. * @returns true if the mesh is completely in the frustum planes
  33496. */
  33497. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33498. /**
  33499. * True if the mesh intersects another mesh or a SolidParticle object
  33500. * @param mesh defines a target mesh or SolidParticle to test
  33501. * @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)
  33502. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33503. * @returns true if there is an intersection
  33504. */
  33505. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33506. /**
  33507. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33508. * @param point defines the point to test
  33509. * @returns true if there is an intersection
  33510. */
  33511. intersectsPoint(point: Vector3): boolean;
  33512. /**
  33513. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33514. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33515. */
  33516. get checkCollisions(): boolean;
  33517. set checkCollisions(collisionEnabled: boolean);
  33518. /**
  33519. * Gets Collider object used to compute collisions (not physics)
  33520. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33521. */
  33522. get collider(): Nullable<Collider>;
  33523. /**
  33524. * Move the mesh using collision engine
  33525. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33526. * @param displacement defines the requested displacement vector
  33527. * @returns the current mesh
  33528. */
  33529. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33530. private _onCollisionPositionChange;
  33531. /** @hidden */
  33532. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33533. /** @hidden */
  33534. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33535. /** @hidden */
  33536. _checkCollision(collider: Collider): AbstractMesh;
  33537. /** @hidden */
  33538. _generatePointsArray(): boolean;
  33539. /**
  33540. * Checks if the passed Ray intersects with the mesh
  33541. * @param ray defines the ray to use
  33542. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33543. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33544. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33545. * @returns the picking info
  33546. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33547. */
  33548. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  33549. /**
  33550. * Clones the current mesh
  33551. * @param name defines the mesh name
  33552. * @param newParent defines the new mesh parent
  33553. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33554. * @returns the new mesh
  33555. */
  33556. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33557. /**
  33558. * Disposes all the submeshes of the current meshnp
  33559. * @returns the current mesh
  33560. */
  33561. releaseSubMeshes(): AbstractMesh;
  33562. /**
  33563. * Releases resources associated with this abstract mesh.
  33564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33566. */
  33567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33568. /**
  33569. * Adds the passed mesh as a child to the current mesh
  33570. * @param mesh defines the child mesh
  33571. * @returns the current mesh
  33572. */
  33573. addChild(mesh: AbstractMesh): AbstractMesh;
  33574. /**
  33575. * Removes the passed mesh from the current mesh children list
  33576. * @param mesh defines the child mesh
  33577. * @returns the current mesh
  33578. */
  33579. removeChild(mesh: AbstractMesh): AbstractMesh;
  33580. /** @hidden */
  33581. private _initFacetData;
  33582. /**
  33583. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33584. * This method can be called within the render loop.
  33585. * 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
  33586. * @returns the current mesh
  33587. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33588. */
  33589. updateFacetData(): AbstractMesh;
  33590. /**
  33591. * Returns the facetLocalNormals array.
  33592. * The normals are expressed in the mesh local spac
  33593. * @returns an array of Vector3
  33594. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33595. */
  33596. getFacetLocalNormals(): Vector3[];
  33597. /**
  33598. * Returns the facetLocalPositions array.
  33599. * The facet positions are expressed in the mesh local space
  33600. * @returns an array of Vector3
  33601. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33602. */
  33603. getFacetLocalPositions(): Vector3[];
  33604. /**
  33605. * Returns the facetLocalPartioning array
  33606. * @returns an array of array of numbers
  33607. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33608. */
  33609. getFacetLocalPartitioning(): number[][];
  33610. /**
  33611. * Returns the i-th facet position in the world system.
  33612. * This method allocates a new Vector3 per call
  33613. * @param i defines the facet index
  33614. * @returns a new Vector3
  33615. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33616. */
  33617. getFacetPosition(i: number): Vector3;
  33618. /**
  33619. * Sets the reference Vector3 with the i-th facet position in the world system
  33620. * @param i defines the facet index
  33621. * @param ref defines the target vector
  33622. * @returns the current mesh
  33623. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33624. */
  33625. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33626. /**
  33627. * Returns the i-th facet normal in the world system.
  33628. * This method allocates a new Vector3 per call
  33629. * @param i defines the facet index
  33630. * @returns a new Vector3
  33631. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33632. */
  33633. getFacetNormal(i: number): Vector3;
  33634. /**
  33635. * Sets the reference Vector3 with the i-th facet normal in the world system
  33636. * @param i defines the facet index
  33637. * @param ref defines the target vector
  33638. * @returns the current mesh
  33639. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33640. */
  33641. getFacetNormalToRef(i: number, ref: Vector3): this;
  33642. /**
  33643. * 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)
  33644. * @param x defines x coordinate
  33645. * @param y defines y coordinate
  33646. * @param z defines z coordinate
  33647. * @returns the array of facet indexes
  33648. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33649. */
  33650. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33651. /**
  33652. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33653. * @param projected sets as the (x,y,z) world projection on the facet
  33654. * @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
  33655. * @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
  33656. * @param x defines x coordinate
  33657. * @param y defines y coordinate
  33658. * @param z defines z coordinate
  33659. * @returns the face index if found (or null instead)
  33660. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33661. */
  33662. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33663. /**
  33664. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33665. * @param projected sets as the (x,y,z) local projection on the facet
  33666. * @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
  33667. * @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
  33668. * @param x defines x coordinate
  33669. * @param y defines y coordinate
  33670. * @param z defines z coordinate
  33671. * @returns the face index if found (or null instead)
  33672. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33673. */
  33674. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33675. /**
  33676. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33677. * @returns the parameters
  33678. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33679. */
  33680. getFacetDataParameters(): any;
  33681. /**
  33682. * Disables the feature FacetData and frees the related memory
  33683. * @returns the current mesh
  33684. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33685. */
  33686. disableFacetData(): AbstractMesh;
  33687. /**
  33688. * Updates the AbstractMesh indices array
  33689. * @param indices defines the data source
  33690. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33691. * @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)
  33692. * @returns the current mesh
  33693. */
  33694. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33695. /**
  33696. * Creates new normals data for the mesh
  33697. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33698. * @returns the current mesh
  33699. */
  33700. createNormals(updatable: boolean): AbstractMesh;
  33701. /**
  33702. * Align the mesh with a normal
  33703. * @param normal defines the normal to use
  33704. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33705. * @returns the current mesh
  33706. */
  33707. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33708. /** @hidden */
  33709. _checkOcclusionQuery(): boolean;
  33710. /**
  33711. * Disables the mesh edge rendering mode
  33712. * @returns the currentAbstractMesh
  33713. */
  33714. disableEdgesRendering(): AbstractMesh;
  33715. /**
  33716. * Enables the edge rendering mode on the mesh.
  33717. * This mode makes the mesh edges visible
  33718. * @param epsilon defines the maximal distance between two angles to detect a face
  33719. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33720. * @returns the currentAbstractMesh
  33721. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33722. */
  33723. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33724. /**
  33725. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33726. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33727. */
  33728. getConnectedParticleSystems(): IParticleSystem[];
  33729. }
  33730. }
  33731. declare module "babylonjs/Actions/actionEvent" {
  33732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33733. import { Nullable } from "babylonjs/types";
  33734. import { Sprite } from "babylonjs/Sprites/sprite";
  33735. import { Scene } from "babylonjs/scene";
  33736. import { Vector2 } from "babylonjs/Maths/math.vector";
  33737. /**
  33738. * Interface used to define ActionEvent
  33739. */
  33740. export interface IActionEvent {
  33741. /** The mesh or sprite that triggered the action */
  33742. source: any;
  33743. /** The X mouse cursor position at the time of the event */
  33744. pointerX: number;
  33745. /** The Y mouse cursor position at the time of the event */
  33746. pointerY: number;
  33747. /** The mesh that is currently pointed at (can be null) */
  33748. meshUnderPointer: Nullable<AbstractMesh>;
  33749. /** the original (browser) event that triggered the ActionEvent */
  33750. sourceEvent?: any;
  33751. /** additional data for the event */
  33752. additionalData?: any;
  33753. }
  33754. /**
  33755. * ActionEvent is the event being sent when an action is triggered.
  33756. */
  33757. export class ActionEvent implements IActionEvent {
  33758. /** The mesh or sprite that triggered the action */
  33759. source: any;
  33760. /** The X mouse cursor position at the time of the event */
  33761. pointerX: number;
  33762. /** The Y mouse cursor position at the time of the event */
  33763. pointerY: number;
  33764. /** The mesh that is currently pointed at (can be null) */
  33765. meshUnderPointer: Nullable<AbstractMesh>;
  33766. /** the original (browser) event that triggered the ActionEvent */
  33767. sourceEvent?: any;
  33768. /** additional data for the event */
  33769. additionalData?: any;
  33770. /**
  33771. * Creates a new ActionEvent
  33772. * @param source The mesh or sprite that triggered the action
  33773. * @param pointerX The X mouse cursor position at the time of the event
  33774. * @param pointerY The Y mouse cursor position at the time of the event
  33775. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33776. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33777. * @param additionalData additional data for the event
  33778. */
  33779. constructor(
  33780. /** The mesh or sprite that triggered the action */
  33781. source: any,
  33782. /** The X mouse cursor position at the time of the event */
  33783. pointerX: number,
  33784. /** The Y mouse cursor position at the time of the event */
  33785. pointerY: number,
  33786. /** The mesh that is currently pointed at (can be null) */
  33787. meshUnderPointer: Nullable<AbstractMesh>,
  33788. /** the original (browser) event that triggered the ActionEvent */
  33789. sourceEvent?: any,
  33790. /** additional data for the event */
  33791. additionalData?: any);
  33792. /**
  33793. * Helper function to auto-create an ActionEvent from a source mesh.
  33794. * @param source The source mesh that triggered the event
  33795. * @param evt The original (browser) event
  33796. * @param additionalData additional data for the event
  33797. * @returns the new ActionEvent
  33798. */
  33799. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33800. /**
  33801. * Helper function to auto-create an ActionEvent from a source sprite
  33802. * @param source The source sprite that triggered the event
  33803. * @param scene Scene associated with the sprite
  33804. * @param evt The original (browser) event
  33805. * @param additionalData additional data for the event
  33806. * @returns the new ActionEvent
  33807. */
  33808. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33809. /**
  33810. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33811. * @param scene the scene where the event occurred
  33812. * @param evt The original (browser) event
  33813. * @returns the new ActionEvent
  33814. */
  33815. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33816. /**
  33817. * Helper function to auto-create an ActionEvent from a primitive
  33818. * @param prim defines the target primitive
  33819. * @param pointerPos defines the pointer position
  33820. * @param evt The original (browser) event
  33821. * @param additionalData additional data for the event
  33822. * @returns the new ActionEvent
  33823. */
  33824. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33825. }
  33826. }
  33827. declare module "babylonjs/Actions/abstractActionManager" {
  33828. import { IDisposable } from "babylonjs/scene";
  33829. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33830. import { IAction } from "babylonjs/Actions/action";
  33831. import { Nullable } from "babylonjs/types";
  33832. /**
  33833. * Abstract class used to decouple action Manager from scene and meshes.
  33834. * Do not instantiate.
  33835. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33836. */
  33837. export abstract class AbstractActionManager implements IDisposable {
  33838. /** Gets the list of active triggers */
  33839. static Triggers: {
  33840. [key: string]: number;
  33841. };
  33842. /** Gets the cursor to use when hovering items */
  33843. hoverCursor: string;
  33844. /** Gets the list of actions */
  33845. actions: IAction[];
  33846. /**
  33847. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33848. */
  33849. isRecursive: boolean;
  33850. /**
  33851. * Releases all associated resources
  33852. */
  33853. abstract dispose(): void;
  33854. /**
  33855. * Does this action manager has pointer triggers
  33856. */
  33857. abstract get hasPointerTriggers(): boolean;
  33858. /**
  33859. * Does this action manager has pick triggers
  33860. */
  33861. abstract get hasPickTriggers(): boolean;
  33862. /**
  33863. * Process a specific trigger
  33864. * @param trigger defines the trigger to process
  33865. * @param evt defines the event details to be processed
  33866. */
  33867. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33868. /**
  33869. * Does this action manager handles actions of any of the given triggers
  33870. * @param triggers defines the triggers to be tested
  33871. * @return a boolean indicating whether one (or more) of the triggers is handled
  33872. */
  33873. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33874. /**
  33875. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33876. * speed.
  33877. * @param triggerA defines the trigger to be tested
  33878. * @param triggerB defines the trigger to be tested
  33879. * @return a boolean indicating whether one (or more) of the triggers is handled
  33880. */
  33881. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33882. /**
  33883. * Does this action manager handles actions of a given trigger
  33884. * @param trigger defines the trigger to be tested
  33885. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33886. * @return whether the trigger is handled
  33887. */
  33888. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33889. /**
  33890. * Serialize this manager to a JSON object
  33891. * @param name defines the property name to store this manager
  33892. * @returns a JSON representation of this manager
  33893. */
  33894. abstract serialize(name: string): any;
  33895. /**
  33896. * Registers an action to this action manager
  33897. * @param action defines the action to be registered
  33898. * @return the action amended (prepared) after registration
  33899. */
  33900. abstract registerAction(action: IAction): Nullable<IAction>;
  33901. /**
  33902. * Unregisters an action to this action manager
  33903. * @param action defines the action to be unregistered
  33904. * @return a boolean indicating whether the action has been unregistered
  33905. */
  33906. abstract unregisterAction(action: IAction): Boolean;
  33907. /**
  33908. * Does exist one action manager with at least one trigger
  33909. **/
  33910. static get HasTriggers(): boolean;
  33911. /**
  33912. * Does exist one action manager with at least one pick trigger
  33913. **/
  33914. static get HasPickTriggers(): boolean;
  33915. /**
  33916. * Does exist one action manager that handles actions of a given trigger
  33917. * @param trigger defines the trigger to be tested
  33918. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33919. **/
  33920. static HasSpecificTrigger(trigger: number): boolean;
  33921. }
  33922. }
  33923. declare module "babylonjs/node" {
  33924. import { Scene } from "babylonjs/scene";
  33925. import { Nullable } from "babylonjs/types";
  33926. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33927. import { Engine } from "babylonjs/Engines/engine";
  33928. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33929. import { Observable } from "babylonjs/Misc/observable";
  33930. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33931. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33932. import { Animatable } from "babylonjs/Animations/animatable";
  33933. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33934. import { Animation } from "babylonjs/Animations/animation";
  33935. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33937. /**
  33938. * Defines how a node can be built from a string name.
  33939. */
  33940. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33941. /**
  33942. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33943. */
  33944. export class Node implements IBehaviorAware<Node> {
  33945. /** @hidden */
  33946. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33947. private static _NodeConstructors;
  33948. /**
  33949. * Add a new node constructor
  33950. * @param type defines the type name of the node to construct
  33951. * @param constructorFunc defines the constructor function
  33952. */
  33953. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33954. /**
  33955. * Returns a node constructor based on type name
  33956. * @param type defines the type name
  33957. * @param name defines the new node name
  33958. * @param scene defines the hosting scene
  33959. * @param options defines optional options to transmit to constructors
  33960. * @returns the new constructor or null
  33961. */
  33962. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33963. /**
  33964. * Gets or sets the name of the node
  33965. */
  33966. name: string;
  33967. /**
  33968. * Gets or sets the id of the node
  33969. */
  33970. id: string;
  33971. /**
  33972. * Gets or sets the unique id of the node
  33973. */
  33974. uniqueId: number;
  33975. /**
  33976. * Gets or sets a string used to store user defined state for the node
  33977. */
  33978. state: string;
  33979. /**
  33980. * Gets or sets an object used to store user defined information for the node
  33981. */
  33982. metadata: any;
  33983. /**
  33984. * For internal use only. Please do not use.
  33985. */
  33986. reservedDataStore: any;
  33987. /**
  33988. * List of inspectable custom properties (used by the Inspector)
  33989. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33990. */
  33991. inspectableCustomProperties: IInspectable[];
  33992. private _doNotSerialize;
  33993. /**
  33994. * Gets or sets a boolean used to define if the node must be serialized
  33995. */
  33996. get doNotSerialize(): boolean;
  33997. set doNotSerialize(value: boolean);
  33998. /** @hidden */
  33999. _isDisposed: boolean;
  34000. /**
  34001. * Gets a list of Animations associated with the node
  34002. */
  34003. animations: import("babylonjs/Animations/animation").Animation[];
  34004. protected _ranges: {
  34005. [name: string]: Nullable<AnimationRange>;
  34006. };
  34007. /**
  34008. * Callback raised when the node is ready to be used
  34009. */
  34010. onReady: Nullable<(node: Node) => void>;
  34011. private _isEnabled;
  34012. private _isParentEnabled;
  34013. private _isReady;
  34014. /** @hidden */
  34015. _currentRenderId: number;
  34016. private _parentUpdateId;
  34017. /** @hidden */
  34018. _childUpdateId: number;
  34019. /** @hidden */
  34020. _waitingParentId: Nullable<string>;
  34021. /** @hidden */
  34022. _scene: Scene;
  34023. /** @hidden */
  34024. _cache: any;
  34025. private _parentNode;
  34026. private _children;
  34027. /** @hidden */
  34028. _worldMatrix: Matrix;
  34029. /** @hidden */
  34030. _worldMatrixDeterminant: number;
  34031. /** @hidden */
  34032. _worldMatrixDeterminantIsDirty: boolean;
  34033. /** @hidden */
  34034. private _sceneRootNodesIndex;
  34035. /**
  34036. * Gets a boolean indicating if the node has been disposed
  34037. * @returns true if the node was disposed
  34038. */
  34039. isDisposed(): boolean;
  34040. /**
  34041. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34042. * @see https://doc.babylonjs.com/how_to/parenting
  34043. */
  34044. set parent(parent: Nullable<Node>);
  34045. get parent(): Nullable<Node>;
  34046. /** @hidden */
  34047. _addToSceneRootNodes(): void;
  34048. /** @hidden */
  34049. _removeFromSceneRootNodes(): void;
  34050. private _animationPropertiesOverride;
  34051. /**
  34052. * Gets or sets the animation properties override
  34053. */
  34054. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34055. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34056. /**
  34057. * Gets a string idenfifying the name of the class
  34058. * @returns "Node" string
  34059. */
  34060. getClassName(): string;
  34061. /** @hidden */
  34062. readonly _isNode: boolean;
  34063. /**
  34064. * An event triggered when the mesh is disposed
  34065. */
  34066. onDisposeObservable: Observable<Node>;
  34067. private _onDisposeObserver;
  34068. /**
  34069. * Sets a callback that will be raised when the node will be disposed
  34070. */
  34071. set onDispose(callback: () => void);
  34072. /**
  34073. * Creates a new Node
  34074. * @param name the name and id to be given to this node
  34075. * @param scene the scene this node will be added to
  34076. */
  34077. constructor(name: string, scene?: Nullable<Scene>);
  34078. /**
  34079. * Gets the scene of the node
  34080. * @returns a scene
  34081. */
  34082. getScene(): Scene;
  34083. /**
  34084. * Gets the engine of the node
  34085. * @returns a Engine
  34086. */
  34087. getEngine(): Engine;
  34088. private _behaviors;
  34089. /**
  34090. * Attach a behavior to the node
  34091. * @see https://doc.babylonjs.com/features/behaviour
  34092. * @param behavior defines the behavior to attach
  34093. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34094. * @returns the current Node
  34095. */
  34096. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34097. /**
  34098. * Remove an attached behavior
  34099. * @see https://doc.babylonjs.com/features/behaviour
  34100. * @param behavior defines the behavior to attach
  34101. * @returns the current Node
  34102. */
  34103. removeBehavior(behavior: Behavior<Node>): Node;
  34104. /**
  34105. * Gets the list of attached behaviors
  34106. * @see https://doc.babylonjs.com/features/behaviour
  34107. */
  34108. get behaviors(): Behavior<Node>[];
  34109. /**
  34110. * Gets an attached behavior by name
  34111. * @param name defines the name of the behavior to look for
  34112. * @see https://doc.babylonjs.com/features/behaviour
  34113. * @returns null if behavior was not found else the requested behavior
  34114. */
  34115. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34116. /**
  34117. * Returns the latest update of the World matrix
  34118. * @returns a Matrix
  34119. */
  34120. getWorldMatrix(): Matrix;
  34121. /** @hidden */
  34122. _getWorldMatrixDeterminant(): number;
  34123. /**
  34124. * Returns directly the latest state of the mesh World matrix.
  34125. * A Matrix is returned.
  34126. */
  34127. get worldMatrixFromCache(): Matrix;
  34128. /** @hidden */
  34129. _initCache(): void;
  34130. /** @hidden */
  34131. updateCache(force?: boolean): void;
  34132. /** @hidden */
  34133. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34134. /** @hidden */
  34135. _updateCache(ignoreParentClass?: boolean): void;
  34136. /** @hidden */
  34137. _isSynchronized(): boolean;
  34138. /** @hidden */
  34139. _markSyncedWithParent(): void;
  34140. /** @hidden */
  34141. isSynchronizedWithParent(): boolean;
  34142. /** @hidden */
  34143. isSynchronized(): boolean;
  34144. /**
  34145. * Is this node ready to be used/rendered
  34146. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34147. * @return true if the node is ready
  34148. */
  34149. isReady(completeCheck?: boolean): boolean;
  34150. /**
  34151. * Is this node enabled?
  34152. * 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
  34153. * @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
  34154. * @return whether this node (and its parent) is enabled
  34155. */
  34156. isEnabled(checkAncestors?: boolean): boolean;
  34157. /** @hidden */
  34158. protected _syncParentEnabledState(): void;
  34159. /**
  34160. * Set the enabled state of this node
  34161. * @param value defines the new enabled state
  34162. */
  34163. setEnabled(value: boolean): void;
  34164. /**
  34165. * Is this node a descendant of the given node?
  34166. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34167. * @param ancestor defines the parent node to inspect
  34168. * @returns a boolean indicating if this node is a descendant of the given node
  34169. */
  34170. isDescendantOf(ancestor: Node): boolean;
  34171. /** @hidden */
  34172. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34173. /**
  34174. * Will return all nodes that have this node as ascendant
  34175. * @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
  34176. * @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
  34177. * @return all children nodes of all types
  34178. */
  34179. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34180. /**
  34181. * Get all child-meshes of this node
  34182. * @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)
  34183. * @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
  34184. * @returns an array of AbstractMesh
  34185. */
  34186. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34187. /**
  34188. * Get all direct children of this node
  34189. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  34190. * @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)
  34191. * @returns an array of Node
  34192. */
  34193. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34194. /** @hidden */
  34195. _setReady(state: boolean): void;
  34196. /**
  34197. * Get an animation by name
  34198. * @param name defines the name of the animation to look for
  34199. * @returns null if not found else the requested animation
  34200. */
  34201. getAnimationByName(name: string): Nullable<Animation>;
  34202. /**
  34203. * Creates an animation range for this node
  34204. * @param name defines the name of the range
  34205. * @param from defines the starting key
  34206. * @param to defines the end key
  34207. */
  34208. createAnimationRange(name: string, from: number, to: number): void;
  34209. /**
  34210. * Delete a specific animation range
  34211. * @param name defines the name of the range to delete
  34212. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34213. */
  34214. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34215. /**
  34216. * Get an animation range by name
  34217. * @param name defines the name of the animation range to look for
  34218. * @returns null if not found else the requested animation range
  34219. */
  34220. getAnimationRange(name: string): Nullable<AnimationRange>;
  34221. /**
  34222. * Gets the list of all animation ranges defined on this node
  34223. * @returns an array
  34224. */
  34225. getAnimationRanges(): Nullable<AnimationRange>[];
  34226. /**
  34227. * Will start the animation sequence
  34228. * @param name defines the range frames for animation sequence
  34229. * @param loop defines if the animation should loop (false by default)
  34230. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34231. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34232. * @returns the object created for this animation. If range does not exist, it will return null
  34233. */
  34234. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34235. /**
  34236. * Serialize animation ranges into a JSON compatible object
  34237. * @returns serialization object
  34238. */
  34239. serializeAnimationRanges(): any;
  34240. /**
  34241. * Computes the world matrix of the node
  34242. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34243. * @returns the world matrix
  34244. */
  34245. computeWorldMatrix(force?: boolean): Matrix;
  34246. /**
  34247. * Releases resources associated with this node.
  34248. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34249. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34250. */
  34251. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34252. /**
  34253. * Parse animation range data from a serialization object and store them into a given node
  34254. * @param node defines where to store the animation ranges
  34255. * @param parsedNode defines the serialization object to read data from
  34256. * @param scene defines the hosting scene
  34257. */
  34258. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34259. /**
  34260. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34261. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34262. * @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
  34263. * @returns the new bounding vectors
  34264. */
  34265. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34266. min: Vector3;
  34267. max: Vector3;
  34268. };
  34269. }
  34270. }
  34271. declare module "babylonjs/Animations/animation" {
  34272. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34273. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34274. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34275. import { Nullable } from "babylonjs/types";
  34276. import { Scene } from "babylonjs/scene";
  34277. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34278. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34279. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34280. import { Node } from "babylonjs/node";
  34281. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34282. import { Size } from "babylonjs/Maths/math.size";
  34283. import { Animatable } from "babylonjs/Animations/animatable";
  34284. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34285. /**
  34286. * @hidden
  34287. */
  34288. export class _IAnimationState {
  34289. key: number;
  34290. repeatCount: number;
  34291. workValue?: any;
  34292. loopMode?: number;
  34293. offsetValue?: any;
  34294. highLimitValue?: any;
  34295. }
  34296. /**
  34297. * Class used to store any kind of animation
  34298. */
  34299. export class Animation {
  34300. /**Name of the animation */
  34301. name: string;
  34302. /**Property to animate */
  34303. targetProperty: string;
  34304. /**The frames per second of the animation */
  34305. framePerSecond: number;
  34306. /**The data type of the animation */
  34307. dataType: number;
  34308. /**The loop mode of the animation */
  34309. loopMode?: number | undefined;
  34310. /**Specifies if blending should be enabled */
  34311. enableBlending?: boolean | undefined;
  34312. /**
  34313. * Use matrix interpolation instead of using direct key value when animating matrices
  34314. */
  34315. static AllowMatricesInterpolation: boolean;
  34316. /**
  34317. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34318. */
  34319. static AllowMatrixDecomposeForInterpolation: boolean;
  34320. /** Define the Url to load snippets */
  34321. static SnippetUrl: string;
  34322. /** Snippet ID if the animation was created from the snippet server */
  34323. snippetId: string;
  34324. /**
  34325. * Stores the key frames of the animation
  34326. */
  34327. private _keys;
  34328. /**
  34329. * Stores the easing function of the animation
  34330. */
  34331. private _easingFunction;
  34332. /**
  34333. * @hidden Internal use only
  34334. */
  34335. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34336. /**
  34337. * The set of event that will be linked to this animation
  34338. */
  34339. private _events;
  34340. /**
  34341. * Stores an array of target property paths
  34342. */
  34343. targetPropertyPath: string[];
  34344. /**
  34345. * Stores the blending speed of the animation
  34346. */
  34347. blendingSpeed: number;
  34348. /**
  34349. * Stores the animation ranges for the animation
  34350. */
  34351. private _ranges;
  34352. /**
  34353. * @hidden Internal use
  34354. */
  34355. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34356. /**
  34357. * Sets up an animation
  34358. * @param property The property to animate
  34359. * @param animationType The animation type to apply
  34360. * @param framePerSecond The frames per second of the animation
  34361. * @param easingFunction The easing function used in the animation
  34362. * @returns The created animation
  34363. */
  34364. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34365. /**
  34366. * Create and start an animation on a node
  34367. * @param name defines the name of the global animation that will be run on all nodes
  34368. * @param node defines the root node where the animation will take place
  34369. * @param targetProperty defines property to animate
  34370. * @param framePerSecond defines the number of frame per second yo use
  34371. * @param totalFrame defines the number of frames in total
  34372. * @param from defines the initial value
  34373. * @param to defines the final value
  34374. * @param loopMode defines which loop mode you want to use (off by default)
  34375. * @param easingFunction defines the easing function to use (linear by default)
  34376. * @param onAnimationEnd defines the callback to call when animation end
  34377. * @returns the animatable created for this animation
  34378. */
  34379. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34380. /**
  34381. * Create and start an animation on a node and its descendants
  34382. * @param name defines the name of the global animation that will be run on all nodes
  34383. * @param node defines the root node where the animation will take place
  34384. * @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
  34385. * @param targetProperty defines property to animate
  34386. * @param framePerSecond defines the number of frame per second to use
  34387. * @param totalFrame defines the number of frames in total
  34388. * @param from defines the initial value
  34389. * @param to defines the final value
  34390. * @param loopMode defines which loop mode you want to use (off by default)
  34391. * @param easingFunction defines the easing function to use (linear by default)
  34392. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34393. * @returns the list of animatables created for all nodes
  34394. * @example https://www.babylonjs-playground.com/#MH0VLI
  34395. */
  34396. 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[]>;
  34397. /**
  34398. * Creates a new animation, merges it with the existing animations and starts it
  34399. * @param name Name of the animation
  34400. * @param node Node which contains the scene that begins the animations
  34401. * @param targetProperty Specifies which property to animate
  34402. * @param framePerSecond The frames per second of the animation
  34403. * @param totalFrame The total number of frames
  34404. * @param from The frame at the beginning of the animation
  34405. * @param to The frame at the end of the animation
  34406. * @param loopMode Specifies the loop mode of the animation
  34407. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34408. * @param onAnimationEnd Callback to run once the animation is complete
  34409. * @returns Nullable animation
  34410. */
  34411. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34412. /**
  34413. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34414. * @param sourceAnimation defines the Animation containing keyframes to convert
  34415. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34416. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34417. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34418. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34419. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34420. */
  34421. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34422. /**
  34423. * Transition property of an host to the target Value
  34424. * @param property The property to transition
  34425. * @param targetValue The target Value of the property
  34426. * @param host The object where the property to animate belongs
  34427. * @param scene Scene used to run the animation
  34428. * @param frameRate Framerate (in frame/s) to use
  34429. * @param transition The transition type we want to use
  34430. * @param duration The duration of the animation, in milliseconds
  34431. * @param onAnimationEnd Callback trigger at the end of the animation
  34432. * @returns Nullable animation
  34433. */
  34434. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34435. /**
  34436. * Return the array of runtime animations currently using this animation
  34437. */
  34438. get runtimeAnimations(): RuntimeAnimation[];
  34439. /**
  34440. * Specifies if any of the runtime animations are currently running
  34441. */
  34442. get hasRunningRuntimeAnimations(): boolean;
  34443. /**
  34444. * Initializes the animation
  34445. * @param name Name of the animation
  34446. * @param targetProperty Property to animate
  34447. * @param framePerSecond The frames per second of the animation
  34448. * @param dataType The data type of the animation
  34449. * @param loopMode The loop mode of the animation
  34450. * @param enableBlending Specifies if blending should be enabled
  34451. */
  34452. constructor(
  34453. /**Name of the animation */
  34454. name: string,
  34455. /**Property to animate */
  34456. targetProperty: string,
  34457. /**The frames per second of the animation */
  34458. framePerSecond: number,
  34459. /**The data type of the animation */
  34460. dataType: number,
  34461. /**The loop mode of the animation */
  34462. loopMode?: number | undefined,
  34463. /**Specifies if blending should be enabled */
  34464. enableBlending?: boolean | undefined);
  34465. /**
  34466. * Converts the animation to a string
  34467. * @param fullDetails support for multiple levels of logging within scene loading
  34468. * @returns String form of the animation
  34469. */
  34470. toString(fullDetails?: boolean): string;
  34471. /**
  34472. * Add an event to this animation
  34473. * @param event Event to add
  34474. */
  34475. addEvent(event: AnimationEvent): void;
  34476. /**
  34477. * Remove all events found at the given frame
  34478. * @param frame The frame to remove events from
  34479. */
  34480. removeEvents(frame: number): void;
  34481. /**
  34482. * Retrieves all the events from the animation
  34483. * @returns Events from the animation
  34484. */
  34485. getEvents(): AnimationEvent[];
  34486. /**
  34487. * Creates an animation range
  34488. * @param name Name of the animation range
  34489. * @param from Starting frame of the animation range
  34490. * @param to Ending frame of the animation
  34491. */
  34492. createRange(name: string, from: number, to: number): void;
  34493. /**
  34494. * Deletes an animation range by name
  34495. * @param name Name of the animation range to delete
  34496. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34497. */
  34498. deleteRange(name: string, deleteFrames?: boolean): void;
  34499. /**
  34500. * Gets the animation range by name, or null if not defined
  34501. * @param name Name of the animation range
  34502. * @returns Nullable animation range
  34503. */
  34504. getRange(name: string): Nullable<AnimationRange>;
  34505. /**
  34506. * Gets the key frames from the animation
  34507. * @returns The key frames of the animation
  34508. */
  34509. getKeys(): Array<IAnimationKey>;
  34510. /**
  34511. * Gets the highest frame rate of the animation
  34512. * @returns Highest frame rate of the animation
  34513. */
  34514. getHighestFrame(): number;
  34515. /**
  34516. * Gets the easing function of the animation
  34517. * @returns Easing function of the animation
  34518. */
  34519. getEasingFunction(): IEasingFunction;
  34520. /**
  34521. * Sets the easing function of the animation
  34522. * @param easingFunction A custom mathematical formula for animation
  34523. */
  34524. setEasingFunction(easingFunction: EasingFunction): void;
  34525. /**
  34526. * Interpolates a scalar linearly
  34527. * @param startValue Start value of the animation curve
  34528. * @param endValue End value of the animation curve
  34529. * @param gradient Scalar amount to interpolate
  34530. * @returns Interpolated scalar value
  34531. */
  34532. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34533. /**
  34534. * Interpolates a scalar cubically
  34535. * @param startValue Start value of the animation curve
  34536. * @param outTangent End tangent of the animation
  34537. * @param endValue End value of the animation curve
  34538. * @param inTangent Start tangent of the animation curve
  34539. * @param gradient Scalar amount to interpolate
  34540. * @returns Interpolated scalar value
  34541. */
  34542. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34543. /**
  34544. * Interpolates a quaternion using a spherical linear interpolation
  34545. * @param startValue Start value of the animation curve
  34546. * @param endValue End value of the animation curve
  34547. * @param gradient Scalar amount to interpolate
  34548. * @returns Interpolated quaternion value
  34549. */
  34550. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34551. /**
  34552. * Interpolates a quaternion cubically
  34553. * @param startValue Start value of the animation curve
  34554. * @param outTangent End tangent of the animation curve
  34555. * @param endValue End value of the animation curve
  34556. * @param inTangent Start tangent of the animation curve
  34557. * @param gradient Scalar amount to interpolate
  34558. * @returns Interpolated quaternion value
  34559. */
  34560. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34561. /**
  34562. * Interpolates a Vector3 linearl
  34563. * @param startValue Start value of the animation curve
  34564. * @param endValue End value of the animation curve
  34565. * @param gradient Scalar amount to interpolate
  34566. * @returns Interpolated scalar value
  34567. */
  34568. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34569. /**
  34570. * Interpolates a Vector3 cubically
  34571. * @param startValue Start value of the animation curve
  34572. * @param outTangent End tangent of the animation
  34573. * @param endValue End value of the animation curve
  34574. * @param inTangent Start tangent of the animation curve
  34575. * @param gradient Scalar amount to interpolate
  34576. * @returns InterpolatedVector3 value
  34577. */
  34578. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34579. /**
  34580. * Interpolates a Vector2 linearly
  34581. * @param startValue Start value of the animation curve
  34582. * @param endValue End value of the animation curve
  34583. * @param gradient Scalar amount to interpolate
  34584. * @returns Interpolated Vector2 value
  34585. */
  34586. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34587. /**
  34588. * Interpolates a Vector2 cubically
  34589. * @param startValue Start value of the animation curve
  34590. * @param outTangent End tangent of the animation
  34591. * @param endValue End value of the animation curve
  34592. * @param inTangent Start tangent of the animation curve
  34593. * @param gradient Scalar amount to interpolate
  34594. * @returns Interpolated Vector2 value
  34595. */
  34596. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34597. /**
  34598. * Interpolates a size linearly
  34599. * @param startValue Start value of the animation curve
  34600. * @param endValue End value of the animation curve
  34601. * @param gradient Scalar amount to interpolate
  34602. * @returns Interpolated Size value
  34603. */
  34604. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34605. /**
  34606. * Interpolates a Color3 linearly
  34607. * @param startValue Start value of the animation curve
  34608. * @param endValue End value of the animation curve
  34609. * @param gradient Scalar amount to interpolate
  34610. * @returns Interpolated Color3 value
  34611. */
  34612. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34613. /**
  34614. * Interpolates a Color4 linearly
  34615. * @param startValue Start value of the animation curve
  34616. * @param endValue End value of the animation curve
  34617. * @param gradient Scalar amount to interpolate
  34618. * @returns Interpolated Color3 value
  34619. */
  34620. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34621. /**
  34622. * @hidden Internal use only
  34623. */
  34624. _getKeyValue(value: any): any;
  34625. /**
  34626. * @hidden Internal use only
  34627. */
  34628. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34629. /**
  34630. * Defines the function to use to interpolate matrices
  34631. * @param startValue defines the start matrix
  34632. * @param endValue defines the end matrix
  34633. * @param gradient defines the gradient between both matrices
  34634. * @param result defines an optional target matrix where to store the interpolation
  34635. * @returns the interpolated matrix
  34636. */
  34637. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34638. /**
  34639. * Makes a copy of the animation
  34640. * @returns Cloned animation
  34641. */
  34642. clone(): Animation;
  34643. /**
  34644. * Sets the key frames of the animation
  34645. * @param values The animation key frames to set
  34646. */
  34647. setKeys(values: Array<IAnimationKey>): void;
  34648. /**
  34649. * Serializes the animation to an object
  34650. * @returns Serialized object
  34651. */
  34652. serialize(): any;
  34653. /**
  34654. * Float animation type
  34655. */
  34656. static readonly ANIMATIONTYPE_FLOAT: number;
  34657. /**
  34658. * Vector3 animation type
  34659. */
  34660. static readonly ANIMATIONTYPE_VECTOR3: number;
  34661. /**
  34662. * Quaternion animation type
  34663. */
  34664. static readonly ANIMATIONTYPE_QUATERNION: number;
  34665. /**
  34666. * Matrix animation type
  34667. */
  34668. static readonly ANIMATIONTYPE_MATRIX: number;
  34669. /**
  34670. * Color3 animation type
  34671. */
  34672. static readonly ANIMATIONTYPE_COLOR3: number;
  34673. /**
  34674. * Color3 animation type
  34675. */
  34676. static readonly ANIMATIONTYPE_COLOR4: number;
  34677. /**
  34678. * Vector2 animation type
  34679. */
  34680. static readonly ANIMATIONTYPE_VECTOR2: number;
  34681. /**
  34682. * Size animation type
  34683. */
  34684. static readonly ANIMATIONTYPE_SIZE: number;
  34685. /**
  34686. * Relative Loop Mode
  34687. */
  34688. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34689. /**
  34690. * Cycle Loop Mode
  34691. */
  34692. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34693. /**
  34694. * Constant Loop Mode
  34695. */
  34696. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34697. /** @hidden */
  34698. static _UniversalLerp(left: any, right: any, amount: number): any;
  34699. /**
  34700. * Parses an animation object and creates an animation
  34701. * @param parsedAnimation Parsed animation object
  34702. * @returns Animation object
  34703. */
  34704. static Parse(parsedAnimation: any): Animation;
  34705. /**
  34706. * Appends the serialized animations from the source animations
  34707. * @param source Source containing the animations
  34708. * @param destination Target to store the animations
  34709. */
  34710. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34711. /**
  34712. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34713. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34714. * @param url defines the url to load from
  34715. * @returns a promise that will resolve to the new animation or an array of animations
  34716. */
  34717. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34718. /**
  34719. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34720. * @param snippetId defines the snippet to load
  34721. * @returns a promise that will resolve to the new animation or a new array of animations
  34722. */
  34723. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34724. }
  34725. }
  34726. declare module "babylonjs/Animations/animatable.interface" {
  34727. import { Nullable } from "babylonjs/types";
  34728. import { Animation } from "babylonjs/Animations/animation";
  34729. /**
  34730. * Interface containing an array of animations
  34731. */
  34732. export interface IAnimatable {
  34733. /**
  34734. * Array of animations
  34735. */
  34736. animations: Nullable<Array<Animation>>;
  34737. }
  34738. }
  34739. declare module "babylonjs/Misc/decorators" {
  34740. import { Nullable } from "babylonjs/types";
  34741. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34742. import { Scene } from "babylonjs/scene";
  34743. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34744. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34745. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34747. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34748. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34749. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34750. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34751. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34752. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34753. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34754. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34755. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34756. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34757. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34758. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34759. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34760. /**
  34761. * Decorator used to define property that can be serialized as reference to a camera
  34762. * @param sourceName defines the name of the property to decorate
  34763. */
  34764. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34765. /**
  34766. * Class used to help serialization objects
  34767. */
  34768. export class SerializationHelper {
  34769. /** @hidden */
  34770. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34771. /** @hidden */
  34772. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34773. /** @hidden */
  34774. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34775. /** @hidden */
  34776. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34777. /**
  34778. * Appends the serialized animations from the source animations
  34779. * @param source Source containing the animations
  34780. * @param destination Target to store the animations
  34781. */
  34782. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34783. /**
  34784. * Static function used to serialized a specific entity
  34785. * @param entity defines the entity to serialize
  34786. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34787. * @returns a JSON compatible object representing the serialization of the entity
  34788. */
  34789. static Serialize<T>(entity: T, serializationObject?: any): any;
  34790. /**
  34791. * Creates a new entity from a serialization data object
  34792. * @param creationFunction defines a function used to instanciated the new entity
  34793. * @param source defines the source serialization data
  34794. * @param scene defines the hosting scene
  34795. * @param rootUrl defines the root url for resources
  34796. * @returns a new entity
  34797. */
  34798. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34799. /**
  34800. * Clones an object
  34801. * @param creationFunction defines the function used to instanciate the new object
  34802. * @param source defines the source object
  34803. * @returns the cloned object
  34804. */
  34805. static Clone<T>(creationFunction: () => T, source: T): T;
  34806. /**
  34807. * Instanciates a new object based on a source one (some data will be shared between both object)
  34808. * @param creationFunction defines the function used to instanciate the new object
  34809. * @param source defines the source object
  34810. * @returns the new object
  34811. */
  34812. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34813. }
  34814. }
  34815. declare module "babylonjs/Materials/Textures/baseTexture" {
  34816. import { Observable } from "babylonjs/Misc/observable";
  34817. import { Nullable } from "babylonjs/types";
  34818. import { Scene } from "babylonjs/scene";
  34819. import { Matrix } from "babylonjs/Maths/math.vector";
  34820. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34821. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34822. import { ISize } from "babylonjs/Maths/math.size";
  34823. import "babylonjs/Misc/fileTools";
  34824. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34825. /**
  34826. * Base class of all the textures in babylon.
  34827. * It groups all the common properties the materials, post process, lights... might need
  34828. * in order to make a correct use of the texture.
  34829. */
  34830. export class BaseTexture implements IAnimatable {
  34831. /**
  34832. * Default anisotropic filtering level for the application.
  34833. * It is set to 4 as a good tradeoff between perf and quality.
  34834. */
  34835. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34836. /**
  34837. * Gets or sets the unique id of the texture
  34838. */
  34839. uniqueId: number;
  34840. /**
  34841. * Define the name of the texture.
  34842. */
  34843. name: string;
  34844. /**
  34845. * Gets or sets an object used to store user defined information.
  34846. */
  34847. metadata: any;
  34848. /**
  34849. * For internal use only. Please do not use.
  34850. */
  34851. reservedDataStore: any;
  34852. private _hasAlpha;
  34853. /**
  34854. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34855. */
  34856. set hasAlpha(value: boolean);
  34857. get hasAlpha(): boolean;
  34858. /**
  34859. * Defines if the alpha value should be determined via the rgb values.
  34860. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34861. */
  34862. getAlphaFromRGB: boolean;
  34863. /**
  34864. * Intensity or strength of the texture.
  34865. * It is commonly used by materials to fine tune the intensity of the texture
  34866. */
  34867. level: number;
  34868. /**
  34869. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34870. * This is part of the texture as textures usually maps to one uv set.
  34871. */
  34872. coordinatesIndex: number;
  34873. private _coordinatesMode;
  34874. /**
  34875. * How a texture is mapped.
  34876. *
  34877. * | Value | Type | Description |
  34878. * | ----- | ----------------------------------- | ----------- |
  34879. * | 0 | EXPLICIT_MODE | |
  34880. * | 1 | SPHERICAL_MODE | |
  34881. * | 2 | PLANAR_MODE | |
  34882. * | 3 | CUBIC_MODE | |
  34883. * | 4 | PROJECTION_MODE | |
  34884. * | 5 | SKYBOX_MODE | |
  34885. * | 6 | INVCUBIC_MODE | |
  34886. * | 7 | EQUIRECTANGULAR_MODE | |
  34887. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34888. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34889. */
  34890. set coordinatesMode(value: number);
  34891. get coordinatesMode(): number;
  34892. /**
  34893. * | Value | Type | Description |
  34894. * | ----- | ------------------ | ----------- |
  34895. * | 0 | CLAMP_ADDRESSMODE | |
  34896. * | 1 | WRAP_ADDRESSMODE | |
  34897. * | 2 | MIRROR_ADDRESSMODE | |
  34898. */
  34899. wrapU: number;
  34900. /**
  34901. * | Value | Type | Description |
  34902. * | ----- | ------------------ | ----------- |
  34903. * | 0 | CLAMP_ADDRESSMODE | |
  34904. * | 1 | WRAP_ADDRESSMODE | |
  34905. * | 2 | MIRROR_ADDRESSMODE | |
  34906. */
  34907. wrapV: number;
  34908. /**
  34909. * | Value | Type | Description |
  34910. * | ----- | ------------------ | ----------- |
  34911. * | 0 | CLAMP_ADDRESSMODE | |
  34912. * | 1 | WRAP_ADDRESSMODE | |
  34913. * | 2 | MIRROR_ADDRESSMODE | |
  34914. */
  34915. wrapR: number;
  34916. /**
  34917. * With compliant hardware and browser (supporting anisotropic filtering)
  34918. * this defines the level of anisotropic filtering in the texture.
  34919. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34920. */
  34921. anisotropicFilteringLevel: number;
  34922. /**
  34923. * Define if the texture is a cube texture or if false a 2d texture.
  34924. */
  34925. get isCube(): boolean;
  34926. set isCube(value: boolean);
  34927. /**
  34928. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34929. */
  34930. get is3D(): boolean;
  34931. set is3D(value: boolean);
  34932. /**
  34933. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34934. */
  34935. get is2DArray(): boolean;
  34936. set is2DArray(value: boolean);
  34937. /**
  34938. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34939. * HDR texture are usually stored in linear space.
  34940. * This only impacts the PBR and Background materials
  34941. */
  34942. gammaSpace: boolean;
  34943. /**
  34944. * Gets or sets whether or not the texture contains RGBD data.
  34945. */
  34946. get isRGBD(): boolean;
  34947. set isRGBD(value: boolean);
  34948. /**
  34949. * Is Z inverted in the texture (useful in a cube texture).
  34950. */
  34951. invertZ: boolean;
  34952. /**
  34953. * Are mip maps generated for this texture or not.
  34954. */
  34955. get noMipmap(): boolean;
  34956. /**
  34957. * @hidden
  34958. */
  34959. lodLevelInAlpha: boolean;
  34960. /**
  34961. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34962. */
  34963. get lodGenerationOffset(): number;
  34964. set lodGenerationOffset(value: number);
  34965. /**
  34966. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34967. */
  34968. get lodGenerationScale(): number;
  34969. set lodGenerationScale(value: number);
  34970. /**
  34971. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34972. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34973. * average roughness values.
  34974. */
  34975. get linearSpecularLOD(): boolean;
  34976. set linearSpecularLOD(value: boolean);
  34977. /**
  34978. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34979. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34980. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34981. */
  34982. get irradianceTexture(): Nullable<BaseTexture>;
  34983. set irradianceTexture(value: Nullable<BaseTexture>);
  34984. /**
  34985. * Define if the texture is a render target.
  34986. */
  34987. isRenderTarget: boolean;
  34988. /**
  34989. * Define the unique id of the texture in the scene.
  34990. */
  34991. get uid(): string;
  34992. /** @hidden */
  34993. _prefiltered: boolean;
  34994. /**
  34995. * Return a string representation of the texture.
  34996. * @returns the texture as a string
  34997. */
  34998. toString(): string;
  34999. /**
  35000. * Get the class name of the texture.
  35001. * @returns "BaseTexture"
  35002. */
  35003. getClassName(): string;
  35004. /**
  35005. * Define the list of animation attached to the texture.
  35006. */
  35007. animations: import("babylonjs/Animations/animation").Animation[];
  35008. /**
  35009. * An event triggered when the texture is disposed.
  35010. */
  35011. onDisposeObservable: Observable<BaseTexture>;
  35012. private _onDisposeObserver;
  35013. /**
  35014. * Callback triggered when the texture has been disposed.
  35015. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35016. */
  35017. set onDispose(callback: () => void);
  35018. /**
  35019. * Define the current state of the loading sequence when in delayed load mode.
  35020. */
  35021. delayLoadState: number;
  35022. private _scene;
  35023. private _engine;
  35024. /** @hidden */
  35025. _texture: Nullable<InternalTexture>;
  35026. private _uid;
  35027. /**
  35028. * Define if the texture is preventinga material to render or not.
  35029. * If not and the texture is not ready, the engine will use a default black texture instead.
  35030. */
  35031. get isBlocking(): boolean;
  35032. /**
  35033. * Instantiates a new BaseTexture.
  35034. * Base class of all the textures in babylon.
  35035. * It groups all the common properties the materials, post process, lights... might need
  35036. * in order to make a correct use of the texture.
  35037. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35038. */
  35039. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35040. /**
  35041. * Get the scene the texture belongs to.
  35042. * @returns the scene or null if undefined
  35043. */
  35044. getScene(): Nullable<Scene>;
  35045. /** @hidden */
  35046. protected _getEngine(): Nullable<ThinEngine>;
  35047. /**
  35048. * Get the texture transform matrix used to offset tile the texture for istance.
  35049. * @returns the transformation matrix
  35050. */
  35051. getTextureMatrix(): Matrix;
  35052. /**
  35053. * Get the texture reflection matrix used to rotate/transform the reflection.
  35054. * @returns the reflection matrix
  35055. */
  35056. getReflectionTextureMatrix(): Matrix;
  35057. /**
  35058. * Get the underlying lower level texture from Babylon.
  35059. * @returns the insternal texture
  35060. */
  35061. getInternalTexture(): Nullable<InternalTexture>;
  35062. /**
  35063. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35064. * @returns true if ready or not blocking
  35065. */
  35066. isReadyOrNotBlocking(): boolean;
  35067. /**
  35068. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35069. * @returns true if fully ready
  35070. */
  35071. isReady(): boolean;
  35072. private _cachedSize;
  35073. /**
  35074. * Get the size of the texture.
  35075. * @returns the texture size.
  35076. */
  35077. getSize(): ISize;
  35078. /**
  35079. * Get the base size of the texture.
  35080. * It can be different from the size if the texture has been resized for POT for instance
  35081. * @returns the base size
  35082. */
  35083. getBaseSize(): ISize;
  35084. /**
  35085. * Update the sampling mode of the texture.
  35086. * Default is Trilinear mode.
  35087. *
  35088. * | Value | Type | Description |
  35089. * | ----- | ------------------ | ----------- |
  35090. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35091. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35092. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35093. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35094. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35095. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35096. * | 7 | NEAREST_LINEAR | |
  35097. * | 8 | NEAREST_NEAREST | |
  35098. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35099. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35100. * | 11 | LINEAR_LINEAR | |
  35101. * | 12 | LINEAR_NEAREST | |
  35102. *
  35103. * > _mag_: magnification filter (close to the viewer)
  35104. * > _min_: minification filter (far from the viewer)
  35105. * > _mip_: filter used between mip map levels
  35106. *@param samplingMode Define the new sampling mode of the texture
  35107. */
  35108. updateSamplingMode(samplingMode: number): void;
  35109. /**
  35110. * Scales the texture if is `canRescale()`
  35111. * @param ratio the resize factor we want to use to rescale
  35112. */
  35113. scale(ratio: number): void;
  35114. /**
  35115. * Get if the texture can rescale.
  35116. */
  35117. get canRescale(): boolean;
  35118. /** @hidden */
  35119. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35120. /** @hidden */
  35121. _rebuild(): void;
  35122. /**
  35123. * Triggers the load sequence in delayed load mode.
  35124. */
  35125. delayLoad(): void;
  35126. /**
  35127. * Clones the texture.
  35128. * @returns the cloned texture
  35129. */
  35130. clone(): Nullable<BaseTexture>;
  35131. /**
  35132. * Get the texture underlying type (INT, FLOAT...)
  35133. */
  35134. get textureType(): number;
  35135. /**
  35136. * Get the texture underlying format (RGB, RGBA...)
  35137. */
  35138. get textureFormat(): number;
  35139. /**
  35140. * Indicates that textures need to be re-calculated for all materials
  35141. */
  35142. protected _markAllSubMeshesAsTexturesDirty(): void;
  35143. /**
  35144. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35145. * This will returns an RGBA array buffer containing either in values (0-255) or
  35146. * float values (0-1) depending of the underlying buffer type.
  35147. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35148. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35149. * @param buffer defines a user defined buffer to fill with data (can be null)
  35150. * @returns The Array buffer containing the pixels data.
  35151. */
  35152. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35153. /**
  35154. * Release and destroy the underlying lower level texture aka internalTexture.
  35155. */
  35156. releaseInternalTexture(): void;
  35157. /** @hidden */
  35158. get _lodTextureHigh(): Nullable<BaseTexture>;
  35159. /** @hidden */
  35160. get _lodTextureMid(): Nullable<BaseTexture>;
  35161. /** @hidden */
  35162. get _lodTextureLow(): Nullable<BaseTexture>;
  35163. /**
  35164. * Dispose the texture and release its associated resources.
  35165. */
  35166. dispose(): void;
  35167. /**
  35168. * Serialize the texture into a JSON representation that can be parsed later on.
  35169. * @returns the JSON representation of the texture
  35170. */
  35171. serialize(): any;
  35172. /**
  35173. * Helper function to be called back once a list of texture contains only ready textures.
  35174. * @param textures Define the list of textures to wait for
  35175. * @param callback Define the callback triggered once the entire list will be ready
  35176. */
  35177. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35178. private static _isScene;
  35179. }
  35180. }
  35181. declare module "babylonjs/Materials/effect" {
  35182. import { Observable } from "babylonjs/Misc/observable";
  35183. import { Nullable } from "babylonjs/types";
  35184. import { IDisposable } from "babylonjs/scene";
  35185. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35186. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35187. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35188. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35189. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35190. import { Engine } from "babylonjs/Engines/engine";
  35191. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35193. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35194. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35195. /**
  35196. * Options to be used when creating an effect.
  35197. */
  35198. export interface IEffectCreationOptions {
  35199. /**
  35200. * Atrributes that will be used in the shader.
  35201. */
  35202. attributes: string[];
  35203. /**
  35204. * Uniform varible names that will be set in the shader.
  35205. */
  35206. uniformsNames: string[];
  35207. /**
  35208. * Uniform buffer variable names that will be set in the shader.
  35209. */
  35210. uniformBuffersNames: string[];
  35211. /**
  35212. * Sampler texture variable names that will be set in the shader.
  35213. */
  35214. samplers: string[];
  35215. /**
  35216. * Define statements that will be set in the shader.
  35217. */
  35218. defines: any;
  35219. /**
  35220. * Possible fallbacks for this effect to improve performance when needed.
  35221. */
  35222. fallbacks: Nullable<IEffectFallbacks>;
  35223. /**
  35224. * Callback that will be called when the shader is compiled.
  35225. */
  35226. onCompiled: Nullable<(effect: Effect) => void>;
  35227. /**
  35228. * Callback that will be called if an error occurs during shader compilation.
  35229. */
  35230. onError: Nullable<(effect: Effect, errors: string) => void>;
  35231. /**
  35232. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35233. */
  35234. indexParameters?: any;
  35235. /**
  35236. * Max number of lights that can be used in the shader.
  35237. */
  35238. maxSimultaneousLights?: number;
  35239. /**
  35240. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35241. */
  35242. transformFeedbackVaryings?: Nullable<string[]>;
  35243. /**
  35244. * 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
  35245. */
  35246. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35247. /**
  35248. * Is this effect rendering to several color attachments ?
  35249. */
  35250. multiTarget?: boolean;
  35251. }
  35252. /**
  35253. * Effect containing vertex and fragment shader that can be executed on an object.
  35254. */
  35255. export class Effect implements IDisposable {
  35256. /**
  35257. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35258. */
  35259. static ShadersRepository: string;
  35260. /**
  35261. * Enable logging of the shader code when a compilation error occurs
  35262. */
  35263. static LogShaderCodeOnCompilationError: boolean;
  35264. /**
  35265. * Name of the effect.
  35266. */
  35267. name: any;
  35268. /**
  35269. * String container all the define statements that should be set on the shader.
  35270. */
  35271. defines: string;
  35272. /**
  35273. * Callback that will be called when the shader is compiled.
  35274. */
  35275. onCompiled: Nullable<(effect: Effect) => void>;
  35276. /**
  35277. * Callback that will be called if an error occurs during shader compilation.
  35278. */
  35279. onError: Nullable<(effect: Effect, errors: string) => void>;
  35280. /**
  35281. * Callback that will be called when effect is bound.
  35282. */
  35283. onBind: Nullable<(effect: Effect) => void>;
  35284. /**
  35285. * Unique ID of the effect.
  35286. */
  35287. uniqueId: number;
  35288. /**
  35289. * Observable that will be called when the shader is compiled.
  35290. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35291. */
  35292. onCompileObservable: Observable<Effect>;
  35293. /**
  35294. * Observable that will be called if an error occurs during shader compilation.
  35295. */
  35296. onErrorObservable: Observable<Effect>;
  35297. /** @hidden */
  35298. _onBindObservable: Nullable<Observable<Effect>>;
  35299. /**
  35300. * @hidden
  35301. * Specifies if the effect was previously ready
  35302. */
  35303. _wasPreviouslyReady: boolean;
  35304. /**
  35305. * Observable that will be called when effect is bound.
  35306. */
  35307. get onBindObservable(): Observable<Effect>;
  35308. /** @hidden */
  35309. _bonesComputationForcedToCPU: boolean;
  35310. /** @hidden */
  35311. _multiTarget: boolean;
  35312. private static _uniqueIdSeed;
  35313. private _engine;
  35314. private _uniformBuffersNames;
  35315. private _uniformBuffersNamesList;
  35316. private _uniformsNames;
  35317. private _samplerList;
  35318. private _samplers;
  35319. private _isReady;
  35320. private _compilationError;
  35321. private _allFallbacksProcessed;
  35322. private _attributesNames;
  35323. private _attributes;
  35324. private _attributeLocationByName;
  35325. private _uniforms;
  35326. /**
  35327. * Key for the effect.
  35328. * @hidden
  35329. */
  35330. _key: string;
  35331. private _indexParameters;
  35332. private _fallbacks;
  35333. private _vertexSourceCode;
  35334. private _fragmentSourceCode;
  35335. private _vertexSourceCodeOverride;
  35336. private _fragmentSourceCodeOverride;
  35337. private _transformFeedbackVaryings;
  35338. /**
  35339. * Compiled shader to webGL program.
  35340. * @hidden
  35341. */
  35342. _pipelineContext: Nullable<IPipelineContext>;
  35343. private _valueCache;
  35344. private static _baseCache;
  35345. /**
  35346. * Instantiates an effect.
  35347. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35348. * @param baseName Name of the effect.
  35349. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35350. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35351. * @param samplers List of sampler variables that will be passed to the shader.
  35352. * @param engine Engine to be used to render the effect
  35353. * @param defines Define statements to be added to the shader.
  35354. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35355. * @param onCompiled Callback that will be called when the shader is compiled.
  35356. * @param onError Callback that will be called if an error occurs during shader compilation.
  35357. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35358. */
  35359. 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);
  35360. private _useFinalCode;
  35361. /**
  35362. * Unique key for this effect
  35363. */
  35364. get key(): string;
  35365. /**
  35366. * If the effect has been compiled and prepared.
  35367. * @returns if the effect is compiled and prepared.
  35368. */
  35369. isReady(): boolean;
  35370. private _isReadyInternal;
  35371. /**
  35372. * The engine the effect was initialized with.
  35373. * @returns the engine.
  35374. */
  35375. getEngine(): Engine;
  35376. /**
  35377. * The pipeline context for this effect
  35378. * @returns the associated pipeline context
  35379. */
  35380. getPipelineContext(): Nullable<IPipelineContext>;
  35381. /**
  35382. * The set of names of attribute variables for the shader.
  35383. * @returns An array of attribute names.
  35384. */
  35385. getAttributesNames(): string[];
  35386. /**
  35387. * Returns the attribute at the given index.
  35388. * @param index The index of the attribute.
  35389. * @returns The location of the attribute.
  35390. */
  35391. getAttributeLocation(index: number): number;
  35392. /**
  35393. * Returns the attribute based on the name of the variable.
  35394. * @param name of the attribute to look up.
  35395. * @returns the attribute location.
  35396. */
  35397. getAttributeLocationByName(name: string): number;
  35398. /**
  35399. * The number of attributes.
  35400. * @returns the numnber of attributes.
  35401. */
  35402. getAttributesCount(): number;
  35403. /**
  35404. * Gets the index of a uniform variable.
  35405. * @param uniformName of the uniform to look up.
  35406. * @returns the index.
  35407. */
  35408. getUniformIndex(uniformName: string): number;
  35409. /**
  35410. * Returns the attribute based on the name of the variable.
  35411. * @param uniformName of the uniform to look up.
  35412. * @returns the location of the uniform.
  35413. */
  35414. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35415. /**
  35416. * Returns an array of sampler variable names
  35417. * @returns The array of sampler variable names.
  35418. */
  35419. getSamplers(): string[];
  35420. /**
  35421. * Returns an array of uniform variable names
  35422. * @returns The array of uniform variable names.
  35423. */
  35424. getUniformNames(): string[];
  35425. /**
  35426. * Returns an array of uniform buffer variable names
  35427. * @returns The array of uniform buffer variable names.
  35428. */
  35429. getUniformBuffersNames(): string[];
  35430. /**
  35431. * Returns the index parameters used to create the effect
  35432. * @returns The index parameters object
  35433. */
  35434. getIndexParameters(): any;
  35435. /**
  35436. * The error from the last compilation.
  35437. * @returns the error string.
  35438. */
  35439. getCompilationError(): string;
  35440. /**
  35441. * Gets a boolean indicating that all fallbacks were used during compilation
  35442. * @returns true if all fallbacks were used
  35443. */
  35444. allFallbacksProcessed(): boolean;
  35445. /**
  35446. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35447. * @param func The callback to be used.
  35448. */
  35449. executeWhenCompiled(func: (effect: Effect) => void): void;
  35450. private _checkIsReady;
  35451. private _loadShader;
  35452. /**
  35453. * Gets the vertex shader source code of this effect
  35454. */
  35455. get vertexSourceCode(): string;
  35456. /**
  35457. * Gets the fragment shader source code of this effect
  35458. */
  35459. get fragmentSourceCode(): string;
  35460. /**
  35461. * Recompiles the webGL program
  35462. * @param vertexSourceCode The source code for the vertex shader.
  35463. * @param fragmentSourceCode The source code for the fragment shader.
  35464. * @param onCompiled Callback called when completed.
  35465. * @param onError Callback called on error.
  35466. * @hidden
  35467. */
  35468. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35469. /**
  35470. * Prepares the effect
  35471. * @hidden
  35472. */
  35473. _prepareEffect(): void;
  35474. private _getShaderCodeAndErrorLine;
  35475. private _processCompilationErrors;
  35476. /**
  35477. * Checks if the effect is supported. (Must be called after compilation)
  35478. */
  35479. get isSupported(): boolean;
  35480. /**
  35481. * Binds a texture to the engine to be used as output of the shader.
  35482. * @param channel Name of the output variable.
  35483. * @param texture Texture to bind.
  35484. * @hidden
  35485. */
  35486. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35487. /**
  35488. * Sets a texture on the engine to be used in the shader.
  35489. * @param channel Name of the sampler variable.
  35490. * @param texture Texture to set.
  35491. */
  35492. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35493. /**
  35494. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35495. * @param channel Name of the sampler variable.
  35496. * @param texture Texture to set.
  35497. */
  35498. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35499. /**
  35500. * Sets an array of textures on the engine to be used in the shader.
  35501. * @param channel Name of the variable.
  35502. * @param textures Textures to set.
  35503. */
  35504. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35505. /**
  35506. * 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)
  35507. * @param channel Name of the sampler variable.
  35508. * @param postProcess Post process to get the input texture from.
  35509. */
  35510. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35511. /**
  35512. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35513. * 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)
  35514. * @param channel Name of the sampler variable.
  35515. * @param postProcess Post process to get the output texture from.
  35516. */
  35517. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35518. /** @hidden */
  35519. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35520. /** @hidden */
  35521. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35522. /** @hidden */
  35523. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35524. /** @hidden */
  35525. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35526. /**
  35527. * Binds a buffer to a uniform.
  35528. * @param buffer Buffer to bind.
  35529. * @param name Name of the uniform variable to bind to.
  35530. */
  35531. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35532. /**
  35533. * Binds block to a uniform.
  35534. * @param blockName Name of the block to bind.
  35535. * @param index Index to bind.
  35536. */
  35537. bindUniformBlock(blockName: string, index: number): void;
  35538. /**
  35539. * Sets an interger value on a uniform variable.
  35540. * @param uniformName Name of the variable.
  35541. * @param value Value to be set.
  35542. * @returns this effect.
  35543. */
  35544. setInt(uniformName: string, value: number): Effect;
  35545. /**
  35546. * Sets an int array on a uniform variable.
  35547. * @param uniformName Name of the variable.
  35548. * @param array array to be set.
  35549. * @returns this effect.
  35550. */
  35551. setIntArray(uniformName: string, array: Int32Array): Effect;
  35552. /**
  35553. * 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)
  35554. * @param uniformName Name of the variable.
  35555. * @param array array to be set.
  35556. * @returns this effect.
  35557. */
  35558. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35559. /**
  35560. * 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)
  35561. * @param uniformName Name of the variable.
  35562. * @param array array to be set.
  35563. * @returns this effect.
  35564. */
  35565. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35566. /**
  35567. * 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)
  35568. * @param uniformName Name of the variable.
  35569. * @param array array to be set.
  35570. * @returns this effect.
  35571. */
  35572. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35573. /**
  35574. * Sets an float array on a uniform variable.
  35575. * @param uniformName Name of the variable.
  35576. * @param array array to be set.
  35577. * @returns this effect.
  35578. */
  35579. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35580. /**
  35581. * 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)
  35582. * @param uniformName Name of the variable.
  35583. * @param array array to be set.
  35584. * @returns this effect.
  35585. */
  35586. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35587. /**
  35588. * 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)
  35589. * @param uniformName Name of the variable.
  35590. * @param array array to be set.
  35591. * @returns this effect.
  35592. */
  35593. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35594. /**
  35595. * 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)
  35596. * @param uniformName Name of the variable.
  35597. * @param array array to be set.
  35598. * @returns this effect.
  35599. */
  35600. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35601. /**
  35602. * Sets an array on a uniform variable.
  35603. * @param uniformName Name of the variable.
  35604. * @param array array to be set.
  35605. * @returns this effect.
  35606. */
  35607. setArray(uniformName: string, array: number[]): Effect;
  35608. /**
  35609. * 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)
  35610. * @param uniformName Name of the variable.
  35611. * @param array array to be set.
  35612. * @returns this effect.
  35613. */
  35614. setArray2(uniformName: string, array: number[]): Effect;
  35615. /**
  35616. * 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)
  35617. * @param uniformName Name of the variable.
  35618. * @param array array to be set.
  35619. * @returns this effect.
  35620. */
  35621. setArray3(uniformName: string, array: number[]): Effect;
  35622. /**
  35623. * 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)
  35624. * @param uniformName Name of the variable.
  35625. * @param array array to be set.
  35626. * @returns this effect.
  35627. */
  35628. setArray4(uniformName: string, array: number[]): Effect;
  35629. /**
  35630. * Sets matrices on a uniform variable.
  35631. * @param uniformName Name of the variable.
  35632. * @param matrices matrices to be set.
  35633. * @returns this effect.
  35634. */
  35635. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35636. /**
  35637. * Sets matrix on a uniform variable.
  35638. * @param uniformName Name of the variable.
  35639. * @param matrix matrix to be set.
  35640. * @returns this effect.
  35641. */
  35642. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35643. /**
  35644. * 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)
  35645. * @param uniformName Name of the variable.
  35646. * @param matrix matrix to be set.
  35647. * @returns this effect.
  35648. */
  35649. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35650. /**
  35651. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35652. * @param uniformName Name of the variable.
  35653. * @param matrix matrix to be set.
  35654. * @returns this effect.
  35655. */
  35656. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35657. /**
  35658. * Sets a float on a uniform variable.
  35659. * @param uniformName Name of the variable.
  35660. * @param value value to be set.
  35661. * @returns this effect.
  35662. */
  35663. setFloat(uniformName: string, value: number): Effect;
  35664. /**
  35665. * Sets a boolean on a uniform variable.
  35666. * @param uniformName Name of the variable.
  35667. * @param bool value to be set.
  35668. * @returns this effect.
  35669. */
  35670. setBool(uniformName: string, bool: boolean): Effect;
  35671. /**
  35672. * Sets a Vector2 on a uniform variable.
  35673. * @param uniformName Name of the variable.
  35674. * @param vector2 vector2 to be set.
  35675. * @returns this effect.
  35676. */
  35677. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35678. /**
  35679. * Sets a float2 on a uniform variable.
  35680. * @param uniformName Name of the variable.
  35681. * @param x First float in float2.
  35682. * @param y Second float in float2.
  35683. * @returns this effect.
  35684. */
  35685. setFloat2(uniformName: string, x: number, y: number): Effect;
  35686. /**
  35687. * Sets a Vector3 on a uniform variable.
  35688. * @param uniformName Name of the variable.
  35689. * @param vector3 Value to be set.
  35690. * @returns this effect.
  35691. */
  35692. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35693. /**
  35694. * Sets a float3 on a uniform variable.
  35695. * @param uniformName Name of the variable.
  35696. * @param x First float in float3.
  35697. * @param y Second float in float3.
  35698. * @param z Third float in float3.
  35699. * @returns this effect.
  35700. */
  35701. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35702. /**
  35703. * Sets a Vector4 on a uniform variable.
  35704. * @param uniformName Name of the variable.
  35705. * @param vector4 Value to be set.
  35706. * @returns this effect.
  35707. */
  35708. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35709. /**
  35710. * Sets a float4 on a uniform variable.
  35711. * @param uniformName Name of the variable.
  35712. * @param x First float in float4.
  35713. * @param y Second float in float4.
  35714. * @param z Third float in float4.
  35715. * @param w Fourth float in float4.
  35716. * @returns this effect.
  35717. */
  35718. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35719. /**
  35720. * Sets a Color3 on a uniform variable.
  35721. * @param uniformName Name of the variable.
  35722. * @param color3 Value to be set.
  35723. * @returns this effect.
  35724. */
  35725. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35726. /**
  35727. * Sets a Color4 on a uniform variable.
  35728. * @param uniformName Name of the variable.
  35729. * @param color3 Value to be set.
  35730. * @param alpha Alpha value to be set.
  35731. * @returns this effect.
  35732. */
  35733. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35734. /**
  35735. * Sets a Color4 on a uniform variable
  35736. * @param uniformName defines the name of the variable
  35737. * @param color4 defines the value to be set
  35738. * @returns this effect.
  35739. */
  35740. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35741. /** Release all associated resources */
  35742. dispose(): void;
  35743. /**
  35744. * This function will add a new shader to the shader store
  35745. * @param name the name of the shader
  35746. * @param pixelShader optional pixel shader content
  35747. * @param vertexShader optional vertex shader content
  35748. */
  35749. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35750. /**
  35751. * Store of each shader (The can be looked up using effect.key)
  35752. */
  35753. static ShadersStore: {
  35754. [key: string]: string;
  35755. };
  35756. /**
  35757. * Store of each included file for a shader (The can be looked up using effect.key)
  35758. */
  35759. static IncludesShadersStore: {
  35760. [key: string]: string;
  35761. };
  35762. /**
  35763. * Resets the cache of effects.
  35764. */
  35765. static ResetCache(): void;
  35766. }
  35767. }
  35768. declare module "babylonjs/Engines/engineCapabilities" {
  35769. /**
  35770. * Interface used to describe the capabilities of the engine relatively to the current browser
  35771. */
  35772. export interface EngineCapabilities {
  35773. /** Maximum textures units per fragment shader */
  35774. maxTexturesImageUnits: number;
  35775. /** Maximum texture units per vertex shader */
  35776. maxVertexTextureImageUnits: number;
  35777. /** Maximum textures units in the entire pipeline */
  35778. maxCombinedTexturesImageUnits: number;
  35779. /** Maximum texture size */
  35780. maxTextureSize: number;
  35781. /** Maximum texture samples */
  35782. maxSamples?: number;
  35783. /** Maximum cube texture size */
  35784. maxCubemapTextureSize: number;
  35785. /** Maximum render texture size */
  35786. maxRenderTextureSize: number;
  35787. /** Maximum number of vertex attributes */
  35788. maxVertexAttribs: number;
  35789. /** Maximum number of varyings */
  35790. maxVaryingVectors: number;
  35791. /** Maximum number of uniforms per vertex shader */
  35792. maxVertexUniformVectors: number;
  35793. /** Maximum number of uniforms per fragment shader */
  35794. maxFragmentUniformVectors: number;
  35795. /** Defines if standard derivates (dx/dy) are supported */
  35796. standardDerivatives: boolean;
  35797. /** Defines if s3tc texture compression is supported */
  35798. s3tc?: WEBGL_compressed_texture_s3tc;
  35799. /** Defines if pvrtc texture compression is supported */
  35800. pvrtc: any;
  35801. /** Defines if etc1 texture compression is supported */
  35802. etc1: any;
  35803. /** Defines if etc2 texture compression is supported */
  35804. etc2: any;
  35805. /** Defines if astc texture compression is supported */
  35806. astc: any;
  35807. /** Defines if float textures are supported */
  35808. textureFloat: boolean;
  35809. /** Defines if vertex array objects are supported */
  35810. vertexArrayObject: boolean;
  35811. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35812. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35813. /** Gets the maximum level of anisotropy supported */
  35814. maxAnisotropy: number;
  35815. /** Defines if instancing is supported */
  35816. instancedArrays: boolean;
  35817. /** Defines if 32 bits indices are supported */
  35818. uintIndices: boolean;
  35819. /** Defines if high precision shaders are supported */
  35820. highPrecisionShaderSupported: boolean;
  35821. /** Defines if depth reading in the fragment shader is supported */
  35822. fragmentDepthSupported: boolean;
  35823. /** Defines if float texture linear filtering is supported*/
  35824. textureFloatLinearFiltering: boolean;
  35825. /** Defines if rendering to float textures is supported */
  35826. textureFloatRender: boolean;
  35827. /** Defines if half float textures are supported*/
  35828. textureHalfFloat: boolean;
  35829. /** Defines if half float texture linear filtering is supported*/
  35830. textureHalfFloatLinearFiltering: boolean;
  35831. /** Defines if rendering to half float textures is supported */
  35832. textureHalfFloatRender: boolean;
  35833. /** Defines if textureLOD shader command is supported */
  35834. textureLOD: boolean;
  35835. /** Defines if draw buffers extension is supported */
  35836. drawBuffersExtension: boolean;
  35837. /** Defines if depth textures are supported */
  35838. depthTextureExtension: boolean;
  35839. /** Defines if float color buffer are supported */
  35840. colorBufferFloat: boolean;
  35841. /** Gets disjoint timer query extension (null if not supported) */
  35842. timerQuery?: EXT_disjoint_timer_query;
  35843. /** Defines if timestamp can be used with timer query */
  35844. canUseTimestampForTimerQuery: boolean;
  35845. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35846. multiview?: any;
  35847. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35848. oculusMultiview?: any;
  35849. /** Function used to let the system compiles shaders in background */
  35850. parallelShaderCompile?: {
  35851. COMPLETION_STATUS_KHR: number;
  35852. };
  35853. /** Max number of texture samples for MSAA */
  35854. maxMSAASamples: number;
  35855. /** Defines if the blend min max extension is supported */
  35856. blendMinMax: boolean;
  35857. }
  35858. }
  35859. declare module "babylonjs/States/depthCullingState" {
  35860. import { Nullable } from "babylonjs/types";
  35861. /**
  35862. * @hidden
  35863. **/
  35864. export class DepthCullingState {
  35865. private _isDepthTestDirty;
  35866. private _isDepthMaskDirty;
  35867. private _isDepthFuncDirty;
  35868. private _isCullFaceDirty;
  35869. private _isCullDirty;
  35870. private _isZOffsetDirty;
  35871. private _isFrontFaceDirty;
  35872. private _depthTest;
  35873. private _depthMask;
  35874. private _depthFunc;
  35875. private _cull;
  35876. private _cullFace;
  35877. private _zOffset;
  35878. private _frontFace;
  35879. /**
  35880. * Initializes the state.
  35881. */
  35882. constructor();
  35883. get isDirty(): boolean;
  35884. get zOffset(): number;
  35885. set zOffset(value: number);
  35886. get cullFace(): Nullable<number>;
  35887. set cullFace(value: Nullable<number>);
  35888. get cull(): Nullable<boolean>;
  35889. set cull(value: Nullable<boolean>);
  35890. get depthFunc(): Nullable<number>;
  35891. set depthFunc(value: Nullable<number>);
  35892. get depthMask(): boolean;
  35893. set depthMask(value: boolean);
  35894. get depthTest(): boolean;
  35895. set depthTest(value: boolean);
  35896. get frontFace(): Nullable<number>;
  35897. set frontFace(value: Nullable<number>);
  35898. reset(): void;
  35899. apply(gl: WebGLRenderingContext): void;
  35900. }
  35901. }
  35902. declare module "babylonjs/States/stencilState" {
  35903. /**
  35904. * @hidden
  35905. **/
  35906. export class StencilState {
  35907. /** 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 */
  35908. static readonly ALWAYS: number;
  35909. /** Passed to stencilOperation to specify that stencil value must be kept */
  35910. static readonly KEEP: number;
  35911. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35912. static readonly REPLACE: number;
  35913. private _isStencilTestDirty;
  35914. private _isStencilMaskDirty;
  35915. private _isStencilFuncDirty;
  35916. private _isStencilOpDirty;
  35917. private _stencilTest;
  35918. private _stencilMask;
  35919. private _stencilFunc;
  35920. private _stencilFuncRef;
  35921. private _stencilFuncMask;
  35922. private _stencilOpStencilFail;
  35923. private _stencilOpDepthFail;
  35924. private _stencilOpStencilDepthPass;
  35925. get isDirty(): boolean;
  35926. get stencilFunc(): number;
  35927. set stencilFunc(value: number);
  35928. get stencilFuncRef(): number;
  35929. set stencilFuncRef(value: number);
  35930. get stencilFuncMask(): number;
  35931. set stencilFuncMask(value: number);
  35932. get stencilOpStencilFail(): number;
  35933. set stencilOpStencilFail(value: number);
  35934. get stencilOpDepthFail(): number;
  35935. set stencilOpDepthFail(value: number);
  35936. get stencilOpStencilDepthPass(): number;
  35937. set stencilOpStencilDepthPass(value: number);
  35938. get stencilMask(): number;
  35939. set stencilMask(value: number);
  35940. get stencilTest(): boolean;
  35941. set stencilTest(value: boolean);
  35942. constructor();
  35943. reset(): void;
  35944. apply(gl: WebGLRenderingContext): void;
  35945. }
  35946. }
  35947. declare module "babylonjs/States/alphaCullingState" {
  35948. /**
  35949. * @hidden
  35950. **/
  35951. export class AlphaState {
  35952. private _isAlphaBlendDirty;
  35953. private _isBlendFunctionParametersDirty;
  35954. private _isBlendEquationParametersDirty;
  35955. private _isBlendConstantsDirty;
  35956. private _alphaBlend;
  35957. private _blendFunctionParameters;
  35958. private _blendEquationParameters;
  35959. private _blendConstants;
  35960. /**
  35961. * Initializes the state.
  35962. */
  35963. constructor();
  35964. get isDirty(): boolean;
  35965. get alphaBlend(): boolean;
  35966. set alphaBlend(value: boolean);
  35967. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35968. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35969. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35970. reset(): void;
  35971. apply(gl: WebGLRenderingContext): void;
  35972. }
  35973. }
  35974. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35975. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35976. /** @hidden */
  35977. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35978. attributeProcessor(attribute: string): string;
  35979. varyingProcessor(varying: string, isFragment: boolean): string;
  35980. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35981. }
  35982. }
  35983. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35984. /**
  35985. * Interface for attribute information associated with buffer instanciation
  35986. */
  35987. export interface InstancingAttributeInfo {
  35988. /**
  35989. * Name of the GLSL attribute
  35990. * if attribute index is not specified, this is used to retrieve the index from the effect
  35991. */
  35992. attributeName: string;
  35993. /**
  35994. * Index/offset of the attribute in the vertex shader
  35995. * if not specified, this will be computes from the name.
  35996. */
  35997. index?: number;
  35998. /**
  35999. * size of the attribute, 1, 2, 3 or 4
  36000. */
  36001. attributeSize: number;
  36002. /**
  36003. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36004. */
  36005. offset: number;
  36006. /**
  36007. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36008. * default to 1
  36009. */
  36010. divisor?: number;
  36011. /**
  36012. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36013. * default is FLOAT
  36014. */
  36015. attributeType?: number;
  36016. /**
  36017. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36018. */
  36019. normalized?: boolean;
  36020. }
  36021. }
  36022. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36023. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36024. import { Nullable } from "babylonjs/types";
  36025. module "babylonjs/Engines/thinEngine" {
  36026. interface ThinEngine {
  36027. /**
  36028. * Update a video texture
  36029. * @param texture defines the texture to update
  36030. * @param video defines the video element to use
  36031. * @param invertY defines if data must be stored with Y axis inverted
  36032. */
  36033. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36034. }
  36035. }
  36036. }
  36037. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36038. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36039. import { Nullable } from "babylonjs/types";
  36040. module "babylonjs/Engines/thinEngine" {
  36041. interface ThinEngine {
  36042. /**
  36043. * Creates a dynamic texture
  36044. * @param width defines the width of the texture
  36045. * @param height defines the height of the texture
  36046. * @param generateMipMaps defines if the engine should generate the mip levels
  36047. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36048. * @returns the dynamic texture inside an InternalTexture
  36049. */
  36050. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36051. /**
  36052. * Update the content of a dynamic texture
  36053. * @param texture defines the texture to update
  36054. * @param canvas defines the canvas containing the source
  36055. * @param invertY defines if data must be stored with Y axis inverted
  36056. * @param premulAlpha defines if alpha is stored as premultiplied
  36057. * @param format defines the format of the data
  36058. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36059. */
  36060. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36061. }
  36062. }
  36063. }
  36064. declare module "babylonjs/Materials/Textures/videoTexture" {
  36065. import { Observable } from "babylonjs/Misc/observable";
  36066. import { Nullable } from "babylonjs/types";
  36067. import { Scene } from "babylonjs/scene";
  36068. import { Texture } from "babylonjs/Materials/Textures/texture";
  36069. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36070. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36071. /**
  36072. * Settings for finer control over video usage
  36073. */
  36074. export interface VideoTextureSettings {
  36075. /**
  36076. * Applies `autoplay` to video, if specified
  36077. */
  36078. autoPlay?: boolean;
  36079. /**
  36080. * Applies `loop` to video, if specified
  36081. */
  36082. loop?: boolean;
  36083. /**
  36084. * Automatically updates internal texture from video at every frame in the render loop
  36085. */
  36086. autoUpdateTexture: boolean;
  36087. /**
  36088. * Image src displayed during the video loading or until the user interacts with the video.
  36089. */
  36090. poster?: string;
  36091. }
  36092. /**
  36093. * If you want to display a video in your scene, this is the special texture for that.
  36094. * This special texture works similar to other textures, with the exception of a few parameters.
  36095. * @see https://doc.babylonjs.com/how_to/video_texture
  36096. */
  36097. export class VideoTexture extends Texture {
  36098. /**
  36099. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36100. */
  36101. readonly autoUpdateTexture: boolean;
  36102. /**
  36103. * The video instance used by the texture internally
  36104. */
  36105. readonly video: HTMLVideoElement;
  36106. private _onUserActionRequestedObservable;
  36107. /**
  36108. * Event triggerd when a dom action is required by the user to play the video.
  36109. * This happens due to recent changes in browser policies preventing video to auto start.
  36110. */
  36111. get onUserActionRequestedObservable(): Observable<Texture>;
  36112. private _generateMipMaps;
  36113. private _stillImageCaptured;
  36114. private _displayingPosterTexture;
  36115. private _settings;
  36116. private _createInternalTextureOnEvent;
  36117. private _frameId;
  36118. private _currentSrc;
  36119. /**
  36120. * Creates a video texture.
  36121. * If you want to display a video in your scene, this is the special texture for that.
  36122. * This special texture works similar to other textures, with the exception of a few parameters.
  36123. * @see https://doc.babylonjs.com/how_to/video_texture
  36124. * @param name optional name, will detect from video source, if not defined
  36125. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36126. * @param scene is obviously the current scene.
  36127. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36128. * @param invertY is false by default but can be used to invert video on Y axis
  36129. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36130. * @param settings allows finer control over video usage
  36131. */
  36132. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36133. private _getName;
  36134. private _getVideo;
  36135. private _createInternalTexture;
  36136. private reset;
  36137. /**
  36138. * @hidden Internal method to initiate `update`.
  36139. */
  36140. _rebuild(): void;
  36141. /**
  36142. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36143. */
  36144. update(): void;
  36145. /**
  36146. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36147. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36148. */
  36149. updateTexture(isVisible: boolean): void;
  36150. protected _updateInternalTexture: () => void;
  36151. /**
  36152. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36153. * @param url New url.
  36154. */
  36155. updateURL(url: string): void;
  36156. /**
  36157. * Clones the texture.
  36158. * @returns the cloned texture
  36159. */
  36160. clone(): VideoTexture;
  36161. /**
  36162. * Dispose the texture and release its associated resources.
  36163. */
  36164. dispose(): void;
  36165. /**
  36166. * Creates a video texture straight from a stream.
  36167. * @param scene Define the scene the texture should be created in
  36168. * @param stream Define the stream the texture should be created from
  36169. * @returns The created video texture as a promise
  36170. */
  36171. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36172. /**
  36173. * Creates a video texture straight from your WebCam video feed.
  36174. * @param scene Define the scene the texture should be created in
  36175. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36176. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36177. * @returns The created video texture as a promise
  36178. */
  36179. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36180. minWidth: number;
  36181. maxWidth: number;
  36182. minHeight: number;
  36183. maxHeight: number;
  36184. deviceId: string;
  36185. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36186. /**
  36187. * Creates a video texture straight from your WebCam video feed.
  36188. * @param scene Define the scene the texture should be created in
  36189. * @param onReady Define a callback to triggered once the texture will be ready
  36190. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36191. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36192. */
  36193. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36194. minWidth: number;
  36195. maxWidth: number;
  36196. minHeight: number;
  36197. maxHeight: number;
  36198. deviceId: string;
  36199. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36200. }
  36201. }
  36202. declare module "babylonjs/Engines/thinEngine" {
  36203. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36204. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36205. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36206. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36207. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36208. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36209. import { Observable } from "babylonjs/Misc/observable";
  36210. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36211. import { StencilState } from "babylonjs/States/stencilState";
  36212. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36213. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36214. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36216. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36217. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36218. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36219. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36220. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36222. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36223. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36224. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36225. import { WebRequest } from "babylonjs/Misc/webRequest";
  36226. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36227. /**
  36228. * Defines the interface used by objects working like Scene
  36229. * @hidden
  36230. */
  36231. export interface ISceneLike {
  36232. _addPendingData(data: any): void;
  36233. _removePendingData(data: any): void;
  36234. offlineProvider: IOfflineProvider;
  36235. }
  36236. /** Interface defining initialization parameters for Engine class */
  36237. export interface EngineOptions extends WebGLContextAttributes {
  36238. /**
  36239. * Defines if the engine should no exceed a specified device ratio
  36240. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36241. */
  36242. limitDeviceRatio?: number;
  36243. /**
  36244. * Defines if webvr should be enabled automatically
  36245. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36246. */
  36247. autoEnableWebVR?: boolean;
  36248. /**
  36249. * Defines if webgl2 should be turned off even if supported
  36250. * @see https://doc.babylonjs.com/features/webgl2
  36251. */
  36252. disableWebGL2Support?: boolean;
  36253. /**
  36254. * Defines if webaudio should be initialized as well
  36255. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36256. */
  36257. audioEngine?: boolean;
  36258. /**
  36259. * Defines if animations should run using a deterministic lock step
  36260. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36261. */
  36262. deterministicLockstep?: boolean;
  36263. /** Defines the maximum steps to use with deterministic lock step mode */
  36264. lockstepMaxSteps?: number;
  36265. /** Defines the seconds between each deterministic lock step */
  36266. timeStep?: number;
  36267. /**
  36268. * Defines that engine should ignore context lost events
  36269. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36270. */
  36271. doNotHandleContextLost?: boolean;
  36272. /**
  36273. * Defines that engine should ignore modifying touch action attribute and style
  36274. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36275. */
  36276. doNotHandleTouchAction?: boolean;
  36277. /**
  36278. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36279. */
  36280. useHighPrecisionFloats?: boolean;
  36281. /**
  36282. * Make the canvas XR Compatible for XR sessions
  36283. */
  36284. xrCompatible?: boolean;
  36285. /**
  36286. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36287. */
  36288. useHighPrecisionMatrix?: boolean;
  36289. }
  36290. /**
  36291. * The base engine class (root of all engines)
  36292. */
  36293. export class ThinEngine {
  36294. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36295. static ExceptionList: ({
  36296. key: string;
  36297. capture: string;
  36298. captureConstraint: number;
  36299. targets: string[];
  36300. } | {
  36301. key: string;
  36302. capture: null;
  36303. captureConstraint: null;
  36304. targets: string[];
  36305. })[];
  36306. /** @hidden */
  36307. static _TextureLoaders: IInternalTextureLoader[];
  36308. /**
  36309. * Returns the current npm package of the sdk
  36310. */
  36311. static get NpmPackage(): string;
  36312. /**
  36313. * Returns the current version of the framework
  36314. */
  36315. static get Version(): string;
  36316. /**
  36317. * Returns a string describing the current engine
  36318. */
  36319. get description(): string;
  36320. /**
  36321. * Gets or sets the epsilon value used by collision engine
  36322. */
  36323. static CollisionsEpsilon: number;
  36324. /**
  36325. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36326. */
  36327. static get ShadersRepository(): string;
  36328. static set ShadersRepository(value: string);
  36329. /** @hidden */
  36330. _shaderProcessor: IShaderProcessor;
  36331. /**
  36332. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36333. */
  36334. forcePOTTextures: boolean;
  36335. /**
  36336. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36337. */
  36338. isFullscreen: boolean;
  36339. /**
  36340. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36341. */
  36342. cullBackFaces: boolean;
  36343. /**
  36344. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36345. */
  36346. renderEvenInBackground: boolean;
  36347. /**
  36348. * Gets or sets a boolean indicating that cache can be kept between frames
  36349. */
  36350. preventCacheWipeBetweenFrames: boolean;
  36351. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36352. validateShaderPrograms: boolean;
  36353. /**
  36354. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36355. * This can provide greater z depth for distant objects.
  36356. */
  36357. useReverseDepthBuffer: boolean;
  36358. /**
  36359. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36360. */
  36361. disableUniformBuffers: boolean;
  36362. /** @hidden */
  36363. _uniformBuffers: UniformBuffer[];
  36364. /**
  36365. * Gets a boolean indicating that the engine supports uniform buffers
  36366. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36367. */
  36368. get supportsUniformBuffers(): boolean;
  36369. /** @hidden */
  36370. _gl: WebGLRenderingContext;
  36371. /** @hidden */
  36372. _webGLVersion: number;
  36373. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36374. protected _windowIsBackground: boolean;
  36375. protected _creationOptions: EngineOptions;
  36376. protected _highPrecisionShadersAllowed: boolean;
  36377. /** @hidden */
  36378. get _shouldUseHighPrecisionShader(): boolean;
  36379. /**
  36380. * Gets a boolean indicating that only power of 2 textures are supported
  36381. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36382. */
  36383. get needPOTTextures(): boolean;
  36384. /** @hidden */
  36385. _badOS: boolean;
  36386. /** @hidden */
  36387. _badDesktopOS: boolean;
  36388. private _hardwareScalingLevel;
  36389. /** @hidden */
  36390. _caps: EngineCapabilities;
  36391. private _isStencilEnable;
  36392. private _glVersion;
  36393. private _glRenderer;
  36394. private _glVendor;
  36395. /** @hidden */
  36396. _videoTextureSupported: boolean;
  36397. protected _renderingQueueLaunched: boolean;
  36398. protected _activeRenderLoops: (() => void)[];
  36399. /**
  36400. * Observable signaled when a context lost event is raised
  36401. */
  36402. onContextLostObservable: Observable<ThinEngine>;
  36403. /**
  36404. * Observable signaled when a context restored event is raised
  36405. */
  36406. onContextRestoredObservable: Observable<ThinEngine>;
  36407. private _onContextLost;
  36408. private _onContextRestored;
  36409. protected _contextWasLost: boolean;
  36410. /** @hidden */
  36411. _doNotHandleContextLost: boolean;
  36412. /**
  36413. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36414. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36415. */
  36416. get doNotHandleContextLost(): boolean;
  36417. set doNotHandleContextLost(value: boolean);
  36418. /**
  36419. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36420. */
  36421. disableVertexArrayObjects: boolean;
  36422. /** @hidden */
  36423. protected _colorWrite: boolean;
  36424. /** @hidden */
  36425. protected _colorWriteChanged: boolean;
  36426. /** @hidden */
  36427. protected _depthCullingState: DepthCullingState;
  36428. /** @hidden */
  36429. protected _stencilState: StencilState;
  36430. /** @hidden */
  36431. _alphaState: AlphaState;
  36432. /** @hidden */
  36433. _alphaMode: number;
  36434. /** @hidden */
  36435. _alphaEquation: number;
  36436. /** @hidden */
  36437. _internalTexturesCache: InternalTexture[];
  36438. /** @hidden */
  36439. protected _activeChannel: number;
  36440. private _currentTextureChannel;
  36441. /** @hidden */
  36442. protected _boundTexturesCache: {
  36443. [key: string]: Nullable<InternalTexture>;
  36444. };
  36445. /** @hidden */
  36446. protected _currentEffect: Nullable<Effect>;
  36447. /** @hidden */
  36448. protected _currentProgram: Nullable<WebGLProgram>;
  36449. private _compiledEffects;
  36450. private _vertexAttribArraysEnabled;
  36451. /** @hidden */
  36452. protected _cachedViewport: Nullable<IViewportLike>;
  36453. private _cachedVertexArrayObject;
  36454. /** @hidden */
  36455. protected _cachedVertexBuffers: any;
  36456. /** @hidden */
  36457. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36458. /** @hidden */
  36459. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36460. /** @hidden */
  36461. _currentRenderTarget: Nullable<InternalTexture>;
  36462. private _uintIndicesCurrentlySet;
  36463. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36464. /** @hidden */
  36465. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36466. /** @hidden */
  36467. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36468. private _currentBufferPointers;
  36469. private _currentInstanceLocations;
  36470. private _currentInstanceBuffers;
  36471. private _textureUnits;
  36472. /** @hidden */
  36473. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36474. /** @hidden */
  36475. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36476. /** @hidden */
  36477. _boundRenderFunction: any;
  36478. private _vaoRecordInProgress;
  36479. private _mustWipeVertexAttributes;
  36480. private _emptyTexture;
  36481. private _emptyCubeTexture;
  36482. private _emptyTexture3D;
  36483. private _emptyTexture2DArray;
  36484. /** @hidden */
  36485. _frameHandler: number;
  36486. private _nextFreeTextureSlots;
  36487. private _maxSimultaneousTextures;
  36488. private _activeRequests;
  36489. /** @hidden */
  36490. _transformTextureUrl: Nullable<(url: string) => string>;
  36491. protected get _supportsHardwareTextureRescaling(): boolean;
  36492. private _framebufferDimensionsObject;
  36493. /**
  36494. * sets the object from which width and height will be taken from when getting render width and height
  36495. * Will fallback to the gl object
  36496. * @param dimensions the framebuffer width and height that will be used.
  36497. */
  36498. set framebufferDimensionsObject(dimensions: Nullable<{
  36499. framebufferWidth: number;
  36500. framebufferHeight: number;
  36501. }>);
  36502. /**
  36503. * Gets the current viewport
  36504. */
  36505. get currentViewport(): Nullable<IViewportLike>;
  36506. /**
  36507. * Gets the default empty texture
  36508. */
  36509. get emptyTexture(): InternalTexture;
  36510. /**
  36511. * Gets the default empty 3D texture
  36512. */
  36513. get emptyTexture3D(): InternalTexture;
  36514. /**
  36515. * Gets the default empty 2D array texture
  36516. */
  36517. get emptyTexture2DArray(): InternalTexture;
  36518. /**
  36519. * Gets the default empty cube texture
  36520. */
  36521. get emptyCubeTexture(): InternalTexture;
  36522. /**
  36523. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36524. */
  36525. readonly premultipliedAlpha: boolean;
  36526. /**
  36527. * Observable event triggered before each texture is initialized
  36528. */
  36529. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36530. /**
  36531. * Creates a new engine
  36532. * @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
  36533. * @param antialias defines enable antialiasing (default: false)
  36534. * @param options defines further options to be sent to the getContext() function
  36535. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36536. */
  36537. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36538. private _rebuildInternalTextures;
  36539. private _rebuildEffects;
  36540. /**
  36541. * Gets a boolean indicating if all created effects are ready
  36542. * @returns true if all effects are ready
  36543. */
  36544. areAllEffectsReady(): boolean;
  36545. protected _rebuildBuffers(): void;
  36546. protected _initGLContext(): void;
  36547. /**
  36548. * Gets version of the current webGL context
  36549. */
  36550. get webGLVersion(): number;
  36551. /**
  36552. * Gets a string idenfifying the name of the class
  36553. * @returns "Engine" string
  36554. */
  36555. getClassName(): string;
  36556. /**
  36557. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36558. */
  36559. get isStencilEnable(): boolean;
  36560. /** @hidden */
  36561. _prepareWorkingCanvas(): void;
  36562. /**
  36563. * Reset the texture cache to empty state
  36564. */
  36565. resetTextureCache(): void;
  36566. /**
  36567. * Gets an object containing information about the current webGL context
  36568. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36569. */
  36570. getGlInfo(): {
  36571. vendor: string;
  36572. renderer: string;
  36573. version: string;
  36574. };
  36575. /**
  36576. * Defines the hardware scaling level.
  36577. * By default the hardware scaling level is computed from the window device ratio.
  36578. * 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.
  36579. * @param level defines the level to use
  36580. */
  36581. setHardwareScalingLevel(level: number): void;
  36582. /**
  36583. * Gets the current hardware scaling level.
  36584. * By default the hardware scaling level is computed from the window device ratio.
  36585. * 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.
  36586. * @returns a number indicating the current hardware scaling level
  36587. */
  36588. getHardwareScalingLevel(): number;
  36589. /**
  36590. * Gets the list of loaded textures
  36591. * @returns an array containing all loaded textures
  36592. */
  36593. getLoadedTexturesCache(): InternalTexture[];
  36594. /**
  36595. * Gets the object containing all engine capabilities
  36596. * @returns the EngineCapabilities object
  36597. */
  36598. getCaps(): EngineCapabilities;
  36599. /**
  36600. * stop executing a render loop function and remove it from the execution array
  36601. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36602. */
  36603. stopRenderLoop(renderFunction?: () => void): void;
  36604. /** @hidden */
  36605. _renderLoop(): void;
  36606. /**
  36607. * Gets the HTML canvas attached with the current webGL context
  36608. * @returns a HTML canvas
  36609. */
  36610. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36611. /**
  36612. * Gets host window
  36613. * @returns the host window object
  36614. */
  36615. getHostWindow(): Nullable<Window>;
  36616. /**
  36617. * Gets the current render width
  36618. * @param useScreen defines if screen size must be used (or the current render target if any)
  36619. * @returns a number defining the current render width
  36620. */
  36621. getRenderWidth(useScreen?: boolean): number;
  36622. /**
  36623. * Gets the current render height
  36624. * @param useScreen defines if screen size must be used (or the current render target if any)
  36625. * @returns a number defining the current render height
  36626. */
  36627. getRenderHeight(useScreen?: boolean): number;
  36628. /**
  36629. * Can be used to override the current requestAnimationFrame requester.
  36630. * @hidden
  36631. */
  36632. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36633. /**
  36634. * Register and execute a render loop. The engine can have more than one render function
  36635. * @param renderFunction defines the function to continuously execute
  36636. */
  36637. runRenderLoop(renderFunction: () => void): void;
  36638. /**
  36639. * Clear the current render buffer or the current render target (if any is set up)
  36640. * @param color defines the color to use
  36641. * @param backBuffer defines if the back buffer must be cleared
  36642. * @param depth defines if the depth buffer must be cleared
  36643. * @param stencil defines if the stencil buffer must be cleared
  36644. */
  36645. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36646. private _viewportCached;
  36647. /** @hidden */
  36648. _viewport(x: number, y: number, width: number, height: number): void;
  36649. /**
  36650. * Set the WebGL's viewport
  36651. * @param viewport defines the viewport element to be used
  36652. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36653. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36654. */
  36655. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36656. /**
  36657. * Begin a new frame
  36658. */
  36659. beginFrame(): void;
  36660. /**
  36661. * Enf the current frame
  36662. */
  36663. endFrame(): void;
  36664. /**
  36665. * Resize the view according to the canvas' size
  36666. */
  36667. resize(): void;
  36668. /**
  36669. * Force a specific size of the canvas
  36670. * @param width defines the new canvas' width
  36671. * @param height defines the new canvas' height
  36672. * @returns true if the size was changed
  36673. */
  36674. setSize(width: number, height: number): boolean;
  36675. /**
  36676. * Binds the frame buffer to the specified texture.
  36677. * @param texture The texture to render to or null for the default canvas
  36678. * @param faceIndex The face of the texture to render to in case of cube texture
  36679. * @param requiredWidth The width of the target to render to
  36680. * @param requiredHeight The height of the target to render to
  36681. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36682. * @param lodLevel defines the lod level to bind to the frame buffer
  36683. * @param layer defines the 2d array index to bind to frame buffer to
  36684. */
  36685. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36686. /** @hidden */
  36687. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36688. /**
  36689. * Unbind the current render target texture from the webGL context
  36690. * @param texture defines the render target texture to unbind
  36691. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36692. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36693. */
  36694. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36695. /**
  36696. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36697. */
  36698. flushFramebuffer(): void;
  36699. /**
  36700. * Unbind the current render target and bind the default framebuffer
  36701. */
  36702. restoreDefaultFramebuffer(): void;
  36703. /** @hidden */
  36704. protected _resetVertexBufferBinding(): void;
  36705. /**
  36706. * Creates a vertex buffer
  36707. * @param data the data for the vertex buffer
  36708. * @returns the new WebGL static buffer
  36709. */
  36710. createVertexBuffer(data: DataArray): DataBuffer;
  36711. private _createVertexBuffer;
  36712. /**
  36713. * Creates a dynamic vertex buffer
  36714. * @param data the data for the dynamic vertex buffer
  36715. * @returns the new WebGL dynamic buffer
  36716. */
  36717. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36718. protected _resetIndexBufferBinding(): void;
  36719. /**
  36720. * Creates a new index buffer
  36721. * @param indices defines the content of the index buffer
  36722. * @param updatable defines if the index buffer must be updatable
  36723. * @returns a new webGL buffer
  36724. */
  36725. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36726. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36727. /**
  36728. * Bind a webGL buffer to the webGL context
  36729. * @param buffer defines the buffer to bind
  36730. */
  36731. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36732. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36733. private bindBuffer;
  36734. /**
  36735. * update the bound buffer with the given data
  36736. * @param data defines the data to update
  36737. */
  36738. updateArrayBuffer(data: Float32Array): void;
  36739. private _vertexAttribPointer;
  36740. /** @hidden */
  36741. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36742. private _bindVertexBuffersAttributes;
  36743. /**
  36744. * Records a vertex array object
  36745. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36746. * @param vertexBuffers defines the list of vertex buffers to store
  36747. * @param indexBuffer defines the index buffer to store
  36748. * @param effect defines the effect to store
  36749. * @returns the new vertex array object
  36750. */
  36751. recordVertexArrayObject(vertexBuffers: {
  36752. [key: string]: VertexBuffer;
  36753. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36754. /**
  36755. * Bind a specific vertex array object
  36756. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36757. * @param vertexArrayObject defines the vertex array object to bind
  36758. * @param indexBuffer defines the index buffer to bind
  36759. */
  36760. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36761. /**
  36762. * Bind webGl buffers directly to the webGL context
  36763. * @param vertexBuffer defines the vertex buffer to bind
  36764. * @param indexBuffer defines the index buffer to bind
  36765. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36766. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36767. * @param effect defines the effect associated with the vertex buffer
  36768. */
  36769. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36770. private _unbindVertexArrayObject;
  36771. /**
  36772. * Bind a list of vertex buffers to the webGL context
  36773. * @param vertexBuffers defines the list of vertex buffers to bind
  36774. * @param indexBuffer defines the index buffer to bind
  36775. * @param effect defines the effect associated with the vertex buffers
  36776. */
  36777. bindBuffers(vertexBuffers: {
  36778. [key: string]: Nullable<VertexBuffer>;
  36779. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36780. /**
  36781. * Unbind all instance attributes
  36782. */
  36783. unbindInstanceAttributes(): void;
  36784. /**
  36785. * Release and free the memory of a vertex array object
  36786. * @param vao defines the vertex array object to delete
  36787. */
  36788. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36789. /** @hidden */
  36790. _releaseBuffer(buffer: DataBuffer): boolean;
  36791. protected _deleteBuffer(buffer: DataBuffer): void;
  36792. /**
  36793. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36794. * @param instancesBuffer defines the webGL buffer to update and bind
  36795. * @param data defines the data to store in the buffer
  36796. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36797. */
  36798. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36799. /**
  36800. * Bind the content of a webGL buffer used with instantiation
  36801. * @param instancesBuffer defines the webGL buffer to bind
  36802. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36803. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36804. */
  36805. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36806. /**
  36807. * Disable the instance attribute corresponding to the name in parameter
  36808. * @param name defines the name of the attribute to disable
  36809. */
  36810. disableInstanceAttributeByName(name: string): void;
  36811. /**
  36812. * Disable the instance attribute corresponding to the location in parameter
  36813. * @param attributeLocation defines the attribute location of the attribute to disable
  36814. */
  36815. disableInstanceAttribute(attributeLocation: number): void;
  36816. /**
  36817. * Disable the attribute corresponding to the location in parameter
  36818. * @param attributeLocation defines the attribute location of the attribute to disable
  36819. */
  36820. disableAttributeByIndex(attributeLocation: number): void;
  36821. /**
  36822. * Send a draw order
  36823. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36824. * @param indexStart defines the starting index
  36825. * @param indexCount defines the number of index to draw
  36826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36827. */
  36828. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36829. /**
  36830. * Draw a list of points
  36831. * @param verticesStart defines the index of first vertex to draw
  36832. * @param verticesCount defines the count of vertices to draw
  36833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36834. */
  36835. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36836. /**
  36837. * Draw a list of unindexed primitives
  36838. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36839. * @param verticesStart defines the index of first vertex to draw
  36840. * @param verticesCount defines the count of vertices to draw
  36841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36842. */
  36843. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36844. /**
  36845. * Draw a list of indexed primitives
  36846. * @param fillMode defines the primitive to use
  36847. * @param indexStart defines the starting index
  36848. * @param indexCount defines the number of index to draw
  36849. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36850. */
  36851. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36852. /**
  36853. * Draw a list of unindexed primitives
  36854. * @param fillMode defines the primitive to use
  36855. * @param verticesStart defines the index of first vertex to draw
  36856. * @param verticesCount defines the count of vertices to draw
  36857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36858. */
  36859. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36860. private _drawMode;
  36861. /** @hidden */
  36862. protected _reportDrawCall(): void;
  36863. /** @hidden */
  36864. _releaseEffect(effect: Effect): void;
  36865. /** @hidden */
  36866. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36867. /**
  36868. * Create a new effect (used to store vertex/fragment shaders)
  36869. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36870. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36871. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36872. * @param samplers defines an array of string used to represent textures
  36873. * @param defines defines the string containing the defines to use to compile the shaders
  36874. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36875. * @param onCompiled defines a function to call when the effect creation is successful
  36876. * @param onError defines a function to call when the effect creation has failed
  36877. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36878. * @returns the new Effect
  36879. */
  36880. 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;
  36881. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36882. private _compileShader;
  36883. private _compileRawShader;
  36884. /** @hidden */
  36885. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36886. /**
  36887. * Directly creates a webGL program
  36888. * @param pipelineContext defines the pipeline context to attach to
  36889. * @param vertexCode defines the vertex shader code to use
  36890. * @param fragmentCode defines the fragment shader code to use
  36891. * @param context defines the webGL context to use (if not set, the current one will be used)
  36892. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36893. * @returns the new webGL program
  36894. */
  36895. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36896. /**
  36897. * Creates a webGL program
  36898. * @param pipelineContext defines the pipeline context to attach to
  36899. * @param vertexCode defines the vertex shader code to use
  36900. * @param fragmentCode defines the fragment shader code to use
  36901. * @param defines defines the string containing the defines to use to compile the shaders
  36902. * @param context defines the webGL context to use (if not set, the current one will be used)
  36903. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36904. * @returns the new webGL program
  36905. */
  36906. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36907. /**
  36908. * Creates a new pipeline context
  36909. * @returns the new pipeline
  36910. */
  36911. createPipelineContext(): IPipelineContext;
  36912. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36913. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36914. /** @hidden */
  36915. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36916. /** @hidden */
  36917. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36918. /** @hidden */
  36919. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36920. /**
  36921. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36922. * @param pipelineContext defines the pipeline context to use
  36923. * @param uniformsNames defines the list of uniform names
  36924. * @returns an array of webGL uniform locations
  36925. */
  36926. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36927. /**
  36928. * Gets the lsit of active attributes for a given webGL program
  36929. * @param pipelineContext defines the pipeline context to use
  36930. * @param attributesNames defines the list of attribute names to get
  36931. * @returns an array of indices indicating the offset of each attribute
  36932. */
  36933. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36934. /**
  36935. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36936. * @param effect defines the effect to activate
  36937. */
  36938. enableEffect(effect: Nullable<Effect>): void;
  36939. /**
  36940. * Set the value of an uniform to a number (int)
  36941. * @param uniform defines the webGL uniform location where to store the value
  36942. * @param value defines the int number to store
  36943. */
  36944. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36945. /**
  36946. * Set the value of an uniform to an array of int32
  36947. * @param uniform defines the webGL uniform location where to store the value
  36948. * @param array defines the array of int32 to store
  36949. */
  36950. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36951. /**
  36952. * Set the value of an uniform to an array of int32 (stored as vec2)
  36953. * @param uniform defines the webGL uniform location where to store the value
  36954. * @param array defines the array of int32 to store
  36955. */
  36956. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36957. /**
  36958. * Set the value of an uniform to an array of int32 (stored as vec3)
  36959. * @param uniform defines the webGL uniform location where to store the value
  36960. * @param array defines the array of int32 to store
  36961. */
  36962. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36963. /**
  36964. * Set the value of an uniform to an array of int32 (stored as vec4)
  36965. * @param uniform defines the webGL uniform location where to store the value
  36966. * @param array defines the array of int32 to store
  36967. */
  36968. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36969. /**
  36970. * Set the value of an uniform to an array of number
  36971. * @param uniform defines the webGL uniform location where to store the value
  36972. * @param array defines the array of number to store
  36973. */
  36974. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36975. /**
  36976. * Set the value of an uniform to an array of number (stored as vec2)
  36977. * @param uniform defines the webGL uniform location where to store the value
  36978. * @param array defines the array of number to store
  36979. */
  36980. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36981. /**
  36982. * Set the value of an uniform to an array of number (stored as vec3)
  36983. * @param uniform defines the webGL uniform location where to store the value
  36984. * @param array defines the array of number to store
  36985. */
  36986. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36987. /**
  36988. * Set the value of an uniform to an array of number (stored as vec4)
  36989. * @param uniform defines the webGL uniform location where to store the value
  36990. * @param array defines the array of number to store
  36991. */
  36992. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36993. /**
  36994. * Set the value of an uniform to an array of float32 (stored as matrices)
  36995. * @param uniform defines the webGL uniform location where to store the value
  36996. * @param matrices defines the array of float32 to store
  36997. */
  36998. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36999. /**
  37000. * Set the value of an uniform to a matrix (3x3)
  37001. * @param uniform defines the webGL uniform location where to store the value
  37002. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37003. */
  37004. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37005. /**
  37006. * Set the value of an uniform to a matrix (2x2)
  37007. * @param uniform defines the webGL uniform location where to store the value
  37008. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37009. */
  37010. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37011. /**
  37012. * Set the value of an uniform to a number (float)
  37013. * @param uniform defines the webGL uniform location where to store the value
  37014. * @param value defines the float number to store
  37015. */
  37016. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37017. /**
  37018. * Set the value of an uniform to a vec2
  37019. * @param uniform defines the webGL uniform location where to store the value
  37020. * @param x defines the 1st component of the value
  37021. * @param y defines the 2nd component of the value
  37022. */
  37023. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37024. /**
  37025. * Set the value of an uniform to a vec3
  37026. * @param uniform defines the webGL uniform location where to store the value
  37027. * @param x defines the 1st component of the value
  37028. * @param y defines the 2nd component of the value
  37029. * @param z defines the 3rd component of the value
  37030. */
  37031. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37032. /**
  37033. * Set the value of an uniform to a vec4
  37034. * @param uniform defines the webGL uniform location where to store the value
  37035. * @param x defines the 1st component of the value
  37036. * @param y defines the 2nd component of the value
  37037. * @param z defines the 3rd component of the value
  37038. * @param w defines the 4th component of the value
  37039. */
  37040. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37041. /**
  37042. * Apply all cached states (depth, culling, stencil and alpha)
  37043. */
  37044. applyStates(): void;
  37045. /**
  37046. * Enable or disable color writing
  37047. * @param enable defines the state to set
  37048. */
  37049. setColorWrite(enable: boolean): void;
  37050. /**
  37051. * Gets a boolean indicating if color writing is enabled
  37052. * @returns the current color writing state
  37053. */
  37054. getColorWrite(): boolean;
  37055. /**
  37056. * Gets the depth culling state manager
  37057. */
  37058. get depthCullingState(): DepthCullingState;
  37059. /**
  37060. * Gets the alpha state manager
  37061. */
  37062. get alphaState(): AlphaState;
  37063. /**
  37064. * Gets the stencil state manager
  37065. */
  37066. get stencilState(): StencilState;
  37067. /**
  37068. * Clears the list of texture accessible through engine.
  37069. * This can help preventing texture load conflict due to name collision.
  37070. */
  37071. clearInternalTexturesCache(): void;
  37072. /**
  37073. * Force the entire cache to be cleared
  37074. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37075. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37076. */
  37077. wipeCaches(bruteForce?: boolean): void;
  37078. /** @hidden */
  37079. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37080. min: number;
  37081. mag: number;
  37082. };
  37083. /** @hidden */
  37084. _createTexture(): WebGLTexture;
  37085. /**
  37086. * Usually called from Texture.ts.
  37087. * Passed information to create a WebGLTexture
  37088. * @param url defines a value which contains one of the following:
  37089. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37090. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37091. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37092. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37093. * @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)
  37094. * @param scene needed for loading to the correct scene
  37095. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37096. * @param onLoad optional callback to be called upon successful completion
  37097. * @param onError optional callback to be called upon failure
  37098. * @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
  37099. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37100. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37101. * @param forcedExtension defines the extension to use to pick the right loader
  37102. * @param mimeType defines an optional mime type
  37103. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37104. */
  37105. 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;
  37106. /**
  37107. * Loads an image as an HTMLImageElement.
  37108. * @param input url string, ArrayBuffer, or Blob to load
  37109. * @param onLoad callback called when the image successfully loads
  37110. * @param onError callback called when the image fails to load
  37111. * @param offlineProvider offline provider for caching
  37112. * @param mimeType optional mime type
  37113. * @returns the HTMLImageElement of the loaded image
  37114. * @hidden
  37115. */
  37116. 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>;
  37117. /**
  37118. * @hidden
  37119. */
  37120. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37121. private _unpackFlipYCached;
  37122. /**
  37123. * In case you are sharing the context with other applications, it might
  37124. * be interested to not cache the unpack flip y state to ensure a consistent
  37125. * value would be set.
  37126. */
  37127. enableUnpackFlipYCached: boolean;
  37128. /** @hidden */
  37129. _unpackFlipY(value: boolean): void;
  37130. /** @hidden */
  37131. _getUnpackAlignement(): number;
  37132. private _getTextureTarget;
  37133. /**
  37134. * Update the sampling mode of a given texture
  37135. * @param samplingMode defines the required sampling mode
  37136. * @param texture defines the texture to update
  37137. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37138. */
  37139. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37140. /**
  37141. * Update the sampling mode of a given texture
  37142. * @param texture defines the texture to update
  37143. * @param wrapU defines the texture wrap mode of the u coordinates
  37144. * @param wrapV defines the texture wrap mode of the v coordinates
  37145. * @param wrapR defines the texture wrap mode of the r coordinates
  37146. */
  37147. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37148. /** @hidden */
  37149. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37150. width: number;
  37151. height: number;
  37152. layers?: number;
  37153. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37154. /** @hidden */
  37155. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37156. /** @hidden */
  37157. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37158. /**
  37159. * Update a portion of an internal texture
  37160. * @param texture defines the texture to update
  37161. * @param imageData defines the data to store into the texture
  37162. * @param xOffset defines the x coordinates of the update rectangle
  37163. * @param yOffset defines the y coordinates of the update rectangle
  37164. * @param width defines the width of the update rectangle
  37165. * @param height defines the height of the update rectangle
  37166. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37167. * @param lod defines the lod level to update (0 by default)
  37168. */
  37169. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37170. /** @hidden */
  37171. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37172. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37173. private _prepareWebGLTexture;
  37174. /** @hidden */
  37175. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37176. private _getDepthStencilBuffer;
  37177. /** @hidden */
  37178. _releaseFramebufferObjects(texture: InternalTexture): void;
  37179. /** @hidden */
  37180. _releaseTexture(texture: InternalTexture): void;
  37181. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37182. protected _setProgram(program: WebGLProgram): void;
  37183. protected _boundUniforms: {
  37184. [key: number]: WebGLUniformLocation;
  37185. };
  37186. /**
  37187. * Binds an effect to the webGL context
  37188. * @param effect defines the effect to bind
  37189. */
  37190. bindSamplers(effect: Effect): void;
  37191. private _activateCurrentTexture;
  37192. /** @hidden */
  37193. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37194. /** @hidden */
  37195. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37196. /**
  37197. * Unbind all textures from the webGL context
  37198. */
  37199. unbindAllTextures(): void;
  37200. /**
  37201. * Sets a texture to the according uniform.
  37202. * @param channel The texture channel
  37203. * @param uniform The uniform to set
  37204. * @param texture The texture to apply
  37205. */
  37206. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37207. private _bindSamplerUniformToChannel;
  37208. private _getTextureWrapMode;
  37209. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37210. /**
  37211. * Sets an array of texture to the webGL context
  37212. * @param channel defines the channel where the texture array must be set
  37213. * @param uniform defines the associated uniform location
  37214. * @param textures defines the array of textures to bind
  37215. */
  37216. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37217. /** @hidden */
  37218. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37219. private _setTextureParameterFloat;
  37220. private _setTextureParameterInteger;
  37221. /**
  37222. * Unbind all vertex attributes from the webGL context
  37223. */
  37224. unbindAllAttributes(): void;
  37225. /**
  37226. * 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
  37227. */
  37228. releaseEffects(): void;
  37229. /**
  37230. * Dispose and release all associated resources
  37231. */
  37232. dispose(): void;
  37233. /**
  37234. * Attach a new callback raised when context lost event is fired
  37235. * @param callback defines the callback to call
  37236. */
  37237. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37238. /**
  37239. * Attach a new callback raised when context restored event is fired
  37240. * @param callback defines the callback to call
  37241. */
  37242. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37243. /**
  37244. * Get the current error code of the webGL context
  37245. * @returns the error code
  37246. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37247. */
  37248. getError(): number;
  37249. private _canRenderToFloatFramebuffer;
  37250. private _canRenderToHalfFloatFramebuffer;
  37251. private _canRenderToFramebuffer;
  37252. /** @hidden */
  37253. _getWebGLTextureType(type: number): number;
  37254. /** @hidden */
  37255. _getInternalFormat(format: number): number;
  37256. /** @hidden */
  37257. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37258. /** @hidden */
  37259. _getRGBAMultiSampleBufferFormat(type: number): number;
  37260. /** @hidden */
  37261. _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;
  37262. /**
  37263. * Loads a file from a url
  37264. * @param url url to load
  37265. * @param onSuccess callback called when the file successfully loads
  37266. * @param onProgress callback called while file is loading (if the server supports this mode)
  37267. * @param offlineProvider defines the offline provider for caching
  37268. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37269. * @param onError callback called when the file fails to load
  37270. * @returns a file request object
  37271. * @hidden
  37272. */
  37273. 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;
  37274. /**
  37275. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37276. * @param x defines the x coordinate of the rectangle where pixels must be read
  37277. * @param y defines the y coordinate of the rectangle where pixels must be read
  37278. * @param width defines the width of the rectangle where pixels must be read
  37279. * @param height defines the height of the rectangle where pixels must be read
  37280. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37281. * @returns a Uint8Array containing RGBA colors
  37282. */
  37283. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37284. private static _isSupported;
  37285. /**
  37286. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37287. * @returns true if the engine can be created
  37288. * @ignorenaming
  37289. */
  37290. static isSupported(): boolean;
  37291. /**
  37292. * Find the next highest power of two.
  37293. * @param x Number to start search from.
  37294. * @return Next highest power of two.
  37295. */
  37296. static CeilingPOT(x: number): number;
  37297. /**
  37298. * Find the next lowest power of two.
  37299. * @param x Number to start search from.
  37300. * @return Next lowest power of two.
  37301. */
  37302. static FloorPOT(x: number): number;
  37303. /**
  37304. * Find the nearest power of two.
  37305. * @param x Number to start search from.
  37306. * @return Next nearest power of two.
  37307. */
  37308. static NearestPOT(x: number): number;
  37309. /**
  37310. * Get the closest exponent of two
  37311. * @param value defines the value to approximate
  37312. * @param max defines the maximum value to return
  37313. * @param mode defines how to define the closest value
  37314. * @returns closest exponent of two of the given value
  37315. */
  37316. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37317. /**
  37318. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37319. * @param func - the function to be called
  37320. * @param requester - the object that will request the next frame. Falls back to window.
  37321. * @returns frame number
  37322. */
  37323. static QueueNewFrame(func: () => void, requester?: any): number;
  37324. /**
  37325. * Gets host document
  37326. * @returns the host document object
  37327. */
  37328. getHostDocument(): Nullable<Document>;
  37329. }
  37330. }
  37331. declare module "babylonjs/Maths/sphericalPolynomial" {
  37332. import { Vector3 } from "babylonjs/Maths/math.vector";
  37333. import { Color3 } from "babylonjs/Maths/math.color";
  37334. /**
  37335. * Class representing spherical harmonics coefficients to the 3rd degree
  37336. */
  37337. export class SphericalHarmonics {
  37338. /**
  37339. * Defines whether or not the harmonics have been prescaled for rendering.
  37340. */
  37341. preScaled: boolean;
  37342. /**
  37343. * The l0,0 coefficients of the spherical harmonics
  37344. */
  37345. l00: Vector3;
  37346. /**
  37347. * The l1,-1 coefficients of the spherical harmonics
  37348. */
  37349. l1_1: Vector3;
  37350. /**
  37351. * The l1,0 coefficients of the spherical harmonics
  37352. */
  37353. l10: Vector3;
  37354. /**
  37355. * The l1,1 coefficients of the spherical harmonics
  37356. */
  37357. l11: Vector3;
  37358. /**
  37359. * The l2,-2 coefficients of the spherical harmonics
  37360. */
  37361. l2_2: Vector3;
  37362. /**
  37363. * The l2,-1 coefficients of the spherical harmonics
  37364. */
  37365. l2_1: Vector3;
  37366. /**
  37367. * The l2,0 coefficients of the spherical harmonics
  37368. */
  37369. l20: Vector3;
  37370. /**
  37371. * The l2,1 coefficients of the spherical harmonics
  37372. */
  37373. l21: Vector3;
  37374. /**
  37375. * The l2,2 coefficients of the spherical harmonics
  37376. */
  37377. l22: Vector3;
  37378. /**
  37379. * Adds a light to the spherical harmonics
  37380. * @param direction the direction of the light
  37381. * @param color the color of the light
  37382. * @param deltaSolidAngle the delta solid angle of the light
  37383. */
  37384. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37385. /**
  37386. * Scales the spherical harmonics by the given amount
  37387. * @param scale the amount to scale
  37388. */
  37389. scaleInPlace(scale: number): void;
  37390. /**
  37391. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37392. *
  37393. * ```
  37394. * E_lm = A_l * L_lm
  37395. * ```
  37396. *
  37397. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37398. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37399. * the scaling factors are given in equation 9.
  37400. */
  37401. convertIncidentRadianceToIrradiance(): void;
  37402. /**
  37403. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37404. *
  37405. * ```
  37406. * L = (1/pi) * E * rho
  37407. * ```
  37408. *
  37409. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37410. */
  37411. convertIrradianceToLambertianRadiance(): void;
  37412. /**
  37413. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37414. * required operations at run time.
  37415. *
  37416. * This is simply done by scaling back the SH with Ylm constants parameter.
  37417. * The trigonometric part being applied by the shader at run time.
  37418. */
  37419. preScaleForRendering(): void;
  37420. /**
  37421. * Constructs a spherical harmonics from an array.
  37422. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37423. * @returns the spherical harmonics
  37424. */
  37425. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37426. /**
  37427. * Gets the spherical harmonics from polynomial
  37428. * @param polynomial the spherical polynomial
  37429. * @returns the spherical harmonics
  37430. */
  37431. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37432. }
  37433. /**
  37434. * Class representing spherical polynomial coefficients to the 3rd degree
  37435. */
  37436. export class SphericalPolynomial {
  37437. private _harmonics;
  37438. /**
  37439. * The spherical harmonics used to create the polynomials.
  37440. */
  37441. get preScaledHarmonics(): SphericalHarmonics;
  37442. /**
  37443. * The x coefficients of the spherical polynomial
  37444. */
  37445. x: Vector3;
  37446. /**
  37447. * The y coefficients of the spherical polynomial
  37448. */
  37449. y: Vector3;
  37450. /**
  37451. * The z coefficients of the spherical polynomial
  37452. */
  37453. z: Vector3;
  37454. /**
  37455. * The xx coefficients of the spherical polynomial
  37456. */
  37457. xx: Vector3;
  37458. /**
  37459. * The yy coefficients of the spherical polynomial
  37460. */
  37461. yy: Vector3;
  37462. /**
  37463. * The zz coefficients of the spherical polynomial
  37464. */
  37465. zz: Vector3;
  37466. /**
  37467. * The xy coefficients of the spherical polynomial
  37468. */
  37469. xy: Vector3;
  37470. /**
  37471. * The yz coefficients of the spherical polynomial
  37472. */
  37473. yz: Vector3;
  37474. /**
  37475. * The zx coefficients of the spherical polynomial
  37476. */
  37477. zx: Vector3;
  37478. /**
  37479. * Adds an ambient color to the spherical polynomial
  37480. * @param color the color to add
  37481. */
  37482. addAmbient(color: Color3): void;
  37483. /**
  37484. * Scales the spherical polynomial by the given amount
  37485. * @param scale the amount to scale
  37486. */
  37487. scaleInPlace(scale: number): void;
  37488. /**
  37489. * Gets the spherical polynomial from harmonics
  37490. * @param harmonics the spherical harmonics
  37491. * @returns the spherical polynomial
  37492. */
  37493. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37494. /**
  37495. * Constructs a spherical polynomial from an array.
  37496. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37497. * @returns the spherical polynomial
  37498. */
  37499. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37500. }
  37501. }
  37502. declare module "babylonjs/Materials/Textures/internalTexture" {
  37503. import { Observable } from "babylonjs/Misc/observable";
  37504. import { Nullable, int } from "babylonjs/types";
  37505. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37507. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37508. /**
  37509. * Defines the source of the internal texture
  37510. */
  37511. export enum InternalTextureSource {
  37512. /**
  37513. * The source of the texture data is unknown
  37514. */
  37515. Unknown = 0,
  37516. /**
  37517. * Texture data comes from an URL
  37518. */
  37519. Url = 1,
  37520. /**
  37521. * Texture data is only used for temporary storage
  37522. */
  37523. Temp = 2,
  37524. /**
  37525. * Texture data comes from raw data (ArrayBuffer)
  37526. */
  37527. Raw = 3,
  37528. /**
  37529. * Texture content is dynamic (video or dynamic texture)
  37530. */
  37531. Dynamic = 4,
  37532. /**
  37533. * Texture content is generated by rendering to it
  37534. */
  37535. RenderTarget = 5,
  37536. /**
  37537. * Texture content is part of a multi render target process
  37538. */
  37539. MultiRenderTarget = 6,
  37540. /**
  37541. * Texture data comes from a cube data file
  37542. */
  37543. Cube = 7,
  37544. /**
  37545. * Texture data comes from a raw cube data
  37546. */
  37547. CubeRaw = 8,
  37548. /**
  37549. * Texture data come from a prefiltered cube data file
  37550. */
  37551. CubePrefiltered = 9,
  37552. /**
  37553. * Texture content is raw 3D data
  37554. */
  37555. Raw3D = 10,
  37556. /**
  37557. * Texture content is raw 2D array data
  37558. */
  37559. Raw2DArray = 11,
  37560. /**
  37561. * Texture content is a depth texture
  37562. */
  37563. Depth = 12,
  37564. /**
  37565. * Texture data comes from a raw cube data encoded with RGBD
  37566. */
  37567. CubeRawRGBD = 13
  37568. }
  37569. /**
  37570. * Class used to store data associated with WebGL texture data for the engine
  37571. * This class should not be used directly
  37572. */
  37573. export class InternalTexture {
  37574. /** @hidden */
  37575. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37576. /**
  37577. * Defines if the texture is ready
  37578. */
  37579. isReady: boolean;
  37580. /**
  37581. * Defines if the texture is a cube texture
  37582. */
  37583. isCube: boolean;
  37584. /**
  37585. * Defines if the texture contains 3D data
  37586. */
  37587. is3D: boolean;
  37588. /**
  37589. * Defines if the texture contains 2D array data
  37590. */
  37591. is2DArray: boolean;
  37592. /**
  37593. * Defines if the texture contains multiview data
  37594. */
  37595. isMultiview: boolean;
  37596. /**
  37597. * Gets the URL used to load this texture
  37598. */
  37599. url: string;
  37600. /**
  37601. * Gets the sampling mode of the texture
  37602. */
  37603. samplingMode: number;
  37604. /**
  37605. * Gets a boolean indicating if the texture needs mipmaps generation
  37606. */
  37607. generateMipMaps: boolean;
  37608. /**
  37609. * Gets the number of samples used by the texture (WebGL2+ only)
  37610. */
  37611. samples: number;
  37612. /**
  37613. * Gets the type of the texture (int, float...)
  37614. */
  37615. type: number;
  37616. /**
  37617. * Gets the format of the texture (RGB, RGBA...)
  37618. */
  37619. format: number;
  37620. /**
  37621. * Observable called when the texture is loaded
  37622. */
  37623. onLoadedObservable: Observable<InternalTexture>;
  37624. /**
  37625. * Gets the width of the texture
  37626. */
  37627. width: number;
  37628. /**
  37629. * Gets the height of the texture
  37630. */
  37631. height: number;
  37632. /**
  37633. * Gets the depth of the texture
  37634. */
  37635. depth: number;
  37636. /**
  37637. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37638. */
  37639. baseWidth: number;
  37640. /**
  37641. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37642. */
  37643. baseHeight: number;
  37644. /**
  37645. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37646. */
  37647. baseDepth: number;
  37648. /**
  37649. * Gets a boolean indicating if the texture is inverted on Y axis
  37650. */
  37651. invertY: boolean;
  37652. /** @hidden */
  37653. _invertVScale: boolean;
  37654. /** @hidden */
  37655. _associatedChannel: number;
  37656. /** @hidden */
  37657. _source: InternalTextureSource;
  37658. /** @hidden */
  37659. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37660. /** @hidden */
  37661. _bufferView: Nullable<ArrayBufferView>;
  37662. /** @hidden */
  37663. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37664. /** @hidden */
  37665. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37666. /** @hidden */
  37667. _size: number;
  37668. /** @hidden */
  37669. _extension: string;
  37670. /** @hidden */
  37671. _files: Nullable<string[]>;
  37672. /** @hidden */
  37673. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37674. /** @hidden */
  37675. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37676. /** @hidden */
  37677. _framebuffer: Nullable<WebGLFramebuffer>;
  37678. /** @hidden */
  37679. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37680. /** @hidden */
  37681. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37682. /** @hidden */
  37683. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37684. /** @hidden */
  37685. _attachments: Nullable<number[]>;
  37686. /** @hidden */
  37687. _textureArray: Nullable<InternalTexture[]>;
  37688. /** @hidden */
  37689. _cachedCoordinatesMode: Nullable<number>;
  37690. /** @hidden */
  37691. _cachedWrapU: Nullable<number>;
  37692. /** @hidden */
  37693. _cachedWrapV: Nullable<number>;
  37694. /** @hidden */
  37695. _cachedWrapR: Nullable<number>;
  37696. /** @hidden */
  37697. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37698. /** @hidden */
  37699. _isDisabled: boolean;
  37700. /** @hidden */
  37701. _compression: Nullable<string>;
  37702. /** @hidden */
  37703. _generateStencilBuffer: boolean;
  37704. /** @hidden */
  37705. _generateDepthBuffer: boolean;
  37706. /** @hidden */
  37707. _comparisonFunction: number;
  37708. /** @hidden */
  37709. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37710. /** @hidden */
  37711. _lodGenerationScale: number;
  37712. /** @hidden */
  37713. _lodGenerationOffset: number;
  37714. /** @hidden */
  37715. _depthStencilTexture: Nullable<InternalTexture>;
  37716. /** @hidden */
  37717. _colorTextureArray: Nullable<WebGLTexture>;
  37718. /** @hidden */
  37719. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37720. /** @hidden */
  37721. _lodTextureHigh: Nullable<BaseTexture>;
  37722. /** @hidden */
  37723. _lodTextureMid: Nullable<BaseTexture>;
  37724. /** @hidden */
  37725. _lodTextureLow: Nullable<BaseTexture>;
  37726. /** @hidden */
  37727. _isRGBD: boolean;
  37728. /** @hidden */
  37729. _linearSpecularLOD: boolean;
  37730. /** @hidden */
  37731. _irradianceTexture: Nullable<BaseTexture>;
  37732. /** @hidden */
  37733. _webGLTexture: Nullable<WebGLTexture>;
  37734. /** @hidden */
  37735. _references: number;
  37736. private _engine;
  37737. /**
  37738. * Gets the Engine the texture belongs to.
  37739. * @returns The babylon engine
  37740. */
  37741. getEngine(): ThinEngine;
  37742. /**
  37743. * Gets the data source type of the texture
  37744. */
  37745. get source(): InternalTextureSource;
  37746. /**
  37747. * Creates a new InternalTexture
  37748. * @param engine defines the engine to use
  37749. * @param source defines the type of data that will be used
  37750. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37751. */
  37752. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37753. /**
  37754. * Increments the number of references (ie. the number of Texture that point to it)
  37755. */
  37756. incrementReferences(): void;
  37757. /**
  37758. * Change the size of the texture (not the size of the content)
  37759. * @param width defines the new width
  37760. * @param height defines the new height
  37761. * @param depth defines the new depth (1 by default)
  37762. */
  37763. updateSize(width: int, height: int, depth?: int): void;
  37764. /** @hidden */
  37765. _rebuild(): void;
  37766. /** @hidden */
  37767. _swapAndDie(target: InternalTexture): void;
  37768. /**
  37769. * Dispose the current allocated resources
  37770. */
  37771. dispose(): void;
  37772. }
  37773. }
  37774. declare module "babylonjs/Audio/analyser" {
  37775. import { Scene } from "babylonjs/scene";
  37776. /**
  37777. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37778. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37779. */
  37780. export class Analyser {
  37781. /**
  37782. * Gets or sets the smoothing
  37783. * @ignorenaming
  37784. */
  37785. SMOOTHING: number;
  37786. /**
  37787. * Gets or sets the FFT table size
  37788. * @ignorenaming
  37789. */
  37790. FFT_SIZE: number;
  37791. /**
  37792. * Gets or sets the bar graph amplitude
  37793. * @ignorenaming
  37794. */
  37795. BARGRAPHAMPLITUDE: number;
  37796. /**
  37797. * Gets or sets the position of the debug canvas
  37798. * @ignorenaming
  37799. */
  37800. DEBUGCANVASPOS: {
  37801. x: number;
  37802. y: number;
  37803. };
  37804. /**
  37805. * Gets or sets the debug canvas size
  37806. * @ignorenaming
  37807. */
  37808. DEBUGCANVASSIZE: {
  37809. width: number;
  37810. height: number;
  37811. };
  37812. private _byteFreqs;
  37813. private _byteTime;
  37814. private _floatFreqs;
  37815. private _webAudioAnalyser;
  37816. private _debugCanvas;
  37817. private _debugCanvasContext;
  37818. private _scene;
  37819. private _registerFunc;
  37820. private _audioEngine;
  37821. /**
  37822. * Creates a new analyser
  37823. * @param scene defines hosting scene
  37824. */
  37825. constructor(scene: Scene);
  37826. /**
  37827. * Get the number of data values you will have to play with for the visualization
  37828. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37829. * @returns a number
  37830. */
  37831. getFrequencyBinCount(): number;
  37832. /**
  37833. * Gets the current frequency data as a byte array
  37834. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37835. * @returns a Uint8Array
  37836. */
  37837. getByteFrequencyData(): Uint8Array;
  37838. /**
  37839. * Gets the current waveform as a byte array
  37840. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37841. * @returns a Uint8Array
  37842. */
  37843. getByteTimeDomainData(): Uint8Array;
  37844. /**
  37845. * Gets the current frequency data as a float array
  37846. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37847. * @returns a Float32Array
  37848. */
  37849. getFloatFrequencyData(): Float32Array;
  37850. /**
  37851. * Renders the debug canvas
  37852. */
  37853. drawDebugCanvas(): void;
  37854. /**
  37855. * Stops rendering the debug canvas and removes it
  37856. */
  37857. stopDebugCanvas(): void;
  37858. /**
  37859. * Connects two audio nodes
  37860. * @param inputAudioNode defines first node to connect
  37861. * @param outputAudioNode defines second node to connect
  37862. */
  37863. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37864. /**
  37865. * Releases all associated resources
  37866. */
  37867. dispose(): void;
  37868. }
  37869. }
  37870. declare module "babylonjs/Audio/audioEngine" {
  37871. import { IDisposable } from "babylonjs/scene";
  37872. import { Analyser } from "babylonjs/Audio/analyser";
  37873. import { Nullable } from "babylonjs/types";
  37874. import { Observable } from "babylonjs/Misc/observable";
  37875. /**
  37876. * This represents an audio engine and it is responsible
  37877. * to play, synchronize and analyse sounds throughout the application.
  37878. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37879. */
  37880. export interface IAudioEngine extends IDisposable {
  37881. /**
  37882. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37883. */
  37884. readonly canUseWebAudio: boolean;
  37885. /**
  37886. * Gets the current AudioContext if available.
  37887. */
  37888. readonly audioContext: Nullable<AudioContext>;
  37889. /**
  37890. * The master gain node defines the global audio volume of your audio engine.
  37891. */
  37892. readonly masterGain: GainNode;
  37893. /**
  37894. * Gets whether or not mp3 are supported by your browser.
  37895. */
  37896. readonly isMP3supported: boolean;
  37897. /**
  37898. * Gets whether or not ogg are supported by your browser.
  37899. */
  37900. readonly isOGGsupported: boolean;
  37901. /**
  37902. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37903. * @ignoreNaming
  37904. */
  37905. WarnedWebAudioUnsupported: boolean;
  37906. /**
  37907. * Defines if the audio engine relies on a custom unlocked button.
  37908. * In this case, the embedded button will not be displayed.
  37909. */
  37910. useCustomUnlockedButton: boolean;
  37911. /**
  37912. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37913. */
  37914. readonly unlocked: boolean;
  37915. /**
  37916. * Event raised when audio has been unlocked on the browser.
  37917. */
  37918. onAudioUnlockedObservable: Observable<AudioEngine>;
  37919. /**
  37920. * Event raised when audio has been locked on the browser.
  37921. */
  37922. onAudioLockedObservable: Observable<AudioEngine>;
  37923. /**
  37924. * Flags the audio engine in Locked state.
  37925. * This happens due to new browser policies preventing audio to autoplay.
  37926. */
  37927. lock(): void;
  37928. /**
  37929. * Unlocks the audio engine once a user action has been done on the dom.
  37930. * This is helpful to resume play once browser policies have been satisfied.
  37931. */
  37932. unlock(): void;
  37933. /**
  37934. * Gets the global volume sets on the master gain.
  37935. * @returns the global volume if set or -1 otherwise
  37936. */
  37937. getGlobalVolume(): number;
  37938. /**
  37939. * Sets the global volume of your experience (sets on the master gain).
  37940. * @param newVolume Defines the new global volume of the application
  37941. */
  37942. setGlobalVolume(newVolume: number): void;
  37943. /**
  37944. * Connect the audio engine to an audio analyser allowing some amazing
  37945. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37946. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37947. * @param analyser The analyser to connect to the engine
  37948. */
  37949. connectToAnalyser(analyser: Analyser): void;
  37950. }
  37951. /**
  37952. * This represents the default audio engine used in babylon.
  37953. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37954. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37955. */
  37956. export class AudioEngine implements IAudioEngine {
  37957. private _audioContext;
  37958. private _audioContextInitialized;
  37959. private _muteButton;
  37960. private _hostElement;
  37961. /**
  37962. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37963. */
  37964. canUseWebAudio: boolean;
  37965. /**
  37966. * The master gain node defines the global audio volume of your audio engine.
  37967. */
  37968. masterGain: GainNode;
  37969. /**
  37970. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37971. * @ignoreNaming
  37972. */
  37973. WarnedWebAudioUnsupported: boolean;
  37974. /**
  37975. * Gets whether or not mp3 are supported by your browser.
  37976. */
  37977. isMP3supported: boolean;
  37978. /**
  37979. * Gets whether or not ogg are supported by your browser.
  37980. */
  37981. isOGGsupported: boolean;
  37982. /**
  37983. * Gets whether audio has been unlocked on the device.
  37984. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37985. * a user interaction has happened.
  37986. */
  37987. unlocked: boolean;
  37988. /**
  37989. * Defines if the audio engine relies on a custom unlocked button.
  37990. * In this case, the embedded button will not be displayed.
  37991. */
  37992. useCustomUnlockedButton: boolean;
  37993. /**
  37994. * Event raised when audio has been unlocked on the browser.
  37995. */
  37996. onAudioUnlockedObservable: Observable<AudioEngine>;
  37997. /**
  37998. * Event raised when audio has been locked on the browser.
  37999. */
  38000. onAudioLockedObservable: Observable<AudioEngine>;
  38001. /**
  38002. * Gets the current AudioContext if available.
  38003. */
  38004. get audioContext(): Nullable<AudioContext>;
  38005. private _connectedAnalyser;
  38006. /**
  38007. * Instantiates a new audio engine.
  38008. *
  38009. * There should be only one per page as some browsers restrict the number
  38010. * of audio contexts you can create.
  38011. * @param hostElement defines the host element where to display the mute icon if necessary
  38012. */
  38013. constructor(hostElement?: Nullable<HTMLElement>);
  38014. /**
  38015. * Flags the audio engine in Locked state.
  38016. * This happens due to new browser policies preventing audio to autoplay.
  38017. */
  38018. lock(): void;
  38019. /**
  38020. * Unlocks the audio engine once a user action has been done on the dom.
  38021. * This is helpful to resume play once browser policies have been satisfied.
  38022. */
  38023. unlock(): void;
  38024. private _resumeAudioContext;
  38025. private _initializeAudioContext;
  38026. private _tryToRun;
  38027. private _triggerRunningState;
  38028. private _triggerSuspendedState;
  38029. private _displayMuteButton;
  38030. private _moveButtonToTopLeft;
  38031. private _onResize;
  38032. private _hideMuteButton;
  38033. /**
  38034. * Destroy and release the resources associated with the audio ccontext.
  38035. */
  38036. dispose(): void;
  38037. /**
  38038. * Gets the global volume sets on the master gain.
  38039. * @returns the global volume if set or -1 otherwise
  38040. */
  38041. getGlobalVolume(): number;
  38042. /**
  38043. * Sets the global volume of your experience (sets on the master gain).
  38044. * @param newVolume Defines the new global volume of the application
  38045. */
  38046. setGlobalVolume(newVolume: number): void;
  38047. /**
  38048. * Connect the audio engine to an audio analyser allowing some amazing
  38049. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38050. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38051. * @param analyser The analyser to connect to the engine
  38052. */
  38053. connectToAnalyser(analyser: Analyser): void;
  38054. }
  38055. }
  38056. declare module "babylonjs/Loading/loadingScreen" {
  38057. /**
  38058. * Interface used to present a loading screen while loading a scene
  38059. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38060. */
  38061. export interface ILoadingScreen {
  38062. /**
  38063. * Function called to display the loading screen
  38064. */
  38065. displayLoadingUI: () => void;
  38066. /**
  38067. * Function called to hide the loading screen
  38068. */
  38069. hideLoadingUI: () => void;
  38070. /**
  38071. * Gets or sets the color to use for the background
  38072. */
  38073. loadingUIBackgroundColor: string;
  38074. /**
  38075. * Gets or sets the text to display while loading
  38076. */
  38077. loadingUIText: string;
  38078. }
  38079. /**
  38080. * Class used for the default loading screen
  38081. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38082. */
  38083. export class DefaultLoadingScreen implements ILoadingScreen {
  38084. private _renderingCanvas;
  38085. private _loadingText;
  38086. private _loadingDivBackgroundColor;
  38087. private _loadingDiv;
  38088. private _loadingTextDiv;
  38089. /** Gets or sets the logo url to use for the default loading screen */
  38090. static DefaultLogoUrl: string;
  38091. /** Gets or sets the spinner url to use for the default loading screen */
  38092. static DefaultSpinnerUrl: string;
  38093. /**
  38094. * Creates a new default loading screen
  38095. * @param _renderingCanvas defines the canvas used to render the scene
  38096. * @param _loadingText defines the default text to display
  38097. * @param _loadingDivBackgroundColor defines the default background color
  38098. */
  38099. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38100. /**
  38101. * Function called to display the loading screen
  38102. */
  38103. displayLoadingUI(): void;
  38104. /**
  38105. * Function called to hide the loading screen
  38106. */
  38107. hideLoadingUI(): void;
  38108. /**
  38109. * Gets or sets the text to display while loading
  38110. */
  38111. set loadingUIText(text: string);
  38112. get loadingUIText(): string;
  38113. /**
  38114. * Gets or sets the color to use for the background
  38115. */
  38116. get loadingUIBackgroundColor(): string;
  38117. set loadingUIBackgroundColor(color: string);
  38118. private _resizeLoadingUI;
  38119. }
  38120. }
  38121. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38122. /**
  38123. * Interface for any object that can request an animation frame
  38124. */
  38125. export interface ICustomAnimationFrameRequester {
  38126. /**
  38127. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38128. */
  38129. renderFunction?: Function;
  38130. /**
  38131. * Called to request the next frame to render to
  38132. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38133. */
  38134. requestAnimationFrame: Function;
  38135. /**
  38136. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38137. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38138. */
  38139. requestID?: number;
  38140. }
  38141. }
  38142. declare module "babylonjs/Misc/performanceMonitor" {
  38143. /**
  38144. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38145. */
  38146. export class PerformanceMonitor {
  38147. private _enabled;
  38148. private _rollingFrameTime;
  38149. private _lastFrameTimeMs;
  38150. /**
  38151. * constructor
  38152. * @param frameSampleSize The number of samples required to saturate the sliding window
  38153. */
  38154. constructor(frameSampleSize?: number);
  38155. /**
  38156. * Samples current frame
  38157. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38158. */
  38159. sampleFrame(timeMs?: number): void;
  38160. /**
  38161. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38162. */
  38163. get averageFrameTime(): number;
  38164. /**
  38165. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38166. */
  38167. get averageFrameTimeVariance(): number;
  38168. /**
  38169. * Returns the frame time of the most recent frame
  38170. */
  38171. get instantaneousFrameTime(): number;
  38172. /**
  38173. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38174. */
  38175. get averageFPS(): number;
  38176. /**
  38177. * Returns the average framerate in frames per second using the most recent frame time
  38178. */
  38179. get instantaneousFPS(): number;
  38180. /**
  38181. * Returns true if enough samples have been taken to completely fill the sliding window
  38182. */
  38183. get isSaturated(): boolean;
  38184. /**
  38185. * Enables contributions to the sliding window sample set
  38186. */
  38187. enable(): void;
  38188. /**
  38189. * Disables contributions to the sliding window sample set
  38190. * Samples will not be interpolated over the disabled period
  38191. */
  38192. disable(): void;
  38193. /**
  38194. * Returns true if sampling is enabled
  38195. */
  38196. get isEnabled(): boolean;
  38197. /**
  38198. * Resets performance monitor
  38199. */
  38200. reset(): void;
  38201. }
  38202. /**
  38203. * RollingAverage
  38204. *
  38205. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38206. */
  38207. export class RollingAverage {
  38208. /**
  38209. * Current average
  38210. */
  38211. average: number;
  38212. /**
  38213. * Current variance
  38214. */
  38215. variance: number;
  38216. protected _samples: Array<number>;
  38217. protected _sampleCount: number;
  38218. protected _pos: number;
  38219. protected _m2: number;
  38220. /**
  38221. * constructor
  38222. * @param length The number of samples required to saturate the sliding window
  38223. */
  38224. constructor(length: number);
  38225. /**
  38226. * Adds a sample to the sample set
  38227. * @param v The sample value
  38228. */
  38229. add(v: number): void;
  38230. /**
  38231. * Returns previously added values or null if outside of history or outside the sliding window domain
  38232. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38233. * @return Value previously recorded with add() or null if outside of range
  38234. */
  38235. history(i: number): number;
  38236. /**
  38237. * Returns true if enough samples have been taken to completely fill the sliding window
  38238. * @return true if sample-set saturated
  38239. */
  38240. isSaturated(): boolean;
  38241. /**
  38242. * Resets the rolling average (equivalent to 0 samples taken so far)
  38243. */
  38244. reset(): void;
  38245. /**
  38246. * Wraps a value around the sample range boundaries
  38247. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38248. * @return Wrapped position in sample range
  38249. */
  38250. protected _wrapPosition(i: number): number;
  38251. }
  38252. }
  38253. declare module "babylonjs/Misc/perfCounter" {
  38254. /**
  38255. * This class is used to track a performance counter which is number based.
  38256. * The user has access to many properties which give statistics of different nature.
  38257. *
  38258. * The implementer can track two kinds of Performance Counter: time and count.
  38259. * 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.
  38260. * 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.
  38261. */
  38262. export class PerfCounter {
  38263. /**
  38264. * Gets or sets a global boolean to turn on and off all the counters
  38265. */
  38266. static Enabled: boolean;
  38267. /**
  38268. * Returns the smallest value ever
  38269. */
  38270. get min(): number;
  38271. /**
  38272. * Returns the biggest value ever
  38273. */
  38274. get max(): number;
  38275. /**
  38276. * Returns the average value since the performance counter is running
  38277. */
  38278. get average(): number;
  38279. /**
  38280. * Returns the average value of the last second the counter was monitored
  38281. */
  38282. get lastSecAverage(): number;
  38283. /**
  38284. * Returns the current value
  38285. */
  38286. get current(): number;
  38287. /**
  38288. * Gets the accumulated total
  38289. */
  38290. get total(): number;
  38291. /**
  38292. * Gets the total value count
  38293. */
  38294. get count(): number;
  38295. /**
  38296. * Creates a new counter
  38297. */
  38298. constructor();
  38299. /**
  38300. * Call this method to start monitoring a new frame.
  38301. * 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.
  38302. */
  38303. fetchNewFrame(): void;
  38304. /**
  38305. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38306. * @param newCount the count value to add to the monitored count
  38307. * @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.
  38308. */
  38309. addCount(newCount: number, fetchResult: boolean): void;
  38310. /**
  38311. * Start monitoring this performance counter
  38312. */
  38313. beginMonitoring(): void;
  38314. /**
  38315. * Compute the time lapsed since the previous beginMonitoring() call.
  38316. * @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
  38317. */
  38318. endMonitoring(newFrame?: boolean): void;
  38319. private _fetchResult;
  38320. private _startMonitoringTime;
  38321. private _min;
  38322. private _max;
  38323. private _average;
  38324. private _current;
  38325. private _totalValueCount;
  38326. private _totalAccumulated;
  38327. private _lastSecAverage;
  38328. private _lastSecAccumulated;
  38329. private _lastSecTime;
  38330. private _lastSecValueCount;
  38331. }
  38332. }
  38333. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  38334. module "babylonjs/Engines/thinEngine" {
  38335. interface ThinEngine {
  38336. /**
  38337. * Sets alpha constants used by some alpha blending modes
  38338. * @param r defines the red component
  38339. * @param g defines the green component
  38340. * @param b defines the blue component
  38341. * @param a defines the alpha component
  38342. */
  38343. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  38344. /**
  38345. * Sets the current alpha mode
  38346. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  38347. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  38348. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38349. */
  38350. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  38351. /**
  38352. * Gets the current alpha mode
  38353. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38354. * @returns the current alpha mode
  38355. */
  38356. getAlphaMode(): number;
  38357. /**
  38358. * Sets the current alpha equation
  38359. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  38360. */
  38361. setAlphaEquation(equation: number): void;
  38362. /**
  38363. * Gets the current alpha equation.
  38364. * @returns the current alpha equation
  38365. */
  38366. getAlphaEquation(): number;
  38367. }
  38368. }
  38369. }
  38370. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38372. import { Nullable } from "babylonjs/types";
  38373. module "babylonjs/Engines/thinEngine" {
  38374. interface ThinEngine {
  38375. /** @hidden */
  38376. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38377. }
  38378. }
  38379. }
  38380. declare module "babylonjs/Engines/engine" {
  38381. import { Observable } from "babylonjs/Misc/observable";
  38382. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  38383. import { Scene } from "babylonjs/scene";
  38384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38385. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38386. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38387. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38388. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38389. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38390. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38391. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38392. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38394. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38395. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38396. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38397. import "babylonjs/Engines/Extensions/engine.alpha";
  38398. import "babylonjs/Engines/Extensions/engine.readTexture";
  38399. import { Material } from "babylonjs/Materials/material";
  38400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38401. /**
  38402. * Defines the interface used by display changed events
  38403. */
  38404. export interface IDisplayChangedEventArgs {
  38405. /** Gets the vrDisplay object (if any) */
  38406. vrDisplay: Nullable<any>;
  38407. /** Gets a boolean indicating if webVR is supported */
  38408. vrSupported: boolean;
  38409. }
  38410. /**
  38411. * Defines the interface used by objects containing a viewport (like a camera)
  38412. */
  38413. interface IViewportOwnerLike {
  38414. /**
  38415. * Gets or sets the viewport
  38416. */
  38417. viewport: IViewportLike;
  38418. }
  38419. /**
  38420. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38421. */
  38422. export class Engine extends ThinEngine {
  38423. /** Defines that alpha blending is disabled */
  38424. static readonly ALPHA_DISABLE: number;
  38425. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38426. static readonly ALPHA_ADD: number;
  38427. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38428. static readonly ALPHA_COMBINE: number;
  38429. /** Defines that alpha blending to DEST - SRC * DEST */
  38430. static readonly ALPHA_SUBTRACT: number;
  38431. /** Defines that alpha blending to SRC * DEST */
  38432. static readonly ALPHA_MULTIPLY: number;
  38433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38434. static readonly ALPHA_MAXIMIZED: number;
  38435. /** Defines that alpha blending to SRC + DEST */
  38436. static readonly ALPHA_ONEONE: number;
  38437. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38438. static readonly ALPHA_PREMULTIPLIED: number;
  38439. /**
  38440. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38441. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38442. */
  38443. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38444. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38445. static readonly ALPHA_INTERPOLATE: number;
  38446. /**
  38447. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38448. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38449. */
  38450. static readonly ALPHA_SCREENMODE: number;
  38451. /** Defines that the ressource is not delayed*/
  38452. static readonly DELAYLOADSTATE_NONE: number;
  38453. /** Defines that the ressource was successfully delay loaded */
  38454. static readonly DELAYLOADSTATE_LOADED: number;
  38455. /** Defines that the ressource is currently delay loading */
  38456. static readonly DELAYLOADSTATE_LOADING: number;
  38457. /** Defines that the ressource is delayed and has not started loading */
  38458. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38460. static readonly NEVER: number;
  38461. /** 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 */
  38462. static readonly ALWAYS: number;
  38463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38464. static readonly LESS: number;
  38465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38466. static readonly EQUAL: number;
  38467. /** 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 */
  38468. static readonly LEQUAL: number;
  38469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38470. static readonly GREATER: number;
  38471. /** 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 */
  38472. static readonly GEQUAL: number;
  38473. /** 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 */
  38474. static readonly NOTEQUAL: number;
  38475. /** Passed to stencilOperation to specify that stencil value must be kept */
  38476. static readonly KEEP: number;
  38477. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38478. static readonly REPLACE: number;
  38479. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38480. static readonly INCR: number;
  38481. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38482. static readonly DECR: number;
  38483. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38484. static readonly INVERT: number;
  38485. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38486. static readonly INCR_WRAP: number;
  38487. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38488. static readonly DECR_WRAP: number;
  38489. /** Texture is not repeating outside of 0..1 UVs */
  38490. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38491. /** Texture is repeating outside of 0..1 UVs */
  38492. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38493. /** Texture is repeating and mirrored */
  38494. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38495. /** ALPHA */
  38496. static readonly TEXTUREFORMAT_ALPHA: number;
  38497. /** LUMINANCE */
  38498. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38499. /** LUMINANCE_ALPHA */
  38500. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38501. /** RGB */
  38502. static readonly TEXTUREFORMAT_RGB: number;
  38503. /** RGBA */
  38504. static readonly TEXTUREFORMAT_RGBA: number;
  38505. /** RED */
  38506. static readonly TEXTUREFORMAT_RED: number;
  38507. /** RED (2nd reference) */
  38508. static readonly TEXTUREFORMAT_R: number;
  38509. /** RG */
  38510. static readonly TEXTUREFORMAT_RG: number;
  38511. /** RED_INTEGER */
  38512. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38513. /** RED_INTEGER (2nd reference) */
  38514. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38515. /** RG_INTEGER */
  38516. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38517. /** RGB_INTEGER */
  38518. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38519. /** RGBA_INTEGER */
  38520. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38521. /** UNSIGNED_BYTE */
  38522. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38523. /** UNSIGNED_BYTE (2nd reference) */
  38524. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38525. /** FLOAT */
  38526. static readonly TEXTURETYPE_FLOAT: number;
  38527. /** HALF_FLOAT */
  38528. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38529. /** BYTE */
  38530. static readonly TEXTURETYPE_BYTE: number;
  38531. /** SHORT */
  38532. static readonly TEXTURETYPE_SHORT: number;
  38533. /** UNSIGNED_SHORT */
  38534. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38535. /** INT */
  38536. static readonly TEXTURETYPE_INT: number;
  38537. /** UNSIGNED_INT */
  38538. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38539. /** UNSIGNED_SHORT_4_4_4_4 */
  38540. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38541. /** UNSIGNED_SHORT_5_5_5_1 */
  38542. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38543. /** UNSIGNED_SHORT_5_6_5 */
  38544. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38545. /** UNSIGNED_INT_2_10_10_10_REV */
  38546. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38547. /** UNSIGNED_INT_24_8 */
  38548. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38549. /** UNSIGNED_INT_10F_11F_11F_REV */
  38550. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38551. /** UNSIGNED_INT_5_9_9_9_REV */
  38552. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38553. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38554. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38555. /** nearest is mag = nearest and min = nearest and mip = linear */
  38556. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38557. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38558. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38559. /** Trilinear is mag = linear and min = linear and mip = linear */
  38560. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38561. /** nearest is mag = nearest and min = nearest and mip = linear */
  38562. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38564. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38565. /** Trilinear is mag = linear and min = linear and mip = linear */
  38566. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38567. /** mag = nearest and min = nearest and mip = nearest */
  38568. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38569. /** mag = nearest and min = linear and mip = nearest */
  38570. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38571. /** mag = nearest and min = linear and mip = linear */
  38572. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38573. /** mag = nearest and min = linear and mip = none */
  38574. static readonly TEXTURE_NEAREST_LINEAR: number;
  38575. /** mag = nearest and min = nearest and mip = none */
  38576. static readonly TEXTURE_NEAREST_NEAREST: number;
  38577. /** mag = linear and min = nearest and mip = nearest */
  38578. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38579. /** mag = linear and min = nearest and mip = linear */
  38580. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38581. /** mag = linear and min = linear and mip = none */
  38582. static readonly TEXTURE_LINEAR_LINEAR: number;
  38583. /** mag = linear and min = nearest and mip = none */
  38584. static readonly TEXTURE_LINEAR_NEAREST: number;
  38585. /** Explicit coordinates mode */
  38586. static readonly TEXTURE_EXPLICIT_MODE: number;
  38587. /** Spherical coordinates mode */
  38588. static readonly TEXTURE_SPHERICAL_MODE: number;
  38589. /** Planar coordinates mode */
  38590. static readonly TEXTURE_PLANAR_MODE: number;
  38591. /** Cubic coordinates mode */
  38592. static readonly TEXTURE_CUBIC_MODE: number;
  38593. /** Projection coordinates mode */
  38594. static readonly TEXTURE_PROJECTION_MODE: number;
  38595. /** Skybox coordinates mode */
  38596. static readonly TEXTURE_SKYBOX_MODE: number;
  38597. /** Inverse Cubic coordinates mode */
  38598. static readonly TEXTURE_INVCUBIC_MODE: number;
  38599. /** Equirectangular coordinates mode */
  38600. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38601. /** Equirectangular Fixed coordinates mode */
  38602. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38603. /** Equirectangular Fixed Mirrored coordinates mode */
  38604. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38605. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38606. static readonly SCALEMODE_FLOOR: number;
  38607. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38608. static readonly SCALEMODE_NEAREST: number;
  38609. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38610. static readonly SCALEMODE_CEILING: number;
  38611. /**
  38612. * Returns the current npm package of the sdk
  38613. */
  38614. static get NpmPackage(): string;
  38615. /**
  38616. * Returns the current version of the framework
  38617. */
  38618. static get Version(): string;
  38619. /** Gets the list of created engines */
  38620. static get Instances(): Engine[];
  38621. /**
  38622. * Gets the latest created engine
  38623. */
  38624. static get LastCreatedEngine(): Nullable<Engine>;
  38625. /**
  38626. * Gets the latest created scene
  38627. */
  38628. static get LastCreatedScene(): Nullable<Scene>;
  38629. /**
  38630. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38631. * @param flag defines which part of the materials must be marked as dirty
  38632. * @param predicate defines a predicate used to filter which materials should be affected
  38633. */
  38634. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38635. /**
  38636. * Method called to create the default loading screen.
  38637. * This can be overriden in your own app.
  38638. * @param canvas The rendering canvas element
  38639. * @returns The loading screen
  38640. */
  38641. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38642. /**
  38643. * Method called to create the default rescale post process on each engine.
  38644. */
  38645. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38646. /**
  38647. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38648. **/
  38649. enableOfflineSupport: boolean;
  38650. /**
  38651. * 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)
  38652. **/
  38653. disableManifestCheck: boolean;
  38654. /**
  38655. * Gets the list of created scenes
  38656. */
  38657. scenes: Scene[];
  38658. /**
  38659. * Event raised when a new scene is created
  38660. */
  38661. onNewSceneAddedObservable: Observable<Scene>;
  38662. /**
  38663. * Gets the list of created postprocesses
  38664. */
  38665. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38666. /**
  38667. * Gets a boolean indicating if the pointer is currently locked
  38668. */
  38669. isPointerLock: boolean;
  38670. /**
  38671. * Observable event triggered each time the rendering canvas is resized
  38672. */
  38673. onResizeObservable: Observable<Engine>;
  38674. /**
  38675. * Observable event triggered each time the canvas loses focus
  38676. */
  38677. onCanvasBlurObservable: Observable<Engine>;
  38678. /**
  38679. * Observable event triggered each time the canvas gains focus
  38680. */
  38681. onCanvasFocusObservable: Observable<Engine>;
  38682. /**
  38683. * Observable event triggered each time the canvas receives pointerout event
  38684. */
  38685. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38686. /**
  38687. * Observable raised when the engine begins a new frame
  38688. */
  38689. onBeginFrameObservable: Observable<Engine>;
  38690. /**
  38691. * If set, will be used to request the next animation frame for the render loop
  38692. */
  38693. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38694. /**
  38695. * Observable raised when the engine ends the current frame
  38696. */
  38697. onEndFrameObservable: Observable<Engine>;
  38698. /**
  38699. * Observable raised when the engine is about to compile a shader
  38700. */
  38701. onBeforeShaderCompilationObservable: Observable<Engine>;
  38702. /**
  38703. * Observable raised when the engine has jsut compiled a shader
  38704. */
  38705. onAfterShaderCompilationObservable: Observable<Engine>;
  38706. /**
  38707. * Gets the audio engine
  38708. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38709. * @ignorenaming
  38710. */
  38711. static audioEngine: IAudioEngine;
  38712. /**
  38713. * Default AudioEngine factory responsible of creating the Audio Engine.
  38714. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38715. */
  38716. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38717. /**
  38718. * Default offline support factory responsible of creating a tool used to store data locally.
  38719. * By default, this will create a Database object if the workload has been embedded.
  38720. */
  38721. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38722. private _loadingScreen;
  38723. private _pointerLockRequested;
  38724. private _rescalePostProcess;
  38725. private _deterministicLockstep;
  38726. private _lockstepMaxSteps;
  38727. private _timeStep;
  38728. protected get _supportsHardwareTextureRescaling(): boolean;
  38729. private _fps;
  38730. private _deltaTime;
  38731. /** @hidden */
  38732. _drawCalls: PerfCounter;
  38733. /** 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 */
  38734. canvasTabIndex: number;
  38735. /**
  38736. * Turn this value on if you want to pause FPS computation when in background
  38737. */
  38738. disablePerformanceMonitorInBackground: boolean;
  38739. private _performanceMonitor;
  38740. /**
  38741. * Gets the performance monitor attached to this engine
  38742. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38743. */
  38744. get performanceMonitor(): PerformanceMonitor;
  38745. private _onFocus;
  38746. private _onBlur;
  38747. private _onCanvasPointerOut;
  38748. private _onCanvasBlur;
  38749. private _onCanvasFocus;
  38750. private _onFullscreenChange;
  38751. private _onPointerLockChange;
  38752. /**
  38753. * Gets the HTML element used to attach event listeners
  38754. * @returns a HTML element
  38755. */
  38756. getInputElement(): Nullable<HTMLElement>;
  38757. /**
  38758. * Creates a new engine
  38759. * @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
  38760. * @param antialias defines enable antialiasing (default: false)
  38761. * @param options defines further options to be sent to the getContext() function
  38762. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38763. */
  38764. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38765. /**
  38766. * Gets current aspect ratio
  38767. * @param viewportOwner defines the camera to use to get the aspect ratio
  38768. * @param useScreen defines if screen size must be used (or the current render target if any)
  38769. * @returns a number defining the aspect ratio
  38770. */
  38771. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38772. /**
  38773. * Gets current screen aspect ratio
  38774. * @returns a number defining the aspect ratio
  38775. */
  38776. getScreenAspectRatio(): number;
  38777. /**
  38778. * Gets the client rect of the HTML canvas attached with the current webGL context
  38779. * @returns a client rectanglee
  38780. */
  38781. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38782. /**
  38783. * Gets the client rect of the HTML element used for events
  38784. * @returns a client rectanglee
  38785. */
  38786. getInputElementClientRect(): Nullable<ClientRect>;
  38787. /**
  38788. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38789. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38790. * @returns true if engine is in deterministic lock step mode
  38791. */
  38792. isDeterministicLockStep(): boolean;
  38793. /**
  38794. * Gets the max steps when engine is running in deterministic lock step
  38795. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38796. * @returns the max steps
  38797. */
  38798. getLockstepMaxSteps(): number;
  38799. /**
  38800. * Returns the time in ms between steps when using deterministic lock step.
  38801. * @returns time step in (ms)
  38802. */
  38803. getTimeStep(): number;
  38804. /**
  38805. * Force the mipmap generation for the given render target texture
  38806. * @param texture defines the render target texture to use
  38807. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38808. */
  38809. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38810. /** States */
  38811. /**
  38812. * Set various states to the webGL context
  38813. * @param culling defines backface culling state
  38814. * @param zOffset defines the value to apply to zOffset (0 by default)
  38815. * @param force defines if states must be applied even if cache is up to date
  38816. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38817. */
  38818. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38819. /**
  38820. * Set the z offset to apply to current rendering
  38821. * @param value defines the offset to apply
  38822. */
  38823. setZOffset(value: number): void;
  38824. /**
  38825. * Gets the current value of the zOffset
  38826. * @returns the current zOffset state
  38827. */
  38828. getZOffset(): number;
  38829. /**
  38830. * Enable or disable depth buffering
  38831. * @param enable defines the state to set
  38832. */
  38833. setDepthBuffer(enable: boolean): void;
  38834. /**
  38835. * Gets a boolean indicating if depth writing is enabled
  38836. * @returns the current depth writing state
  38837. */
  38838. getDepthWrite(): boolean;
  38839. /**
  38840. * Enable or disable depth writing
  38841. * @param enable defines the state to set
  38842. */
  38843. setDepthWrite(enable: boolean): void;
  38844. /**
  38845. * Gets a boolean indicating if stencil buffer is enabled
  38846. * @returns the current stencil buffer state
  38847. */
  38848. getStencilBuffer(): boolean;
  38849. /**
  38850. * Enable or disable the stencil buffer
  38851. * @param enable defines if the stencil buffer must be enabled or disabled
  38852. */
  38853. setStencilBuffer(enable: boolean): void;
  38854. /**
  38855. * Gets the current stencil mask
  38856. * @returns a number defining the new stencil mask to use
  38857. */
  38858. getStencilMask(): number;
  38859. /**
  38860. * Sets the current stencil mask
  38861. * @param mask defines the new stencil mask to use
  38862. */
  38863. setStencilMask(mask: number): void;
  38864. /**
  38865. * Gets the current stencil function
  38866. * @returns a number defining the stencil function to use
  38867. */
  38868. getStencilFunction(): number;
  38869. /**
  38870. * Gets the current stencil reference value
  38871. * @returns a number defining the stencil reference value to use
  38872. */
  38873. getStencilFunctionReference(): number;
  38874. /**
  38875. * Gets the current stencil mask
  38876. * @returns a number defining the stencil mask to use
  38877. */
  38878. getStencilFunctionMask(): number;
  38879. /**
  38880. * Sets the current stencil function
  38881. * @param stencilFunc defines the new stencil function to use
  38882. */
  38883. setStencilFunction(stencilFunc: number): void;
  38884. /**
  38885. * Sets the current stencil reference
  38886. * @param reference defines the new stencil reference to use
  38887. */
  38888. setStencilFunctionReference(reference: number): void;
  38889. /**
  38890. * Sets the current stencil mask
  38891. * @param mask defines the new stencil mask to use
  38892. */
  38893. setStencilFunctionMask(mask: number): void;
  38894. /**
  38895. * Gets the current stencil operation when stencil fails
  38896. * @returns a number defining stencil operation to use when stencil fails
  38897. */
  38898. getStencilOperationFail(): number;
  38899. /**
  38900. * Gets the current stencil operation when depth fails
  38901. * @returns a number defining stencil operation to use when depth fails
  38902. */
  38903. getStencilOperationDepthFail(): number;
  38904. /**
  38905. * Gets the current stencil operation when stencil passes
  38906. * @returns a number defining stencil operation to use when stencil passes
  38907. */
  38908. getStencilOperationPass(): number;
  38909. /**
  38910. * Sets the stencil operation to use when stencil fails
  38911. * @param operation defines the stencil operation to use when stencil fails
  38912. */
  38913. setStencilOperationFail(operation: number): void;
  38914. /**
  38915. * Sets the stencil operation to use when depth fails
  38916. * @param operation defines the stencil operation to use when depth fails
  38917. */
  38918. setStencilOperationDepthFail(operation: number): void;
  38919. /**
  38920. * Sets the stencil operation to use when stencil passes
  38921. * @param operation defines the stencil operation to use when stencil passes
  38922. */
  38923. setStencilOperationPass(operation: number): void;
  38924. /**
  38925. * Sets a boolean indicating if the dithering state is enabled or disabled
  38926. * @param value defines the dithering state
  38927. */
  38928. setDitheringState(value: boolean): void;
  38929. /**
  38930. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38931. * @param value defines the rasterizer state
  38932. */
  38933. setRasterizerState(value: boolean): void;
  38934. /**
  38935. * Gets the current depth function
  38936. * @returns a number defining the depth function
  38937. */
  38938. getDepthFunction(): Nullable<number>;
  38939. /**
  38940. * Sets the current depth function
  38941. * @param depthFunc defines the function to use
  38942. */
  38943. setDepthFunction(depthFunc: number): void;
  38944. /**
  38945. * Sets the current depth function to GREATER
  38946. */
  38947. setDepthFunctionToGreater(): void;
  38948. /**
  38949. * Sets the current depth function to GEQUAL
  38950. */
  38951. setDepthFunctionToGreaterOrEqual(): void;
  38952. /**
  38953. * Sets the current depth function to LESS
  38954. */
  38955. setDepthFunctionToLess(): void;
  38956. /**
  38957. * Sets the current depth function to LEQUAL
  38958. */
  38959. setDepthFunctionToLessOrEqual(): void;
  38960. private _cachedStencilBuffer;
  38961. private _cachedStencilFunction;
  38962. private _cachedStencilMask;
  38963. private _cachedStencilOperationPass;
  38964. private _cachedStencilOperationFail;
  38965. private _cachedStencilOperationDepthFail;
  38966. private _cachedStencilReference;
  38967. /**
  38968. * Caches the the state of the stencil buffer
  38969. */
  38970. cacheStencilState(): void;
  38971. /**
  38972. * Restores the state of the stencil buffer
  38973. */
  38974. restoreStencilState(): void;
  38975. /**
  38976. * Directly set the WebGL Viewport
  38977. * @param x defines the x coordinate of the viewport (in screen space)
  38978. * @param y defines the y coordinate of the viewport (in screen space)
  38979. * @param width defines the width of the viewport (in screen space)
  38980. * @param height defines the height of the viewport (in screen space)
  38981. * @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
  38982. */
  38983. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38984. /**
  38985. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38986. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38987. * @param y defines the y-coordinate of the corner of the clear rectangle
  38988. * @param width defines the width of the clear rectangle
  38989. * @param height defines the height of the clear rectangle
  38990. * @param clearColor defines the clear color
  38991. */
  38992. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38993. /**
  38994. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38995. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38996. * @param y defines the y-coordinate of the corner of the clear rectangle
  38997. * @param width defines the width of the clear rectangle
  38998. * @param height defines the height of the clear rectangle
  38999. */
  39000. enableScissor(x: number, y: number, width: number, height: number): void;
  39001. /**
  39002. * Disable previously set scissor test rectangle
  39003. */
  39004. disableScissor(): void;
  39005. protected _reportDrawCall(): void;
  39006. /**
  39007. * Initializes a webVR display and starts listening to display change events
  39008. * The onVRDisplayChangedObservable will be notified upon these changes
  39009. * @returns The onVRDisplayChangedObservable
  39010. */
  39011. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39012. /** @hidden */
  39013. _prepareVRComponent(): void;
  39014. /** @hidden */
  39015. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39016. /** @hidden */
  39017. _submitVRFrame(): void;
  39018. /**
  39019. * Call this function to leave webVR mode
  39020. * Will do nothing if webVR is not supported or if there is no webVR device
  39021. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39022. */
  39023. disableVR(): void;
  39024. /**
  39025. * Gets a boolean indicating that the system is in VR mode and is presenting
  39026. * @returns true if VR mode is engaged
  39027. */
  39028. isVRPresenting(): boolean;
  39029. /** @hidden */
  39030. _requestVRFrame(): void;
  39031. /** @hidden */
  39032. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39033. /**
  39034. * Gets the source code of the vertex shader associated with a specific webGL program
  39035. * @param program defines the program to use
  39036. * @returns a string containing the source code of the vertex shader associated with the program
  39037. */
  39038. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39039. /**
  39040. * Gets the source code of the fragment shader associated with a specific webGL program
  39041. * @param program defines the program to use
  39042. * @returns a string containing the source code of the fragment shader associated with the program
  39043. */
  39044. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39045. /**
  39046. * Sets a depth stencil texture from a render target to the according uniform.
  39047. * @param channel The texture channel
  39048. * @param uniform The uniform to set
  39049. * @param texture The render target texture containing the depth stencil texture to apply
  39050. */
  39051. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39052. /**
  39053. * Sets a texture to the webGL context from a postprocess
  39054. * @param channel defines the channel to use
  39055. * @param postProcess defines the source postprocess
  39056. */
  39057. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39058. /**
  39059. * Binds the output of the passed in post process to the texture channel specified
  39060. * @param channel The channel the texture should be bound to
  39061. * @param postProcess The post process which's output should be bound
  39062. */
  39063. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39064. protected _rebuildBuffers(): void;
  39065. /** @hidden */
  39066. _renderFrame(): void;
  39067. _renderLoop(): void;
  39068. /** @hidden */
  39069. _renderViews(): boolean;
  39070. /**
  39071. * Toggle full screen mode
  39072. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39073. */
  39074. switchFullscreen(requestPointerLock: boolean): void;
  39075. /**
  39076. * Enters full screen mode
  39077. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39078. */
  39079. enterFullscreen(requestPointerLock: boolean): void;
  39080. /**
  39081. * Exits full screen mode
  39082. */
  39083. exitFullscreen(): void;
  39084. /**
  39085. * Enters Pointerlock mode
  39086. */
  39087. enterPointerlock(): void;
  39088. /**
  39089. * Exits Pointerlock mode
  39090. */
  39091. exitPointerlock(): void;
  39092. /**
  39093. * Begin a new frame
  39094. */
  39095. beginFrame(): void;
  39096. /**
  39097. * Enf the current frame
  39098. */
  39099. endFrame(): void;
  39100. resize(): void;
  39101. /**
  39102. * Force a specific size of the canvas
  39103. * @param width defines the new canvas' width
  39104. * @param height defines the new canvas' height
  39105. * @returns true if the size was changed
  39106. */
  39107. setSize(width: number, height: number): boolean;
  39108. /**
  39109. * Updates a dynamic vertex buffer.
  39110. * @param vertexBuffer the vertex buffer to update
  39111. * @param data the data used to update the vertex buffer
  39112. * @param byteOffset the byte offset of the data
  39113. * @param byteLength the byte length of the data
  39114. */
  39115. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  39116. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39117. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39118. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39119. _releaseTexture(texture: InternalTexture): void;
  39120. /**
  39121. * @hidden
  39122. * Rescales a texture
  39123. * @param source input texutre
  39124. * @param destination destination texture
  39125. * @param scene scene to use to render the resize
  39126. * @param internalFormat format to use when resizing
  39127. * @param onComplete callback to be called when resize has completed
  39128. */
  39129. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39130. /**
  39131. * Gets the current framerate
  39132. * @returns a number representing the framerate
  39133. */
  39134. getFps(): number;
  39135. /**
  39136. * Gets the time spent between current and previous frame
  39137. * @returns a number representing the delta time in ms
  39138. */
  39139. getDeltaTime(): number;
  39140. private _measureFps;
  39141. /** @hidden */
  39142. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39143. /**
  39144. * Update a dynamic index buffer
  39145. * @param indexBuffer defines the target index buffer
  39146. * @param indices defines the data to update
  39147. * @param offset defines the offset in the target index buffer where update should start
  39148. */
  39149. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  39150. /**
  39151. * Updates the sample count of a render target texture
  39152. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39153. * @param texture defines the texture to update
  39154. * @param samples defines the sample count to set
  39155. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39156. */
  39157. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39158. /**
  39159. * Updates a depth texture Comparison Mode and Function.
  39160. * If the comparison Function is equal to 0, the mode will be set to none.
  39161. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39162. * @param texture The texture to set the comparison function for
  39163. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39164. */
  39165. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39166. /**
  39167. * Creates a webGL buffer to use with instanciation
  39168. * @param capacity defines the size of the buffer
  39169. * @returns the webGL buffer
  39170. */
  39171. createInstancesBuffer(capacity: number): DataBuffer;
  39172. /**
  39173. * Delete a webGL buffer used with instanciation
  39174. * @param buffer defines the webGL buffer to delete
  39175. */
  39176. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39177. private _clientWaitAsync;
  39178. /** @hidden */
  39179. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39180. dispose(): void;
  39181. private _disableTouchAction;
  39182. /**
  39183. * Display the loading screen
  39184. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39185. */
  39186. displayLoadingUI(): void;
  39187. /**
  39188. * Hide the loading screen
  39189. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39190. */
  39191. hideLoadingUI(): void;
  39192. /**
  39193. * Gets the current loading screen object
  39194. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39195. */
  39196. get loadingScreen(): ILoadingScreen;
  39197. /**
  39198. * Sets the current loading screen object
  39199. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39200. */
  39201. set loadingScreen(loadingScreen: ILoadingScreen);
  39202. /**
  39203. * Sets the current loading screen text
  39204. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39205. */
  39206. set loadingUIText(text: string);
  39207. /**
  39208. * Sets the current loading screen background color
  39209. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39210. */
  39211. set loadingUIBackgroundColor(color: string);
  39212. /** Pointerlock and fullscreen */
  39213. /**
  39214. * Ask the browser to promote the current element to pointerlock mode
  39215. * @param element defines the DOM element to promote
  39216. */
  39217. static _RequestPointerlock(element: HTMLElement): void;
  39218. /**
  39219. * Asks the browser to exit pointerlock mode
  39220. */
  39221. static _ExitPointerlock(): void;
  39222. /**
  39223. * Ask the browser to promote the current element to fullscreen rendering mode
  39224. * @param element defines the DOM element to promote
  39225. */
  39226. static _RequestFullscreen(element: HTMLElement): void;
  39227. /**
  39228. * Asks the browser to exit fullscreen mode
  39229. */
  39230. static _ExitFullscreen(): void;
  39231. }
  39232. }
  39233. declare module "babylonjs/Engines/engineStore" {
  39234. import { Nullable } from "babylonjs/types";
  39235. import { Engine } from "babylonjs/Engines/engine";
  39236. import { Scene } from "babylonjs/scene";
  39237. /**
  39238. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39239. * during the life time of the application.
  39240. */
  39241. export class EngineStore {
  39242. /** Gets the list of created engines */
  39243. static Instances: import("babylonjs/Engines/engine").Engine[];
  39244. /** @hidden */
  39245. static _LastCreatedScene: Nullable<Scene>;
  39246. /**
  39247. * Gets the latest created engine
  39248. */
  39249. static get LastCreatedEngine(): Nullable<Engine>;
  39250. /**
  39251. * Gets the latest created scene
  39252. */
  39253. static get LastCreatedScene(): Nullable<Scene>;
  39254. /**
  39255. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39256. * @ignorenaming
  39257. */
  39258. static UseFallbackTexture: boolean;
  39259. /**
  39260. * Texture content used if a texture cannot loaded
  39261. * @ignorenaming
  39262. */
  39263. static FallbackTexture: string;
  39264. }
  39265. }
  39266. declare module "babylonjs/Misc/promise" {
  39267. /**
  39268. * Helper class that provides a small promise polyfill
  39269. */
  39270. export class PromisePolyfill {
  39271. /**
  39272. * Static function used to check if the polyfill is required
  39273. * If this is the case then the function will inject the polyfill to window.Promise
  39274. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39275. */
  39276. static Apply(force?: boolean): void;
  39277. }
  39278. }
  39279. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39280. /**
  39281. * Interface for screenshot methods with describe argument called `size` as object with options
  39282. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39283. */
  39284. export interface IScreenshotSize {
  39285. /**
  39286. * number in pixels for canvas height
  39287. */
  39288. height?: number;
  39289. /**
  39290. * multiplier allowing render at a higher or lower resolution
  39291. * If value is defined then height and width will be ignored and taken from camera
  39292. */
  39293. precision?: number;
  39294. /**
  39295. * number in pixels for canvas width
  39296. */
  39297. width?: number;
  39298. }
  39299. }
  39300. declare module "babylonjs/Misc/tools" {
  39301. import { Nullable, float } from "babylonjs/types";
  39302. import { DomManagement } from "babylonjs/Misc/domManagement";
  39303. import { WebRequest } from "babylonjs/Misc/webRequest";
  39304. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39305. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39306. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39307. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39308. import { Camera } from "babylonjs/Cameras/camera";
  39309. import { Engine } from "babylonjs/Engines/engine";
  39310. interface IColor4Like {
  39311. r: float;
  39312. g: float;
  39313. b: float;
  39314. a: float;
  39315. }
  39316. /**
  39317. * Class containing a set of static utilities functions
  39318. */
  39319. export class Tools {
  39320. /**
  39321. * Gets or sets the base URL to use to load assets
  39322. */
  39323. static get BaseUrl(): string;
  39324. static set BaseUrl(value: string);
  39325. /**
  39326. * Enable/Disable Custom HTTP Request Headers globally.
  39327. * default = false
  39328. * @see CustomRequestHeaders
  39329. */
  39330. static UseCustomRequestHeaders: boolean;
  39331. /**
  39332. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39333. * i.e. when loading files, where the server/service expects an Authorization header
  39334. */
  39335. static CustomRequestHeaders: {
  39336. [key: string]: string;
  39337. };
  39338. /**
  39339. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39340. */
  39341. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39342. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39343. /**
  39344. * Default behaviour for cors in the application.
  39345. * It can be a string if the expected behavior is identical in the entire app.
  39346. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39347. */
  39348. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39349. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39350. /**
  39351. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39352. * @ignorenaming
  39353. */
  39354. static get UseFallbackTexture(): boolean;
  39355. static set UseFallbackTexture(value: boolean);
  39356. /**
  39357. * Use this object to register external classes like custom textures or material
  39358. * to allow the laoders to instantiate them
  39359. */
  39360. static get RegisteredExternalClasses(): {
  39361. [key: string]: Object;
  39362. };
  39363. static set RegisteredExternalClasses(classes: {
  39364. [key: string]: Object;
  39365. });
  39366. /**
  39367. * Texture content used if a texture cannot loaded
  39368. * @ignorenaming
  39369. */
  39370. static get fallbackTexture(): string;
  39371. static set fallbackTexture(value: string);
  39372. /**
  39373. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39374. * @param u defines the coordinate on X axis
  39375. * @param v defines the coordinate on Y axis
  39376. * @param width defines the width of the source data
  39377. * @param height defines the height of the source data
  39378. * @param pixels defines the source byte array
  39379. * @param color defines the output color
  39380. */
  39381. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39382. /**
  39383. * Interpolates between a and b via alpha
  39384. * @param a The lower value (returned when alpha = 0)
  39385. * @param b The upper value (returned when alpha = 1)
  39386. * @param alpha The interpolation-factor
  39387. * @return The mixed value
  39388. */
  39389. static Mix(a: number, b: number, alpha: number): number;
  39390. /**
  39391. * Tries to instantiate a new object from a given class name
  39392. * @param className defines the class name to instantiate
  39393. * @returns the new object or null if the system was not able to do the instantiation
  39394. */
  39395. static Instantiate(className: string): any;
  39396. /**
  39397. * Provides a slice function that will work even on IE
  39398. * @param data defines the array to slice
  39399. * @param start defines the start of the data (optional)
  39400. * @param end defines the end of the data (optional)
  39401. * @returns the new sliced array
  39402. */
  39403. static Slice<T>(data: T, start?: number, end?: number): T;
  39404. /**
  39405. * Polyfill for setImmediate
  39406. * @param action defines the action to execute after the current execution block
  39407. */
  39408. static SetImmediate(action: () => void): void;
  39409. /**
  39410. * Function indicating if a number is an exponent of 2
  39411. * @param value defines the value to test
  39412. * @returns true if the value is an exponent of 2
  39413. */
  39414. static IsExponentOfTwo(value: number): boolean;
  39415. private static _tmpFloatArray;
  39416. /**
  39417. * Returns the nearest 32-bit single precision float representation of a Number
  39418. * @param value A Number. If the parameter is of a different type, it will get converted
  39419. * to a number or to NaN if it cannot be converted
  39420. * @returns number
  39421. */
  39422. static FloatRound(value: number): number;
  39423. /**
  39424. * Extracts the filename from a path
  39425. * @param path defines the path to use
  39426. * @returns the filename
  39427. */
  39428. static GetFilename(path: string): string;
  39429. /**
  39430. * Extracts the "folder" part of a path (everything before the filename).
  39431. * @param uri The URI to extract the info from
  39432. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39433. * @returns The "folder" part of the path
  39434. */
  39435. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39436. /**
  39437. * Extracts text content from a DOM element hierarchy
  39438. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39439. */
  39440. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39441. /**
  39442. * Convert an angle in radians to degrees
  39443. * @param angle defines the angle to convert
  39444. * @returns the angle in degrees
  39445. */
  39446. static ToDegrees(angle: number): number;
  39447. /**
  39448. * Convert an angle in degrees to radians
  39449. * @param angle defines the angle to convert
  39450. * @returns the angle in radians
  39451. */
  39452. static ToRadians(angle: number): number;
  39453. /**
  39454. * Returns an array if obj is not an array
  39455. * @param obj defines the object to evaluate as an array
  39456. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39457. * @returns either obj directly if obj is an array or a new array containing obj
  39458. */
  39459. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39460. /**
  39461. * Gets the pointer prefix to use
  39462. * @param engine defines the engine we are finding the prefix for
  39463. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39464. */
  39465. static GetPointerPrefix(engine: Engine): string;
  39466. /**
  39467. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39468. * @param url define the url we are trying
  39469. * @param element define the dom element where to configure the cors policy
  39470. */
  39471. static SetCorsBehavior(url: string | string[], element: {
  39472. crossOrigin: string | null;
  39473. }): void;
  39474. /**
  39475. * Removes unwanted characters from an url
  39476. * @param url defines the url to clean
  39477. * @returns the cleaned url
  39478. */
  39479. static CleanUrl(url: string): string;
  39480. /**
  39481. * Gets or sets a function used to pre-process url before using them to load assets
  39482. */
  39483. static get PreprocessUrl(): (url: string) => string;
  39484. static set PreprocessUrl(processor: (url: string) => string);
  39485. /**
  39486. * Loads an image as an HTMLImageElement.
  39487. * @param input url string, ArrayBuffer, or Blob to load
  39488. * @param onLoad callback called when the image successfully loads
  39489. * @param onError callback called when the image fails to load
  39490. * @param offlineProvider offline provider for caching
  39491. * @param mimeType optional mime type
  39492. * @returns the HTMLImageElement of the loaded image
  39493. */
  39494. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39495. /**
  39496. * Loads a file from a url
  39497. * @param url url string, ArrayBuffer, or Blob to load
  39498. * @param onSuccess callback called when the file successfully loads
  39499. * @param onProgress callback called while file is loading (if the server supports this mode)
  39500. * @param offlineProvider defines the offline provider for caching
  39501. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39502. * @param onError callback called when the file fails to load
  39503. * @returns a file request object
  39504. */
  39505. 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;
  39506. /**
  39507. * Loads a file from a url
  39508. * @param url the file url to load
  39509. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39510. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39511. */
  39512. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39513. /**
  39514. * Load a script (identified by an url). When the url returns, the
  39515. * content of this file is added into a new script element, attached to the DOM (body element)
  39516. * @param scriptUrl defines the url of the script to laod
  39517. * @param onSuccess defines the callback called when the script is loaded
  39518. * @param onError defines the callback to call if an error occurs
  39519. * @param scriptId defines the id of the script element
  39520. */
  39521. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39522. /**
  39523. * Load an asynchronous script (identified by an url). When the url returns, the
  39524. * content of this file is added into a new script element, attached to the DOM (body element)
  39525. * @param scriptUrl defines the url of the script to laod
  39526. * @param scriptId defines the id of the script element
  39527. * @returns a promise request object
  39528. */
  39529. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39530. /**
  39531. * Loads a file from a blob
  39532. * @param fileToLoad defines the blob to use
  39533. * @param callback defines the callback to call when data is loaded
  39534. * @param progressCallback defines the callback to call during loading process
  39535. * @returns a file request object
  39536. */
  39537. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39538. /**
  39539. * Reads a file from a File object
  39540. * @param file defines the file to load
  39541. * @param onSuccess defines the callback to call when data is loaded
  39542. * @param onProgress defines the callback to call during loading process
  39543. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39544. * @param onError defines the callback to call when an error occurs
  39545. * @returns a file request object
  39546. */
  39547. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39548. /**
  39549. * Creates a data url from a given string content
  39550. * @param content defines the content to convert
  39551. * @returns the new data url link
  39552. */
  39553. static FileAsURL(content: string): string;
  39554. /**
  39555. * Format the given number to a specific decimal format
  39556. * @param value defines the number to format
  39557. * @param decimals defines the number of decimals to use
  39558. * @returns the formatted string
  39559. */
  39560. static Format(value: number, decimals?: number): string;
  39561. /**
  39562. * Tries to copy an object by duplicating every property
  39563. * @param source defines the source object
  39564. * @param destination defines the target object
  39565. * @param doNotCopyList defines a list of properties to avoid
  39566. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39567. */
  39568. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39569. /**
  39570. * Gets a boolean indicating if the given object has no own property
  39571. * @param obj defines the object to test
  39572. * @returns true if object has no own property
  39573. */
  39574. static IsEmpty(obj: any): boolean;
  39575. /**
  39576. * Function used to register events at window level
  39577. * @param windowElement defines the Window object to use
  39578. * @param events defines the events to register
  39579. */
  39580. static RegisterTopRootEvents(windowElement: Window, events: {
  39581. name: string;
  39582. handler: Nullable<(e: FocusEvent) => any>;
  39583. }[]): void;
  39584. /**
  39585. * Function used to unregister events from window level
  39586. * @param windowElement defines the Window object to use
  39587. * @param events defines the events to unregister
  39588. */
  39589. static UnregisterTopRootEvents(windowElement: Window, events: {
  39590. name: string;
  39591. handler: Nullable<(e: FocusEvent) => any>;
  39592. }[]): void;
  39593. /**
  39594. * @ignore
  39595. */
  39596. static _ScreenshotCanvas: HTMLCanvasElement;
  39597. /**
  39598. * Dumps the current bound framebuffer
  39599. * @param width defines the rendering width
  39600. * @param height defines the rendering height
  39601. * @param engine defines the hosting engine
  39602. * @param successCallback defines the callback triggered once the data are available
  39603. * @param mimeType defines the mime type of the result
  39604. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39605. */
  39606. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39607. /**
  39608. * Converts the canvas data to blob.
  39609. * This acts as a polyfill for browsers not supporting the to blob function.
  39610. * @param canvas Defines the canvas to extract the data from
  39611. * @param successCallback Defines the callback triggered once the data are available
  39612. * @param mimeType Defines the mime type of the result
  39613. */
  39614. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39615. /**
  39616. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39617. * @param successCallback defines the callback triggered once the data are available
  39618. * @param mimeType defines the mime type of the result
  39619. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39620. */
  39621. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39622. /**
  39623. * Downloads a blob in the browser
  39624. * @param blob defines the blob to download
  39625. * @param fileName defines the name of the downloaded file
  39626. */
  39627. static Download(blob: Blob, fileName: string): void;
  39628. /**
  39629. * Captures a screenshot of the current rendering
  39630. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39631. * @param engine defines the rendering engine
  39632. * @param camera defines the source camera
  39633. * @param size This parameter can be set to a single number or to an object with the
  39634. * following (optional) properties: precision, width, height. If a single number is passed,
  39635. * it will be used for both width and height. If an object is passed, the screenshot size
  39636. * will be derived from the parameters. The precision property is a multiplier allowing
  39637. * rendering at a higher or lower resolution
  39638. * @param successCallback defines the callback receives a single parameter which contains the
  39639. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39640. * src parameter of an <img> to display it
  39641. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39642. * Check your browser for supported MIME types
  39643. */
  39644. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39645. /**
  39646. * Captures a screenshot of the current rendering
  39647. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39648. * @param engine defines the rendering engine
  39649. * @param camera defines the source camera
  39650. * @param size This parameter can be set to a single number or to an object with the
  39651. * following (optional) properties: precision, width, height. If a single number is passed,
  39652. * it will be used for both width and height. If an object is passed, the screenshot size
  39653. * will be derived from the parameters. The precision property is a multiplier allowing
  39654. * rendering at a higher or lower resolution
  39655. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39656. * Check your browser for supported MIME types
  39657. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39658. * to the src parameter of an <img> to display it
  39659. */
  39660. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39661. /**
  39662. * Generates an image screenshot from the specified camera.
  39663. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39664. * @param engine The engine to use for rendering
  39665. * @param camera The camera to use for rendering
  39666. * @param size This parameter can be set to a single number or to an object with the
  39667. * following (optional) properties: precision, width, height. If a single number is passed,
  39668. * it will be used for both width and height. If an object is passed, the screenshot size
  39669. * will be derived from the parameters. The precision property is a multiplier allowing
  39670. * rendering at a higher or lower resolution
  39671. * @param successCallback The callback receives a single parameter which contains the
  39672. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39673. * src parameter of an <img> to display it
  39674. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39675. * Check your browser for supported MIME types
  39676. * @param samples Texture samples (default: 1)
  39677. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39678. * @param fileName A name for for the downloaded file.
  39679. */
  39680. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39681. /**
  39682. * Generates an image screenshot from the specified camera.
  39683. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39684. * @param engine The engine to use for rendering
  39685. * @param camera The camera to use for rendering
  39686. * @param size This parameter can be set to a single number or to an object with the
  39687. * following (optional) properties: precision, width, height. If a single number is passed,
  39688. * it will be used for both width and height. If an object is passed, the screenshot size
  39689. * will be derived from the parameters. The precision property is a multiplier allowing
  39690. * rendering at a higher or lower resolution
  39691. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39692. * Check your browser for supported MIME types
  39693. * @param samples Texture samples (default: 1)
  39694. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39695. * @param fileName A name for for the downloaded file.
  39696. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39697. * to the src parameter of an <img> to display it
  39698. */
  39699. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39700. /**
  39701. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39702. * Be aware Math.random() could cause collisions, but:
  39703. * "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"
  39704. * @returns a pseudo random id
  39705. */
  39706. static RandomId(): string;
  39707. /**
  39708. * Test if the given uri is a base64 string
  39709. * @param uri The uri to test
  39710. * @return True if the uri is a base64 string or false otherwise
  39711. */
  39712. static IsBase64(uri: string): boolean;
  39713. /**
  39714. * Decode the given base64 uri.
  39715. * @param uri The uri to decode
  39716. * @return The decoded base64 data.
  39717. */
  39718. static DecodeBase64(uri: string): ArrayBuffer;
  39719. /**
  39720. * Gets the absolute url.
  39721. * @param url the input url
  39722. * @return the absolute url
  39723. */
  39724. static GetAbsoluteUrl(url: string): string;
  39725. /**
  39726. * No log
  39727. */
  39728. static readonly NoneLogLevel: number;
  39729. /**
  39730. * Only message logs
  39731. */
  39732. static readonly MessageLogLevel: number;
  39733. /**
  39734. * Only warning logs
  39735. */
  39736. static readonly WarningLogLevel: number;
  39737. /**
  39738. * Only error logs
  39739. */
  39740. static readonly ErrorLogLevel: number;
  39741. /**
  39742. * All logs
  39743. */
  39744. static readonly AllLogLevel: number;
  39745. /**
  39746. * Gets a value indicating the number of loading errors
  39747. * @ignorenaming
  39748. */
  39749. static get errorsCount(): number;
  39750. /**
  39751. * Callback called when a new log is added
  39752. */
  39753. static OnNewCacheEntry: (entry: string) => void;
  39754. /**
  39755. * Log a message to the console
  39756. * @param message defines the message to log
  39757. */
  39758. static Log(message: string): void;
  39759. /**
  39760. * Write a warning message to the console
  39761. * @param message defines the message to log
  39762. */
  39763. static Warn(message: string): void;
  39764. /**
  39765. * Write an error message to the console
  39766. * @param message defines the message to log
  39767. */
  39768. static Error(message: string): void;
  39769. /**
  39770. * Gets current log cache (list of logs)
  39771. */
  39772. static get LogCache(): string;
  39773. /**
  39774. * Clears the log cache
  39775. */
  39776. static ClearLogCache(): void;
  39777. /**
  39778. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39779. */
  39780. static set LogLevels(level: number);
  39781. /**
  39782. * Checks if the window object exists
  39783. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39784. */
  39785. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39786. /**
  39787. * No performance log
  39788. */
  39789. static readonly PerformanceNoneLogLevel: number;
  39790. /**
  39791. * Use user marks to log performance
  39792. */
  39793. static readonly PerformanceUserMarkLogLevel: number;
  39794. /**
  39795. * Log performance to the console
  39796. */
  39797. static readonly PerformanceConsoleLogLevel: number;
  39798. private static _performance;
  39799. /**
  39800. * Sets the current performance log level
  39801. */
  39802. static set PerformanceLogLevel(level: number);
  39803. private static _StartPerformanceCounterDisabled;
  39804. private static _EndPerformanceCounterDisabled;
  39805. private static _StartUserMark;
  39806. private static _EndUserMark;
  39807. private static _StartPerformanceConsole;
  39808. private static _EndPerformanceConsole;
  39809. /**
  39810. * Starts a performance counter
  39811. */
  39812. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39813. /**
  39814. * Ends a specific performance coutner
  39815. */
  39816. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39817. /**
  39818. * Gets either window.performance.now() if supported or Date.now() else
  39819. */
  39820. static get Now(): number;
  39821. /**
  39822. * This method will return the name of the class used to create the instance of the given object.
  39823. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39824. * @param object the object to get the class name from
  39825. * @param isType defines if the object is actually a type
  39826. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39827. */
  39828. static GetClassName(object: any, isType?: boolean): string;
  39829. /**
  39830. * Gets the first element of an array satisfying a given predicate
  39831. * @param array defines the array to browse
  39832. * @param predicate defines the predicate to use
  39833. * @returns null if not found or the element
  39834. */
  39835. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39836. /**
  39837. * This method will return the name of the full name of the class, including its owning module (if any).
  39838. * 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).
  39839. * @param object the object to get the class name from
  39840. * @param isType defines if the object is actually a type
  39841. * @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.
  39842. * @ignorenaming
  39843. */
  39844. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39845. /**
  39846. * Returns a promise that resolves after the given amount of time.
  39847. * @param delay Number of milliseconds to delay
  39848. * @returns Promise that resolves after the given amount of time
  39849. */
  39850. static DelayAsync(delay: number): Promise<void>;
  39851. /**
  39852. * Utility function to detect if the current user agent is Safari
  39853. * @returns whether or not the current user agent is safari
  39854. */
  39855. static IsSafari(): boolean;
  39856. }
  39857. /**
  39858. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39859. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39860. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39861. * @param name The name of the class, case should be preserved
  39862. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39863. */
  39864. export function className(name: string, module?: string): (target: Object) => void;
  39865. /**
  39866. * An implementation of a loop for asynchronous functions.
  39867. */
  39868. export class AsyncLoop {
  39869. /**
  39870. * Defines the number of iterations for the loop
  39871. */
  39872. iterations: number;
  39873. /**
  39874. * Defines the current index of the loop.
  39875. */
  39876. index: number;
  39877. private _done;
  39878. private _fn;
  39879. private _successCallback;
  39880. /**
  39881. * Constructor.
  39882. * @param iterations the number of iterations.
  39883. * @param func the function to run each iteration
  39884. * @param successCallback the callback that will be called upon succesful execution
  39885. * @param offset starting offset.
  39886. */
  39887. constructor(
  39888. /**
  39889. * Defines the number of iterations for the loop
  39890. */
  39891. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39892. /**
  39893. * Execute the next iteration. Must be called after the last iteration was finished.
  39894. */
  39895. executeNext(): void;
  39896. /**
  39897. * Break the loop and run the success callback.
  39898. */
  39899. breakLoop(): void;
  39900. /**
  39901. * Create and run an async loop.
  39902. * @param iterations the number of iterations.
  39903. * @param fn the function to run each iteration
  39904. * @param successCallback the callback that will be called upon succesful execution
  39905. * @param offset starting offset.
  39906. * @returns the created async loop object
  39907. */
  39908. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39909. /**
  39910. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39911. * @param iterations total number of iterations
  39912. * @param syncedIterations number of synchronous iterations in each async iteration.
  39913. * @param fn the function to call each iteration.
  39914. * @param callback a success call back that will be called when iterating stops.
  39915. * @param breakFunction a break condition (optional)
  39916. * @param timeout timeout settings for the setTimeout function. default - 0.
  39917. * @returns the created async loop object
  39918. */
  39919. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39920. }
  39921. }
  39922. declare module "babylonjs/Misc/stringDictionary" {
  39923. import { Nullable } from "babylonjs/types";
  39924. /**
  39925. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39926. * The underlying implementation relies on an associative array to ensure the best performances.
  39927. * The value can be anything including 'null' but except 'undefined'
  39928. */
  39929. export class StringDictionary<T> {
  39930. /**
  39931. * This will clear this dictionary and copy the content from the 'source' one.
  39932. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39933. * @param source the dictionary to take the content from and copy to this dictionary
  39934. */
  39935. copyFrom(source: StringDictionary<T>): void;
  39936. /**
  39937. * Get a value based from its key
  39938. * @param key the given key to get the matching value from
  39939. * @return the value if found, otherwise undefined is returned
  39940. */
  39941. get(key: string): T | undefined;
  39942. /**
  39943. * Get a value from its key or add it if it doesn't exist.
  39944. * This method will ensure you that a given key/data will be present in the dictionary.
  39945. * @param key the given key to get the matching value from
  39946. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39947. * The factory will only be invoked if there's no data for the given key.
  39948. * @return the value corresponding to the key.
  39949. */
  39950. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39951. /**
  39952. * Get a value from its key if present in the dictionary otherwise add it
  39953. * @param key the key to get the value from
  39954. * @param val if there's no such key/value pair in the dictionary add it with this value
  39955. * @return the value corresponding to the key
  39956. */
  39957. getOrAdd(key: string, val: T): T;
  39958. /**
  39959. * Check if there's a given key in the dictionary
  39960. * @param key the key to check for
  39961. * @return true if the key is present, false otherwise
  39962. */
  39963. contains(key: string): boolean;
  39964. /**
  39965. * Add a new key and its corresponding value
  39966. * @param key the key to add
  39967. * @param value the value corresponding to the key
  39968. * @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
  39969. */
  39970. add(key: string, value: T): boolean;
  39971. /**
  39972. * Update a specific value associated to a key
  39973. * @param key defines the key to use
  39974. * @param value defines the value to store
  39975. * @returns true if the value was updated (or false if the key was not found)
  39976. */
  39977. set(key: string, value: T): boolean;
  39978. /**
  39979. * Get the element of the given key and remove it from the dictionary
  39980. * @param key defines the key to search
  39981. * @returns the value associated with the key or null if not found
  39982. */
  39983. getAndRemove(key: string): Nullable<T>;
  39984. /**
  39985. * Remove a key/value from the dictionary.
  39986. * @param key the key to remove
  39987. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39988. */
  39989. remove(key: string): boolean;
  39990. /**
  39991. * Clear the whole content of the dictionary
  39992. */
  39993. clear(): void;
  39994. /**
  39995. * Gets the current count
  39996. */
  39997. get count(): number;
  39998. /**
  39999. * Execute a callback on each key/val of the dictionary.
  40000. * Note that you can remove any element in this dictionary in the callback implementation
  40001. * @param callback the callback to execute on a given key/value pair
  40002. */
  40003. forEach(callback: (key: string, val: T) => void): void;
  40004. /**
  40005. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40006. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40007. * Note that you can remove any element in this dictionary in the callback implementation
  40008. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40009. * @returns the first item
  40010. */
  40011. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40012. private _count;
  40013. private _data;
  40014. }
  40015. }
  40016. declare module "babylonjs/Collisions/collisionCoordinator" {
  40017. import { Nullable } from "babylonjs/types";
  40018. import { Scene } from "babylonjs/scene";
  40019. import { Vector3 } from "babylonjs/Maths/math.vector";
  40020. import { Collider } from "babylonjs/Collisions/collider";
  40021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40022. /** @hidden */
  40023. export interface ICollisionCoordinator {
  40024. createCollider(): Collider;
  40025. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40026. init(scene: Scene): void;
  40027. }
  40028. /** @hidden */
  40029. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40030. private _scene;
  40031. private _scaledPosition;
  40032. private _scaledVelocity;
  40033. private _finalPosition;
  40034. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40035. createCollider(): Collider;
  40036. init(scene: Scene): void;
  40037. private _collideWithWorld;
  40038. }
  40039. }
  40040. declare module "babylonjs/Inputs/scene.inputManager" {
  40041. import { Nullable } from "babylonjs/types";
  40042. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40043. import { Vector2 } from "babylonjs/Maths/math.vector";
  40044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40045. import { Scene } from "babylonjs/scene";
  40046. /**
  40047. * Class used to manage all inputs for the scene.
  40048. */
  40049. export class InputManager {
  40050. /** The distance in pixel that you have to move to prevent some events */
  40051. static DragMovementThreshold: number;
  40052. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40053. static LongPressDelay: number;
  40054. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40055. static DoubleClickDelay: number;
  40056. /** If you need to check double click without raising a single click at first click, enable this flag */
  40057. static ExclusiveDoubleClickMode: boolean;
  40058. /** 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. */
  40059. private _alreadyAttached;
  40060. private _wheelEventName;
  40061. private _onPointerMove;
  40062. private _onPointerDown;
  40063. private _onPointerUp;
  40064. private _initClickEvent;
  40065. private _initActionManager;
  40066. private _delayedSimpleClick;
  40067. private _delayedSimpleClickTimeout;
  40068. private _previousDelayedSimpleClickTimeout;
  40069. private _meshPickProceed;
  40070. private _previousButtonPressed;
  40071. private _currentPickResult;
  40072. private _previousPickResult;
  40073. private _totalPointersPressed;
  40074. private _doubleClickOccured;
  40075. private _pointerOverMesh;
  40076. private _pickedDownMesh;
  40077. private _pickedUpMesh;
  40078. private _pointerX;
  40079. private _pointerY;
  40080. private _unTranslatedPointerX;
  40081. private _unTranslatedPointerY;
  40082. private _startingPointerPosition;
  40083. private _previousStartingPointerPosition;
  40084. private _startingPointerTime;
  40085. private _previousStartingPointerTime;
  40086. private _pointerCaptures;
  40087. private _onKeyDown;
  40088. private _onKeyUp;
  40089. private _onCanvasFocusObserver;
  40090. private _onCanvasBlurObserver;
  40091. private _scene;
  40092. /**
  40093. * Creates a new InputManager
  40094. * @param scene defines the hosting scene
  40095. */
  40096. constructor(scene: Scene);
  40097. /**
  40098. * Gets the mesh that is currently under the pointer
  40099. */
  40100. get meshUnderPointer(): Nullable<AbstractMesh>;
  40101. /**
  40102. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40103. */
  40104. get unTranslatedPointer(): Vector2;
  40105. /**
  40106. * Gets or sets the current on-screen X position of the pointer
  40107. */
  40108. get pointerX(): number;
  40109. set pointerX(value: number);
  40110. /**
  40111. * Gets or sets the current on-screen Y position of the pointer
  40112. */
  40113. get pointerY(): number;
  40114. set pointerY(value: number);
  40115. private _updatePointerPosition;
  40116. private _processPointerMove;
  40117. private _setRayOnPointerInfo;
  40118. private _checkPrePointerObservable;
  40119. /**
  40120. * Use this method to simulate a pointer move on a mesh
  40121. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40122. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40123. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40124. */
  40125. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40126. /**
  40127. * Use this method to simulate a pointer down on a mesh
  40128. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40129. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40130. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40131. */
  40132. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40133. private _processPointerDown;
  40134. /** @hidden */
  40135. _isPointerSwiping(): boolean;
  40136. /**
  40137. * Use this method to simulate a pointer up on a mesh
  40138. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40139. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40140. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40141. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40142. */
  40143. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40144. private _processPointerUp;
  40145. /**
  40146. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40147. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40148. * @returns true if the pointer was captured
  40149. */
  40150. isPointerCaptured(pointerId?: number): boolean;
  40151. /**
  40152. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40153. * @param attachUp defines if you want to attach events to pointerup
  40154. * @param attachDown defines if you want to attach events to pointerdown
  40155. * @param attachMove defines if you want to attach events to pointermove
  40156. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40157. */
  40158. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40159. /**
  40160. * Detaches all event handlers
  40161. */
  40162. detachControl(): void;
  40163. /**
  40164. * Force the value of meshUnderPointer
  40165. * @param mesh defines the mesh to use
  40166. */
  40167. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40168. /**
  40169. * Gets the mesh under the pointer
  40170. * @returns a Mesh or null if no mesh is under the pointer
  40171. */
  40172. getPointerOverMesh(): Nullable<AbstractMesh>;
  40173. }
  40174. }
  40175. declare module "babylonjs/Animations/animationGroup" {
  40176. import { Animatable } from "babylonjs/Animations/animatable";
  40177. import { Animation } from "babylonjs/Animations/animation";
  40178. import { Scene, IDisposable } from "babylonjs/scene";
  40179. import { Observable } from "babylonjs/Misc/observable";
  40180. import { Nullable } from "babylonjs/types";
  40181. import "babylonjs/Animations/animatable";
  40182. /**
  40183. * This class defines the direct association between an animation and a target
  40184. */
  40185. export class TargetedAnimation {
  40186. /**
  40187. * Animation to perform
  40188. */
  40189. animation: Animation;
  40190. /**
  40191. * Target to animate
  40192. */
  40193. target: any;
  40194. /**
  40195. * Returns the string "TargetedAnimation"
  40196. * @returns "TargetedAnimation"
  40197. */
  40198. getClassName(): string;
  40199. /**
  40200. * Serialize the object
  40201. * @returns the JSON object representing the current entity
  40202. */
  40203. serialize(): any;
  40204. }
  40205. /**
  40206. * Use this class to create coordinated animations on multiple targets
  40207. */
  40208. export class AnimationGroup implements IDisposable {
  40209. /** The name of the animation group */
  40210. name: string;
  40211. private _scene;
  40212. private _targetedAnimations;
  40213. private _animatables;
  40214. private _from;
  40215. private _to;
  40216. private _isStarted;
  40217. private _isPaused;
  40218. private _speedRatio;
  40219. private _loopAnimation;
  40220. private _isAdditive;
  40221. /**
  40222. * Gets or sets the unique id of the node
  40223. */
  40224. uniqueId: number;
  40225. /**
  40226. * This observable will notify when one animation have ended
  40227. */
  40228. onAnimationEndObservable: Observable<TargetedAnimation>;
  40229. /**
  40230. * Observer raised when one animation loops
  40231. */
  40232. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40233. /**
  40234. * Observer raised when all animations have looped
  40235. */
  40236. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40237. /**
  40238. * This observable will notify when all animations have ended.
  40239. */
  40240. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40241. /**
  40242. * This observable will notify when all animations have paused.
  40243. */
  40244. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40245. /**
  40246. * This observable will notify when all animations are playing.
  40247. */
  40248. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40249. /**
  40250. * Gets the first frame
  40251. */
  40252. get from(): number;
  40253. /**
  40254. * Gets the last frame
  40255. */
  40256. get to(): number;
  40257. /**
  40258. * Define if the animations are started
  40259. */
  40260. get isStarted(): boolean;
  40261. /**
  40262. * Gets a value indicating that the current group is playing
  40263. */
  40264. get isPlaying(): boolean;
  40265. /**
  40266. * Gets or sets the speed ratio to use for all animations
  40267. */
  40268. get speedRatio(): number;
  40269. /**
  40270. * Gets or sets the speed ratio to use for all animations
  40271. */
  40272. set speedRatio(value: number);
  40273. /**
  40274. * Gets or sets if all animations should loop or not
  40275. */
  40276. get loopAnimation(): boolean;
  40277. set loopAnimation(value: boolean);
  40278. /**
  40279. * Gets or sets if all animations should be evaluated additively
  40280. */
  40281. get isAdditive(): boolean;
  40282. set isAdditive(value: boolean);
  40283. /**
  40284. * Gets the targeted animations for this animation group
  40285. */
  40286. get targetedAnimations(): Array<TargetedAnimation>;
  40287. /**
  40288. * returning the list of animatables controlled by this animation group.
  40289. */
  40290. get animatables(): Array<Animatable>;
  40291. /**
  40292. * Gets the list of target animations
  40293. */
  40294. get children(): TargetedAnimation[];
  40295. /**
  40296. * Instantiates a new Animation Group.
  40297. * This helps managing several animations at once.
  40298. * @see https://doc.babylonjs.com/how_to/group
  40299. * @param name Defines the name of the group
  40300. * @param scene Defines the scene the group belongs to
  40301. */
  40302. constructor(
  40303. /** The name of the animation group */
  40304. name: string, scene?: Nullable<Scene>);
  40305. /**
  40306. * Add an animation (with its target) in the group
  40307. * @param animation defines the animation we want to add
  40308. * @param target defines the target of the animation
  40309. * @returns the TargetedAnimation object
  40310. */
  40311. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40312. /**
  40313. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40314. * It can add constant keys at begin or end
  40315. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40316. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40317. * @returns the animation group
  40318. */
  40319. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40320. private _animationLoopCount;
  40321. private _animationLoopFlags;
  40322. private _processLoop;
  40323. /**
  40324. * Start all animations on given targets
  40325. * @param loop defines if animations must loop
  40326. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40327. * @param from defines the from key (optional)
  40328. * @param to defines the to key (optional)
  40329. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40330. * @returns the current animation group
  40331. */
  40332. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40333. /**
  40334. * Pause all animations
  40335. * @returns the animation group
  40336. */
  40337. pause(): AnimationGroup;
  40338. /**
  40339. * Play all animations to initial state
  40340. * This function will start() the animations if they were not started or will restart() them if they were paused
  40341. * @param loop defines if animations must loop
  40342. * @returns the animation group
  40343. */
  40344. play(loop?: boolean): AnimationGroup;
  40345. /**
  40346. * Reset all animations to initial state
  40347. * @returns the animation group
  40348. */
  40349. reset(): AnimationGroup;
  40350. /**
  40351. * Restart animations from key 0
  40352. * @returns the animation group
  40353. */
  40354. restart(): AnimationGroup;
  40355. /**
  40356. * Stop all animations
  40357. * @returns the animation group
  40358. */
  40359. stop(): AnimationGroup;
  40360. /**
  40361. * Set animation weight for all animatables
  40362. * @param weight defines the weight to use
  40363. * @return the animationGroup
  40364. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40365. */
  40366. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40367. /**
  40368. * Synchronize and normalize all animatables with a source animatable
  40369. * @param root defines the root animatable to synchronize with
  40370. * @return the animationGroup
  40371. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40372. */
  40373. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40374. /**
  40375. * Goes to a specific frame in this animation group
  40376. * @param frame the frame number to go to
  40377. * @return the animationGroup
  40378. */
  40379. goToFrame(frame: number): AnimationGroup;
  40380. /**
  40381. * Dispose all associated resources
  40382. */
  40383. dispose(): void;
  40384. private _checkAnimationGroupEnded;
  40385. /**
  40386. * Clone the current animation group and returns a copy
  40387. * @param newName defines the name of the new group
  40388. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40389. * @returns the new aniamtion group
  40390. */
  40391. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40392. /**
  40393. * Serializes the animationGroup to an object
  40394. * @returns Serialized object
  40395. */
  40396. serialize(): any;
  40397. /**
  40398. * Returns a new AnimationGroup object parsed from the source provided.
  40399. * @param parsedAnimationGroup defines the source
  40400. * @param scene defines the scene that will receive the animationGroup
  40401. * @returns a new AnimationGroup
  40402. */
  40403. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40404. /**
  40405. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40406. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40407. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40408. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40409. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40410. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40411. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40412. */
  40413. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40414. /**
  40415. * Returns the string "AnimationGroup"
  40416. * @returns "AnimationGroup"
  40417. */
  40418. getClassName(): string;
  40419. /**
  40420. * Creates a detailled string about the object
  40421. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40422. * @returns a string representing the object
  40423. */
  40424. toString(fullDetails?: boolean): string;
  40425. }
  40426. }
  40427. declare module "babylonjs/scene" {
  40428. import { Nullable } from "babylonjs/types";
  40429. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40430. import { Observable } from "babylonjs/Misc/observable";
  40431. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40432. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40433. import { Geometry } from "babylonjs/Meshes/geometry";
  40434. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40435. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40437. import { Mesh } from "babylonjs/Meshes/mesh";
  40438. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40439. import { Bone } from "babylonjs/Bones/bone";
  40440. import { Skeleton } from "babylonjs/Bones/skeleton";
  40441. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40442. import { Camera } from "babylonjs/Cameras/camera";
  40443. import { AbstractScene } from "babylonjs/abstractScene";
  40444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40446. import { Material } from "babylonjs/Materials/material";
  40447. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40448. import { Effect } from "babylonjs/Materials/effect";
  40449. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40450. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40451. import { Light } from "babylonjs/Lights/light";
  40452. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40453. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40454. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40455. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40456. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40457. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40458. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40459. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40460. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40461. import { Engine } from "babylonjs/Engines/engine";
  40462. import { Node } from "babylonjs/node";
  40463. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40464. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40465. import { WebRequest } from "babylonjs/Misc/webRequest";
  40466. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40467. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40469. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40470. import { Plane } from "babylonjs/Maths/math.plane";
  40471. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40472. import { Ray } from "babylonjs/Culling/ray";
  40473. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40474. import { Animation } from "babylonjs/Animations/animation";
  40475. import { Animatable } from "babylonjs/Animations/animatable";
  40476. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40477. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40478. import { Collider } from "babylonjs/Collisions/collider";
  40479. /**
  40480. * Define an interface for all classes that will hold resources
  40481. */
  40482. export interface IDisposable {
  40483. /**
  40484. * Releases all held resources
  40485. */
  40486. dispose(): void;
  40487. }
  40488. /** Interface defining initialization parameters for Scene class */
  40489. export interface SceneOptions {
  40490. /**
  40491. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40492. * It will improve performance when the number of geometries becomes important.
  40493. */
  40494. useGeometryUniqueIdsMap?: boolean;
  40495. /**
  40496. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40497. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40498. */
  40499. useMaterialMeshMap?: boolean;
  40500. /**
  40501. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40502. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40503. */
  40504. useClonedMeshMap?: boolean;
  40505. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40506. virtual?: boolean;
  40507. }
  40508. /**
  40509. * Represents a scene to be rendered by the engine.
  40510. * @see https://doc.babylonjs.com/features/scene
  40511. */
  40512. export class Scene extends AbstractScene implements IAnimatable {
  40513. /** The fog is deactivated */
  40514. static readonly FOGMODE_NONE: number;
  40515. /** The fog density is following an exponential function */
  40516. static readonly FOGMODE_EXP: number;
  40517. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40518. static readonly FOGMODE_EXP2: number;
  40519. /** The fog density is following a linear function. */
  40520. static readonly FOGMODE_LINEAR: number;
  40521. /**
  40522. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40523. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40524. */
  40525. static MinDeltaTime: number;
  40526. /**
  40527. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40528. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40529. */
  40530. static MaxDeltaTime: number;
  40531. /**
  40532. * Factory used to create the default material.
  40533. * @param name The name of the material to create
  40534. * @param scene The scene to create the material for
  40535. * @returns The default material
  40536. */
  40537. static DefaultMaterialFactory(scene: Scene): Material;
  40538. /**
  40539. * Factory used to create the a collision coordinator.
  40540. * @returns The collision coordinator
  40541. */
  40542. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40543. /** @hidden */
  40544. _inputManager: InputManager;
  40545. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40546. cameraToUseForPointers: Nullable<Camera>;
  40547. /** @hidden */
  40548. readonly _isScene: boolean;
  40549. /** @hidden */
  40550. _blockEntityCollection: boolean;
  40551. /**
  40552. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40553. */
  40554. autoClear: boolean;
  40555. /**
  40556. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40557. */
  40558. autoClearDepthAndStencil: boolean;
  40559. /**
  40560. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40561. */
  40562. clearColor: Color4;
  40563. /**
  40564. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40565. */
  40566. ambientColor: Color3;
  40567. /**
  40568. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40569. * It should only be one of the following (if not the default embedded one):
  40570. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40571. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40572. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40573. * The material properties need to be setup according to the type of texture in use.
  40574. */
  40575. environmentBRDFTexture: BaseTexture;
  40576. /** @hidden */
  40577. protected _environmentTexture: Nullable<BaseTexture>;
  40578. /**
  40579. * Texture used in all pbr material as the reflection texture.
  40580. * As in the majority of the scene they are the same (exception for multi room and so on),
  40581. * this is easier to reference from here than from all the materials.
  40582. */
  40583. get environmentTexture(): Nullable<BaseTexture>;
  40584. /**
  40585. * Texture used in all pbr material as the reflection texture.
  40586. * As in the majority of the scene they are the same (exception for multi room and so on),
  40587. * this is easier to set here than in all the materials.
  40588. */
  40589. set environmentTexture(value: Nullable<BaseTexture>);
  40590. /** @hidden */
  40591. protected _environmentIntensity: number;
  40592. /**
  40593. * Intensity of the environment in all pbr material.
  40594. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40595. * As in the majority of the scene they are the same (exception for multi room and so on),
  40596. * this is easier to reference from here than from all the materials.
  40597. */
  40598. get environmentIntensity(): number;
  40599. /**
  40600. * Intensity of the environment in all pbr material.
  40601. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40602. * As in the majority of the scene they are the same (exception for multi room and so on),
  40603. * this is easier to set here than in all the materials.
  40604. */
  40605. set environmentIntensity(value: number);
  40606. /** @hidden */
  40607. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40608. /**
  40609. * Default image processing configuration used either in the rendering
  40610. * Forward main pass or through the imageProcessingPostProcess if present.
  40611. * As in the majority of the scene they are the same (exception for multi camera),
  40612. * this is easier to reference from here than from all the materials and post process.
  40613. *
  40614. * No setter as we it is a shared configuration, you can set the values instead.
  40615. */
  40616. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40617. private _forceWireframe;
  40618. /**
  40619. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40620. */
  40621. set forceWireframe(value: boolean);
  40622. get forceWireframe(): boolean;
  40623. private _skipFrustumClipping;
  40624. /**
  40625. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40626. */
  40627. set skipFrustumClipping(value: boolean);
  40628. get skipFrustumClipping(): boolean;
  40629. private _forcePointsCloud;
  40630. /**
  40631. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40632. */
  40633. set forcePointsCloud(value: boolean);
  40634. get forcePointsCloud(): boolean;
  40635. /**
  40636. * Gets or sets the active clipplane 1
  40637. */
  40638. clipPlane: Nullable<Plane>;
  40639. /**
  40640. * Gets or sets the active clipplane 2
  40641. */
  40642. clipPlane2: Nullable<Plane>;
  40643. /**
  40644. * Gets or sets the active clipplane 3
  40645. */
  40646. clipPlane3: Nullable<Plane>;
  40647. /**
  40648. * Gets or sets the active clipplane 4
  40649. */
  40650. clipPlane4: Nullable<Plane>;
  40651. /**
  40652. * Gets or sets the active clipplane 5
  40653. */
  40654. clipPlane5: Nullable<Plane>;
  40655. /**
  40656. * Gets or sets the active clipplane 6
  40657. */
  40658. clipPlane6: Nullable<Plane>;
  40659. /**
  40660. * Gets or sets a boolean indicating if animations are enabled
  40661. */
  40662. animationsEnabled: boolean;
  40663. private _animationPropertiesOverride;
  40664. /**
  40665. * Gets or sets the animation properties override
  40666. */
  40667. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40668. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40669. /**
  40670. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40671. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40672. */
  40673. useConstantAnimationDeltaTime: boolean;
  40674. /**
  40675. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40676. * Please note that it requires to run a ray cast through the scene on every frame
  40677. */
  40678. constantlyUpdateMeshUnderPointer: boolean;
  40679. /**
  40680. * Defines the HTML cursor to use when hovering over interactive elements
  40681. */
  40682. hoverCursor: string;
  40683. /**
  40684. * Defines the HTML default cursor to use (empty by default)
  40685. */
  40686. defaultCursor: string;
  40687. /**
  40688. * Defines whether cursors are handled by the scene.
  40689. */
  40690. doNotHandleCursors: boolean;
  40691. /**
  40692. * This is used to call preventDefault() on pointer down
  40693. * in order to block unwanted artifacts like system double clicks
  40694. */
  40695. preventDefaultOnPointerDown: boolean;
  40696. /**
  40697. * This is used to call preventDefault() on pointer up
  40698. * in order to block unwanted artifacts like system double clicks
  40699. */
  40700. preventDefaultOnPointerUp: boolean;
  40701. /**
  40702. * Gets or sets user defined metadata
  40703. */
  40704. metadata: any;
  40705. /**
  40706. * For internal use only. Please do not use.
  40707. */
  40708. reservedDataStore: any;
  40709. /**
  40710. * Gets the name of the plugin used to load this scene (null by default)
  40711. */
  40712. loadingPluginName: string;
  40713. /**
  40714. * Use this array to add regular expressions used to disable offline support for specific urls
  40715. */
  40716. disableOfflineSupportExceptionRules: RegExp[];
  40717. /**
  40718. * An event triggered when the scene is disposed.
  40719. */
  40720. onDisposeObservable: Observable<Scene>;
  40721. private _onDisposeObserver;
  40722. /** Sets a function to be executed when this scene is disposed. */
  40723. set onDispose(callback: () => void);
  40724. /**
  40725. * An event triggered before rendering the scene (right after animations and physics)
  40726. */
  40727. onBeforeRenderObservable: Observable<Scene>;
  40728. private _onBeforeRenderObserver;
  40729. /** Sets a function to be executed before rendering this scene */
  40730. set beforeRender(callback: Nullable<() => void>);
  40731. /**
  40732. * An event triggered after rendering the scene
  40733. */
  40734. onAfterRenderObservable: Observable<Scene>;
  40735. /**
  40736. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40737. */
  40738. onAfterRenderCameraObservable: Observable<Camera>;
  40739. private _onAfterRenderObserver;
  40740. /** Sets a function to be executed after rendering this scene */
  40741. set afterRender(callback: Nullable<() => void>);
  40742. /**
  40743. * An event triggered before animating the scene
  40744. */
  40745. onBeforeAnimationsObservable: Observable<Scene>;
  40746. /**
  40747. * An event triggered after animations processing
  40748. */
  40749. onAfterAnimationsObservable: Observable<Scene>;
  40750. /**
  40751. * An event triggered before draw calls are ready to be sent
  40752. */
  40753. onBeforeDrawPhaseObservable: Observable<Scene>;
  40754. /**
  40755. * An event triggered after draw calls have been sent
  40756. */
  40757. onAfterDrawPhaseObservable: Observable<Scene>;
  40758. /**
  40759. * An event triggered when the scene is ready
  40760. */
  40761. onReadyObservable: Observable<Scene>;
  40762. /**
  40763. * An event triggered before rendering a camera
  40764. */
  40765. onBeforeCameraRenderObservable: Observable<Camera>;
  40766. private _onBeforeCameraRenderObserver;
  40767. /** Sets a function to be executed before rendering a camera*/
  40768. set beforeCameraRender(callback: () => void);
  40769. /**
  40770. * An event triggered after rendering a camera
  40771. */
  40772. onAfterCameraRenderObservable: Observable<Camera>;
  40773. private _onAfterCameraRenderObserver;
  40774. /** Sets a function to be executed after rendering a camera*/
  40775. set afterCameraRender(callback: () => void);
  40776. /**
  40777. * An event triggered when active meshes evaluation is about to start
  40778. */
  40779. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40780. /**
  40781. * An event triggered when active meshes evaluation is done
  40782. */
  40783. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40784. /**
  40785. * An event triggered when particles rendering is about to start
  40786. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40787. */
  40788. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40789. /**
  40790. * An event triggered when particles rendering is done
  40791. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40792. */
  40793. onAfterParticlesRenderingObservable: Observable<Scene>;
  40794. /**
  40795. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40796. */
  40797. onDataLoadedObservable: Observable<Scene>;
  40798. /**
  40799. * An event triggered when a camera is created
  40800. */
  40801. onNewCameraAddedObservable: Observable<Camera>;
  40802. /**
  40803. * An event triggered when a camera is removed
  40804. */
  40805. onCameraRemovedObservable: Observable<Camera>;
  40806. /**
  40807. * An event triggered when a light is created
  40808. */
  40809. onNewLightAddedObservable: Observable<Light>;
  40810. /**
  40811. * An event triggered when a light is removed
  40812. */
  40813. onLightRemovedObservable: Observable<Light>;
  40814. /**
  40815. * An event triggered when a geometry is created
  40816. */
  40817. onNewGeometryAddedObservable: Observable<Geometry>;
  40818. /**
  40819. * An event triggered when a geometry is removed
  40820. */
  40821. onGeometryRemovedObservable: Observable<Geometry>;
  40822. /**
  40823. * An event triggered when a transform node is created
  40824. */
  40825. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40826. /**
  40827. * An event triggered when a transform node is removed
  40828. */
  40829. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40830. /**
  40831. * An event triggered when a mesh is created
  40832. */
  40833. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40834. /**
  40835. * An event triggered when a mesh is removed
  40836. */
  40837. onMeshRemovedObservable: Observable<AbstractMesh>;
  40838. /**
  40839. * An event triggered when a skeleton is created
  40840. */
  40841. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40842. /**
  40843. * An event triggered when a skeleton is removed
  40844. */
  40845. onSkeletonRemovedObservable: Observable<Skeleton>;
  40846. /**
  40847. * An event triggered when a material is created
  40848. */
  40849. onNewMaterialAddedObservable: Observable<Material>;
  40850. /**
  40851. * An event triggered when a material is removed
  40852. */
  40853. onMaterialRemovedObservable: Observable<Material>;
  40854. /**
  40855. * An event triggered when a texture is created
  40856. */
  40857. onNewTextureAddedObservable: Observable<BaseTexture>;
  40858. /**
  40859. * An event triggered when a texture is removed
  40860. */
  40861. onTextureRemovedObservable: Observable<BaseTexture>;
  40862. /**
  40863. * An event triggered when render targets are about to be rendered
  40864. * Can happen multiple times per frame.
  40865. */
  40866. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40867. /**
  40868. * An event triggered when render targets were rendered.
  40869. * Can happen multiple times per frame.
  40870. */
  40871. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40872. /**
  40873. * An event triggered before calculating deterministic simulation step
  40874. */
  40875. onBeforeStepObservable: Observable<Scene>;
  40876. /**
  40877. * An event triggered after calculating deterministic simulation step
  40878. */
  40879. onAfterStepObservable: Observable<Scene>;
  40880. /**
  40881. * An event triggered when the activeCamera property is updated
  40882. */
  40883. onActiveCameraChanged: Observable<Scene>;
  40884. /**
  40885. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40886. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40887. * 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)
  40888. */
  40889. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40890. /**
  40891. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40892. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40893. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  40894. */
  40895. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40896. /**
  40897. * This Observable will when a mesh has been imported into the scene.
  40898. */
  40899. onMeshImportedObservable: Observable<AbstractMesh>;
  40900. /**
  40901. * This Observable will when an animation file has been imported into the scene.
  40902. */
  40903. onAnimationFileImportedObservable: Observable<Scene>;
  40904. /**
  40905. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40906. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40907. */
  40908. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40909. /** @hidden */
  40910. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40911. /**
  40912. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40913. */
  40914. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40915. /**
  40916. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40917. */
  40918. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40919. /**
  40920. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40921. */
  40922. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40923. /** Callback called when a pointer move is detected */
  40924. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40925. /** Callback called when a pointer down is detected */
  40926. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40927. /** Callback called when a pointer up is detected */
  40928. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40929. /** Callback called when a pointer pick is detected */
  40930. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40931. /**
  40932. * 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).
  40933. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40934. */
  40935. onPrePointerObservable: Observable<PointerInfoPre>;
  40936. /**
  40937. * Observable event triggered each time an input event is received from the rendering canvas
  40938. */
  40939. onPointerObservable: Observable<PointerInfo>;
  40940. /**
  40941. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40942. */
  40943. get unTranslatedPointer(): Vector2;
  40944. /**
  40945. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40946. */
  40947. static get DragMovementThreshold(): number;
  40948. static set DragMovementThreshold(value: number);
  40949. /**
  40950. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40951. */
  40952. static get LongPressDelay(): number;
  40953. static set LongPressDelay(value: number);
  40954. /**
  40955. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40956. */
  40957. static get DoubleClickDelay(): number;
  40958. static set DoubleClickDelay(value: number);
  40959. /** If you need to check double click without raising a single click at first click, enable this flag */
  40960. static get ExclusiveDoubleClickMode(): boolean;
  40961. static set ExclusiveDoubleClickMode(value: boolean);
  40962. /** @hidden */
  40963. _mirroredCameraPosition: Nullable<Vector3>;
  40964. /**
  40965. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40966. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40967. */
  40968. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40969. /**
  40970. * Observable event triggered each time an keyboard event is received from the hosting window
  40971. */
  40972. onKeyboardObservable: Observable<KeyboardInfo>;
  40973. private _useRightHandedSystem;
  40974. /**
  40975. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40976. */
  40977. set useRightHandedSystem(value: boolean);
  40978. get useRightHandedSystem(): boolean;
  40979. private _timeAccumulator;
  40980. private _currentStepId;
  40981. private _currentInternalStep;
  40982. /**
  40983. * Sets the step Id used by deterministic lock step
  40984. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40985. * @param newStepId defines the step Id
  40986. */
  40987. setStepId(newStepId: number): void;
  40988. /**
  40989. * Gets the step Id used by deterministic lock step
  40990. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40991. * @returns the step Id
  40992. */
  40993. getStepId(): number;
  40994. /**
  40995. * Gets the internal step used by deterministic lock step
  40996. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40997. * @returns the internal step
  40998. */
  40999. getInternalStep(): number;
  41000. private _fogEnabled;
  41001. /**
  41002. * Gets or sets a boolean indicating if fog is enabled on this scene
  41003. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41004. * (Default is true)
  41005. */
  41006. set fogEnabled(value: boolean);
  41007. get fogEnabled(): boolean;
  41008. private _fogMode;
  41009. /**
  41010. * Gets or sets the fog mode to use
  41011. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41012. * | mode | value |
  41013. * | --- | --- |
  41014. * | FOGMODE_NONE | 0 |
  41015. * | FOGMODE_EXP | 1 |
  41016. * | FOGMODE_EXP2 | 2 |
  41017. * | FOGMODE_LINEAR | 3 |
  41018. */
  41019. set fogMode(value: number);
  41020. get fogMode(): number;
  41021. /**
  41022. * Gets or sets the fog color to use
  41023. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41024. * (Default is Color3(0.2, 0.2, 0.3))
  41025. */
  41026. fogColor: Color3;
  41027. /**
  41028. * Gets or sets the fog density to use
  41029. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41030. * (Default is 0.1)
  41031. */
  41032. fogDensity: number;
  41033. /**
  41034. * Gets or sets the fog start distance to use
  41035. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41036. * (Default is 0)
  41037. */
  41038. fogStart: number;
  41039. /**
  41040. * Gets or sets the fog end distance to use
  41041. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41042. * (Default is 1000)
  41043. */
  41044. fogEnd: number;
  41045. /**
  41046. * Flag indicating that the frame buffer binding is handled by another component
  41047. */
  41048. prePass: boolean;
  41049. private _shadowsEnabled;
  41050. /**
  41051. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41052. */
  41053. set shadowsEnabled(value: boolean);
  41054. get shadowsEnabled(): boolean;
  41055. private _lightsEnabled;
  41056. /**
  41057. * Gets or sets a boolean indicating if lights are enabled on this scene
  41058. */
  41059. set lightsEnabled(value: boolean);
  41060. get lightsEnabled(): boolean;
  41061. /** All of the active cameras added to this scene. */
  41062. activeCameras: Camera[];
  41063. /** @hidden */
  41064. _activeCamera: Nullable<Camera>;
  41065. /** Gets or sets the current active camera */
  41066. get activeCamera(): Nullable<Camera>;
  41067. set activeCamera(value: Nullable<Camera>);
  41068. private _defaultMaterial;
  41069. /** The default material used on meshes when no material is affected */
  41070. get defaultMaterial(): Material;
  41071. /** The default material used on meshes when no material is affected */
  41072. set defaultMaterial(value: Material);
  41073. private _texturesEnabled;
  41074. /**
  41075. * Gets or sets a boolean indicating if textures are enabled on this scene
  41076. */
  41077. set texturesEnabled(value: boolean);
  41078. get texturesEnabled(): boolean;
  41079. /**
  41080. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41081. */
  41082. physicsEnabled: boolean;
  41083. /**
  41084. * Gets or sets a boolean indicating if particles are enabled on this scene
  41085. */
  41086. particlesEnabled: boolean;
  41087. /**
  41088. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41089. */
  41090. spritesEnabled: boolean;
  41091. private _skeletonsEnabled;
  41092. /**
  41093. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41094. */
  41095. set skeletonsEnabled(value: boolean);
  41096. get skeletonsEnabled(): boolean;
  41097. /**
  41098. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41099. */
  41100. lensFlaresEnabled: boolean;
  41101. /**
  41102. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41103. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41104. */
  41105. collisionsEnabled: boolean;
  41106. private _collisionCoordinator;
  41107. /** @hidden */
  41108. get collisionCoordinator(): ICollisionCoordinator;
  41109. /**
  41110. * Defines the gravity applied to this scene (used only for collisions)
  41111. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41112. */
  41113. gravity: Vector3;
  41114. /**
  41115. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41116. */
  41117. postProcessesEnabled: boolean;
  41118. /**
  41119. * The list of postprocesses added to the scene
  41120. */
  41121. postProcesses: PostProcess[];
  41122. /**
  41123. * Gets the current postprocess manager
  41124. */
  41125. postProcessManager: PostProcessManager;
  41126. /**
  41127. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41128. */
  41129. renderTargetsEnabled: boolean;
  41130. /**
  41131. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41132. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41133. */
  41134. dumpNextRenderTargets: boolean;
  41135. /**
  41136. * The list of user defined render targets added to the scene
  41137. */
  41138. customRenderTargets: RenderTargetTexture[];
  41139. /**
  41140. * Defines if texture loading must be delayed
  41141. * If true, textures will only be loaded when they need to be rendered
  41142. */
  41143. useDelayedTextureLoading: boolean;
  41144. /**
  41145. * Gets the list of meshes imported to the scene through SceneLoader
  41146. */
  41147. importedMeshesFiles: String[];
  41148. /**
  41149. * Gets or sets a boolean indicating if probes are enabled on this scene
  41150. */
  41151. probesEnabled: boolean;
  41152. /**
  41153. * Gets or sets the current offline provider to use to store scene data
  41154. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41155. */
  41156. offlineProvider: IOfflineProvider;
  41157. /**
  41158. * Gets or sets the action manager associated with the scene
  41159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41160. */
  41161. actionManager: AbstractActionManager;
  41162. private _meshesForIntersections;
  41163. /**
  41164. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41165. */
  41166. proceduralTexturesEnabled: boolean;
  41167. private _engine;
  41168. private _totalVertices;
  41169. /** @hidden */
  41170. _activeIndices: PerfCounter;
  41171. /** @hidden */
  41172. _activeParticles: PerfCounter;
  41173. /** @hidden */
  41174. _activeBones: PerfCounter;
  41175. private _animationRatio;
  41176. /** @hidden */
  41177. _animationTimeLast: number;
  41178. /** @hidden */
  41179. _animationTime: number;
  41180. /**
  41181. * Gets or sets a general scale for animation speed
  41182. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41183. */
  41184. animationTimeScale: number;
  41185. /** @hidden */
  41186. _cachedMaterial: Nullable<Material>;
  41187. /** @hidden */
  41188. _cachedEffect: Nullable<Effect>;
  41189. /** @hidden */
  41190. _cachedVisibility: Nullable<number>;
  41191. private _renderId;
  41192. private _frameId;
  41193. private _executeWhenReadyTimeoutId;
  41194. private _intermediateRendering;
  41195. private _viewUpdateFlag;
  41196. private _projectionUpdateFlag;
  41197. /** @hidden */
  41198. _toBeDisposed: Nullable<IDisposable>[];
  41199. private _activeRequests;
  41200. /** @hidden */
  41201. _pendingData: any[];
  41202. private _isDisposed;
  41203. /**
  41204. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41205. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41206. */
  41207. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41208. private _activeMeshes;
  41209. private _processedMaterials;
  41210. private _renderTargets;
  41211. /** @hidden */
  41212. _activeParticleSystems: SmartArray<IParticleSystem>;
  41213. private _activeSkeletons;
  41214. private _softwareSkinnedMeshes;
  41215. private _renderingManager;
  41216. /** @hidden */
  41217. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41218. private _transformMatrix;
  41219. private _sceneUbo;
  41220. /** @hidden */
  41221. _viewMatrix: Matrix;
  41222. private _projectionMatrix;
  41223. /** @hidden */
  41224. _forcedViewPosition: Nullable<Vector3>;
  41225. /** @hidden */
  41226. _frustumPlanes: Plane[];
  41227. /**
  41228. * Gets the list of frustum planes (built from the active camera)
  41229. */
  41230. get frustumPlanes(): Plane[];
  41231. /**
  41232. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41233. * This is useful if there are more lights that the maximum simulteanous authorized
  41234. */
  41235. requireLightSorting: boolean;
  41236. /** @hidden */
  41237. readonly useMaterialMeshMap: boolean;
  41238. /** @hidden */
  41239. readonly useClonedMeshMap: boolean;
  41240. private _externalData;
  41241. private _uid;
  41242. /**
  41243. * @hidden
  41244. * Backing store of defined scene components.
  41245. */
  41246. _components: ISceneComponent[];
  41247. /**
  41248. * @hidden
  41249. * Backing store of defined scene components.
  41250. */
  41251. _serializableComponents: ISceneSerializableComponent[];
  41252. /**
  41253. * List of components to register on the next registration step.
  41254. */
  41255. private _transientComponents;
  41256. /**
  41257. * Registers the transient components if needed.
  41258. */
  41259. private _registerTransientComponents;
  41260. /**
  41261. * @hidden
  41262. * Add a component to the scene.
  41263. * Note that the ccomponent could be registered on th next frame if this is called after
  41264. * the register component stage.
  41265. * @param component Defines the component to add to the scene
  41266. */
  41267. _addComponent(component: ISceneComponent): void;
  41268. /**
  41269. * @hidden
  41270. * Gets a component from the scene.
  41271. * @param name defines the name of the component to retrieve
  41272. * @returns the component or null if not present
  41273. */
  41274. _getComponent(name: string): Nullable<ISceneComponent>;
  41275. /**
  41276. * @hidden
  41277. * Defines the actions happening before camera updates.
  41278. */
  41279. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41280. /**
  41281. * @hidden
  41282. * Defines the actions happening before clear the canvas.
  41283. */
  41284. _beforeClearStage: Stage<SimpleStageAction>;
  41285. /**
  41286. * @hidden
  41287. * Defines the actions when collecting render targets for the frame.
  41288. */
  41289. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41290. /**
  41291. * @hidden
  41292. * Defines the actions happening for one camera in the frame.
  41293. */
  41294. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41295. /**
  41296. * @hidden
  41297. * Defines the actions happening during the per mesh ready checks.
  41298. */
  41299. _isReadyForMeshStage: Stage<MeshStageAction>;
  41300. /**
  41301. * @hidden
  41302. * Defines the actions happening before evaluate active mesh checks.
  41303. */
  41304. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41305. /**
  41306. * @hidden
  41307. * Defines the actions happening during the evaluate sub mesh checks.
  41308. */
  41309. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41310. /**
  41311. * @hidden
  41312. * Defines the actions happening during the active mesh stage.
  41313. */
  41314. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41315. /**
  41316. * @hidden
  41317. * Defines the actions happening during the per camera render target step.
  41318. */
  41319. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41320. /**
  41321. * @hidden
  41322. * Defines the actions happening just before the active camera is drawing.
  41323. */
  41324. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41325. /**
  41326. * @hidden
  41327. * Defines the actions happening just before a render target is drawing.
  41328. */
  41329. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41330. /**
  41331. * @hidden
  41332. * Defines the actions happening just before a rendering group is drawing.
  41333. */
  41334. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41335. /**
  41336. * @hidden
  41337. * Defines the actions happening just before a mesh is drawing.
  41338. */
  41339. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41340. /**
  41341. * @hidden
  41342. * Defines the actions happening just after a mesh has been drawn.
  41343. */
  41344. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41345. /**
  41346. * @hidden
  41347. * Defines the actions happening just after a rendering group has been drawn.
  41348. */
  41349. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41350. /**
  41351. * @hidden
  41352. * Defines the actions happening just after the active camera has been drawn.
  41353. */
  41354. _afterCameraDrawStage: Stage<CameraStageAction>;
  41355. /**
  41356. * @hidden
  41357. * Defines the actions happening just after a render target has been drawn.
  41358. */
  41359. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41360. /**
  41361. * @hidden
  41362. * Defines the actions happening just after rendering all cameras and computing intersections.
  41363. */
  41364. _afterRenderStage: Stage<SimpleStageAction>;
  41365. /**
  41366. * @hidden
  41367. * Defines the actions happening when a pointer move event happens.
  41368. */
  41369. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41370. /**
  41371. * @hidden
  41372. * Defines the actions happening when a pointer down event happens.
  41373. */
  41374. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41375. /**
  41376. * @hidden
  41377. * Defines the actions happening when a pointer up event happens.
  41378. */
  41379. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41380. /**
  41381. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41382. */
  41383. private geometriesByUniqueId;
  41384. /**
  41385. * Creates a new Scene
  41386. * @param engine defines the engine to use to render this scene
  41387. * @param options defines the scene options
  41388. */
  41389. constructor(engine: Engine, options?: SceneOptions);
  41390. /**
  41391. * Gets a string idenfifying the name of the class
  41392. * @returns "Scene" string
  41393. */
  41394. getClassName(): string;
  41395. private _defaultMeshCandidates;
  41396. /**
  41397. * @hidden
  41398. */
  41399. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41400. private _defaultSubMeshCandidates;
  41401. /**
  41402. * @hidden
  41403. */
  41404. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41405. /**
  41406. * Sets the default candidate providers for the scene.
  41407. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41408. * and getCollidingSubMeshCandidates to their default function
  41409. */
  41410. setDefaultCandidateProviders(): void;
  41411. /**
  41412. * Gets the mesh that is currently under the pointer
  41413. */
  41414. get meshUnderPointer(): Nullable<AbstractMesh>;
  41415. /**
  41416. * Gets or sets the current on-screen X position of the pointer
  41417. */
  41418. get pointerX(): number;
  41419. set pointerX(value: number);
  41420. /**
  41421. * Gets or sets the current on-screen Y position of the pointer
  41422. */
  41423. get pointerY(): number;
  41424. set pointerY(value: number);
  41425. /**
  41426. * Gets the cached material (ie. the latest rendered one)
  41427. * @returns the cached material
  41428. */
  41429. getCachedMaterial(): Nullable<Material>;
  41430. /**
  41431. * Gets the cached effect (ie. the latest rendered one)
  41432. * @returns the cached effect
  41433. */
  41434. getCachedEffect(): Nullable<Effect>;
  41435. /**
  41436. * Gets the cached visibility state (ie. the latest rendered one)
  41437. * @returns the cached visibility state
  41438. */
  41439. getCachedVisibility(): Nullable<number>;
  41440. /**
  41441. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41442. * @param material defines the current material
  41443. * @param effect defines the current effect
  41444. * @param visibility defines the current visibility state
  41445. * @returns true if one parameter is not cached
  41446. */
  41447. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41448. /**
  41449. * Gets the engine associated with the scene
  41450. * @returns an Engine
  41451. */
  41452. getEngine(): Engine;
  41453. /**
  41454. * Gets the total number of vertices rendered per frame
  41455. * @returns the total number of vertices rendered per frame
  41456. */
  41457. getTotalVertices(): number;
  41458. /**
  41459. * Gets the performance counter for total vertices
  41460. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41461. */
  41462. get totalVerticesPerfCounter(): PerfCounter;
  41463. /**
  41464. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41465. * @returns the total number of active indices rendered per frame
  41466. */
  41467. getActiveIndices(): number;
  41468. /**
  41469. * Gets the performance counter for active indices
  41470. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41471. */
  41472. get totalActiveIndicesPerfCounter(): PerfCounter;
  41473. /**
  41474. * Gets the total number of active particles rendered per frame
  41475. * @returns the total number of active particles rendered per frame
  41476. */
  41477. getActiveParticles(): number;
  41478. /**
  41479. * Gets the performance counter for active particles
  41480. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41481. */
  41482. get activeParticlesPerfCounter(): PerfCounter;
  41483. /**
  41484. * Gets the total number of active bones rendered per frame
  41485. * @returns the total number of active bones rendered per frame
  41486. */
  41487. getActiveBones(): number;
  41488. /**
  41489. * Gets the performance counter for active bones
  41490. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41491. */
  41492. get activeBonesPerfCounter(): PerfCounter;
  41493. /**
  41494. * Gets the array of active meshes
  41495. * @returns an array of AbstractMesh
  41496. */
  41497. getActiveMeshes(): SmartArray<AbstractMesh>;
  41498. /**
  41499. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41500. * @returns a number
  41501. */
  41502. getAnimationRatio(): number;
  41503. /**
  41504. * Gets an unique Id for the current render phase
  41505. * @returns a number
  41506. */
  41507. getRenderId(): number;
  41508. /**
  41509. * Gets an unique Id for the current frame
  41510. * @returns a number
  41511. */
  41512. getFrameId(): number;
  41513. /** Call this function if you want to manually increment the render Id*/
  41514. incrementRenderId(): void;
  41515. private _createUbo;
  41516. /**
  41517. * Use this method to simulate a pointer move on a mesh
  41518. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41519. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41520. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41521. * @returns the current scene
  41522. */
  41523. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41524. /**
  41525. * Use this method to simulate a pointer down on a mesh
  41526. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41527. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41528. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41529. * @returns the current scene
  41530. */
  41531. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41532. /**
  41533. * Use this method to simulate a pointer up on a mesh
  41534. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41535. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41536. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41537. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41538. * @returns the current scene
  41539. */
  41540. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41541. /**
  41542. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41543. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41544. * @returns true if the pointer was captured
  41545. */
  41546. isPointerCaptured(pointerId?: number): boolean;
  41547. /**
  41548. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41549. * @param attachUp defines if you want to attach events to pointerup
  41550. * @param attachDown defines if you want to attach events to pointerdown
  41551. * @param attachMove defines if you want to attach events to pointermove
  41552. */
  41553. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41554. /** Detaches all event handlers*/
  41555. detachControl(): void;
  41556. /**
  41557. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41558. * Delay loaded resources are not taking in account
  41559. * @return true if all required resources are ready
  41560. */
  41561. isReady(): boolean;
  41562. /** Resets all cached information relative to material (including effect and visibility) */
  41563. resetCachedMaterial(): void;
  41564. /**
  41565. * Registers a function to be called before every frame render
  41566. * @param func defines the function to register
  41567. */
  41568. registerBeforeRender(func: () => void): void;
  41569. /**
  41570. * Unregisters a function called before every frame render
  41571. * @param func defines the function to unregister
  41572. */
  41573. unregisterBeforeRender(func: () => void): void;
  41574. /**
  41575. * Registers a function to be called after every frame render
  41576. * @param func defines the function to register
  41577. */
  41578. registerAfterRender(func: () => void): void;
  41579. /**
  41580. * Unregisters a function called after every frame render
  41581. * @param func defines the function to unregister
  41582. */
  41583. unregisterAfterRender(func: () => void): void;
  41584. private _executeOnceBeforeRender;
  41585. /**
  41586. * The provided function will run before render once and will be disposed afterwards.
  41587. * A timeout delay can be provided so that the function will be executed in N ms.
  41588. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41589. * @param func The function to be executed.
  41590. * @param timeout optional delay in ms
  41591. */
  41592. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41593. /** @hidden */
  41594. _addPendingData(data: any): void;
  41595. /** @hidden */
  41596. _removePendingData(data: any): void;
  41597. /**
  41598. * Returns the number of items waiting to be loaded
  41599. * @returns the number of items waiting to be loaded
  41600. */
  41601. getWaitingItemsCount(): number;
  41602. /**
  41603. * Returns a boolean indicating if the scene is still loading data
  41604. */
  41605. get isLoading(): boolean;
  41606. /**
  41607. * Registers a function to be executed when the scene is ready
  41608. * @param {Function} func - the function to be executed
  41609. */
  41610. executeWhenReady(func: () => void): void;
  41611. /**
  41612. * Returns a promise that resolves when the scene is ready
  41613. * @returns A promise that resolves when the scene is ready
  41614. */
  41615. whenReadyAsync(): Promise<void>;
  41616. /** @hidden */
  41617. _checkIsReady(): void;
  41618. /**
  41619. * Gets all animatable attached to the scene
  41620. */
  41621. get animatables(): Animatable[];
  41622. /**
  41623. * Resets the last animation time frame.
  41624. * Useful to override when animations start running when loading a scene for the first time.
  41625. */
  41626. resetLastAnimationTimeFrame(): void;
  41627. /**
  41628. * Gets the current view matrix
  41629. * @returns a Matrix
  41630. */
  41631. getViewMatrix(): Matrix;
  41632. /**
  41633. * Gets the current projection matrix
  41634. * @returns a Matrix
  41635. */
  41636. getProjectionMatrix(): Matrix;
  41637. /**
  41638. * Gets the current transform matrix
  41639. * @returns a Matrix made of View * Projection
  41640. */
  41641. getTransformMatrix(): Matrix;
  41642. /**
  41643. * Sets the current transform matrix
  41644. * @param viewL defines the View matrix to use
  41645. * @param projectionL defines the Projection matrix to use
  41646. * @param viewR defines the right View matrix to use (if provided)
  41647. * @param projectionR defines the right Projection matrix to use (if provided)
  41648. */
  41649. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41650. /**
  41651. * Gets the uniform buffer used to store scene data
  41652. * @returns a UniformBuffer
  41653. */
  41654. getSceneUniformBuffer(): UniformBuffer;
  41655. /**
  41656. * Gets an unique (relatively to the current scene) Id
  41657. * @returns an unique number for the scene
  41658. */
  41659. getUniqueId(): number;
  41660. /**
  41661. * Add a mesh to the list of scene's meshes
  41662. * @param newMesh defines the mesh to add
  41663. * @param recursive if all child meshes should also be added to the scene
  41664. */
  41665. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41666. /**
  41667. * Remove a mesh for the list of scene's meshes
  41668. * @param toRemove defines the mesh to remove
  41669. * @param recursive if all child meshes should also be removed from the scene
  41670. * @returns the index where the mesh was in the mesh list
  41671. */
  41672. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41673. /**
  41674. * Add a transform node to the list of scene's transform nodes
  41675. * @param newTransformNode defines the transform node to add
  41676. */
  41677. addTransformNode(newTransformNode: TransformNode): void;
  41678. /**
  41679. * Remove a transform node for the list of scene's transform nodes
  41680. * @param toRemove defines the transform node to remove
  41681. * @returns the index where the transform node was in the transform node list
  41682. */
  41683. removeTransformNode(toRemove: TransformNode): number;
  41684. /**
  41685. * Remove a skeleton for the list of scene's skeletons
  41686. * @param toRemove defines the skeleton to remove
  41687. * @returns the index where the skeleton was in the skeleton list
  41688. */
  41689. removeSkeleton(toRemove: Skeleton): number;
  41690. /**
  41691. * Remove a morph target for the list of scene's morph targets
  41692. * @param toRemove defines the morph target to remove
  41693. * @returns the index where the morph target was in the morph target list
  41694. */
  41695. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41696. /**
  41697. * Remove a light for the list of scene's lights
  41698. * @param toRemove defines the light to remove
  41699. * @returns the index where the light was in the light list
  41700. */
  41701. removeLight(toRemove: Light): number;
  41702. /**
  41703. * Remove a camera for the list of scene's cameras
  41704. * @param toRemove defines the camera to remove
  41705. * @returns the index where the camera was in the camera list
  41706. */
  41707. removeCamera(toRemove: Camera): number;
  41708. /**
  41709. * Remove a particle system for the list of scene's particle systems
  41710. * @param toRemove defines the particle system to remove
  41711. * @returns the index where the particle system was in the particle system list
  41712. */
  41713. removeParticleSystem(toRemove: IParticleSystem): number;
  41714. /**
  41715. * Remove a animation for the list of scene's animations
  41716. * @param toRemove defines the animation to remove
  41717. * @returns the index where the animation was in the animation list
  41718. */
  41719. removeAnimation(toRemove: Animation): number;
  41720. /**
  41721. * Will stop the animation of the given target
  41722. * @param target - the target
  41723. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41724. * @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)
  41725. */
  41726. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41727. /**
  41728. * Removes the given animation group from this scene.
  41729. * @param toRemove The animation group to remove
  41730. * @returns The index of the removed animation group
  41731. */
  41732. removeAnimationGroup(toRemove: AnimationGroup): number;
  41733. /**
  41734. * Removes the given multi-material from this scene.
  41735. * @param toRemove The multi-material to remove
  41736. * @returns The index of the removed multi-material
  41737. */
  41738. removeMultiMaterial(toRemove: MultiMaterial): number;
  41739. /**
  41740. * Removes the given material from this scene.
  41741. * @param toRemove The material to remove
  41742. * @returns The index of the removed material
  41743. */
  41744. removeMaterial(toRemove: Material): number;
  41745. /**
  41746. * Removes the given action manager from this scene.
  41747. * @param toRemove The action manager to remove
  41748. * @returns The index of the removed action manager
  41749. */
  41750. removeActionManager(toRemove: AbstractActionManager): number;
  41751. /**
  41752. * Removes the given texture from this scene.
  41753. * @param toRemove The texture to remove
  41754. * @returns The index of the removed texture
  41755. */
  41756. removeTexture(toRemove: BaseTexture): number;
  41757. /**
  41758. * Adds the given light to this scene
  41759. * @param newLight The light to add
  41760. */
  41761. addLight(newLight: Light): void;
  41762. /**
  41763. * Sorts the list list based on light priorities
  41764. */
  41765. sortLightsByPriority(): void;
  41766. /**
  41767. * Adds the given camera to this scene
  41768. * @param newCamera The camera to add
  41769. */
  41770. addCamera(newCamera: Camera): void;
  41771. /**
  41772. * Adds the given skeleton to this scene
  41773. * @param newSkeleton The skeleton to add
  41774. */
  41775. addSkeleton(newSkeleton: Skeleton): void;
  41776. /**
  41777. * Adds the given particle system to this scene
  41778. * @param newParticleSystem The particle system to add
  41779. */
  41780. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41781. /**
  41782. * Adds the given animation to this scene
  41783. * @param newAnimation The animation to add
  41784. */
  41785. addAnimation(newAnimation: Animation): void;
  41786. /**
  41787. * Adds the given animation group to this scene.
  41788. * @param newAnimationGroup The animation group to add
  41789. */
  41790. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41791. /**
  41792. * Adds the given multi-material to this scene
  41793. * @param newMultiMaterial The multi-material to add
  41794. */
  41795. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41796. /**
  41797. * Adds the given material to this scene
  41798. * @param newMaterial The material to add
  41799. */
  41800. addMaterial(newMaterial: Material): void;
  41801. /**
  41802. * Adds the given morph target to this scene
  41803. * @param newMorphTargetManager The morph target to add
  41804. */
  41805. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41806. /**
  41807. * Adds the given geometry to this scene
  41808. * @param newGeometry The geometry to add
  41809. */
  41810. addGeometry(newGeometry: Geometry): void;
  41811. /**
  41812. * Adds the given action manager to this scene
  41813. * @param newActionManager The action manager to add
  41814. */
  41815. addActionManager(newActionManager: AbstractActionManager): void;
  41816. /**
  41817. * Adds the given texture to this scene.
  41818. * @param newTexture The texture to add
  41819. */
  41820. addTexture(newTexture: BaseTexture): void;
  41821. /**
  41822. * Switch active camera
  41823. * @param newCamera defines the new active camera
  41824. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41825. */
  41826. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41827. /**
  41828. * sets the active camera of the scene using its ID
  41829. * @param id defines the camera's ID
  41830. * @return the new active camera or null if none found.
  41831. */
  41832. setActiveCameraByID(id: string): Nullable<Camera>;
  41833. /**
  41834. * sets the active camera of the scene using its name
  41835. * @param name defines the camera's name
  41836. * @returns the new active camera or null if none found.
  41837. */
  41838. setActiveCameraByName(name: string): Nullable<Camera>;
  41839. /**
  41840. * get an animation group using its name
  41841. * @param name defines the material's name
  41842. * @return the animation group or null if none found.
  41843. */
  41844. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41845. /**
  41846. * Get a material using its unique id
  41847. * @param uniqueId defines the material's unique id
  41848. * @return the material or null if none found.
  41849. */
  41850. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41851. /**
  41852. * get a material using its id
  41853. * @param id defines the material's ID
  41854. * @return the material or null if none found.
  41855. */
  41856. getMaterialByID(id: string): Nullable<Material>;
  41857. /**
  41858. * Gets a the last added material using a given id
  41859. * @param id defines the material's ID
  41860. * @return the last material with the given id or null if none found.
  41861. */
  41862. getLastMaterialByID(id: string): Nullable<Material>;
  41863. /**
  41864. * Gets a material using its name
  41865. * @param name defines the material's name
  41866. * @return the material or null if none found.
  41867. */
  41868. getMaterialByName(name: string): Nullable<Material>;
  41869. /**
  41870. * Get a texture using its unique id
  41871. * @param uniqueId defines the texture's unique id
  41872. * @return the texture or null if none found.
  41873. */
  41874. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41875. /**
  41876. * Gets a camera using its id
  41877. * @param id defines the id to look for
  41878. * @returns the camera or null if not found
  41879. */
  41880. getCameraByID(id: string): Nullable<Camera>;
  41881. /**
  41882. * Gets a camera using its unique id
  41883. * @param uniqueId defines the unique id to look for
  41884. * @returns the camera or null if not found
  41885. */
  41886. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41887. /**
  41888. * Gets a camera using its name
  41889. * @param name defines the camera's name
  41890. * @return the camera or null if none found.
  41891. */
  41892. getCameraByName(name: string): Nullable<Camera>;
  41893. /**
  41894. * Gets a bone using its id
  41895. * @param id defines the bone's id
  41896. * @return the bone or null if not found
  41897. */
  41898. getBoneByID(id: string): Nullable<Bone>;
  41899. /**
  41900. * Gets a bone using its id
  41901. * @param name defines the bone's name
  41902. * @return the bone or null if not found
  41903. */
  41904. getBoneByName(name: string): Nullable<Bone>;
  41905. /**
  41906. * Gets a light node using its name
  41907. * @param name defines the the light's name
  41908. * @return the light or null if none found.
  41909. */
  41910. getLightByName(name: string): Nullable<Light>;
  41911. /**
  41912. * Gets a light node using its id
  41913. * @param id defines the light's id
  41914. * @return the light or null if none found.
  41915. */
  41916. getLightByID(id: string): Nullable<Light>;
  41917. /**
  41918. * Gets a light node using its scene-generated unique ID
  41919. * @param uniqueId defines the light's unique id
  41920. * @return the light or null if none found.
  41921. */
  41922. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41923. /**
  41924. * Gets a particle system by id
  41925. * @param id defines the particle system id
  41926. * @return the corresponding system or null if none found
  41927. */
  41928. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41929. /**
  41930. * Gets a geometry using its ID
  41931. * @param id defines the geometry's id
  41932. * @return the geometry or null if none found.
  41933. */
  41934. getGeometryByID(id: string): Nullable<Geometry>;
  41935. private _getGeometryByUniqueID;
  41936. /**
  41937. * Add a new geometry to this scene
  41938. * @param geometry defines the geometry to be added to the scene.
  41939. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41940. * @return a boolean defining if the geometry was added or not
  41941. */
  41942. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41943. /**
  41944. * Removes an existing geometry
  41945. * @param geometry defines the geometry to be removed from the scene
  41946. * @return a boolean defining if the geometry was removed or not
  41947. */
  41948. removeGeometry(geometry: Geometry): boolean;
  41949. /**
  41950. * Gets the list of geometries attached to the scene
  41951. * @returns an array of Geometry
  41952. */
  41953. getGeometries(): Geometry[];
  41954. /**
  41955. * Gets the first added mesh found of a given ID
  41956. * @param id defines the id to search for
  41957. * @return the mesh found or null if not found at all
  41958. */
  41959. getMeshByID(id: string): Nullable<AbstractMesh>;
  41960. /**
  41961. * Gets a list of meshes using their id
  41962. * @param id defines the id to search for
  41963. * @returns a list of meshes
  41964. */
  41965. getMeshesByID(id: string): Array<AbstractMesh>;
  41966. /**
  41967. * Gets the first added transform node found of a given ID
  41968. * @param id defines the id to search for
  41969. * @return the found transform node or null if not found at all.
  41970. */
  41971. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41972. /**
  41973. * Gets a transform node with its auto-generated unique id
  41974. * @param uniqueId efines the unique id to search for
  41975. * @return the found transform node or null if not found at all.
  41976. */
  41977. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41978. /**
  41979. * Gets a list of transform nodes using their id
  41980. * @param id defines the id to search for
  41981. * @returns a list of transform nodes
  41982. */
  41983. getTransformNodesByID(id: string): Array<TransformNode>;
  41984. /**
  41985. * Gets a mesh with its auto-generated unique id
  41986. * @param uniqueId defines the unique id to search for
  41987. * @return the found mesh or null if not found at all.
  41988. */
  41989. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41990. /**
  41991. * Gets a the last added mesh using a given id
  41992. * @param id defines the id to search for
  41993. * @return the found mesh or null if not found at all.
  41994. */
  41995. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41996. /**
  41997. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41998. * @param id defines the id to search for
  41999. * @return the found node or null if not found at all
  42000. */
  42001. getLastEntryByID(id: string): Nullable<Node>;
  42002. /**
  42003. * Gets a node (Mesh, Camera, Light) using a given id
  42004. * @param id defines the id to search for
  42005. * @return the found node or null if not found at all
  42006. */
  42007. getNodeByID(id: string): Nullable<Node>;
  42008. /**
  42009. * Gets a node (Mesh, Camera, Light) using a given name
  42010. * @param name defines the name to search for
  42011. * @return the found node or null if not found at all.
  42012. */
  42013. getNodeByName(name: string): Nullable<Node>;
  42014. /**
  42015. * Gets a mesh using a given name
  42016. * @param name defines the name to search for
  42017. * @return the found mesh or null if not found at all.
  42018. */
  42019. getMeshByName(name: string): Nullable<AbstractMesh>;
  42020. /**
  42021. * Gets a transform node using a given name
  42022. * @param name defines the name to search for
  42023. * @return the found transform node or null if not found at all.
  42024. */
  42025. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42026. /**
  42027. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42028. * @param id defines the id to search for
  42029. * @return the found skeleton or null if not found at all.
  42030. */
  42031. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42032. /**
  42033. * Gets a skeleton using a given auto generated unique id
  42034. * @param uniqueId defines the unique id to search for
  42035. * @return the found skeleton or null if not found at all.
  42036. */
  42037. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42038. /**
  42039. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42040. * @param id defines the id to search for
  42041. * @return the found skeleton or null if not found at all.
  42042. */
  42043. getSkeletonById(id: string): Nullable<Skeleton>;
  42044. /**
  42045. * Gets a skeleton using a given name
  42046. * @param name defines the name to search for
  42047. * @return the found skeleton or null if not found at all.
  42048. */
  42049. getSkeletonByName(name: string): Nullable<Skeleton>;
  42050. /**
  42051. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42052. * @param id defines the id to search for
  42053. * @return the found morph target manager or null if not found at all.
  42054. */
  42055. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42056. /**
  42057. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42058. * @param id defines the id to search for
  42059. * @return the found morph target or null if not found at all.
  42060. */
  42061. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42062. /**
  42063. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42064. * @param name defines the name to search for
  42065. * @return the found morph target or null if not found at all.
  42066. */
  42067. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42068. /**
  42069. * Gets a boolean indicating if the given mesh is active
  42070. * @param mesh defines the mesh to look for
  42071. * @returns true if the mesh is in the active list
  42072. */
  42073. isActiveMesh(mesh: AbstractMesh): boolean;
  42074. /**
  42075. * Return a unique id as a string which can serve as an identifier for the scene
  42076. */
  42077. get uid(): string;
  42078. /**
  42079. * Add an externaly attached data from its key.
  42080. * This method call will fail and return false, if such key already exists.
  42081. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42082. * @param key the unique key that identifies the data
  42083. * @param data the data object to associate to the key for this Engine instance
  42084. * @return true if no such key were already present and the data was added successfully, false otherwise
  42085. */
  42086. addExternalData<T>(key: string, data: T): boolean;
  42087. /**
  42088. * Get an externaly attached data from its key
  42089. * @param key the unique key that identifies the data
  42090. * @return the associated data, if present (can be null), or undefined if not present
  42091. */
  42092. getExternalData<T>(key: string): Nullable<T>;
  42093. /**
  42094. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42095. * @param key the unique key that identifies the data
  42096. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42097. * @return the associated data, can be null if the factory returned null.
  42098. */
  42099. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42100. /**
  42101. * Remove an externaly attached data from the Engine instance
  42102. * @param key the unique key that identifies the data
  42103. * @return true if the data was successfully removed, false if it doesn't exist
  42104. */
  42105. removeExternalData(key: string): boolean;
  42106. private _evaluateSubMesh;
  42107. /**
  42108. * Clear the processed materials smart array preventing retention point in material dispose.
  42109. */
  42110. freeProcessedMaterials(): void;
  42111. private _preventFreeActiveMeshesAndRenderingGroups;
  42112. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42113. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42114. * when disposing several meshes in a row or a hierarchy of meshes.
  42115. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42116. */
  42117. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42118. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42119. /**
  42120. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42121. */
  42122. freeActiveMeshes(): void;
  42123. /**
  42124. * Clear the info related to rendering groups preventing retention points during dispose.
  42125. */
  42126. freeRenderingGroups(): void;
  42127. /** @hidden */
  42128. _isInIntermediateRendering(): boolean;
  42129. /**
  42130. * Lambda returning the list of potentially active meshes.
  42131. */
  42132. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42133. /**
  42134. * Lambda returning the list of potentially active sub meshes.
  42135. */
  42136. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42137. /**
  42138. * Lambda returning the list of potentially intersecting sub meshes.
  42139. */
  42140. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42141. /**
  42142. * Lambda returning the list of potentially colliding sub meshes.
  42143. */
  42144. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42145. private _activeMeshesFrozen;
  42146. private _skipEvaluateActiveMeshesCompletely;
  42147. /**
  42148. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42149. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42150. * @returns the current scene
  42151. */
  42152. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42153. /**
  42154. * Use this function to restart evaluating active meshes on every frame
  42155. * @returns the current scene
  42156. */
  42157. unfreezeActiveMeshes(): Scene;
  42158. private _evaluateActiveMeshes;
  42159. private _activeMesh;
  42160. /**
  42161. * Update the transform matrix to update from the current active camera
  42162. * @param force defines a boolean used to force the update even if cache is up to date
  42163. */
  42164. updateTransformMatrix(force?: boolean): void;
  42165. private _bindFrameBuffer;
  42166. /** @hidden */
  42167. _allowPostProcessClearColor: boolean;
  42168. /** @hidden */
  42169. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42170. private _processSubCameras;
  42171. private _checkIntersections;
  42172. /** @hidden */
  42173. _advancePhysicsEngineStep(step: number): void;
  42174. /**
  42175. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42176. */
  42177. getDeterministicFrameTime: () => number;
  42178. /** @hidden */
  42179. _animate(): void;
  42180. /** Execute all animations (for a frame) */
  42181. animate(): void;
  42182. /**
  42183. * Render the scene
  42184. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42185. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42186. */
  42187. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42188. /**
  42189. * Freeze all materials
  42190. * A frozen material will not be updatable but should be faster to render
  42191. */
  42192. freezeMaterials(): void;
  42193. /**
  42194. * Unfreeze all materials
  42195. * A frozen material will not be updatable but should be faster to render
  42196. */
  42197. unfreezeMaterials(): void;
  42198. /**
  42199. * Releases all held ressources
  42200. */
  42201. dispose(): void;
  42202. /**
  42203. * Gets if the scene is already disposed
  42204. */
  42205. get isDisposed(): boolean;
  42206. /**
  42207. * Call this function to reduce memory footprint of the scene.
  42208. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42209. */
  42210. clearCachedVertexData(): void;
  42211. /**
  42212. * This function will remove the local cached buffer data from texture.
  42213. * It will save memory but will prevent the texture from being rebuilt
  42214. */
  42215. cleanCachedTextureBuffer(): void;
  42216. /**
  42217. * Get the world extend vectors with an optional filter
  42218. *
  42219. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42220. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42221. */
  42222. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42223. min: Vector3;
  42224. max: Vector3;
  42225. };
  42226. /**
  42227. * Creates a ray that can be used to pick in the scene
  42228. * @param x defines the x coordinate of the origin (on-screen)
  42229. * @param y defines the y coordinate of the origin (on-screen)
  42230. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42231. * @param camera defines the camera to use for the picking
  42232. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42233. * @returns a Ray
  42234. */
  42235. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42236. /**
  42237. * Creates a ray that can be used to pick in the scene
  42238. * @param x defines the x coordinate of the origin (on-screen)
  42239. * @param y defines the y coordinate of the origin (on-screen)
  42240. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42241. * @param result defines the ray where to store the picking ray
  42242. * @param camera defines the camera to use for the picking
  42243. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42244. * @returns the current scene
  42245. */
  42246. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42247. /**
  42248. * Creates a ray that can be used to pick in the scene
  42249. * @param x defines the x coordinate of the origin (on-screen)
  42250. * @param y defines the y coordinate of the origin (on-screen)
  42251. * @param camera defines the camera to use for the picking
  42252. * @returns a Ray
  42253. */
  42254. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42255. /**
  42256. * Creates a ray that can be used to pick in the scene
  42257. * @param x defines the x coordinate of the origin (on-screen)
  42258. * @param y defines the y coordinate of the origin (on-screen)
  42259. * @param result defines the ray where to store the picking ray
  42260. * @param camera defines the camera to use for the picking
  42261. * @returns the current scene
  42262. */
  42263. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42264. /** Launch a ray to try to pick a mesh in the scene
  42265. * @param x position on screen
  42266. * @param y position on screen
  42267. * @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
  42268. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42269. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42270. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42271. * @returns a PickingInfo
  42272. */
  42273. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42274. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42275. * @param x position on screen
  42276. * @param y position on screen
  42277. * @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
  42278. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42279. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42280. * @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)
  42281. */
  42282. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42283. /** Use the given ray to pick a mesh in the scene
  42284. * @param ray The ray to use to pick meshes
  42285. * @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
  42286. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42287. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42288. * @returns a PickingInfo
  42289. */
  42290. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42291. /**
  42292. * Launch a ray to try to pick a mesh in the scene
  42293. * @param x X position on screen
  42294. * @param y Y position on screen
  42295. * @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
  42296. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42297. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42298. * @returns an array of PickingInfo
  42299. */
  42300. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42301. /**
  42302. * Launch a ray to try to pick a mesh in the scene
  42303. * @param ray Ray to use
  42304. * @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
  42305. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42306. * @returns an array of PickingInfo
  42307. */
  42308. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42309. /**
  42310. * Force the value of meshUnderPointer
  42311. * @param mesh defines the mesh to use
  42312. */
  42313. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42314. /**
  42315. * Gets the mesh under the pointer
  42316. * @returns a Mesh or null if no mesh is under the pointer
  42317. */
  42318. getPointerOverMesh(): Nullable<AbstractMesh>;
  42319. /** @hidden */
  42320. _rebuildGeometries(): void;
  42321. /** @hidden */
  42322. _rebuildTextures(): void;
  42323. private _getByTags;
  42324. /**
  42325. * Get a list of meshes by tags
  42326. * @param tagsQuery defines the tags query to use
  42327. * @param forEach defines a predicate used to filter results
  42328. * @returns an array of Mesh
  42329. */
  42330. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42331. /**
  42332. * Get a list of cameras by tags
  42333. * @param tagsQuery defines the tags query to use
  42334. * @param forEach defines a predicate used to filter results
  42335. * @returns an array of Camera
  42336. */
  42337. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42338. /**
  42339. * Get a list of lights by tags
  42340. * @param tagsQuery defines the tags query to use
  42341. * @param forEach defines a predicate used to filter results
  42342. * @returns an array of Light
  42343. */
  42344. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42345. /**
  42346. * Get a list of materials by tags
  42347. * @param tagsQuery defines the tags query to use
  42348. * @param forEach defines a predicate used to filter results
  42349. * @returns an array of Material
  42350. */
  42351. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42352. /**
  42353. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42354. * This allowed control for front to back rendering or reversly depending of the special needs.
  42355. *
  42356. * @param renderingGroupId The rendering group id corresponding to its index
  42357. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42358. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42359. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42360. */
  42361. 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;
  42362. /**
  42363. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42364. *
  42365. * @param renderingGroupId The rendering group id corresponding to its index
  42366. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42367. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42368. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42369. */
  42370. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42371. /**
  42372. * Gets the current auto clear configuration for one rendering group of the rendering
  42373. * manager.
  42374. * @param index the rendering group index to get the information for
  42375. * @returns The auto clear setup for the requested rendering group
  42376. */
  42377. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42378. private _blockMaterialDirtyMechanism;
  42379. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42380. get blockMaterialDirtyMechanism(): boolean;
  42381. set blockMaterialDirtyMechanism(value: boolean);
  42382. /**
  42383. * Will flag all materials as dirty to trigger new shader compilation
  42384. * @param flag defines the flag used to specify which material part must be marked as dirty
  42385. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42386. */
  42387. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42388. /** @hidden */
  42389. _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;
  42390. /** @hidden */
  42391. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42392. /** @hidden */
  42393. _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;
  42394. /** @hidden */
  42395. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42396. /** @hidden */
  42397. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42398. /** @hidden */
  42399. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42400. }
  42401. }
  42402. declare module "babylonjs/assetContainer" {
  42403. import { AbstractScene } from "babylonjs/abstractScene";
  42404. import { Scene } from "babylonjs/scene";
  42405. import { Mesh } from "babylonjs/Meshes/mesh";
  42406. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42407. import { Skeleton } from "babylonjs/Bones/skeleton";
  42408. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42409. import { Animatable } from "babylonjs/Animations/animatable";
  42410. import { Nullable } from "babylonjs/types";
  42411. import { Node } from "babylonjs/node";
  42412. /**
  42413. * Set of assets to keep when moving a scene into an asset container.
  42414. */
  42415. export class KeepAssets extends AbstractScene {
  42416. }
  42417. /**
  42418. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42419. */
  42420. export class InstantiatedEntries {
  42421. /**
  42422. * List of new root nodes (eg. nodes with no parent)
  42423. */
  42424. rootNodes: TransformNode[];
  42425. /**
  42426. * List of new skeletons
  42427. */
  42428. skeletons: Skeleton[];
  42429. /**
  42430. * List of new animation groups
  42431. */
  42432. animationGroups: AnimationGroup[];
  42433. }
  42434. /**
  42435. * Container with a set of assets that can be added or removed from a scene.
  42436. */
  42437. export class AssetContainer extends AbstractScene {
  42438. private _wasAddedToScene;
  42439. /**
  42440. * The scene the AssetContainer belongs to.
  42441. */
  42442. scene: Scene;
  42443. /**
  42444. * Instantiates an AssetContainer.
  42445. * @param scene The scene the AssetContainer belongs to.
  42446. */
  42447. constructor(scene: Scene);
  42448. /**
  42449. * Instantiate or clone all meshes and add the new ones to the scene.
  42450. * Skeletons and animation groups will all be cloned
  42451. * @param nameFunction defines an optional function used to get new names for clones
  42452. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42453. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42454. */
  42455. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42456. /**
  42457. * Adds all the assets from the container to the scene.
  42458. */
  42459. addAllToScene(): void;
  42460. /**
  42461. * Removes all the assets in the container from the scene
  42462. */
  42463. removeAllFromScene(): void;
  42464. /**
  42465. * Disposes all the assets in the container
  42466. */
  42467. dispose(): void;
  42468. private _moveAssets;
  42469. /**
  42470. * Removes all the assets contained in the scene and adds them to the container.
  42471. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42472. */
  42473. moveAllFromScene(keepAssets?: KeepAssets): void;
  42474. /**
  42475. * 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.
  42476. * @returns the root mesh
  42477. */
  42478. createRootMesh(): Mesh;
  42479. /**
  42480. * Merge animations (direct and animation groups) from this asset container into a scene
  42481. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42482. * @param animatables set of animatables to retarget to a node from the scene
  42483. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42484. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42485. */
  42486. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42487. }
  42488. }
  42489. declare module "babylonjs/abstractScene" {
  42490. import { Scene } from "babylonjs/scene";
  42491. import { Nullable } from "babylonjs/types";
  42492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42493. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42494. import { Geometry } from "babylonjs/Meshes/geometry";
  42495. import { Skeleton } from "babylonjs/Bones/skeleton";
  42496. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42497. import { AssetContainer } from "babylonjs/assetContainer";
  42498. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42499. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42501. import { Material } from "babylonjs/Materials/material";
  42502. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42503. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42504. import { Camera } from "babylonjs/Cameras/camera";
  42505. import { Light } from "babylonjs/Lights/light";
  42506. import { Node } from "babylonjs/node";
  42507. import { Animation } from "babylonjs/Animations/animation";
  42508. /**
  42509. * Defines how the parser contract is defined.
  42510. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42511. */
  42512. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42513. /**
  42514. * Defines how the individual parser contract is defined.
  42515. * These parser can parse an individual asset
  42516. */
  42517. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42518. /**
  42519. * Base class of the scene acting as a container for the different elements composing a scene.
  42520. * This class is dynamically extended by the different components of the scene increasing
  42521. * flexibility and reducing coupling
  42522. */
  42523. export abstract class AbstractScene {
  42524. /**
  42525. * Stores the list of available parsers in the application.
  42526. */
  42527. private static _BabylonFileParsers;
  42528. /**
  42529. * Stores the list of available individual parsers in the application.
  42530. */
  42531. private static _IndividualBabylonFileParsers;
  42532. /**
  42533. * Adds a parser in the list of available ones
  42534. * @param name Defines the name of the parser
  42535. * @param parser Defines the parser to add
  42536. */
  42537. static AddParser(name: string, parser: BabylonFileParser): void;
  42538. /**
  42539. * Gets a general parser from the list of avaialble ones
  42540. * @param name Defines the name of the parser
  42541. * @returns the requested parser or null
  42542. */
  42543. static GetParser(name: string): Nullable<BabylonFileParser>;
  42544. /**
  42545. * Adds n individual parser in the list of available ones
  42546. * @param name Defines the name of the parser
  42547. * @param parser Defines the parser to add
  42548. */
  42549. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42550. /**
  42551. * Gets an individual parser from the list of avaialble ones
  42552. * @param name Defines the name of the parser
  42553. * @returns the requested parser or null
  42554. */
  42555. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42556. /**
  42557. * Parser json data and populate both a scene and its associated container object
  42558. * @param jsonData Defines the data to parse
  42559. * @param scene Defines the scene to parse the data for
  42560. * @param container Defines the container attached to the parsing sequence
  42561. * @param rootUrl Defines the root url of the data
  42562. */
  42563. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42564. /**
  42565. * Gets the list of root nodes (ie. nodes with no parent)
  42566. */
  42567. rootNodes: Node[];
  42568. /** All of the cameras added to this scene
  42569. * @see https://doc.babylonjs.com/babylon101/cameras
  42570. */
  42571. cameras: Camera[];
  42572. /**
  42573. * All of the lights added to this scene
  42574. * @see https://doc.babylonjs.com/babylon101/lights
  42575. */
  42576. lights: Light[];
  42577. /**
  42578. * All of the (abstract) meshes added to this scene
  42579. */
  42580. meshes: AbstractMesh[];
  42581. /**
  42582. * The list of skeletons added to the scene
  42583. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42584. */
  42585. skeletons: Skeleton[];
  42586. /**
  42587. * All of the particle systems added to this scene
  42588. * @see https://doc.babylonjs.com/babylon101/particles
  42589. */
  42590. particleSystems: IParticleSystem[];
  42591. /**
  42592. * Gets a list of Animations associated with the scene
  42593. */
  42594. animations: Animation[];
  42595. /**
  42596. * All of the animation groups added to this scene
  42597. * @see https://doc.babylonjs.com/how_to/group
  42598. */
  42599. animationGroups: AnimationGroup[];
  42600. /**
  42601. * All of the multi-materials added to this scene
  42602. * @see https://doc.babylonjs.com/how_to/multi_materials
  42603. */
  42604. multiMaterials: MultiMaterial[];
  42605. /**
  42606. * All of the materials added to this scene
  42607. * In the context of a Scene, it is not supposed to be modified manually.
  42608. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42609. * Note also that the order of the Material within the array is not significant and might change.
  42610. * @see https://doc.babylonjs.com/babylon101/materials
  42611. */
  42612. materials: Material[];
  42613. /**
  42614. * The list of morph target managers added to the scene
  42615. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42616. */
  42617. morphTargetManagers: MorphTargetManager[];
  42618. /**
  42619. * The list of geometries used in the scene.
  42620. */
  42621. geometries: Geometry[];
  42622. /**
  42623. * All of the tranform nodes added to this scene
  42624. * In the context of a Scene, it is not supposed to be modified manually.
  42625. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42626. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42627. * @see https://doc.babylonjs.com/how_to/transformnode
  42628. */
  42629. transformNodes: TransformNode[];
  42630. /**
  42631. * ActionManagers available on the scene.
  42632. */
  42633. actionManagers: AbstractActionManager[];
  42634. /**
  42635. * Textures to keep.
  42636. */
  42637. textures: BaseTexture[];
  42638. /**
  42639. * Environment texture for the scene
  42640. */
  42641. environmentTexture: Nullable<BaseTexture>;
  42642. /**
  42643. * @returns all meshes, lights, cameras, transformNodes and bones
  42644. */
  42645. getNodes(): Array<Node>;
  42646. }
  42647. }
  42648. declare module "babylonjs/Audio/sound" {
  42649. import { Observable } from "babylonjs/Misc/observable";
  42650. import { Vector3 } from "babylonjs/Maths/math.vector";
  42651. import { Nullable } from "babylonjs/types";
  42652. import { Scene } from "babylonjs/scene";
  42653. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42654. /**
  42655. * Interface used to define options for Sound class
  42656. */
  42657. export interface ISoundOptions {
  42658. /**
  42659. * Does the sound autoplay once loaded.
  42660. */
  42661. autoplay?: boolean;
  42662. /**
  42663. * Does the sound loop after it finishes playing once.
  42664. */
  42665. loop?: boolean;
  42666. /**
  42667. * Sound's volume
  42668. */
  42669. volume?: number;
  42670. /**
  42671. * Is it a spatial sound?
  42672. */
  42673. spatialSound?: boolean;
  42674. /**
  42675. * Maximum distance to hear that sound
  42676. */
  42677. maxDistance?: number;
  42678. /**
  42679. * Uses user defined attenuation function
  42680. */
  42681. useCustomAttenuation?: boolean;
  42682. /**
  42683. * Define the roll off factor of spatial sounds.
  42684. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42685. */
  42686. rolloffFactor?: number;
  42687. /**
  42688. * Define the reference distance the sound should be heard perfectly.
  42689. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42690. */
  42691. refDistance?: number;
  42692. /**
  42693. * Define the distance attenuation model the sound will follow.
  42694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42695. */
  42696. distanceModel?: string;
  42697. /**
  42698. * Defines the playback speed (1 by default)
  42699. */
  42700. playbackRate?: number;
  42701. /**
  42702. * Defines if the sound is from a streaming source
  42703. */
  42704. streaming?: boolean;
  42705. /**
  42706. * Defines an optional length (in seconds) inside the sound file
  42707. */
  42708. length?: number;
  42709. /**
  42710. * Defines an optional offset (in seconds) inside the sound file
  42711. */
  42712. offset?: number;
  42713. /**
  42714. * If true, URLs will not be required to state the audio file codec to use.
  42715. */
  42716. skipCodecCheck?: boolean;
  42717. }
  42718. /**
  42719. * Defines a sound that can be played in the application.
  42720. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42722. */
  42723. export class Sound {
  42724. /**
  42725. * The name of the sound in the scene.
  42726. */
  42727. name: string;
  42728. /**
  42729. * Does the sound autoplay once loaded.
  42730. */
  42731. autoplay: boolean;
  42732. /**
  42733. * Does the sound loop after it finishes playing once.
  42734. */
  42735. loop: boolean;
  42736. /**
  42737. * Does the sound use a custom attenuation curve to simulate the falloff
  42738. * happening when the source gets further away from the camera.
  42739. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42740. */
  42741. useCustomAttenuation: boolean;
  42742. /**
  42743. * The sound track id this sound belongs to.
  42744. */
  42745. soundTrackId: number;
  42746. /**
  42747. * Is this sound currently played.
  42748. */
  42749. isPlaying: boolean;
  42750. /**
  42751. * Is this sound currently paused.
  42752. */
  42753. isPaused: boolean;
  42754. /**
  42755. * Does this sound enables spatial sound.
  42756. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42757. */
  42758. spatialSound: boolean;
  42759. /**
  42760. * Define the reference distance the sound should be heard perfectly.
  42761. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42762. */
  42763. refDistance: number;
  42764. /**
  42765. * Define the roll off factor of spatial sounds.
  42766. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42767. */
  42768. rolloffFactor: number;
  42769. /**
  42770. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42771. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42772. */
  42773. maxDistance: number;
  42774. /**
  42775. * Define the distance attenuation model the sound will follow.
  42776. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42777. */
  42778. distanceModel: string;
  42779. /**
  42780. * @hidden
  42781. * Back Compat
  42782. **/
  42783. onended: () => any;
  42784. /**
  42785. * Gets or sets an object used to store user defined information for the sound.
  42786. */
  42787. metadata: any;
  42788. /**
  42789. * Observable event when the current playing sound finishes.
  42790. */
  42791. onEndedObservable: Observable<Sound>;
  42792. private _panningModel;
  42793. private _playbackRate;
  42794. private _streaming;
  42795. private _startTime;
  42796. private _startOffset;
  42797. private _position;
  42798. /** @hidden */
  42799. _positionInEmitterSpace: boolean;
  42800. private _localDirection;
  42801. private _volume;
  42802. private _isReadyToPlay;
  42803. private _isDirectional;
  42804. private _readyToPlayCallback;
  42805. private _audioBuffer;
  42806. private _soundSource;
  42807. private _streamingSource;
  42808. private _soundPanner;
  42809. private _soundGain;
  42810. private _inputAudioNode;
  42811. private _outputAudioNode;
  42812. private _coneInnerAngle;
  42813. private _coneOuterAngle;
  42814. private _coneOuterGain;
  42815. private _scene;
  42816. private _connectedTransformNode;
  42817. private _customAttenuationFunction;
  42818. private _registerFunc;
  42819. private _isOutputConnected;
  42820. private _htmlAudioElement;
  42821. private _urlType;
  42822. private _length?;
  42823. private _offset?;
  42824. /** @hidden */
  42825. static _SceneComponentInitialization: (scene: Scene) => void;
  42826. /**
  42827. * Create a sound and attach it to a scene
  42828. * @param name Name of your sound
  42829. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42830. * @param scene defines the scene the sound belongs to
  42831. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42832. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42833. */
  42834. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42835. /**
  42836. * Release the sound and its associated resources
  42837. */
  42838. dispose(): void;
  42839. /**
  42840. * Gets if the sounds is ready to be played or not.
  42841. * @returns true if ready, otherwise false
  42842. */
  42843. isReady(): boolean;
  42844. private _soundLoaded;
  42845. /**
  42846. * Sets the data of the sound from an audiobuffer
  42847. * @param audioBuffer The audioBuffer containing the data
  42848. */
  42849. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42850. /**
  42851. * Updates the current sounds options such as maxdistance, loop...
  42852. * @param options A JSON object containing values named as the object properties
  42853. */
  42854. updateOptions(options: ISoundOptions): void;
  42855. private _createSpatialParameters;
  42856. private _updateSpatialParameters;
  42857. /**
  42858. * Switch the panning model to HRTF:
  42859. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42860. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42861. */
  42862. switchPanningModelToHRTF(): void;
  42863. /**
  42864. * Switch the panning model to Equal Power:
  42865. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42866. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42867. */
  42868. switchPanningModelToEqualPower(): void;
  42869. private _switchPanningModel;
  42870. /**
  42871. * Connect this sound to a sound track audio node like gain...
  42872. * @param soundTrackAudioNode the sound track audio node to connect to
  42873. */
  42874. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42875. /**
  42876. * Transform this sound into a directional source
  42877. * @param coneInnerAngle Size of the inner cone in degree
  42878. * @param coneOuterAngle Size of the outer cone in degree
  42879. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42880. */
  42881. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42882. /**
  42883. * Gets or sets the inner angle for the directional cone.
  42884. */
  42885. get directionalConeInnerAngle(): number;
  42886. /**
  42887. * Gets or sets the inner angle for the directional cone.
  42888. */
  42889. set directionalConeInnerAngle(value: number);
  42890. /**
  42891. * Gets or sets the outer angle for the directional cone.
  42892. */
  42893. get directionalConeOuterAngle(): number;
  42894. /**
  42895. * Gets or sets the outer angle for the directional cone.
  42896. */
  42897. set directionalConeOuterAngle(value: number);
  42898. /**
  42899. * Sets the position of the emitter if spatial sound is enabled
  42900. * @param newPosition Defines the new posisiton
  42901. */
  42902. setPosition(newPosition: Vector3): void;
  42903. /**
  42904. * Sets the local direction of the emitter if spatial sound is enabled
  42905. * @param newLocalDirection Defines the new local direction
  42906. */
  42907. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42908. private _updateDirection;
  42909. /** @hidden */
  42910. updateDistanceFromListener(): void;
  42911. /**
  42912. * Sets a new custom attenuation function for the sound.
  42913. * @param callback Defines the function used for the attenuation
  42914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42915. */
  42916. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42917. /**
  42918. * Play the sound
  42919. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42920. * @param offset (optional) Start the sound at a specific time in seconds
  42921. * @param length (optional) Sound duration (in seconds)
  42922. */
  42923. play(time?: number, offset?: number, length?: number): void;
  42924. private _onended;
  42925. /**
  42926. * Stop the sound
  42927. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42928. */
  42929. stop(time?: number): void;
  42930. /**
  42931. * Put the sound in pause
  42932. */
  42933. pause(): void;
  42934. /**
  42935. * Sets a dedicated volume for this sounds
  42936. * @param newVolume Define the new volume of the sound
  42937. * @param time Define time for gradual change to new volume
  42938. */
  42939. setVolume(newVolume: number, time?: number): void;
  42940. /**
  42941. * Set the sound play back rate
  42942. * @param newPlaybackRate Define the playback rate the sound should be played at
  42943. */
  42944. setPlaybackRate(newPlaybackRate: number): void;
  42945. /**
  42946. * Gets the volume of the sound.
  42947. * @returns the volume of the sound
  42948. */
  42949. getVolume(): number;
  42950. /**
  42951. * Attach the sound to a dedicated mesh
  42952. * @param transformNode The transform node to connect the sound with
  42953. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42954. */
  42955. attachToMesh(transformNode: TransformNode): void;
  42956. /**
  42957. * Detach the sound from the previously attached mesh
  42958. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42959. */
  42960. detachFromMesh(): void;
  42961. private _onRegisterAfterWorldMatrixUpdate;
  42962. /**
  42963. * Clone the current sound in the scene.
  42964. * @returns the new sound clone
  42965. */
  42966. clone(): Nullable<Sound>;
  42967. /**
  42968. * Gets the current underlying audio buffer containing the data
  42969. * @returns the audio buffer
  42970. */
  42971. getAudioBuffer(): Nullable<AudioBuffer>;
  42972. /**
  42973. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42974. * @returns the source node
  42975. */
  42976. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42977. /**
  42978. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42979. * @returns the gain node
  42980. */
  42981. getSoundGain(): Nullable<GainNode>;
  42982. /**
  42983. * Serializes the Sound in a JSON representation
  42984. * @returns the JSON representation of the sound
  42985. */
  42986. serialize(): any;
  42987. /**
  42988. * Parse a JSON representation of a sound to innstantiate in a given scene
  42989. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42990. * @param scene Define the scene the new parsed sound should be created in
  42991. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42992. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42993. * @returns the newly parsed sound
  42994. */
  42995. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42996. }
  42997. }
  42998. declare module "babylonjs/Actions/directAudioActions" {
  42999. import { Action } from "babylonjs/Actions/action";
  43000. import { Condition } from "babylonjs/Actions/condition";
  43001. import { Sound } from "babylonjs/Audio/sound";
  43002. /**
  43003. * This defines an action helpful to play a defined sound on a triggered action.
  43004. */
  43005. export class PlaySoundAction extends Action {
  43006. private _sound;
  43007. /**
  43008. * Instantiate the action
  43009. * @param triggerOptions defines the trigger options
  43010. * @param sound defines the sound to play
  43011. * @param condition defines the trigger related conditions
  43012. */
  43013. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43014. /** @hidden */
  43015. _prepare(): void;
  43016. /**
  43017. * Execute the action and play the sound.
  43018. */
  43019. execute(): void;
  43020. /**
  43021. * Serializes the actions and its related information.
  43022. * @param parent defines the object to serialize in
  43023. * @returns the serialized object
  43024. */
  43025. serialize(parent: any): any;
  43026. }
  43027. /**
  43028. * This defines an action helpful to stop a defined sound on a triggered action.
  43029. */
  43030. export class StopSoundAction extends Action {
  43031. private _sound;
  43032. /**
  43033. * Instantiate the action
  43034. * @param triggerOptions defines the trigger options
  43035. * @param sound defines the sound to stop
  43036. * @param condition defines the trigger related conditions
  43037. */
  43038. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43039. /** @hidden */
  43040. _prepare(): void;
  43041. /**
  43042. * Execute the action and stop the sound.
  43043. */
  43044. execute(): void;
  43045. /**
  43046. * Serializes the actions and its related information.
  43047. * @param parent defines the object to serialize in
  43048. * @returns the serialized object
  43049. */
  43050. serialize(parent: any): any;
  43051. }
  43052. }
  43053. declare module "babylonjs/Actions/interpolateValueAction" {
  43054. import { Action } from "babylonjs/Actions/action";
  43055. import { Condition } from "babylonjs/Actions/condition";
  43056. import { Observable } from "babylonjs/Misc/observable";
  43057. /**
  43058. * This defines an action responsible to change the value of a property
  43059. * by interpolating between its current value and the newly set one once triggered.
  43060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43061. */
  43062. export class InterpolateValueAction extends Action {
  43063. /**
  43064. * Defines the path of the property where the value should be interpolated
  43065. */
  43066. propertyPath: string;
  43067. /**
  43068. * Defines the target value at the end of the interpolation.
  43069. */
  43070. value: any;
  43071. /**
  43072. * Defines the time it will take for the property to interpolate to the value.
  43073. */
  43074. duration: number;
  43075. /**
  43076. * Defines if the other scene animations should be stopped when the action has been triggered
  43077. */
  43078. stopOtherAnimations?: boolean;
  43079. /**
  43080. * Defines a callback raised once the interpolation animation has been done.
  43081. */
  43082. onInterpolationDone?: () => void;
  43083. /**
  43084. * Observable triggered once the interpolation animation has been done.
  43085. */
  43086. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43087. private _target;
  43088. private _effectiveTarget;
  43089. private _property;
  43090. /**
  43091. * Instantiate the action
  43092. * @param triggerOptions defines the trigger options
  43093. * @param target defines the object containing the value to interpolate
  43094. * @param propertyPath defines the path to the property in the target object
  43095. * @param value defines the target value at the end of the interpolation
  43096. * @param duration deines the time it will take for the property to interpolate to the value.
  43097. * @param condition defines the trigger related conditions
  43098. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43099. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43100. */
  43101. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43102. /** @hidden */
  43103. _prepare(): void;
  43104. /**
  43105. * Execute the action starts the value interpolation.
  43106. */
  43107. execute(): void;
  43108. /**
  43109. * Serializes the actions and its related information.
  43110. * @param parent defines the object to serialize in
  43111. * @returns the serialized object
  43112. */
  43113. serialize(parent: any): any;
  43114. }
  43115. }
  43116. declare module "babylonjs/Actions/index" {
  43117. export * from "babylonjs/Actions/abstractActionManager";
  43118. export * from "babylonjs/Actions/action";
  43119. export * from "babylonjs/Actions/actionEvent";
  43120. export * from "babylonjs/Actions/actionManager";
  43121. export * from "babylonjs/Actions/condition";
  43122. export * from "babylonjs/Actions/directActions";
  43123. export * from "babylonjs/Actions/directAudioActions";
  43124. export * from "babylonjs/Actions/interpolateValueAction";
  43125. }
  43126. declare module "babylonjs/Animations/index" {
  43127. export * from "babylonjs/Animations/animatable";
  43128. export * from "babylonjs/Animations/animation";
  43129. export * from "babylonjs/Animations/animationGroup";
  43130. export * from "babylonjs/Animations/animationPropertiesOverride";
  43131. export * from "babylonjs/Animations/easing";
  43132. export * from "babylonjs/Animations/runtimeAnimation";
  43133. export * from "babylonjs/Animations/animationEvent";
  43134. export * from "babylonjs/Animations/animationGroup";
  43135. export * from "babylonjs/Animations/animationKey";
  43136. export * from "babylonjs/Animations/animationRange";
  43137. export * from "babylonjs/Animations/animatable.interface";
  43138. }
  43139. declare module "babylonjs/Audio/soundTrack" {
  43140. import { Sound } from "babylonjs/Audio/sound";
  43141. import { Analyser } from "babylonjs/Audio/analyser";
  43142. import { Scene } from "babylonjs/scene";
  43143. /**
  43144. * Options allowed during the creation of a sound track.
  43145. */
  43146. export interface ISoundTrackOptions {
  43147. /**
  43148. * The volume the sound track should take during creation
  43149. */
  43150. volume?: number;
  43151. /**
  43152. * Define if the sound track is the main sound track of the scene
  43153. */
  43154. mainTrack?: boolean;
  43155. }
  43156. /**
  43157. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43158. * It will be also used in a future release to apply effects on a specific track.
  43159. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43160. */
  43161. export class SoundTrack {
  43162. /**
  43163. * The unique identifier of the sound track in the scene.
  43164. */
  43165. id: number;
  43166. /**
  43167. * The list of sounds included in the sound track.
  43168. */
  43169. soundCollection: Array<Sound>;
  43170. private _outputAudioNode;
  43171. private _scene;
  43172. private _connectedAnalyser;
  43173. private _options;
  43174. private _isInitialized;
  43175. /**
  43176. * Creates a new sound track.
  43177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43178. * @param scene Define the scene the sound track belongs to
  43179. * @param options
  43180. */
  43181. constructor(scene: Scene, options?: ISoundTrackOptions);
  43182. private _initializeSoundTrackAudioGraph;
  43183. /**
  43184. * Release the sound track and its associated resources
  43185. */
  43186. dispose(): void;
  43187. /**
  43188. * Adds a sound to this sound track
  43189. * @param sound define the cound to add
  43190. * @ignoreNaming
  43191. */
  43192. AddSound(sound: Sound): void;
  43193. /**
  43194. * Removes a sound to this sound track
  43195. * @param sound define the cound to remove
  43196. * @ignoreNaming
  43197. */
  43198. RemoveSound(sound: Sound): void;
  43199. /**
  43200. * Set a global volume for the full sound track.
  43201. * @param newVolume Define the new volume of the sound track
  43202. */
  43203. setVolume(newVolume: number): void;
  43204. /**
  43205. * Switch the panning model to HRTF:
  43206. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43207. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43208. */
  43209. switchPanningModelToHRTF(): void;
  43210. /**
  43211. * Switch the panning model to Equal Power:
  43212. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43214. */
  43215. switchPanningModelToEqualPower(): void;
  43216. /**
  43217. * Connect the sound track to an audio analyser allowing some amazing
  43218. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43220. * @param analyser The analyser to connect to the engine
  43221. */
  43222. connectToAnalyser(analyser: Analyser): void;
  43223. }
  43224. }
  43225. declare module "babylonjs/Audio/audioSceneComponent" {
  43226. import { Sound } from "babylonjs/Audio/sound";
  43227. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43228. import { Nullable } from "babylonjs/types";
  43229. import { Vector3 } from "babylonjs/Maths/math.vector";
  43230. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43231. import { Scene } from "babylonjs/scene";
  43232. import { AbstractScene } from "babylonjs/abstractScene";
  43233. import "babylonjs/Audio/audioEngine";
  43234. module "babylonjs/abstractScene" {
  43235. interface AbstractScene {
  43236. /**
  43237. * The list of sounds used in the scene.
  43238. */
  43239. sounds: Nullable<Array<Sound>>;
  43240. }
  43241. }
  43242. module "babylonjs/scene" {
  43243. interface Scene {
  43244. /**
  43245. * @hidden
  43246. * Backing field
  43247. */
  43248. _mainSoundTrack: SoundTrack;
  43249. /**
  43250. * The main sound track played by the scene.
  43251. * It cotains your primary collection of sounds.
  43252. */
  43253. mainSoundTrack: SoundTrack;
  43254. /**
  43255. * The list of sound tracks added to the scene
  43256. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43257. */
  43258. soundTracks: Nullable<Array<SoundTrack>>;
  43259. /**
  43260. * Gets a sound using a given name
  43261. * @param name defines the name to search for
  43262. * @return the found sound or null if not found at all.
  43263. */
  43264. getSoundByName(name: string): Nullable<Sound>;
  43265. /**
  43266. * Gets or sets if audio support is enabled
  43267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43268. */
  43269. audioEnabled: boolean;
  43270. /**
  43271. * Gets or sets if audio will be output to headphones
  43272. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43273. */
  43274. headphone: boolean;
  43275. /**
  43276. * Gets or sets custom audio listener position provider
  43277. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43278. */
  43279. audioListenerPositionProvider: Nullable<() => Vector3>;
  43280. /**
  43281. * Gets or sets a refresh rate when using 3D audio positioning
  43282. */
  43283. audioPositioningRefreshRate: number;
  43284. }
  43285. }
  43286. /**
  43287. * Defines the sound scene component responsible to manage any sounds
  43288. * in a given scene.
  43289. */
  43290. export class AudioSceneComponent implements ISceneSerializableComponent {
  43291. /**
  43292. * The component name helpfull to identify the component in the list of scene components.
  43293. */
  43294. readonly name: string;
  43295. /**
  43296. * The scene the component belongs to.
  43297. */
  43298. scene: Scene;
  43299. private _audioEnabled;
  43300. /**
  43301. * Gets whether audio is enabled or not.
  43302. * Please use related enable/disable method to switch state.
  43303. */
  43304. get audioEnabled(): boolean;
  43305. private _headphone;
  43306. /**
  43307. * Gets whether audio is outputing to headphone or not.
  43308. * Please use the according Switch methods to change output.
  43309. */
  43310. get headphone(): boolean;
  43311. /**
  43312. * Gets or sets a refresh rate when using 3D audio positioning
  43313. */
  43314. audioPositioningRefreshRate: number;
  43315. private _audioListenerPositionProvider;
  43316. /**
  43317. * Gets the current audio listener position provider
  43318. */
  43319. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43320. /**
  43321. * Sets a custom listener position for all sounds in the scene
  43322. * By default, this is the position of the first active camera
  43323. */
  43324. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43325. /**
  43326. * Creates a new instance of the component for the given scene
  43327. * @param scene Defines the scene to register the component in
  43328. */
  43329. constructor(scene: Scene);
  43330. /**
  43331. * Registers the component in a given scene
  43332. */
  43333. register(): void;
  43334. /**
  43335. * Rebuilds the elements related to this component in case of
  43336. * context lost for instance.
  43337. */
  43338. rebuild(): void;
  43339. /**
  43340. * Serializes the component data to the specified json object
  43341. * @param serializationObject The object to serialize to
  43342. */
  43343. serialize(serializationObject: any): void;
  43344. /**
  43345. * Adds all the elements from the container to the scene
  43346. * @param container the container holding the elements
  43347. */
  43348. addFromContainer(container: AbstractScene): void;
  43349. /**
  43350. * Removes all the elements in the container from the scene
  43351. * @param container contains the elements to remove
  43352. * @param dispose if the removed element should be disposed (default: false)
  43353. */
  43354. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43355. /**
  43356. * Disposes the component and the associated ressources.
  43357. */
  43358. dispose(): void;
  43359. /**
  43360. * Disables audio in the associated scene.
  43361. */
  43362. disableAudio(): void;
  43363. /**
  43364. * Enables audio in the associated scene.
  43365. */
  43366. enableAudio(): void;
  43367. /**
  43368. * Switch audio to headphone output.
  43369. */
  43370. switchAudioModeForHeadphones(): void;
  43371. /**
  43372. * Switch audio to normal speakers.
  43373. */
  43374. switchAudioModeForNormalSpeakers(): void;
  43375. private _cachedCameraDirection;
  43376. private _cachedCameraPosition;
  43377. private _lastCheck;
  43378. private _afterRender;
  43379. }
  43380. }
  43381. declare module "babylonjs/Audio/weightedsound" {
  43382. import { Sound } from "babylonjs/Audio/sound";
  43383. /**
  43384. * Wraps one or more Sound objects and selects one with random weight for playback.
  43385. */
  43386. export class WeightedSound {
  43387. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43388. loop: boolean;
  43389. private _coneInnerAngle;
  43390. private _coneOuterAngle;
  43391. private _volume;
  43392. /** A Sound is currently playing. */
  43393. isPlaying: boolean;
  43394. /** A Sound is currently paused. */
  43395. isPaused: boolean;
  43396. private _sounds;
  43397. private _weights;
  43398. private _currentIndex?;
  43399. /**
  43400. * Creates a new WeightedSound from the list of sounds given.
  43401. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43402. * @param sounds Array of Sounds that will be selected from.
  43403. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43404. */
  43405. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43406. /**
  43407. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43408. */
  43409. get directionalConeInnerAngle(): number;
  43410. /**
  43411. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43412. */
  43413. set directionalConeInnerAngle(value: number);
  43414. /**
  43415. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43416. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43417. */
  43418. get directionalConeOuterAngle(): number;
  43419. /**
  43420. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43421. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43422. */
  43423. set directionalConeOuterAngle(value: number);
  43424. /**
  43425. * Playback volume.
  43426. */
  43427. get volume(): number;
  43428. /**
  43429. * Playback volume.
  43430. */
  43431. set volume(value: number);
  43432. private _onended;
  43433. /**
  43434. * Suspend playback
  43435. */
  43436. pause(): void;
  43437. /**
  43438. * Stop playback
  43439. */
  43440. stop(): void;
  43441. /**
  43442. * Start playback.
  43443. * @param startOffset Position the clip head at a specific time in seconds.
  43444. */
  43445. play(startOffset?: number): void;
  43446. }
  43447. }
  43448. declare module "babylonjs/Audio/index" {
  43449. export * from "babylonjs/Audio/analyser";
  43450. export * from "babylonjs/Audio/audioEngine";
  43451. export * from "babylonjs/Audio/audioSceneComponent";
  43452. export * from "babylonjs/Audio/sound";
  43453. export * from "babylonjs/Audio/soundTrack";
  43454. export * from "babylonjs/Audio/weightedsound";
  43455. }
  43456. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43457. import { Behavior } from "babylonjs/Behaviors/behavior";
  43458. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43459. import { BackEase } from "babylonjs/Animations/easing";
  43460. /**
  43461. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43462. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43463. */
  43464. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43465. /**
  43466. * Gets the name of the behavior.
  43467. */
  43468. get name(): string;
  43469. /**
  43470. * The easing function used by animations
  43471. */
  43472. static EasingFunction: BackEase;
  43473. /**
  43474. * The easing mode used by animations
  43475. */
  43476. static EasingMode: number;
  43477. /**
  43478. * The duration of the animation, in milliseconds
  43479. */
  43480. transitionDuration: number;
  43481. /**
  43482. * Length of the distance animated by the transition when lower radius is reached
  43483. */
  43484. lowerRadiusTransitionRange: number;
  43485. /**
  43486. * Length of the distance animated by the transition when upper radius is reached
  43487. */
  43488. upperRadiusTransitionRange: number;
  43489. private _autoTransitionRange;
  43490. /**
  43491. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43492. */
  43493. get autoTransitionRange(): boolean;
  43494. /**
  43495. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43496. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43497. */
  43498. set autoTransitionRange(value: boolean);
  43499. private _attachedCamera;
  43500. private _onAfterCheckInputsObserver;
  43501. private _onMeshTargetChangedObserver;
  43502. /**
  43503. * Initializes the behavior.
  43504. */
  43505. init(): void;
  43506. /**
  43507. * Attaches the behavior to its arc rotate camera.
  43508. * @param camera Defines the camera to attach the behavior to
  43509. */
  43510. attach(camera: ArcRotateCamera): void;
  43511. /**
  43512. * Detaches the behavior from its current arc rotate camera.
  43513. */
  43514. detach(): void;
  43515. private _radiusIsAnimating;
  43516. private _radiusBounceTransition;
  43517. private _animatables;
  43518. private _cachedWheelPrecision;
  43519. /**
  43520. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43521. * @param radiusLimit The limit to check against.
  43522. * @return Bool to indicate if at limit.
  43523. */
  43524. private _isRadiusAtLimit;
  43525. /**
  43526. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43527. * @param radiusDelta The delta by which to animate to. Can be negative.
  43528. */
  43529. private _applyBoundRadiusAnimation;
  43530. /**
  43531. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43532. */
  43533. protected _clearAnimationLocks(): void;
  43534. /**
  43535. * Stops and removes all animations that have been applied to the camera
  43536. */
  43537. stopAllAnimations(): void;
  43538. }
  43539. }
  43540. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43541. import { Behavior } from "babylonjs/Behaviors/behavior";
  43542. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43543. import { ExponentialEase } from "babylonjs/Animations/easing";
  43544. import { Nullable } from "babylonjs/types";
  43545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43546. import { Vector3 } from "babylonjs/Maths/math.vector";
  43547. /**
  43548. * 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.
  43549. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43550. */
  43551. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43552. /**
  43553. * Gets the name of the behavior.
  43554. */
  43555. get name(): string;
  43556. private _mode;
  43557. private _radiusScale;
  43558. private _positionScale;
  43559. private _defaultElevation;
  43560. private _elevationReturnTime;
  43561. private _elevationReturnWaitTime;
  43562. private _zoomStopsAnimation;
  43563. private _framingTime;
  43564. /**
  43565. * The easing function used by animations
  43566. */
  43567. static EasingFunction: ExponentialEase;
  43568. /**
  43569. * The easing mode used by animations
  43570. */
  43571. static EasingMode: number;
  43572. /**
  43573. * Sets the current mode used by the behavior
  43574. */
  43575. set mode(mode: number);
  43576. /**
  43577. * Gets current mode used by the behavior.
  43578. */
  43579. get mode(): number;
  43580. /**
  43581. * Sets the scale applied to the radius (1 by default)
  43582. */
  43583. set radiusScale(radius: number);
  43584. /**
  43585. * Gets the scale applied to the radius
  43586. */
  43587. get radiusScale(): number;
  43588. /**
  43589. * Sets 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. set positionScale(scale: number);
  43592. /**
  43593. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43594. */
  43595. get positionScale(): number;
  43596. /**
  43597. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43598. * behaviour is triggered, in radians.
  43599. */
  43600. set defaultElevation(elevation: number);
  43601. /**
  43602. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43603. * behaviour is triggered, in radians.
  43604. */
  43605. get defaultElevation(): number;
  43606. /**
  43607. * Sets the time (in milliseconds) taken to return to the default beta position.
  43608. * Negative value indicates camera should not return to default.
  43609. */
  43610. set elevationReturnTime(speed: number);
  43611. /**
  43612. * Gets the time (in milliseconds) taken to return to the default beta position.
  43613. * Negative value indicates camera should not return to default.
  43614. */
  43615. get elevationReturnTime(): number;
  43616. /**
  43617. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43618. */
  43619. set elevationReturnWaitTime(time: number);
  43620. /**
  43621. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43622. */
  43623. get elevationReturnWaitTime(): number;
  43624. /**
  43625. * Sets the flag that indicates if user zooming should stop animation.
  43626. */
  43627. set zoomStopsAnimation(flag: boolean);
  43628. /**
  43629. * Gets the flag that indicates if user zooming should stop animation.
  43630. */
  43631. get zoomStopsAnimation(): boolean;
  43632. /**
  43633. * Sets the transition time when framing the mesh, in milliseconds
  43634. */
  43635. set framingTime(time: number);
  43636. /**
  43637. * Gets the transition time when framing the mesh, in milliseconds
  43638. */
  43639. get framingTime(): number;
  43640. /**
  43641. * Define if the behavior should automatically change the configured
  43642. * camera limits and sensibilities.
  43643. */
  43644. autoCorrectCameraLimitsAndSensibility: boolean;
  43645. private _onPrePointerObservableObserver;
  43646. private _onAfterCheckInputsObserver;
  43647. private _onMeshTargetChangedObserver;
  43648. private _attachedCamera;
  43649. private _isPointerDown;
  43650. private _lastInteractionTime;
  43651. /**
  43652. * Initializes the behavior.
  43653. */
  43654. init(): void;
  43655. /**
  43656. * Attaches the behavior to its arc rotate camera.
  43657. * @param camera Defines the camera to attach the behavior to
  43658. */
  43659. attach(camera: ArcRotateCamera): void;
  43660. /**
  43661. * Detaches the behavior from its current arc rotate camera.
  43662. */
  43663. detach(): void;
  43664. private _animatables;
  43665. private _betaIsAnimating;
  43666. private _betaTransition;
  43667. private _radiusTransition;
  43668. private _vectorTransition;
  43669. /**
  43670. * Targets the given mesh and updates zoom level accordingly.
  43671. * @param mesh The mesh to target.
  43672. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43673. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43674. */
  43675. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43676. /**
  43677. * Targets the given mesh with its children and updates zoom level accordingly.
  43678. * @param mesh The mesh to target.
  43679. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43680. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43681. */
  43682. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43683. /**
  43684. * Targets the given meshes with their children and updates zoom level accordingly.
  43685. * @param meshes The mesh to target.
  43686. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43687. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43688. */
  43689. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43690. /**
  43691. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43692. * @param minimumWorld Determines the smaller position of the bounding box extend
  43693. * @param maximumWorld Determines the bigger position of the bounding box extend
  43694. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43695. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43696. */
  43697. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43698. /**
  43699. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43700. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43701. * frustum width.
  43702. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43703. * to fully enclose the mesh in the viewing frustum.
  43704. */
  43705. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43706. /**
  43707. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43708. * is automatically returned to its default position (expected to be above ground plane).
  43709. */
  43710. private _maintainCameraAboveGround;
  43711. /**
  43712. * Returns the frustum slope based on the canvas ratio and camera FOV
  43713. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43714. */
  43715. private _getFrustumSlope;
  43716. /**
  43717. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43718. */
  43719. private _clearAnimationLocks;
  43720. /**
  43721. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43722. */
  43723. private _applyUserInteraction;
  43724. /**
  43725. * Stops and removes all animations that have been applied to the camera
  43726. */
  43727. stopAllAnimations(): void;
  43728. /**
  43729. * Gets a value indicating if the user is moving the camera
  43730. */
  43731. get isUserIsMoving(): boolean;
  43732. /**
  43733. * The camera can move all the way towards the mesh.
  43734. */
  43735. static IgnoreBoundsSizeMode: number;
  43736. /**
  43737. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43738. */
  43739. static FitFrustumSidesMode: number;
  43740. }
  43741. }
  43742. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43743. import { Nullable } from "babylonjs/types";
  43744. import { Camera } from "babylonjs/Cameras/camera";
  43745. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43746. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43747. /**
  43748. * Base class for Camera Pointer Inputs.
  43749. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43750. * for example usage.
  43751. */
  43752. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43753. /**
  43754. * Defines the camera the input is attached to.
  43755. */
  43756. abstract camera: Camera;
  43757. /**
  43758. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43759. */
  43760. protected _altKey: boolean;
  43761. protected _ctrlKey: boolean;
  43762. protected _metaKey: boolean;
  43763. protected _shiftKey: boolean;
  43764. /**
  43765. * Which mouse buttons were pressed at time of last mouse event.
  43766. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43767. */
  43768. protected _buttonsPressed: number;
  43769. /**
  43770. * Defines the buttons associated with the input to handle camera move.
  43771. */
  43772. buttons: number[];
  43773. /**
  43774. * Attach the input controls to a specific dom element to get the input from.
  43775. * @param element Defines the element the controls should be listened from
  43776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43777. */
  43778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43779. /**
  43780. * Detach the current controls from the specified dom element.
  43781. * @param element Defines the element to stop listening the inputs from
  43782. */
  43783. detachControl(element: Nullable<HTMLElement>): void;
  43784. /**
  43785. * Gets the class name of the current input.
  43786. * @returns the class name
  43787. */
  43788. getClassName(): string;
  43789. /**
  43790. * Get the friendly name associated with the input class.
  43791. * @returns the input friendly name
  43792. */
  43793. getSimpleName(): string;
  43794. /**
  43795. * Called on pointer POINTERDOUBLETAP event.
  43796. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43797. */
  43798. protected onDoubleTap(type: string): void;
  43799. /**
  43800. * Called on pointer POINTERMOVE event if only a single touch is active.
  43801. * Override this method to provide functionality.
  43802. */
  43803. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43804. /**
  43805. * Called on pointer POINTERMOVE event if multiple touches are active.
  43806. * Override this method to provide functionality.
  43807. */
  43808. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43809. /**
  43810. * Called on JS contextmenu event.
  43811. * Override this method to provide functionality.
  43812. */
  43813. protected onContextMenu(evt: PointerEvent): void;
  43814. /**
  43815. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43816. * press.
  43817. * Override this method to provide functionality.
  43818. */
  43819. protected onButtonDown(evt: PointerEvent): void;
  43820. /**
  43821. * Called each time a new POINTERUP event occurs. Ie, for each button
  43822. * release.
  43823. * Override this method to provide functionality.
  43824. */
  43825. protected onButtonUp(evt: PointerEvent): void;
  43826. /**
  43827. * Called when window becomes inactive.
  43828. * Override this method to provide functionality.
  43829. */
  43830. protected onLostFocus(): void;
  43831. private _pointerInput;
  43832. private _observer;
  43833. private _onLostFocus;
  43834. private pointA;
  43835. private pointB;
  43836. }
  43837. }
  43838. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43839. import { Nullable } from "babylonjs/types";
  43840. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43841. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43842. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43843. /**
  43844. * Manage the pointers inputs to control an arc rotate camera.
  43845. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43846. */
  43847. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43848. /**
  43849. * Defines the camera the input is attached to.
  43850. */
  43851. camera: ArcRotateCamera;
  43852. /**
  43853. * Gets the class name of the current input.
  43854. * @returns the class name
  43855. */
  43856. getClassName(): string;
  43857. /**
  43858. * Defines the buttons associated with the input to handle camera move.
  43859. */
  43860. buttons: number[];
  43861. /**
  43862. * Defines the pointer angular sensibility along the X axis or how fast is
  43863. * the camera rotating.
  43864. */
  43865. angularSensibilityX: number;
  43866. /**
  43867. * Defines the pointer angular sensibility along the Y axis or how fast is
  43868. * the camera rotating.
  43869. */
  43870. angularSensibilityY: number;
  43871. /**
  43872. * Defines the pointer pinch precision or how fast is the camera zooming.
  43873. */
  43874. pinchPrecision: number;
  43875. /**
  43876. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43877. * from 0.
  43878. * It defines the percentage of current camera.radius to use as delta when
  43879. * pinch zoom is used.
  43880. */
  43881. pinchDeltaPercentage: number;
  43882. /**
  43883. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43884. * that any object in the plane at the camera's target point will scale
  43885. * perfectly with finger motion.
  43886. * Overrides pinchDeltaPercentage and pinchPrecision.
  43887. */
  43888. useNaturalPinchZoom: boolean;
  43889. /**
  43890. * Defines the pointer panning sensibility or how fast is the camera moving.
  43891. */
  43892. panningSensibility: number;
  43893. /**
  43894. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43895. */
  43896. multiTouchPanning: boolean;
  43897. /**
  43898. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43899. * zoom (pinch) through multitouch.
  43900. */
  43901. multiTouchPanAndZoom: boolean;
  43902. /**
  43903. * Revers pinch action direction.
  43904. */
  43905. pinchInwards: boolean;
  43906. private _isPanClick;
  43907. private _twoFingerActivityCount;
  43908. private _isPinching;
  43909. /**
  43910. * Called on pointer POINTERMOVE event if only a single touch is active.
  43911. */
  43912. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43913. /**
  43914. * Called on pointer POINTERDOUBLETAP event.
  43915. */
  43916. protected onDoubleTap(type: string): void;
  43917. /**
  43918. * Called on pointer POINTERMOVE event if multiple touches are active.
  43919. */
  43920. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43921. /**
  43922. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43923. * press.
  43924. */
  43925. protected onButtonDown(evt: PointerEvent): void;
  43926. /**
  43927. * Called each time a new POINTERUP event occurs. Ie, for each button
  43928. * release.
  43929. */
  43930. protected onButtonUp(evt: PointerEvent): void;
  43931. /**
  43932. * Called when window becomes inactive.
  43933. */
  43934. protected onLostFocus(): void;
  43935. }
  43936. }
  43937. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43938. import { Nullable } from "babylonjs/types";
  43939. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43940. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43941. /**
  43942. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43943. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43944. */
  43945. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43946. /**
  43947. * Defines the camera the input is attached to.
  43948. */
  43949. camera: ArcRotateCamera;
  43950. /**
  43951. * Defines the list of key codes associated with the up action (increase alpha)
  43952. */
  43953. keysUp: number[];
  43954. /**
  43955. * Defines the list of key codes associated with the down action (decrease alpha)
  43956. */
  43957. keysDown: number[];
  43958. /**
  43959. * Defines the list of key codes associated with the left action (increase beta)
  43960. */
  43961. keysLeft: number[];
  43962. /**
  43963. * Defines the list of key codes associated with the right action (decrease beta)
  43964. */
  43965. keysRight: number[];
  43966. /**
  43967. * Defines the list of key codes associated with the reset action.
  43968. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43969. */
  43970. keysReset: number[];
  43971. /**
  43972. * Defines the panning sensibility of the inputs.
  43973. * (How fast is the camera panning)
  43974. */
  43975. panningSensibility: number;
  43976. /**
  43977. * Defines the zooming sensibility of the inputs.
  43978. * (How fast is the camera zooming)
  43979. */
  43980. zoomingSensibility: number;
  43981. /**
  43982. * Defines whether maintaining the alt key down switch the movement mode from
  43983. * orientation to zoom.
  43984. */
  43985. useAltToZoom: boolean;
  43986. /**
  43987. * Rotation speed of the camera
  43988. */
  43989. angularSpeed: number;
  43990. private _keys;
  43991. private _ctrlPressed;
  43992. private _altPressed;
  43993. private _onCanvasBlurObserver;
  43994. private _onKeyboardObserver;
  43995. private _engine;
  43996. private _scene;
  43997. /**
  43998. * Attach the input controls to a specific dom element to get the input from.
  43999. * @param element Defines the element the controls should be listened from
  44000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44001. */
  44002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44003. /**
  44004. * Detach the current controls from the specified dom element.
  44005. * @param element Defines the element to stop listening the inputs from
  44006. */
  44007. detachControl(element: Nullable<HTMLElement>): void;
  44008. /**
  44009. * Update the current camera state depending on the inputs that have been used this frame.
  44010. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44011. */
  44012. checkInputs(): void;
  44013. /**
  44014. * Gets the class name of the current intput.
  44015. * @returns the class name
  44016. */
  44017. getClassName(): string;
  44018. /**
  44019. * Get the friendly name associated with the input class.
  44020. * @returns the input friendly name
  44021. */
  44022. getSimpleName(): string;
  44023. }
  44024. }
  44025. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44026. import { Nullable } from "babylonjs/types";
  44027. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44028. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44029. /**
  44030. * Manage the mouse wheel inputs to control an arc rotate camera.
  44031. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44032. */
  44033. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44034. /**
  44035. * Defines the camera the input is attached to.
  44036. */
  44037. camera: ArcRotateCamera;
  44038. /**
  44039. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44040. */
  44041. wheelPrecision: number;
  44042. /**
  44043. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44044. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44045. */
  44046. wheelDeltaPercentage: number;
  44047. private _wheel;
  44048. private _observer;
  44049. private computeDeltaFromMouseWheelLegacyEvent;
  44050. /**
  44051. * Attach the input controls to a specific dom element to get the input from.
  44052. * @param element Defines the element the controls should be listened from
  44053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44054. */
  44055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44056. /**
  44057. * Detach the current controls from the specified dom element.
  44058. * @param element Defines the element to stop listening the inputs from
  44059. */
  44060. detachControl(element: Nullable<HTMLElement>): void;
  44061. /**
  44062. * Gets the class name of the current intput.
  44063. * @returns the class name
  44064. */
  44065. getClassName(): string;
  44066. /**
  44067. * Get the friendly name associated with the input class.
  44068. * @returns the input friendly name
  44069. */
  44070. getSimpleName(): string;
  44071. }
  44072. }
  44073. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44074. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44075. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44076. /**
  44077. * Default Inputs manager for the ArcRotateCamera.
  44078. * It groups all the default supported inputs for ease of use.
  44079. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44080. */
  44081. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44082. /**
  44083. * Instantiates a new ArcRotateCameraInputsManager.
  44084. * @param camera Defines the camera the inputs belong to
  44085. */
  44086. constructor(camera: ArcRotateCamera);
  44087. /**
  44088. * Add mouse wheel input support to the input manager.
  44089. * @returns the current input manager
  44090. */
  44091. addMouseWheel(): ArcRotateCameraInputsManager;
  44092. /**
  44093. * Add pointers input support to the input manager.
  44094. * @returns the current input manager
  44095. */
  44096. addPointers(): ArcRotateCameraInputsManager;
  44097. /**
  44098. * Add keyboard input support to the input manager.
  44099. * @returns the current input manager
  44100. */
  44101. addKeyboard(): ArcRotateCameraInputsManager;
  44102. }
  44103. }
  44104. declare module "babylonjs/Cameras/arcRotateCamera" {
  44105. import { Observable } from "babylonjs/Misc/observable";
  44106. import { Nullable } from "babylonjs/types";
  44107. import { Scene } from "babylonjs/scene";
  44108. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44110. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44111. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44112. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44113. import { Camera } from "babylonjs/Cameras/camera";
  44114. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44115. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44116. import { Collider } from "babylonjs/Collisions/collider";
  44117. /**
  44118. * This represents an orbital type of camera.
  44119. *
  44120. * 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.
  44121. * 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.
  44122. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44123. */
  44124. export class ArcRotateCamera extends TargetCamera {
  44125. /**
  44126. * Defines the rotation angle of the camera along the longitudinal axis.
  44127. */
  44128. alpha: number;
  44129. /**
  44130. * Defines the rotation angle of the camera along the latitudinal axis.
  44131. */
  44132. beta: number;
  44133. /**
  44134. * Defines the radius of the camera from it s target point.
  44135. */
  44136. radius: number;
  44137. protected _target: Vector3;
  44138. protected _targetHost: Nullable<AbstractMesh>;
  44139. /**
  44140. * Defines the target point of the camera.
  44141. * The camera looks towards it form the radius distance.
  44142. */
  44143. get target(): Vector3;
  44144. set target(value: Vector3);
  44145. /**
  44146. * Define the current local position of the camera in the scene
  44147. */
  44148. get position(): Vector3;
  44149. set position(newPosition: Vector3);
  44150. protected _upVector: Vector3;
  44151. protected _upToYMatrix: Matrix;
  44152. protected _YToUpMatrix: Matrix;
  44153. /**
  44154. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44155. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44156. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44157. */
  44158. set upVector(vec: Vector3);
  44159. get upVector(): Vector3;
  44160. /**
  44161. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44162. */
  44163. setMatUp(): void;
  44164. /**
  44165. * Current inertia value on the longitudinal axis.
  44166. * The bigger this number the longer it will take for the camera to stop.
  44167. */
  44168. inertialAlphaOffset: number;
  44169. /**
  44170. * Current inertia value on the latitudinal axis.
  44171. * The bigger this number the longer it will take for the camera to stop.
  44172. */
  44173. inertialBetaOffset: number;
  44174. /**
  44175. * Current inertia value on the radius axis.
  44176. * The bigger this number the longer it will take for the camera to stop.
  44177. */
  44178. inertialRadiusOffset: number;
  44179. /**
  44180. * Minimum allowed angle on the longitudinal axis.
  44181. * This can help limiting how the Camera is able to move in the scene.
  44182. */
  44183. lowerAlphaLimit: Nullable<number>;
  44184. /**
  44185. * Maximum allowed angle on the longitudinal axis.
  44186. * This can help limiting how the Camera is able to move in the scene.
  44187. */
  44188. upperAlphaLimit: Nullable<number>;
  44189. /**
  44190. * Minimum allowed angle on the latitudinal axis.
  44191. * This can help limiting how the Camera is able to move in the scene.
  44192. */
  44193. lowerBetaLimit: number;
  44194. /**
  44195. * Maximum allowed angle on the latitudinal axis.
  44196. * This can help limiting how the Camera is able to move in the scene.
  44197. */
  44198. upperBetaLimit: number;
  44199. /**
  44200. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44201. * This can help limiting how the Camera is able to move in the scene.
  44202. */
  44203. lowerRadiusLimit: Nullable<number>;
  44204. /**
  44205. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44206. * This can help limiting how the Camera is able to move in the scene.
  44207. */
  44208. upperRadiusLimit: Nullable<number>;
  44209. /**
  44210. * Defines the current inertia value used during panning of the camera along the X axis.
  44211. */
  44212. inertialPanningX: number;
  44213. /**
  44214. * Defines the current inertia value used during panning of the camera along the Y axis.
  44215. */
  44216. inertialPanningY: number;
  44217. /**
  44218. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44219. * Basically if your fingers moves away from more than this distance you will be considered
  44220. * in pinch mode.
  44221. */
  44222. pinchToPanMaxDistance: number;
  44223. /**
  44224. * Defines the maximum distance the camera can pan.
  44225. * This could help keeping the cammera always in your scene.
  44226. */
  44227. panningDistanceLimit: Nullable<number>;
  44228. /**
  44229. * Defines the target of the camera before paning.
  44230. */
  44231. panningOriginTarget: Vector3;
  44232. /**
  44233. * Defines the value of the inertia used during panning.
  44234. * 0 would mean stop inertia and one would mean no decelleration at all.
  44235. */
  44236. panningInertia: number;
  44237. /**
  44238. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44239. */
  44240. get angularSensibilityX(): number;
  44241. set angularSensibilityX(value: number);
  44242. /**
  44243. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44244. */
  44245. get angularSensibilityY(): number;
  44246. set angularSensibilityY(value: number);
  44247. /**
  44248. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44249. */
  44250. get pinchPrecision(): number;
  44251. set pinchPrecision(value: number);
  44252. /**
  44253. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44254. * It will be used instead of pinchDeltaPrecision if different from 0.
  44255. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44256. */
  44257. get pinchDeltaPercentage(): number;
  44258. set pinchDeltaPercentage(value: number);
  44259. /**
  44260. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44261. * and pinch delta percentage.
  44262. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44263. * that any object in the plane at the camera's target point will scale
  44264. * perfectly with finger motion.
  44265. */
  44266. get useNaturalPinchZoom(): boolean;
  44267. set useNaturalPinchZoom(value: boolean);
  44268. /**
  44269. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44270. */
  44271. get panningSensibility(): number;
  44272. set panningSensibility(value: number);
  44273. /**
  44274. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44275. */
  44276. get keysUp(): number[];
  44277. set keysUp(value: number[]);
  44278. /**
  44279. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44280. */
  44281. get keysDown(): number[];
  44282. set keysDown(value: number[]);
  44283. /**
  44284. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44285. */
  44286. get keysLeft(): number[];
  44287. set keysLeft(value: number[]);
  44288. /**
  44289. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44290. */
  44291. get keysRight(): number[];
  44292. set keysRight(value: number[]);
  44293. /**
  44294. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44295. */
  44296. get wheelPrecision(): number;
  44297. set wheelPrecision(value: number);
  44298. /**
  44299. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44300. * It will be used instead of pinchDeltaPrecision if different from 0.
  44301. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44302. */
  44303. get wheelDeltaPercentage(): number;
  44304. set wheelDeltaPercentage(value: number);
  44305. /**
  44306. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44307. */
  44308. zoomOnFactor: number;
  44309. /**
  44310. * Defines a screen offset for the camera position.
  44311. */
  44312. targetScreenOffset: Vector2;
  44313. /**
  44314. * Allows the camera to be completely reversed.
  44315. * If false the camera can not arrive upside down.
  44316. */
  44317. allowUpsideDown: boolean;
  44318. /**
  44319. * Define if double tap/click is used to restore the previously saved state of the camera.
  44320. */
  44321. useInputToRestoreState: boolean;
  44322. /** @hidden */
  44323. _viewMatrix: Matrix;
  44324. /** @hidden */
  44325. _useCtrlForPanning: boolean;
  44326. /** @hidden */
  44327. _panningMouseButton: number;
  44328. /**
  44329. * Defines the input associated to the camera.
  44330. */
  44331. inputs: ArcRotateCameraInputsManager;
  44332. /** @hidden */
  44333. _reset: () => void;
  44334. /**
  44335. * Defines the allowed panning axis.
  44336. */
  44337. panningAxis: Vector3;
  44338. protected _localDirection: Vector3;
  44339. protected _transformedDirection: Vector3;
  44340. private _bouncingBehavior;
  44341. /**
  44342. * Gets the bouncing behavior of the camera if it has been enabled.
  44343. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44344. */
  44345. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44346. /**
  44347. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44348. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44349. */
  44350. get useBouncingBehavior(): boolean;
  44351. set useBouncingBehavior(value: boolean);
  44352. private _framingBehavior;
  44353. /**
  44354. * Gets the framing behavior of the camera if it has been enabled.
  44355. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44356. */
  44357. get framingBehavior(): Nullable<FramingBehavior>;
  44358. /**
  44359. * Defines if the framing behavior of the camera is enabled on the camera.
  44360. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44361. */
  44362. get useFramingBehavior(): boolean;
  44363. set useFramingBehavior(value: boolean);
  44364. private _autoRotationBehavior;
  44365. /**
  44366. * Gets the auto rotation behavior of the camera if it has been enabled.
  44367. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44368. */
  44369. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44370. /**
  44371. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44372. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44373. */
  44374. get useAutoRotationBehavior(): boolean;
  44375. set useAutoRotationBehavior(value: boolean);
  44376. /**
  44377. * Observable triggered when the mesh target has been changed on the camera.
  44378. */
  44379. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44380. /**
  44381. * Event raised when the camera is colliding with a mesh.
  44382. */
  44383. onCollide: (collidedMesh: AbstractMesh) => void;
  44384. /**
  44385. * Defines whether the camera should check collision with the objects oh the scene.
  44386. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44387. */
  44388. checkCollisions: boolean;
  44389. /**
  44390. * Defines the collision radius of the camera.
  44391. * This simulates a sphere around the camera.
  44392. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44393. */
  44394. collisionRadius: Vector3;
  44395. protected _collider: Collider;
  44396. protected _previousPosition: Vector3;
  44397. protected _collisionVelocity: Vector3;
  44398. protected _newPosition: Vector3;
  44399. protected _previousAlpha: number;
  44400. protected _previousBeta: number;
  44401. protected _previousRadius: number;
  44402. protected _collisionTriggered: boolean;
  44403. protected _targetBoundingCenter: Nullable<Vector3>;
  44404. private _computationVector;
  44405. /**
  44406. * Instantiates a new ArcRotateCamera in a given scene
  44407. * @param name Defines the name of the camera
  44408. * @param alpha Defines the camera rotation along the logitudinal axis
  44409. * @param beta Defines the camera rotation along the latitudinal axis
  44410. * @param radius Defines the camera distance from its target
  44411. * @param target Defines the camera target
  44412. * @param scene Defines the scene the camera belongs to
  44413. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44414. */
  44415. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44416. /** @hidden */
  44417. _initCache(): void;
  44418. /** @hidden */
  44419. _updateCache(ignoreParentClass?: boolean): void;
  44420. protected _getTargetPosition(): Vector3;
  44421. private _storedAlpha;
  44422. private _storedBeta;
  44423. private _storedRadius;
  44424. private _storedTarget;
  44425. private _storedTargetScreenOffset;
  44426. /**
  44427. * Stores the current state of the camera (alpha, beta, radius and target)
  44428. * @returns the camera itself
  44429. */
  44430. storeState(): Camera;
  44431. /**
  44432. * @hidden
  44433. * Restored camera state. You must call storeState() first
  44434. */
  44435. _restoreStateValues(): boolean;
  44436. /** @hidden */
  44437. _isSynchronizedViewMatrix(): boolean;
  44438. /**
  44439. * Attached controls to the current camera.
  44440. * @param element Defines the element the controls should be listened from
  44441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44442. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44443. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44444. */
  44445. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44446. /**
  44447. * Detach the current controls from the camera.
  44448. * The camera will stop reacting to inputs.
  44449. * @param element Defines the element to stop listening the inputs from
  44450. */
  44451. detachControl(element: HTMLElement): void;
  44452. /** @hidden */
  44453. _checkInputs(): void;
  44454. protected _checkLimits(): void;
  44455. /**
  44456. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44457. */
  44458. rebuildAnglesAndRadius(): void;
  44459. /**
  44460. * Use a position to define the current camera related information like alpha, beta and radius
  44461. * @param position Defines the position to set the camera at
  44462. */
  44463. setPosition(position: Vector3): void;
  44464. /**
  44465. * Defines the target the camera should look at.
  44466. * This will automatically adapt alpha beta and radius to fit within the new target.
  44467. * @param target Defines the new target as a Vector or a mesh
  44468. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44469. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44470. */
  44471. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44472. /** @hidden */
  44473. _getViewMatrix(): Matrix;
  44474. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44475. /**
  44476. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44477. * @param meshes Defines the mesh to zoom on
  44478. * @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)
  44479. */
  44480. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44481. /**
  44482. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44483. * The target will be changed but the radius
  44484. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44485. * @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)
  44486. */
  44487. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44488. min: Vector3;
  44489. max: Vector3;
  44490. distance: number;
  44491. }, doNotUpdateMaxZ?: boolean): void;
  44492. /**
  44493. * @override
  44494. * Override Camera.createRigCamera
  44495. */
  44496. createRigCamera(name: string, cameraIndex: number): Camera;
  44497. /**
  44498. * @hidden
  44499. * @override
  44500. * Override Camera._updateRigCameras
  44501. */
  44502. _updateRigCameras(): void;
  44503. /**
  44504. * Destroy the camera and release the current resources hold by it.
  44505. */
  44506. dispose(): void;
  44507. /**
  44508. * Gets the current object class name.
  44509. * @return the class name
  44510. */
  44511. getClassName(): string;
  44512. }
  44513. }
  44514. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44515. import { Behavior } from "babylonjs/Behaviors/behavior";
  44516. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44517. /**
  44518. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44519. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44520. */
  44521. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44522. /**
  44523. * Gets the name of the behavior.
  44524. */
  44525. get name(): string;
  44526. private _zoomStopsAnimation;
  44527. private _idleRotationSpeed;
  44528. private _idleRotationWaitTime;
  44529. private _idleRotationSpinupTime;
  44530. /**
  44531. * Sets the flag that indicates if user zooming should stop animation.
  44532. */
  44533. set zoomStopsAnimation(flag: boolean);
  44534. /**
  44535. * Gets the flag that indicates if user zooming should stop animation.
  44536. */
  44537. get zoomStopsAnimation(): boolean;
  44538. /**
  44539. * Sets the default speed at which the camera rotates around the model.
  44540. */
  44541. set idleRotationSpeed(speed: number);
  44542. /**
  44543. * Gets the default speed at which the camera rotates around the model.
  44544. */
  44545. get idleRotationSpeed(): number;
  44546. /**
  44547. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44548. */
  44549. set idleRotationWaitTime(time: number);
  44550. /**
  44551. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44552. */
  44553. get idleRotationWaitTime(): number;
  44554. /**
  44555. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44556. */
  44557. set idleRotationSpinupTime(time: number);
  44558. /**
  44559. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44560. */
  44561. get idleRotationSpinupTime(): number;
  44562. /**
  44563. * Gets a value indicating if the camera is currently rotating because of this behavior
  44564. */
  44565. get rotationInProgress(): boolean;
  44566. private _onPrePointerObservableObserver;
  44567. private _onAfterCheckInputsObserver;
  44568. private _attachedCamera;
  44569. private _isPointerDown;
  44570. private _lastFrameTime;
  44571. private _lastInteractionTime;
  44572. private _cameraRotationSpeed;
  44573. /**
  44574. * Initializes the behavior.
  44575. */
  44576. init(): void;
  44577. /**
  44578. * Attaches the behavior to its arc rotate camera.
  44579. * @param camera Defines the camera to attach the behavior to
  44580. */
  44581. attach(camera: ArcRotateCamera): void;
  44582. /**
  44583. * Detaches the behavior from its current arc rotate camera.
  44584. */
  44585. detach(): void;
  44586. /**
  44587. * Returns true if user is scrolling.
  44588. * @return true if user is scrolling.
  44589. */
  44590. private _userIsZooming;
  44591. private _lastFrameRadius;
  44592. private _shouldAnimationStopForInteraction;
  44593. /**
  44594. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44595. */
  44596. private _applyUserInteraction;
  44597. private _userIsMoving;
  44598. }
  44599. }
  44600. declare module "babylonjs/Behaviors/Cameras/index" {
  44601. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44602. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44603. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44604. }
  44605. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44606. import { Mesh } from "babylonjs/Meshes/mesh";
  44607. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44608. import { Behavior } from "babylonjs/Behaviors/behavior";
  44609. /**
  44610. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44611. */
  44612. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44613. private ui;
  44614. /**
  44615. * The name of the behavior
  44616. */
  44617. name: string;
  44618. /**
  44619. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44620. */
  44621. distanceAwayFromFace: number;
  44622. /**
  44623. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44624. */
  44625. distanceAwayFromBottomOfFace: number;
  44626. private _faceVectors;
  44627. private _target;
  44628. private _scene;
  44629. private _onRenderObserver;
  44630. private _tmpMatrix;
  44631. private _tmpVector;
  44632. /**
  44633. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44634. * @param ui The transform node that should be attched to the mesh
  44635. */
  44636. constructor(ui: TransformNode);
  44637. /**
  44638. * Initializes the behavior
  44639. */
  44640. init(): void;
  44641. private _closestFace;
  44642. private _zeroVector;
  44643. private _lookAtTmpMatrix;
  44644. private _lookAtToRef;
  44645. /**
  44646. * Attaches the AttachToBoxBehavior to the passed in mesh
  44647. * @param target The mesh that the specified node will be attached to
  44648. */
  44649. attach(target: Mesh): void;
  44650. /**
  44651. * Detaches the behavior from the mesh
  44652. */
  44653. detach(): void;
  44654. }
  44655. }
  44656. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44657. import { Behavior } from "babylonjs/Behaviors/behavior";
  44658. import { Mesh } from "babylonjs/Meshes/mesh";
  44659. /**
  44660. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44661. */
  44662. export class FadeInOutBehavior implements Behavior<Mesh> {
  44663. /**
  44664. * Time in milliseconds to delay before fading in (Default: 0)
  44665. */
  44666. delay: number;
  44667. /**
  44668. * Time in milliseconds for the mesh to fade in (Default: 300)
  44669. */
  44670. fadeInTime: number;
  44671. private _millisecondsPerFrame;
  44672. private _hovered;
  44673. private _hoverValue;
  44674. private _ownerNode;
  44675. /**
  44676. * Instatiates the FadeInOutBehavior
  44677. */
  44678. constructor();
  44679. /**
  44680. * The name of the behavior
  44681. */
  44682. get name(): string;
  44683. /**
  44684. * Initializes the behavior
  44685. */
  44686. init(): void;
  44687. /**
  44688. * Attaches the fade behavior on the passed in mesh
  44689. * @param ownerNode The mesh that will be faded in/out once attached
  44690. */
  44691. attach(ownerNode: Mesh): void;
  44692. /**
  44693. * Detaches the behavior from the mesh
  44694. */
  44695. detach(): void;
  44696. /**
  44697. * Triggers the mesh to begin fading in or out
  44698. * @param value if the object should fade in or out (true to fade in)
  44699. */
  44700. fadeIn(value: boolean): void;
  44701. private _update;
  44702. private _setAllVisibility;
  44703. }
  44704. }
  44705. declare module "babylonjs/Misc/pivotTools" {
  44706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44707. /**
  44708. * Class containing a set of static utilities functions for managing Pivots
  44709. * @hidden
  44710. */
  44711. export class PivotTools {
  44712. private static _PivotCached;
  44713. private static _OldPivotPoint;
  44714. private static _PivotTranslation;
  44715. private static _PivotTmpVector;
  44716. /** @hidden */
  44717. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44718. /** @hidden */
  44719. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44720. }
  44721. }
  44722. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44723. import { Scene } from "babylonjs/scene";
  44724. import { Vector4 } from "babylonjs/Maths/math.vector";
  44725. import { Mesh } from "babylonjs/Meshes/mesh";
  44726. import { Nullable } from "babylonjs/types";
  44727. import { Plane } from "babylonjs/Maths/math.plane";
  44728. /**
  44729. * Class containing static functions to help procedurally build meshes
  44730. */
  44731. export class PlaneBuilder {
  44732. /**
  44733. * Creates a plane mesh
  44734. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44735. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44736. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44740. * @param name defines the name of the mesh
  44741. * @param options defines the options used to create the mesh
  44742. * @param scene defines the hosting scene
  44743. * @returns the plane mesh
  44744. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44745. */
  44746. static CreatePlane(name: string, options: {
  44747. size?: number;
  44748. width?: number;
  44749. height?: number;
  44750. sideOrientation?: number;
  44751. frontUVs?: Vector4;
  44752. backUVs?: Vector4;
  44753. updatable?: boolean;
  44754. sourcePlane?: Plane;
  44755. }, scene?: Nullable<Scene>): Mesh;
  44756. }
  44757. }
  44758. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44759. import { Behavior } from "babylonjs/Behaviors/behavior";
  44760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44761. import { Observable } from "babylonjs/Misc/observable";
  44762. import { Vector3 } from "babylonjs/Maths/math.vector";
  44763. import { Ray } from "babylonjs/Culling/ray";
  44764. import "babylonjs/Meshes/Builders/planeBuilder";
  44765. /**
  44766. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44767. */
  44768. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44769. private static _AnyMouseID;
  44770. /**
  44771. * Abstract mesh the behavior is set on
  44772. */
  44773. attachedNode: AbstractMesh;
  44774. private _dragPlane;
  44775. private _scene;
  44776. private _pointerObserver;
  44777. private _beforeRenderObserver;
  44778. private static _planeScene;
  44779. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44780. /**
  44781. * 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)
  44782. */
  44783. maxDragAngle: number;
  44784. /**
  44785. * @hidden
  44786. */
  44787. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44788. /**
  44789. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44790. */
  44791. currentDraggingPointerID: number;
  44792. /**
  44793. * The last position where the pointer hit the drag plane in world space
  44794. */
  44795. lastDragPosition: Vector3;
  44796. /**
  44797. * If the behavior is currently in a dragging state
  44798. */
  44799. dragging: boolean;
  44800. /**
  44801. * 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)
  44802. */
  44803. dragDeltaRatio: number;
  44804. /**
  44805. * If the drag plane orientation should be updated during the dragging (Default: true)
  44806. */
  44807. updateDragPlane: boolean;
  44808. private _debugMode;
  44809. private _moving;
  44810. /**
  44811. * Fires each time the attached mesh is dragged with the pointer
  44812. * * delta between last drag position and current drag position in world space
  44813. * * dragDistance along the drag axis
  44814. * * dragPlaneNormal normal of the current drag plane used during the drag
  44815. * * dragPlanePoint in world space where the drag intersects the drag plane
  44816. */
  44817. onDragObservable: Observable<{
  44818. delta: Vector3;
  44819. dragPlanePoint: Vector3;
  44820. dragPlaneNormal: Vector3;
  44821. dragDistance: number;
  44822. pointerId: number;
  44823. }>;
  44824. /**
  44825. * Fires each time a drag begins (eg. mouse down on mesh)
  44826. */
  44827. onDragStartObservable: Observable<{
  44828. dragPlanePoint: Vector3;
  44829. pointerId: number;
  44830. }>;
  44831. /**
  44832. * Fires each time a drag ends (eg. mouse release after drag)
  44833. */
  44834. onDragEndObservable: Observable<{
  44835. dragPlanePoint: Vector3;
  44836. pointerId: number;
  44837. }>;
  44838. /**
  44839. * If the attached mesh should be moved when dragged
  44840. */
  44841. moveAttached: boolean;
  44842. /**
  44843. * If the drag behavior will react to drag events (Default: true)
  44844. */
  44845. enabled: boolean;
  44846. /**
  44847. * If pointer events should start and release the drag (Default: true)
  44848. */
  44849. startAndReleaseDragOnPointerEvents: boolean;
  44850. /**
  44851. * If camera controls should be detached during the drag
  44852. */
  44853. detachCameraControls: boolean;
  44854. /**
  44855. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44856. */
  44857. useObjectOrientationForDragging: boolean;
  44858. private _options;
  44859. /**
  44860. * Gets the options used by the behavior
  44861. */
  44862. get options(): {
  44863. dragAxis?: Vector3;
  44864. dragPlaneNormal?: Vector3;
  44865. };
  44866. /**
  44867. * Sets the options used by the behavior
  44868. */
  44869. set options(options: {
  44870. dragAxis?: Vector3;
  44871. dragPlaneNormal?: Vector3;
  44872. });
  44873. /**
  44874. * Creates a pointer drag behavior that can be attached to a mesh
  44875. * @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)
  44876. */
  44877. constructor(options?: {
  44878. dragAxis?: Vector3;
  44879. dragPlaneNormal?: Vector3;
  44880. });
  44881. /**
  44882. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44883. */
  44884. validateDrag: (targetPosition: Vector3) => boolean;
  44885. /**
  44886. * The name of the behavior
  44887. */
  44888. get name(): string;
  44889. /**
  44890. * Initializes the behavior
  44891. */
  44892. init(): void;
  44893. private _tmpVector;
  44894. private _alternatePickedPoint;
  44895. private _worldDragAxis;
  44896. private _targetPosition;
  44897. private _attachedElement;
  44898. /**
  44899. * Attaches the drag behavior the passed in mesh
  44900. * @param ownerNode The mesh that will be dragged around once attached
  44901. * @param predicate Predicate to use for pick filtering
  44902. */
  44903. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44904. /**
  44905. * Force relase the drag action by code.
  44906. */
  44907. releaseDrag(): void;
  44908. private _startDragRay;
  44909. private _lastPointerRay;
  44910. /**
  44911. * Simulates the start of a pointer drag event on the behavior
  44912. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44913. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44914. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44915. */
  44916. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44917. private _startDrag;
  44918. private _dragDelta;
  44919. private _moveDrag;
  44920. private _pickWithRayOnDragPlane;
  44921. private _pointA;
  44922. private _pointC;
  44923. private _localAxis;
  44924. private _lookAt;
  44925. private _updateDragPlanePosition;
  44926. /**
  44927. * Detaches the behavior from the mesh
  44928. */
  44929. detach(): void;
  44930. }
  44931. }
  44932. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44933. import { Mesh } from "babylonjs/Meshes/mesh";
  44934. import { Behavior } from "babylonjs/Behaviors/behavior";
  44935. /**
  44936. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44937. */
  44938. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44939. private _dragBehaviorA;
  44940. private _dragBehaviorB;
  44941. private _startDistance;
  44942. private _initialScale;
  44943. private _targetScale;
  44944. private _ownerNode;
  44945. private _sceneRenderObserver;
  44946. /**
  44947. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44948. */
  44949. constructor();
  44950. /**
  44951. * The name of the behavior
  44952. */
  44953. get name(): string;
  44954. /**
  44955. * Initializes the behavior
  44956. */
  44957. init(): void;
  44958. private _getCurrentDistance;
  44959. /**
  44960. * Attaches the scale behavior the passed in mesh
  44961. * @param ownerNode The mesh that will be scaled around once attached
  44962. */
  44963. attach(ownerNode: Mesh): void;
  44964. /**
  44965. * Detaches the behavior from the mesh
  44966. */
  44967. detach(): void;
  44968. }
  44969. }
  44970. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44971. import { Behavior } from "babylonjs/Behaviors/behavior";
  44972. import { Mesh } from "babylonjs/Meshes/mesh";
  44973. import { Observable } from "babylonjs/Misc/observable";
  44974. /**
  44975. * 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
  44976. */
  44977. export class SixDofDragBehavior implements Behavior<Mesh> {
  44978. private static _virtualScene;
  44979. private _ownerNode;
  44980. private _sceneRenderObserver;
  44981. private _scene;
  44982. private _targetPosition;
  44983. private _virtualOriginMesh;
  44984. private _virtualDragMesh;
  44985. private _pointerObserver;
  44986. private _moving;
  44987. private _startingOrientation;
  44988. private _attachedElement;
  44989. /**
  44990. * 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)
  44991. */
  44992. private zDragFactor;
  44993. /**
  44994. * If the object should rotate to face the drag origin
  44995. */
  44996. rotateDraggedObject: boolean;
  44997. /**
  44998. * If the behavior is currently in a dragging state
  44999. */
  45000. dragging: boolean;
  45001. /**
  45002. * 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)
  45003. */
  45004. dragDeltaRatio: number;
  45005. /**
  45006. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45007. */
  45008. currentDraggingPointerID: number;
  45009. /**
  45010. * If camera controls should be detached during the drag
  45011. */
  45012. detachCameraControls: boolean;
  45013. /**
  45014. * Fires each time a drag starts
  45015. */
  45016. onDragStartObservable: Observable<{}>;
  45017. /**
  45018. * Fires each time a drag ends (eg. mouse release after drag)
  45019. */
  45020. onDragEndObservable: Observable<{}>;
  45021. /**
  45022. * 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
  45023. */
  45024. constructor();
  45025. /**
  45026. * The name of the behavior
  45027. */
  45028. get name(): string;
  45029. /**
  45030. * Initializes the behavior
  45031. */
  45032. init(): void;
  45033. /**
  45034. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45035. */
  45036. private get _pointerCamera();
  45037. /**
  45038. * Attaches the scale behavior the passed in mesh
  45039. * @param ownerNode The mesh that will be scaled around once attached
  45040. */
  45041. attach(ownerNode: Mesh): void;
  45042. /**
  45043. * Detaches the behavior from the mesh
  45044. */
  45045. detach(): void;
  45046. }
  45047. }
  45048. declare module "babylonjs/Behaviors/Meshes/index" {
  45049. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45050. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45051. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45052. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45053. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45054. }
  45055. declare module "babylonjs/Behaviors/index" {
  45056. export * from "babylonjs/Behaviors/behavior";
  45057. export * from "babylonjs/Behaviors/Cameras/index";
  45058. export * from "babylonjs/Behaviors/Meshes/index";
  45059. }
  45060. declare module "babylonjs/Bones/boneIKController" {
  45061. import { Bone } from "babylonjs/Bones/bone";
  45062. import { Vector3 } from "babylonjs/Maths/math.vector";
  45063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45064. import { Nullable } from "babylonjs/types";
  45065. /**
  45066. * Class used to apply inverse kinematics to bones
  45067. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45068. */
  45069. export class BoneIKController {
  45070. private static _tmpVecs;
  45071. private static _tmpQuat;
  45072. private static _tmpMats;
  45073. /**
  45074. * Gets or sets the target mesh
  45075. */
  45076. targetMesh: AbstractMesh;
  45077. /** Gets or sets the mesh used as pole */
  45078. poleTargetMesh: AbstractMesh;
  45079. /**
  45080. * Gets or sets the bone used as pole
  45081. */
  45082. poleTargetBone: Nullable<Bone>;
  45083. /**
  45084. * Gets or sets the target position
  45085. */
  45086. targetPosition: Vector3;
  45087. /**
  45088. * Gets or sets the pole target position
  45089. */
  45090. poleTargetPosition: Vector3;
  45091. /**
  45092. * Gets or sets the pole target local offset
  45093. */
  45094. poleTargetLocalOffset: Vector3;
  45095. /**
  45096. * Gets or sets the pole angle
  45097. */
  45098. poleAngle: number;
  45099. /**
  45100. * Gets or sets the mesh associated with the controller
  45101. */
  45102. mesh: AbstractMesh;
  45103. /**
  45104. * 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)
  45105. */
  45106. slerpAmount: number;
  45107. private _bone1Quat;
  45108. private _bone1Mat;
  45109. private _bone2Ang;
  45110. private _bone1;
  45111. private _bone2;
  45112. private _bone1Length;
  45113. private _bone2Length;
  45114. private _maxAngle;
  45115. private _maxReach;
  45116. private _rightHandedSystem;
  45117. private _bendAxis;
  45118. private _slerping;
  45119. private _adjustRoll;
  45120. /**
  45121. * Gets or sets maximum allowed angle
  45122. */
  45123. get maxAngle(): number;
  45124. set maxAngle(value: number);
  45125. /**
  45126. * Creates a new BoneIKController
  45127. * @param mesh defines the mesh to control
  45128. * @param bone defines the bone to control
  45129. * @param options defines options to set up the controller
  45130. */
  45131. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45132. targetMesh?: AbstractMesh;
  45133. poleTargetMesh?: AbstractMesh;
  45134. poleTargetBone?: Bone;
  45135. poleTargetLocalOffset?: Vector3;
  45136. poleAngle?: number;
  45137. bendAxis?: Vector3;
  45138. maxAngle?: number;
  45139. slerpAmount?: number;
  45140. });
  45141. private _setMaxAngle;
  45142. /**
  45143. * Force the controller to update the bones
  45144. */
  45145. update(): void;
  45146. }
  45147. }
  45148. declare module "babylonjs/Bones/boneLookController" {
  45149. import { Vector3 } from "babylonjs/Maths/math.vector";
  45150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45151. import { Bone } from "babylonjs/Bones/bone";
  45152. import { Space } from "babylonjs/Maths/math.axis";
  45153. /**
  45154. * Class used to make a bone look toward a point in space
  45155. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45156. */
  45157. export class BoneLookController {
  45158. private static _tmpVecs;
  45159. private static _tmpQuat;
  45160. private static _tmpMats;
  45161. /**
  45162. * The target Vector3 that the bone will look at
  45163. */
  45164. target: Vector3;
  45165. /**
  45166. * The mesh that the bone is attached to
  45167. */
  45168. mesh: AbstractMesh;
  45169. /**
  45170. * The bone that will be looking to the target
  45171. */
  45172. bone: Bone;
  45173. /**
  45174. * The up axis of the coordinate system that is used when the bone is rotated
  45175. */
  45176. upAxis: Vector3;
  45177. /**
  45178. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45179. */
  45180. upAxisSpace: Space;
  45181. /**
  45182. * Used to make an adjustment to the yaw of the bone
  45183. */
  45184. adjustYaw: number;
  45185. /**
  45186. * Used to make an adjustment to the pitch of the bone
  45187. */
  45188. adjustPitch: number;
  45189. /**
  45190. * Used to make an adjustment to the roll of the bone
  45191. */
  45192. adjustRoll: number;
  45193. /**
  45194. * 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)
  45195. */
  45196. slerpAmount: number;
  45197. private _minYaw;
  45198. private _maxYaw;
  45199. private _minPitch;
  45200. private _maxPitch;
  45201. private _minYawSin;
  45202. private _minYawCos;
  45203. private _maxYawSin;
  45204. private _maxYawCos;
  45205. private _midYawConstraint;
  45206. private _minPitchTan;
  45207. private _maxPitchTan;
  45208. private _boneQuat;
  45209. private _slerping;
  45210. private _transformYawPitch;
  45211. private _transformYawPitchInv;
  45212. private _firstFrameSkipped;
  45213. private _yawRange;
  45214. private _fowardAxis;
  45215. /**
  45216. * Gets or sets the minimum yaw angle that the bone can look to
  45217. */
  45218. get minYaw(): number;
  45219. set minYaw(value: number);
  45220. /**
  45221. * Gets or sets the maximum yaw angle that the bone can look to
  45222. */
  45223. get maxYaw(): number;
  45224. set maxYaw(value: number);
  45225. /**
  45226. * Gets or sets the minimum pitch angle that the bone can look to
  45227. */
  45228. get minPitch(): number;
  45229. set minPitch(value: number);
  45230. /**
  45231. * Gets or sets the maximum pitch angle that the bone can look to
  45232. */
  45233. get maxPitch(): number;
  45234. set maxPitch(value: number);
  45235. /**
  45236. * Create a BoneLookController
  45237. * @param mesh the mesh that the bone belongs to
  45238. * @param bone the bone that will be looking to the target
  45239. * @param target the target Vector3 to look at
  45240. * @param options optional settings:
  45241. * * maxYaw: the maximum angle the bone will yaw to
  45242. * * minYaw: the minimum angle the bone will yaw to
  45243. * * maxPitch: the maximum angle the bone will pitch to
  45244. * * minPitch: the minimum angle the bone will yaw to
  45245. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45246. * * upAxis: the up axis of the coordinate system
  45247. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45248. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45249. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45250. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45251. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45252. * * adjustRoll: used to make an adjustment to the roll of the bone
  45253. **/
  45254. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45255. maxYaw?: number;
  45256. minYaw?: number;
  45257. maxPitch?: number;
  45258. minPitch?: number;
  45259. slerpAmount?: number;
  45260. upAxis?: Vector3;
  45261. upAxisSpace?: Space;
  45262. yawAxis?: Vector3;
  45263. pitchAxis?: Vector3;
  45264. adjustYaw?: number;
  45265. adjustPitch?: number;
  45266. adjustRoll?: number;
  45267. });
  45268. /**
  45269. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45270. */
  45271. update(): void;
  45272. private _getAngleDiff;
  45273. private _getAngleBetween;
  45274. private _isAngleBetween;
  45275. }
  45276. }
  45277. declare module "babylonjs/Bones/index" {
  45278. export * from "babylonjs/Bones/bone";
  45279. export * from "babylonjs/Bones/boneIKController";
  45280. export * from "babylonjs/Bones/boneLookController";
  45281. export * from "babylonjs/Bones/skeleton";
  45282. }
  45283. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45284. import { Nullable } from "babylonjs/types";
  45285. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45286. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45287. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45288. /**
  45289. * Manage the gamepad inputs to control an arc rotate camera.
  45290. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45291. */
  45292. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45293. /**
  45294. * Defines the camera the input is attached to.
  45295. */
  45296. camera: ArcRotateCamera;
  45297. /**
  45298. * Defines the gamepad the input is gathering event from.
  45299. */
  45300. gamepad: Nullable<Gamepad>;
  45301. /**
  45302. * Defines the gamepad rotation sensiblity.
  45303. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45304. */
  45305. gamepadRotationSensibility: number;
  45306. /**
  45307. * Defines the gamepad move sensiblity.
  45308. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45309. */
  45310. gamepadMoveSensibility: number;
  45311. private _yAxisScale;
  45312. /**
  45313. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45314. */
  45315. get invertYAxis(): boolean;
  45316. set invertYAxis(value: boolean);
  45317. private _onGamepadConnectedObserver;
  45318. private _onGamepadDisconnectedObserver;
  45319. /**
  45320. * Attach the input controls to a specific dom element to get the input from.
  45321. * @param element Defines the element the controls should be listened from
  45322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45323. */
  45324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45325. /**
  45326. * Detach the current controls from the specified dom element.
  45327. * @param element Defines the element to stop listening the inputs from
  45328. */
  45329. detachControl(element: Nullable<HTMLElement>): void;
  45330. /**
  45331. * Update the current camera state depending on the inputs that have been used this frame.
  45332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45333. */
  45334. checkInputs(): void;
  45335. /**
  45336. * Gets the class name of the current intput.
  45337. * @returns the class name
  45338. */
  45339. getClassName(): string;
  45340. /**
  45341. * Get the friendly name associated with the input class.
  45342. * @returns the input friendly name
  45343. */
  45344. getSimpleName(): string;
  45345. }
  45346. }
  45347. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45348. import { Nullable } from "babylonjs/types";
  45349. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45350. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45351. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45352. interface ArcRotateCameraInputsManager {
  45353. /**
  45354. * Add orientation input support to the input manager.
  45355. * @returns the current input manager
  45356. */
  45357. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45358. }
  45359. }
  45360. /**
  45361. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45362. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45363. */
  45364. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45365. /**
  45366. * Defines the camera the input is attached to.
  45367. */
  45368. camera: ArcRotateCamera;
  45369. /**
  45370. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45371. */
  45372. alphaCorrection: number;
  45373. /**
  45374. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45375. */
  45376. gammaCorrection: number;
  45377. private _alpha;
  45378. private _gamma;
  45379. private _dirty;
  45380. private _deviceOrientationHandler;
  45381. /**
  45382. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45383. */
  45384. constructor();
  45385. /**
  45386. * Attach the input controls to a specific dom element to get the input from.
  45387. * @param element Defines the element the controls should be listened from
  45388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45389. */
  45390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45391. /** @hidden */
  45392. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45393. /**
  45394. * Update the current camera state depending on the inputs that have been used this frame.
  45395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45396. */
  45397. checkInputs(): void;
  45398. /**
  45399. * Detach the current controls from the specified dom element.
  45400. * @param element Defines the element to stop listening the inputs from
  45401. */
  45402. detachControl(element: Nullable<HTMLElement>): void;
  45403. /**
  45404. * Gets the class name of the current intput.
  45405. * @returns the class name
  45406. */
  45407. getClassName(): string;
  45408. /**
  45409. * Get the friendly name associated with the input class.
  45410. * @returns the input friendly name
  45411. */
  45412. getSimpleName(): string;
  45413. }
  45414. }
  45415. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45416. import { Nullable } from "babylonjs/types";
  45417. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45418. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45419. /**
  45420. * Listen to mouse events to control the camera.
  45421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45422. */
  45423. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45424. /**
  45425. * Defines the camera the input is attached to.
  45426. */
  45427. camera: FlyCamera;
  45428. /**
  45429. * Defines if touch is enabled. (Default is true.)
  45430. */
  45431. touchEnabled: boolean;
  45432. /**
  45433. * Defines the buttons associated with the input to handle camera rotation.
  45434. */
  45435. buttons: number[];
  45436. /**
  45437. * Assign buttons for Yaw control.
  45438. */
  45439. buttonsYaw: number[];
  45440. /**
  45441. * Assign buttons for Pitch control.
  45442. */
  45443. buttonsPitch: number[];
  45444. /**
  45445. * Assign buttons for Roll control.
  45446. */
  45447. buttonsRoll: number[];
  45448. /**
  45449. * Detect if any button is being pressed while mouse is moved.
  45450. * -1 = Mouse locked.
  45451. * 0 = Left button.
  45452. * 1 = Middle Button.
  45453. * 2 = Right Button.
  45454. */
  45455. activeButton: number;
  45456. /**
  45457. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45458. * Higher values reduce its sensitivity.
  45459. */
  45460. angularSensibility: number;
  45461. private _mousemoveCallback;
  45462. private _observer;
  45463. private _rollObserver;
  45464. private previousPosition;
  45465. private noPreventDefault;
  45466. private element;
  45467. /**
  45468. * Listen to mouse events to control the camera.
  45469. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45470. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45471. */
  45472. constructor(touchEnabled?: boolean);
  45473. /**
  45474. * Attach the mouse control to the HTML DOM element.
  45475. * @param element Defines the element that listens to the input events.
  45476. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45477. */
  45478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45479. /**
  45480. * Detach the current controls from the specified dom element.
  45481. * @param element Defines the element to stop listening the inputs from
  45482. */
  45483. detachControl(element: Nullable<HTMLElement>): void;
  45484. /**
  45485. * Gets the class name of the current input.
  45486. * @returns the class name.
  45487. */
  45488. getClassName(): string;
  45489. /**
  45490. * Get the friendly name associated with the input class.
  45491. * @returns the input's friendly name.
  45492. */
  45493. getSimpleName(): string;
  45494. private _pointerInput;
  45495. private _onMouseMove;
  45496. /**
  45497. * Rotate camera by mouse offset.
  45498. */
  45499. private rotateCamera;
  45500. }
  45501. }
  45502. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45503. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45504. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45505. /**
  45506. * Default Inputs manager for the FlyCamera.
  45507. * It groups all the default supported inputs for ease of use.
  45508. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45509. */
  45510. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45511. /**
  45512. * Instantiates a new FlyCameraInputsManager.
  45513. * @param camera Defines the camera the inputs belong to.
  45514. */
  45515. constructor(camera: FlyCamera);
  45516. /**
  45517. * Add keyboard input support to the input manager.
  45518. * @returns the new FlyCameraKeyboardMoveInput().
  45519. */
  45520. addKeyboard(): FlyCameraInputsManager;
  45521. /**
  45522. * Add mouse input support to the input manager.
  45523. * @param touchEnabled Enable touch screen support.
  45524. * @returns the new FlyCameraMouseInput().
  45525. */
  45526. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45527. }
  45528. }
  45529. declare module "babylonjs/Cameras/flyCamera" {
  45530. import { Scene } from "babylonjs/scene";
  45531. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45533. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45534. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45535. /**
  45536. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45537. * such as in a 3D Space Shooter or a Flight Simulator.
  45538. */
  45539. export class FlyCamera extends TargetCamera {
  45540. /**
  45541. * Define the collision ellipsoid of the camera.
  45542. * This is helpful for simulating a camera body, like a player's body.
  45543. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45544. */
  45545. ellipsoid: Vector3;
  45546. /**
  45547. * Define an offset for the position of the ellipsoid around the camera.
  45548. * This can be helpful if the camera is attached away from the player's body center,
  45549. * such as at its head.
  45550. */
  45551. ellipsoidOffset: Vector3;
  45552. /**
  45553. * Enable or disable collisions of the camera with the rest of the scene objects.
  45554. */
  45555. checkCollisions: boolean;
  45556. /**
  45557. * Enable or disable gravity on the camera.
  45558. */
  45559. applyGravity: boolean;
  45560. /**
  45561. * Define the current direction the camera is moving to.
  45562. */
  45563. cameraDirection: Vector3;
  45564. /**
  45565. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45566. * This overrides and empties cameraRotation.
  45567. */
  45568. rotationQuaternion: Quaternion;
  45569. /**
  45570. * Track Roll to maintain the wanted Rolling when looking around.
  45571. */
  45572. _trackRoll: number;
  45573. /**
  45574. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45575. */
  45576. rollCorrect: number;
  45577. /**
  45578. * Mimic a banked turn, Rolling the camera when Yawing.
  45579. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45580. */
  45581. bankedTurn: boolean;
  45582. /**
  45583. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45584. */
  45585. bankedTurnLimit: number;
  45586. /**
  45587. * Value of 0 disables the banked Roll.
  45588. * Value of 1 is equal to the Yaw angle in radians.
  45589. */
  45590. bankedTurnMultiplier: number;
  45591. /**
  45592. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45593. */
  45594. inputs: FlyCameraInputsManager;
  45595. /**
  45596. * Gets the input sensibility for mouse input.
  45597. * Higher values reduce sensitivity.
  45598. */
  45599. get angularSensibility(): number;
  45600. /**
  45601. * Sets the input sensibility for a mouse input.
  45602. * Higher values reduce sensitivity.
  45603. */
  45604. set angularSensibility(value: number);
  45605. /**
  45606. * Get the keys for camera movement forward.
  45607. */
  45608. get keysForward(): number[];
  45609. /**
  45610. * Set the keys for camera movement forward.
  45611. */
  45612. set keysForward(value: number[]);
  45613. /**
  45614. * Get the keys for camera movement backward.
  45615. */
  45616. get keysBackward(): number[];
  45617. set keysBackward(value: number[]);
  45618. /**
  45619. * Get the keys for camera movement up.
  45620. */
  45621. get keysUp(): number[];
  45622. /**
  45623. * Set the keys for camera movement up.
  45624. */
  45625. set keysUp(value: number[]);
  45626. /**
  45627. * Get the keys for camera movement down.
  45628. */
  45629. get keysDown(): number[];
  45630. /**
  45631. * Set the keys for camera movement down.
  45632. */
  45633. set keysDown(value: number[]);
  45634. /**
  45635. * Get the keys for camera movement left.
  45636. */
  45637. get keysLeft(): number[];
  45638. /**
  45639. * Set the keys for camera movement left.
  45640. */
  45641. set keysLeft(value: number[]);
  45642. /**
  45643. * Set the keys for camera movement right.
  45644. */
  45645. get keysRight(): number[];
  45646. /**
  45647. * Set the keys for camera movement right.
  45648. */
  45649. set keysRight(value: number[]);
  45650. /**
  45651. * Event raised when the camera collides with a mesh in the scene.
  45652. */
  45653. onCollide: (collidedMesh: AbstractMesh) => void;
  45654. private _collider;
  45655. private _needMoveForGravity;
  45656. private _oldPosition;
  45657. private _diffPosition;
  45658. private _newPosition;
  45659. /** @hidden */
  45660. _localDirection: Vector3;
  45661. /** @hidden */
  45662. _transformedDirection: Vector3;
  45663. /**
  45664. * Instantiates a FlyCamera.
  45665. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45666. * such as in a 3D Space Shooter or a Flight Simulator.
  45667. * @param name Define the name of the camera in the scene.
  45668. * @param position Define the starting position of the camera in the scene.
  45669. * @param scene Define the scene the camera belongs to.
  45670. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45671. */
  45672. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45673. /**
  45674. * Attach a control to the HTML DOM element.
  45675. * @param element Defines the element that listens to the input events.
  45676. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45677. */
  45678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45679. /**
  45680. * Detach a control from the HTML DOM element.
  45681. * The camera will stop reacting to that input.
  45682. * @param element Defines the element that listens to the input events.
  45683. */
  45684. detachControl(element: HTMLElement): void;
  45685. private _collisionMask;
  45686. /**
  45687. * Get the mask that the camera ignores in collision events.
  45688. */
  45689. get collisionMask(): number;
  45690. /**
  45691. * Set the mask that the camera ignores in collision events.
  45692. */
  45693. set collisionMask(mask: number);
  45694. /** @hidden */
  45695. _collideWithWorld(displacement: Vector3): void;
  45696. /** @hidden */
  45697. private _onCollisionPositionChange;
  45698. /** @hidden */
  45699. _checkInputs(): void;
  45700. /** @hidden */
  45701. _decideIfNeedsToMove(): boolean;
  45702. /** @hidden */
  45703. _updatePosition(): void;
  45704. /**
  45705. * Restore the Roll to its target value at the rate specified.
  45706. * @param rate - Higher means slower restoring.
  45707. * @hidden
  45708. */
  45709. restoreRoll(rate: number): void;
  45710. /**
  45711. * Destroy the camera and release the current resources held by it.
  45712. */
  45713. dispose(): void;
  45714. /**
  45715. * Get the current object class name.
  45716. * @returns the class name.
  45717. */
  45718. getClassName(): string;
  45719. }
  45720. }
  45721. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45722. import { Nullable } from "babylonjs/types";
  45723. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45724. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45725. /**
  45726. * Listen to keyboard events to control the camera.
  45727. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45728. */
  45729. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45730. /**
  45731. * Defines the camera the input is attached to.
  45732. */
  45733. camera: FlyCamera;
  45734. /**
  45735. * The list of keyboard keys used to control the forward move of the camera.
  45736. */
  45737. keysForward: number[];
  45738. /**
  45739. * The list of keyboard keys used to control the backward move of the camera.
  45740. */
  45741. keysBackward: number[];
  45742. /**
  45743. * The list of keyboard keys used to control the forward move of the camera.
  45744. */
  45745. keysUp: number[];
  45746. /**
  45747. * The list of keyboard keys used to control the backward move of the camera.
  45748. */
  45749. keysDown: number[];
  45750. /**
  45751. * The list of keyboard keys used to control the right strafe move of the camera.
  45752. */
  45753. keysRight: number[];
  45754. /**
  45755. * The list of keyboard keys used to control the left strafe move of the camera.
  45756. */
  45757. keysLeft: number[];
  45758. private _keys;
  45759. private _onCanvasBlurObserver;
  45760. private _onKeyboardObserver;
  45761. private _engine;
  45762. private _scene;
  45763. /**
  45764. * Attach the input controls to a specific dom element to get the input from.
  45765. * @param element Defines the element the controls should be listened from
  45766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45767. */
  45768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45769. /**
  45770. * Detach the current controls from the specified dom element.
  45771. * @param element Defines the element to stop listening the inputs from
  45772. */
  45773. detachControl(element: Nullable<HTMLElement>): void;
  45774. /**
  45775. * Gets the class name of the current intput.
  45776. * @returns the class name
  45777. */
  45778. getClassName(): string;
  45779. /** @hidden */
  45780. _onLostFocus(e: FocusEvent): void;
  45781. /**
  45782. * Get the friendly name associated with the input class.
  45783. * @returns the input friendly name
  45784. */
  45785. getSimpleName(): string;
  45786. /**
  45787. * Update the current camera state depending on the inputs that have been used this frame.
  45788. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45789. */
  45790. checkInputs(): void;
  45791. }
  45792. }
  45793. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45794. import { Nullable } from "babylonjs/types";
  45795. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45796. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45797. /**
  45798. * Manage the mouse wheel inputs to control a follow camera.
  45799. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45800. */
  45801. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45802. /**
  45803. * Defines the camera the input is attached to.
  45804. */
  45805. camera: FollowCamera;
  45806. /**
  45807. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45808. */
  45809. axisControlRadius: boolean;
  45810. /**
  45811. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45812. */
  45813. axisControlHeight: boolean;
  45814. /**
  45815. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45816. */
  45817. axisControlRotation: boolean;
  45818. /**
  45819. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45820. * relation to mouseWheel events.
  45821. */
  45822. wheelPrecision: number;
  45823. /**
  45824. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45825. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45826. */
  45827. wheelDeltaPercentage: number;
  45828. private _wheel;
  45829. private _observer;
  45830. /**
  45831. * Attach the input controls to a specific dom element to get the input from.
  45832. * @param element Defines the element the controls should be listened from
  45833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45834. */
  45835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45836. /**
  45837. * Detach the current controls from the specified dom element.
  45838. * @param element Defines the element to stop listening the inputs from
  45839. */
  45840. detachControl(element: Nullable<HTMLElement>): void;
  45841. /**
  45842. * Gets the class name of the current intput.
  45843. * @returns the class name
  45844. */
  45845. getClassName(): string;
  45846. /**
  45847. * Get the friendly name associated with the input class.
  45848. * @returns the input friendly name
  45849. */
  45850. getSimpleName(): string;
  45851. }
  45852. }
  45853. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45854. import { Nullable } from "babylonjs/types";
  45855. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45856. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45857. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45858. /**
  45859. * Manage the pointers inputs to control an follow camera.
  45860. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45861. */
  45862. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45863. /**
  45864. * Defines the camera the input is attached to.
  45865. */
  45866. camera: FollowCamera;
  45867. /**
  45868. * Gets the class name of the current input.
  45869. * @returns the class name
  45870. */
  45871. getClassName(): string;
  45872. /**
  45873. * Defines the pointer angular sensibility along the X axis or how fast is
  45874. * the camera rotating.
  45875. * A negative number will reverse the axis direction.
  45876. */
  45877. angularSensibilityX: number;
  45878. /**
  45879. * Defines the pointer angular sensibility along the Y axis or how fast is
  45880. * the camera rotating.
  45881. * A negative number will reverse the axis direction.
  45882. */
  45883. angularSensibilityY: number;
  45884. /**
  45885. * Defines the pointer pinch precision or how fast is the camera zooming.
  45886. * A negative number will reverse the axis direction.
  45887. */
  45888. pinchPrecision: number;
  45889. /**
  45890. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45891. * from 0.
  45892. * It defines the percentage of current camera.radius to use as delta when
  45893. * pinch zoom is used.
  45894. */
  45895. pinchDeltaPercentage: number;
  45896. /**
  45897. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45898. */
  45899. axisXControlRadius: boolean;
  45900. /**
  45901. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45902. */
  45903. axisXControlHeight: boolean;
  45904. /**
  45905. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45906. */
  45907. axisXControlRotation: boolean;
  45908. /**
  45909. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45910. */
  45911. axisYControlRadius: boolean;
  45912. /**
  45913. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45914. */
  45915. axisYControlHeight: boolean;
  45916. /**
  45917. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45918. */
  45919. axisYControlRotation: boolean;
  45920. /**
  45921. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45922. */
  45923. axisPinchControlRadius: boolean;
  45924. /**
  45925. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45926. */
  45927. axisPinchControlHeight: boolean;
  45928. /**
  45929. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45930. */
  45931. axisPinchControlRotation: boolean;
  45932. /**
  45933. * Log error messages if basic misconfiguration has occurred.
  45934. */
  45935. warningEnable: boolean;
  45936. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45937. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45938. private _warningCounter;
  45939. private _warning;
  45940. }
  45941. }
  45942. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45943. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45944. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45945. /**
  45946. * Default Inputs manager for the FollowCamera.
  45947. * It groups all the default supported inputs for ease of use.
  45948. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45949. */
  45950. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45951. /**
  45952. * Instantiates a new FollowCameraInputsManager.
  45953. * @param camera Defines the camera the inputs belong to
  45954. */
  45955. constructor(camera: FollowCamera);
  45956. /**
  45957. * Add keyboard input support to the input manager.
  45958. * @returns the current input manager
  45959. */
  45960. addKeyboard(): FollowCameraInputsManager;
  45961. /**
  45962. * Add mouse wheel input support to the input manager.
  45963. * @returns the current input manager
  45964. */
  45965. addMouseWheel(): FollowCameraInputsManager;
  45966. /**
  45967. * Add pointers input support to the input manager.
  45968. * @returns the current input manager
  45969. */
  45970. addPointers(): FollowCameraInputsManager;
  45971. /**
  45972. * Add orientation input support to the input manager.
  45973. * @returns the current input manager
  45974. */
  45975. addVRDeviceOrientation(): FollowCameraInputsManager;
  45976. }
  45977. }
  45978. declare module "babylonjs/Cameras/followCamera" {
  45979. import { Nullable } from "babylonjs/types";
  45980. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45981. import { Scene } from "babylonjs/scene";
  45982. import { Vector3 } from "babylonjs/Maths/math.vector";
  45983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45984. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45985. /**
  45986. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45987. * an arc rotate version arcFollowCamera are available.
  45988. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45989. */
  45990. export class FollowCamera extends TargetCamera {
  45991. /**
  45992. * Distance the follow camera should follow an object at
  45993. */
  45994. radius: number;
  45995. /**
  45996. * Minimum allowed distance of the camera to the axis of rotation
  45997. * (The camera can not get closer).
  45998. * This can help limiting how the Camera is able to move in the scene.
  45999. */
  46000. lowerRadiusLimit: Nullable<number>;
  46001. /**
  46002. * Maximum allowed distance of the camera to the axis of rotation
  46003. * (The camera can not get further).
  46004. * This can help limiting how the Camera is able to move in the scene.
  46005. */
  46006. upperRadiusLimit: Nullable<number>;
  46007. /**
  46008. * Define a rotation offset between the camera and the object it follows
  46009. */
  46010. rotationOffset: number;
  46011. /**
  46012. * Minimum allowed angle to camera position relative to target object.
  46013. * This can help limiting how the Camera is able to move in the scene.
  46014. */
  46015. lowerRotationOffsetLimit: Nullable<number>;
  46016. /**
  46017. * Maximum allowed angle to camera position relative to target object.
  46018. * This can help limiting how the Camera is able to move in the scene.
  46019. */
  46020. upperRotationOffsetLimit: Nullable<number>;
  46021. /**
  46022. * Define a height offset between the camera and the object it follows.
  46023. * It can help following an object from the top (like a car chaing a plane)
  46024. */
  46025. heightOffset: number;
  46026. /**
  46027. * Minimum allowed height of camera position relative to target object.
  46028. * This can help limiting how the Camera is able to move in the scene.
  46029. */
  46030. lowerHeightOffsetLimit: Nullable<number>;
  46031. /**
  46032. * Maximum allowed height of camera position relative to target object.
  46033. * This can help limiting how the Camera is able to move in the scene.
  46034. */
  46035. upperHeightOffsetLimit: Nullable<number>;
  46036. /**
  46037. * Define how fast the camera can accelerate to follow it s target.
  46038. */
  46039. cameraAcceleration: number;
  46040. /**
  46041. * Define the speed limit of the camera following an object.
  46042. */
  46043. maxCameraSpeed: number;
  46044. /**
  46045. * Define the target of the camera.
  46046. */
  46047. lockedTarget: Nullable<AbstractMesh>;
  46048. /**
  46049. * Defines the input associated with the camera.
  46050. */
  46051. inputs: FollowCameraInputsManager;
  46052. /**
  46053. * Instantiates the follow camera.
  46054. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46055. * @param name Define the name of the camera in the scene
  46056. * @param position Define the position of the camera
  46057. * @param scene Define the scene the camera belong to
  46058. * @param lockedTarget Define the target of the camera
  46059. */
  46060. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46061. private _follow;
  46062. /**
  46063. * Attached controls to the current camera.
  46064. * @param element Defines the element the controls should be listened from
  46065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46066. */
  46067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46068. /**
  46069. * Detach the current controls from the camera.
  46070. * The camera will stop reacting to inputs.
  46071. * @param element Defines the element to stop listening the inputs from
  46072. */
  46073. detachControl(element: HTMLElement): void;
  46074. /** @hidden */
  46075. _checkInputs(): void;
  46076. private _checkLimits;
  46077. /**
  46078. * Gets the camera class name.
  46079. * @returns the class name
  46080. */
  46081. getClassName(): string;
  46082. }
  46083. /**
  46084. * Arc Rotate version of the follow camera.
  46085. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46086. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46087. */
  46088. export class ArcFollowCamera extends TargetCamera {
  46089. /** The longitudinal angle of the camera */
  46090. alpha: number;
  46091. /** The latitudinal angle of the camera */
  46092. beta: number;
  46093. /** The radius of the camera from its target */
  46094. radius: number;
  46095. /** Define the camera target (the mesh it should follow) */
  46096. target: Nullable<AbstractMesh>;
  46097. private _cartesianCoordinates;
  46098. /**
  46099. * Instantiates a new ArcFollowCamera
  46100. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46101. * @param name Define the name of the camera
  46102. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46103. * @param beta Define the rotation angle of the camera around the elevation axis
  46104. * @param radius Define the radius of the camera from its target point
  46105. * @param target Define the target of the camera
  46106. * @param scene Define the scene the camera belongs to
  46107. */
  46108. constructor(name: string,
  46109. /** The longitudinal angle of the camera */
  46110. alpha: number,
  46111. /** The latitudinal angle of the camera */
  46112. beta: number,
  46113. /** The radius of the camera from its target */
  46114. radius: number,
  46115. /** Define the camera target (the mesh it should follow) */
  46116. target: Nullable<AbstractMesh>, scene: Scene);
  46117. private _follow;
  46118. /** @hidden */
  46119. _checkInputs(): void;
  46120. /**
  46121. * Returns the class name of the object.
  46122. * It is mostly used internally for serialization purposes.
  46123. */
  46124. getClassName(): string;
  46125. }
  46126. }
  46127. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46128. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46129. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46130. import { Nullable } from "babylonjs/types";
  46131. /**
  46132. * Manage the keyboard inputs to control the movement of a follow camera.
  46133. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46134. */
  46135. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46136. /**
  46137. * Defines the camera the input is attached to.
  46138. */
  46139. camera: FollowCamera;
  46140. /**
  46141. * Defines the list of key codes associated with the up action (increase heightOffset)
  46142. */
  46143. keysHeightOffsetIncr: number[];
  46144. /**
  46145. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46146. */
  46147. keysHeightOffsetDecr: number[];
  46148. /**
  46149. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46150. */
  46151. keysHeightOffsetModifierAlt: boolean;
  46152. /**
  46153. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46154. */
  46155. keysHeightOffsetModifierCtrl: boolean;
  46156. /**
  46157. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46158. */
  46159. keysHeightOffsetModifierShift: boolean;
  46160. /**
  46161. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46162. */
  46163. keysRotationOffsetIncr: number[];
  46164. /**
  46165. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46166. */
  46167. keysRotationOffsetDecr: number[];
  46168. /**
  46169. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46170. */
  46171. keysRotationOffsetModifierAlt: boolean;
  46172. /**
  46173. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46174. */
  46175. keysRotationOffsetModifierCtrl: boolean;
  46176. /**
  46177. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46178. */
  46179. keysRotationOffsetModifierShift: boolean;
  46180. /**
  46181. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46182. */
  46183. keysRadiusIncr: number[];
  46184. /**
  46185. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46186. */
  46187. keysRadiusDecr: number[];
  46188. /**
  46189. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46190. */
  46191. keysRadiusModifierAlt: boolean;
  46192. /**
  46193. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46194. */
  46195. keysRadiusModifierCtrl: boolean;
  46196. /**
  46197. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46198. */
  46199. keysRadiusModifierShift: boolean;
  46200. /**
  46201. * Defines the rate of change of heightOffset.
  46202. */
  46203. heightSensibility: number;
  46204. /**
  46205. * Defines the rate of change of rotationOffset.
  46206. */
  46207. rotationSensibility: number;
  46208. /**
  46209. * Defines the rate of change of radius.
  46210. */
  46211. radiusSensibility: number;
  46212. private _keys;
  46213. private _ctrlPressed;
  46214. private _altPressed;
  46215. private _shiftPressed;
  46216. private _onCanvasBlurObserver;
  46217. private _onKeyboardObserver;
  46218. private _engine;
  46219. private _scene;
  46220. /**
  46221. * Attach the input controls to a specific dom element to get the input from.
  46222. * @param element Defines the element the controls should be listened from
  46223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46224. */
  46225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46226. /**
  46227. * Detach the current controls from the specified dom element.
  46228. * @param element Defines the element to stop listening the inputs from
  46229. */
  46230. detachControl(element: Nullable<HTMLElement>): void;
  46231. /**
  46232. * Update the current camera state depending on the inputs that have been used this frame.
  46233. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46234. */
  46235. checkInputs(): void;
  46236. /**
  46237. * Gets the class name of the current input.
  46238. * @returns the class name
  46239. */
  46240. getClassName(): string;
  46241. /**
  46242. * Get the friendly name associated with the input class.
  46243. * @returns the input friendly name
  46244. */
  46245. getSimpleName(): string;
  46246. /**
  46247. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46248. * allow modification of the heightOffset value.
  46249. */
  46250. private _modifierHeightOffset;
  46251. /**
  46252. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46253. * allow modification of the rotationOffset value.
  46254. */
  46255. private _modifierRotationOffset;
  46256. /**
  46257. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46258. * allow modification of the radius value.
  46259. */
  46260. private _modifierRadius;
  46261. }
  46262. }
  46263. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46264. import { Nullable } from "babylonjs/types";
  46265. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46266. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46267. import { Observable } from "babylonjs/Misc/observable";
  46268. module "babylonjs/Cameras/freeCameraInputsManager" {
  46269. interface FreeCameraInputsManager {
  46270. /**
  46271. * @hidden
  46272. */
  46273. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46274. /**
  46275. * Add orientation input support to the input manager.
  46276. * @returns the current input manager
  46277. */
  46278. addDeviceOrientation(): FreeCameraInputsManager;
  46279. }
  46280. }
  46281. /**
  46282. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46283. * Screen rotation is taken into account.
  46284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46285. */
  46286. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46287. private _camera;
  46288. private _screenOrientationAngle;
  46289. private _constantTranform;
  46290. private _screenQuaternion;
  46291. private _alpha;
  46292. private _beta;
  46293. private _gamma;
  46294. /**
  46295. * Can be used to detect if a device orientation sensor is available on a device
  46296. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46297. * @returns a promise that will resolve on orientation change
  46298. */
  46299. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46300. /**
  46301. * @hidden
  46302. */
  46303. _onDeviceOrientationChangedObservable: Observable<void>;
  46304. /**
  46305. * Instantiates a new input
  46306. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46307. */
  46308. constructor();
  46309. /**
  46310. * Define the camera controlled by the input.
  46311. */
  46312. get camera(): FreeCamera;
  46313. set camera(camera: FreeCamera);
  46314. /**
  46315. * Attach the input controls to a specific dom element to get the input from.
  46316. * @param element Defines the element the controls should be listened from
  46317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46318. */
  46319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46320. private _orientationChanged;
  46321. private _deviceOrientation;
  46322. /**
  46323. * Detach the current controls from the specified dom element.
  46324. * @param element Defines the element to stop listening the inputs from
  46325. */
  46326. detachControl(element: Nullable<HTMLElement>): void;
  46327. /**
  46328. * Update the current camera state depending on the inputs that have been used this frame.
  46329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46330. */
  46331. checkInputs(): void;
  46332. /**
  46333. * Gets the class name of the current intput.
  46334. * @returns the class name
  46335. */
  46336. getClassName(): string;
  46337. /**
  46338. * Get the friendly name associated with the input class.
  46339. * @returns the input friendly name
  46340. */
  46341. getSimpleName(): string;
  46342. }
  46343. }
  46344. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46345. import { Nullable } from "babylonjs/types";
  46346. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46347. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46348. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46349. /**
  46350. * Manage the gamepad inputs to control a free camera.
  46351. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46352. */
  46353. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46354. /**
  46355. * Define the camera the input is attached to.
  46356. */
  46357. camera: FreeCamera;
  46358. /**
  46359. * Define the Gamepad controlling the input
  46360. */
  46361. gamepad: Nullable<Gamepad>;
  46362. /**
  46363. * Defines the gamepad rotation sensiblity.
  46364. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46365. */
  46366. gamepadAngularSensibility: number;
  46367. /**
  46368. * Defines the gamepad move sensiblity.
  46369. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46370. */
  46371. gamepadMoveSensibility: number;
  46372. private _yAxisScale;
  46373. /**
  46374. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46375. */
  46376. get invertYAxis(): boolean;
  46377. set invertYAxis(value: boolean);
  46378. private _onGamepadConnectedObserver;
  46379. private _onGamepadDisconnectedObserver;
  46380. private _cameraTransform;
  46381. private _deltaTransform;
  46382. private _vector3;
  46383. private _vector2;
  46384. /**
  46385. * Attach the input controls to a specific dom element to get the input from.
  46386. * @param element Defines the element the controls should be listened from
  46387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46388. */
  46389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46390. /**
  46391. * Detach the current controls from the specified dom element.
  46392. * @param element Defines the element to stop listening the inputs from
  46393. */
  46394. detachControl(element: Nullable<HTMLElement>): void;
  46395. /**
  46396. * Update the current camera state depending on the inputs that have been used this frame.
  46397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46398. */
  46399. checkInputs(): void;
  46400. /**
  46401. * Gets the class name of the current intput.
  46402. * @returns the class name
  46403. */
  46404. getClassName(): string;
  46405. /**
  46406. * Get the friendly name associated with the input class.
  46407. * @returns the input friendly name
  46408. */
  46409. getSimpleName(): string;
  46410. }
  46411. }
  46412. declare module "babylonjs/Misc/virtualJoystick" {
  46413. import { Nullable } from "babylonjs/types";
  46414. import { Vector3 } from "babylonjs/Maths/math.vector";
  46415. /**
  46416. * Defines the potential axis of a Joystick
  46417. */
  46418. export enum JoystickAxis {
  46419. /** X axis */
  46420. X = 0,
  46421. /** Y axis */
  46422. Y = 1,
  46423. /** Z axis */
  46424. Z = 2
  46425. }
  46426. /**
  46427. * Represents the different customization options available
  46428. * for VirtualJoystick
  46429. */
  46430. interface VirtualJoystickCustomizations {
  46431. /**
  46432. * Size of the joystick's puck
  46433. */
  46434. puckSize: number;
  46435. /**
  46436. * Size of the joystick's container
  46437. */
  46438. containerSize: number;
  46439. /**
  46440. * Color of the joystick && puck
  46441. */
  46442. color: string;
  46443. /**
  46444. * Image URL for the joystick's puck
  46445. */
  46446. puckImage?: string;
  46447. /**
  46448. * Image URL for the joystick's container
  46449. */
  46450. containerImage?: string;
  46451. /**
  46452. * Defines the unmoving position of the joystick container
  46453. */
  46454. position?: {
  46455. x: number;
  46456. y: number;
  46457. };
  46458. /**
  46459. * Defines whether or not the joystick container is always visible
  46460. */
  46461. alwaysVisible: boolean;
  46462. /**
  46463. * Defines whether or not to limit the movement of the puck to the joystick's container
  46464. */
  46465. limitToContainer: boolean;
  46466. }
  46467. /**
  46468. * Class used to define virtual joystick (used in touch mode)
  46469. */
  46470. export class VirtualJoystick {
  46471. /**
  46472. * Gets or sets a boolean indicating that left and right values must be inverted
  46473. */
  46474. reverseLeftRight: boolean;
  46475. /**
  46476. * Gets or sets a boolean indicating that up and down values must be inverted
  46477. */
  46478. reverseUpDown: boolean;
  46479. /**
  46480. * Gets the offset value for the position (ie. the change of the position value)
  46481. */
  46482. deltaPosition: Vector3;
  46483. /**
  46484. * Gets a boolean indicating if the virtual joystick was pressed
  46485. */
  46486. pressed: boolean;
  46487. /**
  46488. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46489. */
  46490. static Canvas: Nullable<HTMLCanvasElement>;
  46491. /**
  46492. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46493. */
  46494. limitToContainer: boolean;
  46495. private static _globalJoystickIndex;
  46496. private static _alwaysVisibleSticks;
  46497. private static vjCanvasContext;
  46498. private static vjCanvasWidth;
  46499. private static vjCanvasHeight;
  46500. private static halfWidth;
  46501. private static _GetDefaultOptions;
  46502. private _action;
  46503. private _axisTargetedByLeftAndRight;
  46504. private _axisTargetedByUpAndDown;
  46505. private _joystickSensibility;
  46506. private _inversedSensibility;
  46507. private _joystickPointerID;
  46508. private _joystickColor;
  46509. private _joystickPointerPos;
  46510. private _joystickPreviousPointerPos;
  46511. private _joystickPointerStartPos;
  46512. private _deltaJoystickVector;
  46513. private _leftJoystick;
  46514. private _touches;
  46515. private _joystickPosition;
  46516. private _alwaysVisible;
  46517. private _puckImage;
  46518. private _containerImage;
  46519. private _joystickPuckSize;
  46520. private _joystickContainerSize;
  46521. private _clearPuckSize;
  46522. private _clearContainerSize;
  46523. private _clearPuckSizeOffset;
  46524. private _clearContainerSizeOffset;
  46525. private _onPointerDownHandlerRef;
  46526. private _onPointerMoveHandlerRef;
  46527. private _onPointerUpHandlerRef;
  46528. private _onResize;
  46529. /**
  46530. * Creates a new virtual joystick
  46531. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46532. * @param customizations Defines the options we want to customize the VirtualJoystick
  46533. */
  46534. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46535. /**
  46536. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46537. * @param newJoystickSensibility defines the new sensibility
  46538. */
  46539. setJoystickSensibility(newJoystickSensibility: number): void;
  46540. private _onPointerDown;
  46541. private _onPointerMove;
  46542. private _onPointerUp;
  46543. /**
  46544. * Change the color of the virtual joystick
  46545. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46546. */
  46547. setJoystickColor(newColor: string): void;
  46548. /**
  46549. * Size of the joystick's container
  46550. */
  46551. set containerSize(newSize: number);
  46552. get containerSize(): number;
  46553. /**
  46554. * Size of the joystick's puck
  46555. */
  46556. set puckSize(newSize: number);
  46557. get puckSize(): number;
  46558. /**
  46559. * Clears the set position of the joystick
  46560. */
  46561. clearPosition(): void;
  46562. /**
  46563. * Defines whether or not the joystick container is always visible
  46564. */
  46565. set alwaysVisible(value: boolean);
  46566. get alwaysVisible(): boolean;
  46567. /**
  46568. * Sets the constant position of the Joystick container
  46569. * @param x X axis coordinate
  46570. * @param y Y axis coordinate
  46571. */
  46572. setPosition(x: number, y: number): void;
  46573. /**
  46574. * Defines a callback to call when the joystick is touched
  46575. * @param action defines the callback
  46576. */
  46577. setActionOnTouch(action: () => any): void;
  46578. /**
  46579. * Defines which axis you'd like to control for left & right
  46580. * @param axis defines the axis to use
  46581. */
  46582. setAxisForLeftRight(axis: JoystickAxis): void;
  46583. /**
  46584. * Defines which axis you'd like to control for up & down
  46585. * @param axis defines the axis to use
  46586. */
  46587. setAxisForUpDown(axis: JoystickAxis): void;
  46588. /**
  46589. * Clears the canvas from the previous puck / container draw
  46590. */
  46591. private _clearPreviousDraw;
  46592. /**
  46593. * Loads `urlPath` to be used for the container's image
  46594. * @param urlPath defines the urlPath of an image to use
  46595. */
  46596. setContainerImage(urlPath: string): void;
  46597. /**
  46598. * Loads `urlPath` to be used for the puck's image
  46599. * @param urlPath defines the urlPath of an image to use
  46600. */
  46601. setPuckImage(urlPath: string): void;
  46602. /**
  46603. * Draws the Virtual Joystick's container
  46604. */
  46605. private _drawContainer;
  46606. /**
  46607. * Draws the Virtual Joystick's puck
  46608. */
  46609. private _drawPuck;
  46610. private _drawVirtualJoystick;
  46611. /**
  46612. * Release internal HTML canvas
  46613. */
  46614. releaseCanvas(): void;
  46615. }
  46616. }
  46617. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46618. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46619. import { Nullable } from "babylonjs/types";
  46620. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46621. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46622. module "babylonjs/Cameras/freeCameraInputsManager" {
  46623. interface FreeCameraInputsManager {
  46624. /**
  46625. * Add virtual joystick input support to the input manager.
  46626. * @returns the current input manager
  46627. */
  46628. addVirtualJoystick(): FreeCameraInputsManager;
  46629. }
  46630. }
  46631. /**
  46632. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46633. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46634. */
  46635. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46636. /**
  46637. * Defines the camera the input is attached to.
  46638. */
  46639. camera: FreeCamera;
  46640. private _leftjoystick;
  46641. private _rightjoystick;
  46642. /**
  46643. * Gets the left stick of the virtual joystick.
  46644. * @returns The virtual Joystick
  46645. */
  46646. getLeftJoystick(): VirtualJoystick;
  46647. /**
  46648. * Gets the right stick of the virtual joystick.
  46649. * @returns The virtual Joystick
  46650. */
  46651. getRightJoystick(): VirtualJoystick;
  46652. /**
  46653. * Update the current camera state depending on the inputs that have been used this frame.
  46654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46655. */
  46656. checkInputs(): void;
  46657. /**
  46658. * Attach the input controls to a specific dom element to get the input from.
  46659. * @param element Defines the element the controls should be listened from
  46660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46661. */
  46662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46663. /**
  46664. * Detach the current controls from the specified dom element.
  46665. * @param element Defines the element to stop listening the inputs from
  46666. */
  46667. detachControl(element: Nullable<HTMLElement>): void;
  46668. /**
  46669. * Gets the class name of the current intput.
  46670. * @returns the class name
  46671. */
  46672. getClassName(): string;
  46673. /**
  46674. * Get the friendly name associated with the input class.
  46675. * @returns the input friendly name
  46676. */
  46677. getSimpleName(): string;
  46678. }
  46679. }
  46680. declare module "babylonjs/Cameras/Inputs/index" {
  46681. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46682. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46683. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46684. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46685. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46686. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46687. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46688. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46689. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46690. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46691. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46692. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46693. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46694. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46695. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46696. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46697. }
  46698. declare module "babylonjs/Cameras/touchCamera" {
  46699. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46700. import { Scene } from "babylonjs/scene";
  46701. import { Vector3 } from "babylonjs/Maths/math.vector";
  46702. /**
  46703. * This represents a FPS type of camera controlled by touch.
  46704. * This is like a universal camera minus the Gamepad controls.
  46705. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46706. */
  46707. export class TouchCamera extends FreeCamera {
  46708. /**
  46709. * Defines the touch sensibility for rotation.
  46710. * The higher the faster.
  46711. */
  46712. get touchAngularSensibility(): number;
  46713. set touchAngularSensibility(value: number);
  46714. /**
  46715. * Defines the touch sensibility for move.
  46716. * The higher the faster.
  46717. */
  46718. get touchMoveSensibility(): number;
  46719. set touchMoveSensibility(value: number);
  46720. /**
  46721. * Instantiates a new touch camera.
  46722. * This represents a FPS type of camera controlled by touch.
  46723. * This is like a universal camera minus the Gamepad controls.
  46724. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46725. * @param name Define the name of the camera in the scene
  46726. * @param position Define the start position of the camera in the scene
  46727. * @param scene Define the scene the camera belongs to
  46728. */
  46729. constructor(name: string, position: Vector3, scene: Scene);
  46730. /**
  46731. * Gets the current object class name.
  46732. * @return the class name
  46733. */
  46734. getClassName(): string;
  46735. /** @hidden */
  46736. _setupInputs(): void;
  46737. }
  46738. }
  46739. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46740. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46741. import { Scene } from "babylonjs/scene";
  46742. import { Vector3 } from "babylonjs/Maths/math.vector";
  46743. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46744. import { Axis } from "babylonjs/Maths/math.axis";
  46745. /**
  46746. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46747. * being tilted forward or back and left or right.
  46748. */
  46749. export class DeviceOrientationCamera extends FreeCamera {
  46750. private _initialQuaternion;
  46751. private _quaternionCache;
  46752. private _tmpDragQuaternion;
  46753. private _disablePointerInputWhenUsingDeviceOrientation;
  46754. /**
  46755. * Creates a new device orientation camera
  46756. * @param name The name of the camera
  46757. * @param position The start position camera
  46758. * @param scene The scene the camera belongs to
  46759. */
  46760. constructor(name: string, position: Vector3, scene: Scene);
  46761. /**
  46762. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46763. */
  46764. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46765. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46766. private _dragFactor;
  46767. /**
  46768. * Enabled turning on the y axis when the orientation sensor is active
  46769. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46770. */
  46771. enableHorizontalDragging(dragFactor?: number): void;
  46772. /**
  46773. * Gets the current instance class name ("DeviceOrientationCamera").
  46774. * This helps avoiding instanceof at run time.
  46775. * @returns the class name
  46776. */
  46777. getClassName(): string;
  46778. /**
  46779. * @hidden
  46780. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46781. */
  46782. _checkInputs(): void;
  46783. /**
  46784. * Reset the camera to its default orientation on the specified axis only.
  46785. * @param axis The axis to reset
  46786. */
  46787. resetToCurrentRotation(axis?: Axis): void;
  46788. }
  46789. }
  46790. declare module "babylonjs/Gamepads/xboxGamepad" {
  46791. import { Observable } from "babylonjs/Misc/observable";
  46792. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46793. /**
  46794. * Defines supported buttons for XBox360 compatible gamepads
  46795. */
  46796. export enum Xbox360Button {
  46797. /** A */
  46798. A = 0,
  46799. /** B */
  46800. B = 1,
  46801. /** X */
  46802. X = 2,
  46803. /** Y */
  46804. Y = 3,
  46805. /** Left button */
  46806. LB = 4,
  46807. /** Right button */
  46808. RB = 5,
  46809. /** Back */
  46810. Back = 8,
  46811. /** Start */
  46812. Start = 9,
  46813. /** Left stick */
  46814. LeftStick = 10,
  46815. /** Right stick */
  46816. RightStick = 11
  46817. }
  46818. /** Defines values for XBox360 DPad */
  46819. export enum Xbox360Dpad {
  46820. /** Up */
  46821. Up = 12,
  46822. /** Down */
  46823. Down = 13,
  46824. /** Left */
  46825. Left = 14,
  46826. /** Right */
  46827. Right = 15
  46828. }
  46829. /**
  46830. * Defines a XBox360 gamepad
  46831. */
  46832. export class Xbox360Pad extends Gamepad {
  46833. private _leftTrigger;
  46834. private _rightTrigger;
  46835. private _onlefttriggerchanged;
  46836. private _onrighttriggerchanged;
  46837. private _onbuttondown;
  46838. private _onbuttonup;
  46839. private _ondpaddown;
  46840. private _ondpadup;
  46841. /** Observable raised when a button is pressed */
  46842. onButtonDownObservable: Observable<Xbox360Button>;
  46843. /** Observable raised when a button is released */
  46844. onButtonUpObservable: Observable<Xbox360Button>;
  46845. /** Observable raised when a pad is pressed */
  46846. onPadDownObservable: Observable<Xbox360Dpad>;
  46847. /** Observable raised when a pad is released */
  46848. onPadUpObservable: Observable<Xbox360Dpad>;
  46849. private _buttonA;
  46850. private _buttonB;
  46851. private _buttonX;
  46852. private _buttonY;
  46853. private _buttonBack;
  46854. private _buttonStart;
  46855. private _buttonLB;
  46856. private _buttonRB;
  46857. private _buttonLeftStick;
  46858. private _buttonRightStick;
  46859. private _dPadUp;
  46860. private _dPadDown;
  46861. private _dPadLeft;
  46862. private _dPadRight;
  46863. private _isXboxOnePad;
  46864. /**
  46865. * Creates a new XBox360 gamepad object
  46866. * @param id defines the id of this gamepad
  46867. * @param index defines its index
  46868. * @param gamepad defines the internal HTML gamepad object
  46869. * @param xboxOne defines if it is a XBox One gamepad
  46870. */
  46871. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46872. /**
  46873. * Defines the callback to call when left trigger is pressed
  46874. * @param callback defines the callback to use
  46875. */
  46876. onlefttriggerchanged(callback: (value: number) => void): void;
  46877. /**
  46878. * Defines the callback to call when right trigger is pressed
  46879. * @param callback defines the callback to use
  46880. */
  46881. onrighttriggerchanged(callback: (value: number) => void): void;
  46882. /**
  46883. * Gets the left trigger value
  46884. */
  46885. get leftTrigger(): number;
  46886. /**
  46887. * Sets the left trigger value
  46888. */
  46889. set leftTrigger(newValue: number);
  46890. /**
  46891. * Gets the right trigger value
  46892. */
  46893. get rightTrigger(): number;
  46894. /**
  46895. * Sets the right trigger value
  46896. */
  46897. set rightTrigger(newValue: number);
  46898. /**
  46899. * Defines the callback to call when a button is pressed
  46900. * @param callback defines the callback to use
  46901. */
  46902. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46903. /**
  46904. * Defines the callback to call when a button is released
  46905. * @param callback defines the callback to use
  46906. */
  46907. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46908. /**
  46909. * Defines the callback to call when a pad is pressed
  46910. * @param callback defines the callback to use
  46911. */
  46912. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46913. /**
  46914. * Defines the callback to call when a pad is released
  46915. * @param callback defines the callback to use
  46916. */
  46917. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46918. private _setButtonValue;
  46919. private _setDPadValue;
  46920. /**
  46921. * Gets the value of the `A` button
  46922. */
  46923. get buttonA(): number;
  46924. /**
  46925. * Sets the value of the `A` button
  46926. */
  46927. set buttonA(value: number);
  46928. /**
  46929. * Gets the value of the `B` button
  46930. */
  46931. get buttonB(): number;
  46932. /**
  46933. * Sets the value of the `B` button
  46934. */
  46935. set buttonB(value: number);
  46936. /**
  46937. * Gets the value of the `X` button
  46938. */
  46939. get buttonX(): number;
  46940. /**
  46941. * Sets the value of the `X` button
  46942. */
  46943. set buttonX(value: number);
  46944. /**
  46945. * Gets the value of the `Y` button
  46946. */
  46947. get buttonY(): number;
  46948. /**
  46949. * Sets the value of the `Y` button
  46950. */
  46951. set buttonY(value: number);
  46952. /**
  46953. * Gets the value of the `Start` button
  46954. */
  46955. get buttonStart(): number;
  46956. /**
  46957. * Sets the value of the `Start` button
  46958. */
  46959. set buttonStart(value: number);
  46960. /**
  46961. * Gets the value of the `Back` button
  46962. */
  46963. get buttonBack(): number;
  46964. /**
  46965. * Sets the value of the `Back` button
  46966. */
  46967. set buttonBack(value: number);
  46968. /**
  46969. * Gets the value of the `Left` button
  46970. */
  46971. get buttonLB(): number;
  46972. /**
  46973. * Sets the value of the `Left` button
  46974. */
  46975. set buttonLB(value: number);
  46976. /**
  46977. * Gets the value of the `Right` button
  46978. */
  46979. get buttonRB(): number;
  46980. /**
  46981. * Sets the value of the `Right` button
  46982. */
  46983. set buttonRB(value: number);
  46984. /**
  46985. * Gets the value of the Left joystick
  46986. */
  46987. get buttonLeftStick(): number;
  46988. /**
  46989. * Sets the value of the Left joystick
  46990. */
  46991. set buttonLeftStick(value: number);
  46992. /**
  46993. * Gets the value of the Right joystick
  46994. */
  46995. get buttonRightStick(): number;
  46996. /**
  46997. * Sets the value of the Right joystick
  46998. */
  46999. set buttonRightStick(value: number);
  47000. /**
  47001. * Gets the value of D-pad up
  47002. */
  47003. get dPadUp(): number;
  47004. /**
  47005. * Sets the value of D-pad up
  47006. */
  47007. set dPadUp(value: number);
  47008. /**
  47009. * Gets the value of D-pad down
  47010. */
  47011. get dPadDown(): number;
  47012. /**
  47013. * Sets the value of D-pad down
  47014. */
  47015. set dPadDown(value: number);
  47016. /**
  47017. * Gets the value of D-pad left
  47018. */
  47019. get dPadLeft(): number;
  47020. /**
  47021. * Sets the value of D-pad left
  47022. */
  47023. set dPadLeft(value: number);
  47024. /**
  47025. * Gets the value of D-pad right
  47026. */
  47027. get dPadRight(): number;
  47028. /**
  47029. * Sets the value of D-pad right
  47030. */
  47031. set dPadRight(value: number);
  47032. /**
  47033. * Force the gamepad to synchronize with device values
  47034. */
  47035. update(): void;
  47036. /**
  47037. * Disposes the gamepad
  47038. */
  47039. dispose(): void;
  47040. }
  47041. }
  47042. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47043. import { Observable } from "babylonjs/Misc/observable";
  47044. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47045. /**
  47046. * Defines supported buttons for DualShock compatible gamepads
  47047. */
  47048. export enum DualShockButton {
  47049. /** Cross */
  47050. Cross = 0,
  47051. /** Circle */
  47052. Circle = 1,
  47053. /** Square */
  47054. Square = 2,
  47055. /** Triangle */
  47056. Triangle = 3,
  47057. /** L1 */
  47058. L1 = 4,
  47059. /** R1 */
  47060. R1 = 5,
  47061. /** Share */
  47062. Share = 8,
  47063. /** Options */
  47064. Options = 9,
  47065. /** Left stick */
  47066. LeftStick = 10,
  47067. /** Right stick */
  47068. RightStick = 11
  47069. }
  47070. /** Defines values for DualShock DPad */
  47071. export enum DualShockDpad {
  47072. /** Up */
  47073. Up = 12,
  47074. /** Down */
  47075. Down = 13,
  47076. /** Left */
  47077. Left = 14,
  47078. /** Right */
  47079. Right = 15
  47080. }
  47081. /**
  47082. * Defines a DualShock gamepad
  47083. */
  47084. export class DualShockPad extends Gamepad {
  47085. private _leftTrigger;
  47086. private _rightTrigger;
  47087. private _onlefttriggerchanged;
  47088. private _onrighttriggerchanged;
  47089. private _onbuttondown;
  47090. private _onbuttonup;
  47091. private _ondpaddown;
  47092. private _ondpadup;
  47093. /** Observable raised when a button is pressed */
  47094. onButtonDownObservable: Observable<DualShockButton>;
  47095. /** Observable raised when a button is released */
  47096. onButtonUpObservable: Observable<DualShockButton>;
  47097. /** Observable raised when a pad is pressed */
  47098. onPadDownObservable: Observable<DualShockDpad>;
  47099. /** Observable raised when a pad is released */
  47100. onPadUpObservable: Observable<DualShockDpad>;
  47101. private _buttonCross;
  47102. private _buttonCircle;
  47103. private _buttonSquare;
  47104. private _buttonTriangle;
  47105. private _buttonShare;
  47106. private _buttonOptions;
  47107. private _buttonL1;
  47108. private _buttonR1;
  47109. private _buttonLeftStick;
  47110. private _buttonRightStick;
  47111. private _dPadUp;
  47112. private _dPadDown;
  47113. private _dPadLeft;
  47114. private _dPadRight;
  47115. /**
  47116. * Creates a new DualShock gamepad object
  47117. * @param id defines the id of this gamepad
  47118. * @param index defines its index
  47119. * @param gamepad defines the internal HTML gamepad object
  47120. */
  47121. constructor(id: string, index: number, gamepad: any);
  47122. /**
  47123. * Defines the callback to call when left trigger is pressed
  47124. * @param callback defines the callback to use
  47125. */
  47126. onlefttriggerchanged(callback: (value: number) => void): void;
  47127. /**
  47128. * Defines the callback to call when right trigger is pressed
  47129. * @param callback defines the callback to use
  47130. */
  47131. onrighttriggerchanged(callback: (value: number) => void): void;
  47132. /**
  47133. * Gets the left trigger value
  47134. */
  47135. get leftTrigger(): number;
  47136. /**
  47137. * Sets the left trigger value
  47138. */
  47139. set leftTrigger(newValue: number);
  47140. /**
  47141. * Gets the right trigger value
  47142. */
  47143. get rightTrigger(): number;
  47144. /**
  47145. * Sets the right trigger value
  47146. */
  47147. set rightTrigger(newValue: number);
  47148. /**
  47149. * Defines the callback to call when a button is pressed
  47150. * @param callback defines the callback to use
  47151. */
  47152. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47153. /**
  47154. * Defines the callback to call when a button is released
  47155. * @param callback defines the callback to use
  47156. */
  47157. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47158. /**
  47159. * Defines the callback to call when a pad is pressed
  47160. * @param callback defines the callback to use
  47161. */
  47162. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47163. /**
  47164. * Defines the callback to call when a pad is released
  47165. * @param callback defines the callback to use
  47166. */
  47167. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47168. private _setButtonValue;
  47169. private _setDPadValue;
  47170. /**
  47171. * Gets the value of the `Cross` button
  47172. */
  47173. get buttonCross(): number;
  47174. /**
  47175. * Sets the value of the `Cross` button
  47176. */
  47177. set buttonCross(value: number);
  47178. /**
  47179. * Gets the value of the `Circle` button
  47180. */
  47181. get buttonCircle(): number;
  47182. /**
  47183. * Sets the value of the `Circle` button
  47184. */
  47185. set buttonCircle(value: number);
  47186. /**
  47187. * Gets the value of the `Square` button
  47188. */
  47189. get buttonSquare(): number;
  47190. /**
  47191. * Sets the value of the `Square` button
  47192. */
  47193. set buttonSquare(value: number);
  47194. /**
  47195. * Gets the value of the `Triangle` button
  47196. */
  47197. get buttonTriangle(): number;
  47198. /**
  47199. * Sets the value of the `Triangle` button
  47200. */
  47201. set buttonTriangle(value: number);
  47202. /**
  47203. * Gets the value of the `Options` button
  47204. */
  47205. get buttonOptions(): number;
  47206. /**
  47207. * Sets the value of the `Options` button
  47208. */
  47209. set buttonOptions(value: number);
  47210. /**
  47211. * Gets the value of the `Share` button
  47212. */
  47213. get buttonShare(): number;
  47214. /**
  47215. * Sets the value of the `Share` button
  47216. */
  47217. set buttonShare(value: number);
  47218. /**
  47219. * Gets the value of the `L1` button
  47220. */
  47221. get buttonL1(): number;
  47222. /**
  47223. * Sets the value of the `L1` button
  47224. */
  47225. set buttonL1(value: number);
  47226. /**
  47227. * Gets the value of the `R1` button
  47228. */
  47229. get buttonR1(): number;
  47230. /**
  47231. * Sets the value of the `R1` button
  47232. */
  47233. set buttonR1(value: number);
  47234. /**
  47235. * Gets the value of the Left joystick
  47236. */
  47237. get buttonLeftStick(): number;
  47238. /**
  47239. * Sets the value of the Left joystick
  47240. */
  47241. set buttonLeftStick(value: number);
  47242. /**
  47243. * Gets the value of the Right joystick
  47244. */
  47245. get buttonRightStick(): number;
  47246. /**
  47247. * Sets the value of the Right joystick
  47248. */
  47249. set buttonRightStick(value: number);
  47250. /**
  47251. * Gets the value of D-pad up
  47252. */
  47253. get dPadUp(): number;
  47254. /**
  47255. * Sets the value of D-pad up
  47256. */
  47257. set dPadUp(value: number);
  47258. /**
  47259. * Gets the value of D-pad down
  47260. */
  47261. get dPadDown(): number;
  47262. /**
  47263. * Sets the value of D-pad down
  47264. */
  47265. set dPadDown(value: number);
  47266. /**
  47267. * Gets the value of D-pad left
  47268. */
  47269. get dPadLeft(): number;
  47270. /**
  47271. * Sets the value of D-pad left
  47272. */
  47273. set dPadLeft(value: number);
  47274. /**
  47275. * Gets the value of D-pad right
  47276. */
  47277. get dPadRight(): number;
  47278. /**
  47279. * Sets the value of D-pad right
  47280. */
  47281. set dPadRight(value: number);
  47282. /**
  47283. * Force the gamepad to synchronize with device values
  47284. */
  47285. update(): void;
  47286. /**
  47287. * Disposes the gamepad
  47288. */
  47289. dispose(): void;
  47290. }
  47291. }
  47292. declare module "babylonjs/Gamepads/gamepadManager" {
  47293. import { Observable } from "babylonjs/Misc/observable";
  47294. import { Nullable } from "babylonjs/types";
  47295. import { Scene } from "babylonjs/scene";
  47296. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47297. /**
  47298. * Manager for handling gamepads
  47299. */
  47300. export class GamepadManager {
  47301. private _scene?;
  47302. private _babylonGamepads;
  47303. private _oneGamepadConnected;
  47304. /** @hidden */
  47305. _isMonitoring: boolean;
  47306. private _gamepadEventSupported;
  47307. private _gamepadSupport?;
  47308. /**
  47309. * observable to be triggered when the gamepad controller has been connected
  47310. */
  47311. onGamepadConnectedObservable: Observable<Gamepad>;
  47312. /**
  47313. * observable to be triggered when the gamepad controller has been disconnected
  47314. */
  47315. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47316. private _onGamepadConnectedEvent;
  47317. private _onGamepadDisconnectedEvent;
  47318. /**
  47319. * Initializes the gamepad manager
  47320. * @param _scene BabylonJS scene
  47321. */
  47322. constructor(_scene?: Scene | undefined);
  47323. /**
  47324. * The gamepads in the game pad manager
  47325. */
  47326. get gamepads(): Gamepad[];
  47327. /**
  47328. * Get the gamepad controllers based on type
  47329. * @param type The type of gamepad controller
  47330. * @returns Nullable gamepad
  47331. */
  47332. getGamepadByType(type?: number): Nullable<Gamepad>;
  47333. /**
  47334. * Disposes the gamepad manager
  47335. */
  47336. dispose(): void;
  47337. private _addNewGamepad;
  47338. private _startMonitoringGamepads;
  47339. private _stopMonitoringGamepads;
  47340. /** @hidden */
  47341. _checkGamepadsStatus(): void;
  47342. private _updateGamepadObjects;
  47343. }
  47344. }
  47345. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47346. import { Nullable } from "babylonjs/types";
  47347. import { Scene } from "babylonjs/scene";
  47348. import { ISceneComponent } from "babylonjs/sceneComponent";
  47349. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47350. module "babylonjs/scene" {
  47351. interface Scene {
  47352. /** @hidden */
  47353. _gamepadManager: Nullable<GamepadManager>;
  47354. /**
  47355. * Gets the gamepad manager associated with the scene
  47356. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47357. */
  47358. gamepadManager: GamepadManager;
  47359. }
  47360. }
  47361. module "babylonjs/Cameras/freeCameraInputsManager" {
  47362. /**
  47363. * Interface representing a free camera inputs manager
  47364. */
  47365. interface FreeCameraInputsManager {
  47366. /**
  47367. * Adds gamepad input support to the FreeCameraInputsManager.
  47368. * @returns the FreeCameraInputsManager
  47369. */
  47370. addGamepad(): FreeCameraInputsManager;
  47371. }
  47372. }
  47373. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47374. /**
  47375. * Interface representing an arc rotate camera inputs manager
  47376. */
  47377. interface ArcRotateCameraInputsManager {
  47378. /**
  47379. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47380. * @returns the camera inputs manager
  47381. */
  47382. addGamepad(): ArcRotateCameraInputsManager;
  47383. }
  47384. }
  47385. /**
  47386. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47387. */
  47388. export class GamepadSystemSceneComponent implements ISceneComponent {
  47389. /**
  47390. * The component name helpfull to identify the component in the list of scene components.
  47391. */
  47392. readonly name: string;
  47393. /**
  47394. * The scene the component belongs to.
  47395. */
  47396. scene: Scene;
  47397. /**
  47398. * Creates a new instance of the component for the given scene
  47399. * @param scene Defines the scene to register the component in
  47400. */
  47401. constructor(scene: Scene);
  47402. /**
  47403. * Registers the component in a given scene
  47404. */
  47405. register(): void;
  47406. /**
  47407. * Rebuilds the elements related to this component in case of
  47408. * context lost for instance.
  47409. */
  47410. rebuild(): void;
  47411. /**
  47412. * Disposes the component and the associated ressources
  47413. */
  47414. dispose(): void;
  47415. private _beforeCameraUpdate;
  47416. }
  47417. }
  47418. declare module "babylonjs/Cameras/universalCamera" {
  47419. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47420. import { Scene } from "babylonjs/scene";
  47421. import { Vector3 } from "babylonjs/Maths/math.vector";
  47422. import "babylonjs/Gamepads/gamepadSceneComponent";
  47423. /**
  47424. * 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,
  47425. * which still works and will still be found in many Playgrounds.
  47426. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47427. */
  47428. export class UniversalCamera extends TouchCamera {
  47429. /**
  47430. * Defines the gamepad rotation sensiblity.
  47431. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47432. */
  47433. get gamepadAngularSensibility(): number;
  47434. set gamepadAngularSensibility(value: number);
  47435. /**
  47436. * Defines the gamepad move sensiblity.
  47437. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47438. */
  47439. get gamepadMoveSensibility(): number;
  47440. set gamepadMoveSensibility(value: number);
  47441. /**
  47442. * 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,
  47443. * which still works and will still be found in many Playgrounds.
  47444. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47445. * @param name Define the name of the camera in the scene
  47446. * @param position Define the start position of the camera in the scene
  47447. * @param scene Define the scene the camera belongs to
  47448. */
  47449. constructor(name: string, position: Vector3, scene: Scene);
  47450. /**
  47451. * Gets the current object class name.
  47452. * @return the class name
  47453. */
  47454. getClassName(): string;
  47455. }
  47456. }
  47457. declare module "babylonjs/Cameras/gamepadCamera" {
  47458. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47459. import { Scene } from "babylonjs/scene";
  47460. import { Vector3 } from "babylonjs/Maths/math.vector";
  47461. /**
  47462. * This represents a FPS type of camera. This is only here for back compat purpose.
  47463. * Please use the UniversalCamera instead as both are identical.
  47464. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47465. */
  47466. export class GamepadCamera extends UniversalCamera {
  47467. /**
  47468. * Instantiates a new Gamepad Camera
  47469. * This represents a FPS type of camera. This is only here for back compat purpose.
  47470. * Please use the UniversalCamera instead as both are identical.
  47471. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47472. * @param name Define the name of the camera in the scene
  47473. * @param position Define the start position of the camera in the scene
  47474. * @param scene Define the scene the camera belongs to
  47475. */
  47476. constructor(name: string, position: Vector3, scene: Scene);
  47477. /**
  47478. * Gets the current object class name.
  47479. * @return the class name
  47480. */
  47481. getClassName(): string;
  47482. }
  47483. }
  47484. declare module "babylonjs/Shaders/pass.fragment" {
  47485. /** @hidden */
  47486. export var passPixelShader: {
  47487. name: string;
  47488. shader: string;
  47489. };
  47490. }
  47491. declare module "babylonjs/Shaders/passCube.fragment" {
  47492. /** @hidden */
  47493. export var passCubePixelShader: {
  47494. name: string;
  47495. shader: string;
  47496. };
  47497. }
  47498. declare module "babylonjs/PostProcesses/passPostProcess" {
  47499. import { Nullable } from "babylonjs/types";
  47500. import { Camera } from "babylonjs/Cameras/camera";
  47501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47502. import { Engine } from "babylonjs/Engines/engine";
  47503. import "babylonjs/Shaders/pass.fragment";
  47504. import "babylonjs/Shaders/passCube.fragment";
  47505. /**
  47506. * PassPostProcess which produces an output the same as it's input
  47507. */
  47508. export class PassPostProcess extends PostProcess {
  47509. /**
  47510. * Creates the PassPostProcess
  47511. * @param name The name of the effect.
  47512. * @param options The required width/height ratio to downsize to before computing the render pass.
  47513. * @param camera The camera to apply the render pass to.
  47514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47515. * @param engine The engine which the post process will be applied. (default: current engine)
  47516. * @param reusable If the post process can be reused on the same frame. (default: false)
  47517. * @param textureType The type of texture to be used when performing the post processing.
  47518. * @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)
  47519. */
  47520. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47521. }
  47522. /**
  47523. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47524. */
  47525. export class PassCubePostProcess extends PostProcess {
  47526. private _face;
  47527. /**
  47528. * Gets or sets the cube face to display.
  47529. * * 0 is +X
  47530. * * 1 is -X
  47531. * * 2 is +Y
  47532. * * 3 is -Y
  47533. * * 4 is +Z
  47534. * * 5 is -Z
  47535. */
  47536. get face(): number;
  47537. set face(value: number);
  47538. /**
  47539. * Creates the PassCubePostProcess
  47540. * @param name The name of the effect.
  47541. * @param options The required width/height ratio to downsize to before computing the render pass.
  47542. * @param camera The camera to apply the render pass to.
  47543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47544. * @param engine The engine which the post process will be applied. (default: current engine)
  47545. * @param reusable If the post process can be reused on the same frame. (default: false)
  47546. * @param textureType The type of texture to be used when performing the post processing.
  47547. * @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)
  47548. */
  47549. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47550. }
  47551. }
  47552. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47553. /** @hidden */
  47554. export var anaglyphPixelShader: {
  47555. name: string;
  47556. shader: string;
  47557. };
  47558. }
  47559. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47560. import { Engine } from "babylonjs/Engines/engine";
  47561. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47562. import { Camera } from "babylonjs/Cameras/camera";
  47563. import "babylonjs/Shaders/anaglyph.fragment";
  47564. /**
  47565. * Postprocess used to generate anaglyphic rendering
  47566. */
  47567. export class AnaglyphPostProcess extends PostProcess {
  47568. private _passedProcess;
  47569. /**
  47570. * Creates a new AnaglyphPostProcess
  47571. * @param name defines postprocess name
  47572. * @param options defines creation options or target ratio scale
  47573. * @param rigCameras defines cameras using this postprocess
  47574. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47575. * @param engine defines hosting engine
  47576. * @param reusable defines if the postprocess will be reused multiple times per frame
  47577. */
  47578. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47579. }
  47580. }
  47581. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47582. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47583. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47584. import { Scene } from "babylonjs/scene";
  47585. import { Vector3 } from "babylonjs/Maths/math.vector";
  47586. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47587. /**
  47588. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47589. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47590. */
  47591. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47592. /**
  47593. * Creates a new AnaglyphArcRotateCamera
  47594. * @param name defines camera name
  47595. * @param alpha defines alpha angle (in radians)
  47596. * @param beta defines beta angle (in radians)
  47597. * @param radius defines radius
  47598. * @param target defines camera target
  47599. * @param interaxialDistance defines distance between each color axis
  47600. * @param scene defines the hosting scene
  47601. */
  47602. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47603. /**
  47604. * Gets camera class name
  47605. * @returns AnaglyphArcRotateCamera
  47606. */
  47607. getClassName(): string;
  47608. }
  47609. }
  47610. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47611. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47612. import { Scene } from "babylonjs/scene";
  47613. import { Vector3 } from "babylonjs/Maths/math.vector";
  47614. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47615. /**
  47616. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47617. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47618. */
  47619. export class AnaglyphFreeCamera extends FreeCamera {
  47620. /**
  47621. * Creates a new AnaglyphFreeCamera
  47622. * @param name defines camera name
  47623. * @param position defines initial position
  47624. * @param interaxialDistance defines distance between each color axis
  47625. * @param scene defines the hosting scene
  47626. */
  47627. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47628. /**
  47629. * Gets camera class name
  47630. * @returns AnaglyphFreeCamera
  47631. */
  47632. getClassName(): string;
  47633. }
  47634. }
  47635. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47636. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47637. import { Scene } from "babylonjs/scene";
  47638. import { Vector3 } from "babylonjs/Maths/math.vector";
  47639. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47640. /**
  47641. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47642. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47643. */
  47644. export class AnaglyphGamepadCamera extends GamepadCamera {
  47645. /**
  47646. * Creates a new AnaglyphGamepadCamera
  47647. * @param name defines camera name
  47648. * @param position defines initial position
  47649. * @param interaxialDistance defines distance between each color axis
  47650. * @param scene defines the hosting scene
  47651. */
  47652. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47653. /**
  47654. * Gets camera class name
  47655. * @returns AnaglyphGamepadCamera
  47656. */
  47657. getClassName(): string;
  47658. }
  47659. }
  47660. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47661. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47662. import { Scene } from "babylonjs/scene";
  47663. import { Vector3 } from "babylonjs/Maths/math.vector";
  47664. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47665. /**
  47666. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47667. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47668. */
  47669. export class AnaglyphUniversalCamera extends UniversalCamera {
  47670. /**
  47671. * Creates a new AnaglyphUniversalCamera
  47672. * @param name defines camera name
  47673. * @param position defines initial position
  47674. * @param interaxialDistance defines distance between each color axis
  47675. * @param scene defines the hosting scene
  47676. */
  47677. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47678. /**
  47679. * Gets camera class name
  47680. * @returns AnaglyphUniversalCamera
  47681. */
  47682. getClassName(): string;
  47683. }
  47684. }
  47685. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47686. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47687. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47688. import { Scene } from "babylonjs/scene";
  47689. import { Vector3 } from "babylonjs/Maths/math.vector";
  47690. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47691. /**
  47692. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47693. * @see https://doc.babylonjs.com/features/cameras
  47694. */
  47695. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47696. /**
  47697. * Creates a new StereoscopicArcRotateCamera
  47698. * @param name defines camera name
  47699. * @param alpha defines alpha angle (in radians)
  47700. * @param beta defines beta angle (in radians)
  47701. * @param radius defines radius
  47702. * @param target defines camera target
  47703. * @param interaxialDistance defines distance between each color axis
  47704. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47705. * @param scene defines the hosting scene
  47706. */
  47707. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47708. /**
  47709. * Gets camera class name
  47710. * @returns StereoscopicArcRotateCamera
  47711. */
  47712. getClassName(): string;
  47713. }
  47714. }
  47715. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47716. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47717. import { Scene } from "babylonjs/scene";
  47718. import { Vector3 } from "babylonjs/Maths/math.vector";
  47719. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47720. /**
  47721. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47722. * @see https://doc.babylonjs.com/features/cameras
  47723. */
  47724. export class StereoscopicFreeCamera extends FreeCamera {
  47725. /**
  47726. * Creates a new StereoscopicFreeCamera
  47727. * @param name defines camera name
  47728. * @param position defines initial position
  47729. * @param interaxialDistance defines distance between each color axis
  47730. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47731. * @param scene defines the hosting scene
  47732. */
  47733. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47734. /**
  47735. * Gets camera class name
  47736. * @returns StereoscopicFreeCamera
  47737. */
  47738. getClassName(): string;
  47739. }
  47740. }
  47741. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47742. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47743. import { Scene } from "babylonjs/scene";
  47744. import { Vector3 } from "babylonjs/Maths/math.vector";
  47745. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47746. /**
  47747. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47748. * @see https://doc.babylonjs.com/features/cameras
  47749. */
  47750. export class StereoscopicGamepadCamera extends GamepadCamera {
  47751. /**
  47752. * Creates a new StereoscopicGamepadCamera
  47753. * @param name defines camera name
  47754. * @param position defines initial position
  47755. * @param interaxialDistance defines distance between each color axis
  47756. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47757. * @param scene defines the hosting scene
  47758. */
  47759. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47760. /**
  47761. * Gets camera class name
  47762. * @returns StereoscopicGamepadCamera
  47763. */
  47764. getClassName(): string;
  47765. }
  47766. }
  47767. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47768. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47769. import { Scene } from "babylonjs/scene";
  47770. import { Vector3 } from "babylonjs/Maths/math.vector";
  47771. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47772. /**
  47773. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47774. * @see https://doc.babylonjs.com/features/cameras
  47775. */
  47776. export class StereoscopicUniversalCamera extends UniversalCamera {
  47777. /**
  47778. * Creates a new StereoscopicUniversalCamera
  47779. * @param name defines camera name
  47780. * @param position defines initial position
  47781. * @param interaxialDistance defines distance between each color axis
  47782. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47783. * @param scene defines the hosting scene
  47784. */
  47785. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47786. /**
  47787. * Gets camera class name
  47788. * @returns StereoscopicUniversalCamera
  47789. */
  47790. getClassName(): string;
  47791. }
  47792. }
  47793. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47794. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47795. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47796. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47797. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47798. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47799. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47800. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47801. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47802. }
  47803. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47804. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47805. import { Scene } from "babylonjs/scene";
  47806. import { Vector3 } from "babylonjs/Maths/math.vector";
  47807. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47808. /**
  47809. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47810. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47811. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47812. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47813. */
  47814. export class VirtualJoysticksCamera extends FreeCamera {
  47815. /**
  47816. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47817. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47818. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47819. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47820. * @param name Define the name of the camera in the scene
  47821. * @param position Define the start position of the camera in the scene
  47822. * @param scene Define the scene the camera belongs to
  47823. */
  47824. constructor(name: string, position: Vector3, scene: Scene);
  47825. /**
  47826. * Gets the current object class name.
  47827. * @return the class name
  47828. */
  47829. getClassName(): string;
  47830. }
  47831. }
  47832. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47833. import { Matrix } from "babylonjs/Maths/math.vector";
  47834. /**
  47835. * This represents all the required metrics to create a VR camera.
  47836. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47837. */
  47838. export class VRCameraMetrics {
  47839. /**
  47840. * Define the horizontal resolution off the screen.
  47841. */
  47842. hResolution: number;
  47843. /**
  47844. * Define the vertical resolution off the screen.
  47845. */
  47846. vResolution: number;
  47847. /**
  47848. * Define the horizontal screen size.
  47849. */
  47850. hScreenSize: number;
  47851. /**
  47852. * Define the vertical screen size.
  47853. */
  47854. vScreenSize: number;
  47855. /**
  47856. * Define the vertical screen center position.
  47857. */
  47858. vScreenCenter: number;
  47859. /**
  47860. * Define the distance of the eyes to the screen.
  47861. */
  47862. eyeToScreenDistance: number;
  47863. /**
  47864. * Define the distance between both lenses
  47865. */
  47866. lensSeparationDistance: number;
  47867. /**
  47868. * Define the distance between both viewer's eyes.
  47869. */
  47870. interpupillaryDistance: number;
  47871. /**
  47872. * Define the distortion factor of the VR postprocess.
  47873. * Please, touch with care.
  47874. */
  47875. distortionK: number[];
  47876. /**
  47877. * Define the chromatic aberration correction factors for the VR post process.
  47878. */
  47879. chromaAbCorrection: number[];
  47880. /**
  47881. * Define the scale factor of the post process.
  47882. * The smaller the better but the slower.
  47883. */
  47884. postProcessScaleFactor: number;
  47885. /**
  47886. * Define an offset for the lens center.
  47887. */
  47888. lensCenterOffset: number;
  47889. /**
  47890. * Define if the current vr camera should compensate the distortion of the lense or not.
  47891. */
  47892. compensateDistortion: boolean;
  47893. /**
  47894. * Defines if multiview should be enabled when rendering (Default: false)
  47895. */
  47896. multiviewEnabled: boolean;
  47897. /**
  47898. * Gets the rendering aspect ratio based on the provided resolutions.
  47899. */
  47900. get aspectRatio(): number;
  47901. /**
  47902. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47903. */
  47904. get aspectRatioFov(): number;
  47905. /**
  47906. * @hidden
  47907. */
  47908. get leftHMatrix(): Matrix;
  47909. /**
  47910. * @hidden
  47911. */
  47912. get rightHMatrix(): Matrix;
  47913. /**
  47914. * @hidden
  47915. */
  47916. get leftPreViewMatrix(): Matrix;
  47917. /**
  47918. * @hidden
  47919. */
  47920. get rightPreViewMatrix(): Matrix;
  47921. /**
  47922. * Get the default VRMetrics based on the most generic setup.
  47923. * @returns the default vr metrics
  47924. */
  47925. static GetDefault(): VRCameraMetrics;
  47926. }
  47927. }
  47928. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47929. /** @hidden */
  47930. export var vrDistortionCorrectionPixelShader: {
  47931. name: string;
  47932. shader: string;
  47933. };
  47934. }
  47935. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47936. import { Camera } from "babylonjs/Cameras/camera";
  47937. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47938. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47939. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47940. /**
  47941. * VRDistortionCorrectionPostProcess used for mobile VR
  47942. */
  47943. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47944. private _isRightEye;
  47945. private _distortionFactors;
  47946. private _postProcessScaleFactor;
  47947. private _lensCenterOffset;
  47948. private _scaleIn;
  47949. private _scaleFactor;
  47950. private _lensCenter;
  47951. /**
  47952. * Initializes the VRDistortionCorrectionPostProcess
  47953. * @param name The name of the effect.
  47954. * @param camera The camera to apply the render pass to.
  47955. * @param isRightEye If this is for the right eye distortion
  47956. * @param vrMetrics All the required metrics for the VR camera
  47957. */
  47958. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47959. }
  47960. }
  47961. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47962. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47963. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47964. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47965. import { Scene } from "babylonjs/scene";
  47966. import { Vector3 } from "babylonjs/Maths/math.vector";
  47967. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47968. import "babylonjs/Cameras/RigModes/vrRigMode";
  47969. /**
  47970. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47971. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47972. */
  47973. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47974. /**
  47975. * Creates a new VRDeviceOrientationArcRotateCamera
  47976. * @param name defines camera name
  47977. * @param alpha defines the camera rotation along the logitudinal axis
  47978. * @param beta defines the camera rotation along the latitudinal axis
  47979. * @param radius defines the camera distance from its target
  47980. * @param target defines the camera target
  47981. * @param scene defines the scene the camera belongs to
  47982. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47983. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47984. */
  47985. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47986. /**
  47987. * Gets camera class name
  47988. * @returns VRDeviceOrientationArcRotateCamera
  47989. */
  47990. getClassName(): string;
  47991. }
  47992. }
  47993. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47994. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47995. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47996. import { Scene } from "babylonjs/scene";
  47997. import { Vector3 } from "babylonjs/Maths/math.vector";
  47998. import "babylonjs/Cameras/RigModes/vrRigMode";
  47999. /**
  48000. * Camera used to simulate VR rendering (based on FreeCamera)
  48001. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48002. */
  48003. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48004. /**
  48005. * Creates a new VRDeviceOrientationFreeCamera
  48006. * @param name defines camera name
  48007. * @param position defines the start position of the camera
  48008. * @param scene defines the scene the camera belongs to
  48009. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48010. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48011. */
  48012. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48013. /**
  48014. * Gets camera class name
  48015. * @returns VRDeviceOrientationFreeCamera
  48016. */
  48017. getClassName(): string;
  48018. }
  48019. }
  48020. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48021. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48022. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48023. import { Scene } from "babylonjs/scene";
  48024. import { Vector3 } from "babylonjs/Maths/math.vector";
  48025. import "babylonjs/Gamepads/gamepadSceneComponent";
  48026. /**
  48027. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48028. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48029. */
  48030. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48031. /**
  48032. * Creates a new VRDeviceOrientationGamepadCamera
  48033. * @param name defines camera name
  48034. * @param position defines the start position of the camera
  48035. * @param scene defines the scene the camera belongs to
  48036. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48037. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48038. */
  48039. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48040. /**
  48041. * Gets camera class name
  48042. * @returns VRDeviceOrientationGamepadCamera
  48043. */
  48044. getClassName(): string;
  48045. }
  48046. }
  48047. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48048. import { Scene } from "babylonjs/scene";
  48049. import { Texture } from "babylonjs/Materials/Textures/texture";
  48050. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48051. /**
  48052. * A class extending Texture allowing drawing on a texture
  48053. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48054. */
  48055. export class DynamicTexture extends Texture {
  48056. private _generateMipMaps;
  48057. private _canvas;
  48058. private _context;
  48059. /**
  48060. * Creates a DynamicTexture
  48061. * @param name defines the name of the texture
  48062. * @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
  48063. * @param scene defines the scene where you want the texture
  48064. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48065. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48066. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48067. */
  48068. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48069. /**
  48070. * Get the current class name of the texture useful for serialization or dynamic coding.
  48071. * @returns "DynamicTexture"
  48072. */
  48073. getClassName(): string;
  48074. /**
  48075. * Gets the current state of canRescale
  48076. */
  48077. get canRescale(): boolean;
  48078. private _recreate;
  48079. /**
  48080. * Scales the texture
  48081. * @param ratio the scale factor to apply to both width and height
  48082. */
  48083. scale(ratio: number): void;
  48084. /**
  48085. * Resizes the texture
  48086. * @param width the new width
  48087. * @param height the new height
  48088. */
  48089. scaleTo(width: number, height: number): void;
  48090. /**
  48091. * Gets the context of the canvas used by the texture
  48092. * @returns the canvas context of the dynamic texture
  48093. */
  48094. getContext(): CanvasRenderingContext2D;
  48095. /**
  48096. * Clears the texture
  48097. */
  48098. clear(): void;
  48099. /**
  48100. * Updates the texture
  48101. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48102. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48103. */
  48104. update(invertY?: boolean, premulAlpha?: boolean): void;
  48105. /**
  48106. * Draws text onto the texture
  48107. * @param text defines the text to be drawn
  48108. * @param x defines the placement of the text from the left
  48109. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48110. * @param font defines the font to be used with font-style, font-size, font-name
  48111. * @param color defines the color used for the text
  48112. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48113. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48114. * @param update defines whether texture is immediately update (default is true)
  48115. */
  48116. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48117. /**
  48118. * Clones the texture
  48119. * @returns the clone of the texture.
  48120. */
  48121. clone(): DynamicTexture;
  48122. /**
  48123. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48124. * @returns a serialized dynamic texture object
  48125. */
  48126. serialize(): any;
  48127. private _IsCanvasElement;
  48128. /** @hidden */
  48129. _rebuild(): void;
  48130. }
  48131. }
  48132. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48133. import { Scene } from "babylonjs/scene";
  48134. import { Color3 } from "babylonjs/Maths/math.color";
  48135. import { Mesh } from "babylonjs/Meshes/mesh";
  48136. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48137. import { Nullable } from "babylonjs/types";
  48138. /**
  48139. * Class containing static functions to help procedurally build meshes
  48140. */
  48141. export class GroundBuilder {
  48142. /**
  48143. * Creates a ground mesh
  48144. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48145. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48147. * @param name defines the name of the mesh
  48148. * @param options defines the options used to create the mesh
  48149. * @param scene defines the hosting scene
  48150. * @returns the ground mesh
  48151. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48152. */
  48153. static CreateGround(name: string, options: {
  48154. width?: number;
  48155. height?: number;
  48156. subdivisions?: number;
  48157. subdivisionsX?: number;
  48158. subdivisionsY?: number;
  48159. updatable?: boolean;
  48160. }, scene: any): Mesh;
  48161. /**
  48162. * Creates a tiled ground mesh
  48163. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48164. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48165. * * 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
  48166. * * 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
  48167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48168. * @param name defines the name of the mesh
  48169. * @param options defines the options used to create the mesh
  48170. * @param scene defines the hosting scene
  48171. * @returns the tiled ground mesh
  48172. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48173. */
  48174. static CreateTiledGround(name: string, options: {
  48175. xmin: number;
  48176. zmin: number;
  48177. xmax: number;
  48178. zmax: number;
  48179. subdivisions?: {
  48180. w: number;
  48181. h: number;
  48182. };
  48183. precision?: {
  48184. w: number;
  48185. h: number;
  48186. };
  48187. updatable?: boolean;
  48188. }, scene?: Nullable<Scene>): Mesh;
  48189. /**
  48190. * Creates a ground mesh from a height map
  48191. * * The parameter `url` sets the URL of the height map image resource.
  48192. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48193. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48194. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48195. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48196. * * 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.
  48197. * * 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).
  48198. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48200. * @param name defines the name of the mesh
  48201. * @param url defines the url to the height map
  48202. * @param options defines the options used to create the mesh
  48203. * @param scene defines the hosting scene
  48204. * @returns the ground mesh
  48205. * @see https://doc.babylonjs.com/babylon101/height_map
  48206. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48207. */
  48208. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48209. width?: number;
  48210. height?: number;
  48211. subdivisions?: number;
  48212. minHeight?: number;
  48213. maxHeight?: number;
  48214. colorFilter?: Color3;
  48215. alphaFilter?: number;
  48216. updatable?: boolean;
  48217. onReady?: (mesh: GroundMesh) => void;
  48218. }, scene?: Nullable<Scene>): GroundMesh;
  48219. }
  48220. }
  48221. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48222. import { Vector4 } from "babylonjs/Maths/math.vector";
  48223. import { Mesh } from "babylonjs/Meshes/mesh";
  48224. /**
  48225. * Class containing static functions to help procedurally build meshes
  48226. */
  48227. export class TorusBuilder {
  48228. /**
  48229. * Creates a torus mesh
  48230. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48231. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48232. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48236. * @param name defines the name of the mesh
  48237. * @param options defines the options used to create the mesh
  48238. * @param scene defines the hosting scene
  48239. * @returns the torus mesh
  48240. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48241. */
  48242. static CreateTorus(name: string, options: {
  48243. diameter?: number;
  48244. thickness?: number;
  48245. tessellation?: number;
  48246. updatable?: boolean;
  48247. sideOrientation?: number;
  48248. frontUVs?: Vector4;
  48249. backUVs?: Vector4;
  48250. }, scene: any): Mesh;
  48251. }
  48252. }
  48253. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48254. import { Vector4 } from "babylonjs/Maths/math.vector";
  48255. import { Color4 } from "babylonjs/Maths/math.color";
  48256. import { Mesh } from "babylonjs/Meshes/mesh";
  48257. /**
  48258. * Class containing static functions to help procedurally build meshes
  48259. */
  48260. export class CylinderBuilder {
  48261. /**
  48262. * Creates a cylinder or a cone mesh
  48263. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48264. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48265. * * 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.
  48266. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48267. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48268. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48269. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48270. * * 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).
  48271. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48272. * * 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).
  48273. * * 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
  48274. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48275. * * 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
  48276. * * 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.
  48277. * * If `enclose` is false, a ring surface is one element.
  48278. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48279. * * 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
  48280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48283. * @param name defines the name of the mesh
  48284. * @param options defines the options used to create the mesh
  48285. * @param scene defines the hosting scene
  48286. * @returns the cylinder mesh
  48287. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48288. */
  48289. static CreateCylinder(name: string, options: {
  48290. height?: number;
  48291. diameterTop?: number;
  48292. diameterBottom?: number;
  48293. diameter?: number;
  48294. tessellation?: number;
  48295. subdivisions?: number;
  48296. arc?: number;
  48297. faceColors?: Color4[];
  48298. faceUV?: Vector4[];
  48299. updatable?: boolean;
  48300. hasRings?: boolean;
  48301. enclose?: boolean;
  48302. cap?: number;
  48303. sideOrientation?: number;
  48304. frontUVs?: Vector4;
  48305. backUVs?: Vector4;
  48306. }, scene: any): Mesh;
  48307. }
  48308. }
  48309. declare module "babylonjs/XR/webXRTypes" {
  48310. import { Nullable } from "babylonjs/types";
  48311. import { IDisposable } from "babylonjs/scene";
  48312. /**
  48313. * States of the webXR experience
  48314. */
  48315. export enum WebXRState {
  48316. /**
  48317. * Transitioning to being in XR mode
  48318. */
  48319. ENTERING_XR = 0,
  48320. /**
  48321. * Transitioning to non XR mode
  48322. */
  48323. EXITING_XR = 1,
  48324. /**
  48325. * In XR mode and presenting
  48326. */
  48327. IN_XR = 2,
  48328. /**
  48329. * Not entered XR mode
  48330. */
  48331. NOT_IN_XR = 3
  48332. }
  48333. /**
  48334. * Abstraction of the XR render target
  48335. */
  48336. export interface WebXRRenderTarget extends IDisposable {
  48337. /**
  48338. * xrpresent context of the canvas which can be used to display/mirror xr content
  48339. */
  48340. canvasContext: WebGLRenderingContext;
  48341. /**
  48342. * xr layer for the canvas
  48343. */
  48344. xrLayer: Nullable<XRWebGLLayer>;
  48345. /**
  48346. * Initializes the xr layer for the session
  48347. * @param xrSession xr session
  48348. * @returns a promise that will resolve once the XR Layer has been created
  48349. */
  48350. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48351. }
  48352. }
  48353. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48354. import { Nullable } from "babylonjs/types";
  48355. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48356. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48357. import { Observable } from "babylonjs/Misc/observable";
  48358. /**
  48359. * COnfiguration object for WebXR output canvas
  48360. */
  48361. export class WebXRManagedOutputCanvasOptions {
  48362. /**
  48363. * An optional canvas in case you wish to create it yourself and provide it here.
  48364. * If not provided, a new canvas will be created
  48365. */
  48366. canvasElement?: HTMLCanvasElement;
  48367. /**
  48368. * Options for this XR Layer output
  48369. */
  48370. canvasOptions?: XRWebGLLayerOptions;
  48371. /**
  48372. * CSS styling for a newly created canvas (if not provided)
  48373. */
  48374. newCanvasCssStyle?: string;
  48375. /**
  48376. * Get the default values of the configuration object
  48377. * @returns default values of this configuration object
  48378. */
  48379. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48380. }
  48381. /**
  48382. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48383. */
  48384. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48385. private _options;
  48386. private _canvas;
  48387. private _engine;
  48388. private _originalCanvasSize;
  48389. /**
  48390. * Rendering context of the canvas which can be used to display/mirror xr content
  48391. */
  48392. canvasContext: WebGLRenderingContext;
  48393. /**
  48394. * xr layer for the canvas
  48395. */
  48396. xrLayer: Nullable<XRWebGLLayer>;
  48397. /**
  48398. * Obseervers registered here will be triggered when the xr layer was initialized
  48399. */
  48400. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48401. /**
  48402. * Initializes the canvas to be added/removed upon entering/exiting xr
  48403. * @param _xrSessionManager The XR Session manager
  48404. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48405. */
  48406. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48407. /**
  48408. * Disposes of the object
  48409. */
  48410. dispose(): void;
  48411. /**
  48412. * Initializes the xr layer for the session
  48413. * @param xrSession xr session
  48414. * @returns a promise that will resolve once the XR Layer has been created
  48415. */
  48416. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48417. private _addCanvas;
  48418. private _removeCanvas;
  48419. private _setCanvasSize;
  48420. private _setManagedOutputCanvas;
  48421. }
  48422. }
  48423. declare module "babylonjs/XR/webXRSessionManager" {
  48424. import { Observable } from "babylonjs/Misc/observable";
  48425. import { Nullable } from "babylonjs/types";
  48426. import { IDisposable, Scene } from "babylonjs/scene";
  48427. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48428. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48429. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48430. /**
  48431. * Manages an XRSession to work with Babylon's engine
  48432. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48433. */
  48434. export class WebXRSessionManager implements IDisposable {
  48435. /** The scene which the session should be created for */
  48436. scene: Scene;
  48437. private _referenceSpace;
  48438. private _rttProvider;
  48439. private _sessionEnded;
  48440. private _xrNavigator;
  48441. private baseLayer;
  48442. /**
  48443. * The base reference space from which the session started. good if you want to reset your
  48444. * reference space
  48445. */
  48446. baseReferenceSpace: XRReferenceSpace;
  48447. /**
  48448. * Current XR frame
  48449. */
  48450. currentFrame: Nullable<XRFrame>;
  48451. /** WebXR timestamp updated every frame */
  48452. currentTimestamp: number;
  48453. /**
  48454. * Used just in case of a failure to initialize an immersive session.
  48455. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48456. */
  48457. defaultHeightCompensation: number;
  48458. /**
  48459. * Fires every time a new xrFrame arrives which can be used to update the camera
  48460. */
  48461. onXRFrameObservable: Observable<XRFrame>;
  48462. /**
  48463. * Fires when the reference space changed
  48464. */
  48465. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48466. /**
  48467. * Fires when the xr session is ended either by the device or manually done
  48468. */
  48469. onXRSessionEnded: Observable<any>;
  48470. /**
  48471. * Fires when the xr session is ended either by the device or manually done
  48472. */
  48473. onXRSessionInit: Observable<XRSession>;
  48474. /**
  48475. * Underlying xr session
  48476. */
  48477. session: XRSession;
  48478. /**
  48479. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48480. * or get the offset the player is currently at.
  48481. */
  48482. viewerReferenceSpace: XRReferenceSpace;
  48483. /**
  48484. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48485. * @param scene The scene which the session should be created for
  48486. */
  48487. constructor(
  48488. /** The scene which the session should be created for */
  48489. scene: Scene);
  48490. /**
  48491. * The current reference space used in this session. This reference space can constantly change!
  48492. * It is mainly used to offset the camera's position.
  48493. */
  48494. get referenceSpace(): XRReferenceSpace;
  48495. /**
  48496. * Set a new reference space and triggers the observable
  48497. */
  48498. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48499. /**
  48500. * Disposes of the session manager
  48501. */
  48502. dispose(): void;
  48503. /**
  48504. * Stops the xrSession and restores the render loop
  48505. * @returns Promise which resolves after it exits XR
  48506. */
  48507. exitXRAsync(): Promise<void>;
  48508. /**
  48509. * Gets the correct render target texture to be rendered this frame for this eye
  48510. * @param eye the eye for which to get the render target
  48511. * @returns the render target for the specified eye
  48512. */
  48513. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48514. /**
  48515. * Creates a WebXRRenderTarget object for the XR session
  48516. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48517. * @param options optional options to provide when creating a new render target
  48518. * @returns a WebXR render target to which the session can render
  48519. */
  48520. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48521. /**
  48522. * Initializes the manager
  48523. * After initialization enterXR can be called to start an XR session
  48524. * @returns Promise which resolves after it is initialized
  48525. */
  48526. initializeAsync(): Promise<void>;
  48527. /**
  48528. * Initializes an xr session
  48529. * @param xrSessionMode mode to initialize
  48530. * @param xrSessionInit defines optional and required values to pass to the session builder
  48531. * @returns a promise which will resolve once the session has been initialized
  48532. */
  48533. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48534. /**
  48535. * Checks if a session would be supported for the creation options specified
  48536. * @param sessionMode session mode to check if supported eg. immersive-vr
  48537. * @returns A Promise that resolves to true if supported and false if not
  48538. */
  48539. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48540. /**
  48541. * Resets the reference space to the one started the session
  48542. */
  48543. resetReferenceSpace(): void;
  48544. /**
  48545. * Starts rendering to the xr layer
  48546. */
  48547. runXRRenderLoop(): void;
  48548. /**
  48549. * Sets the reference space on the xr session
  48550. * @param referenceSpaceType space to set
  48551. * @returns a promise that will resolve once the reference space has been set
  48552. */
  48553. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48554. /**
  48555. * Updates the render state of the session
  48556. * @param state state to set
  48557. * @returns a promise that resolves once the render state has been updated
  48558. */
  48559. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48560. /**
  48561. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48562. * @param sessionMode defines the session to test
  48563. * @returns a promise with boolean as final value
  48564. */
  48565. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48566. private _createRenderTargetTexture;
  48567. }
  48568. }
  48569. declare module "babylonjs/XR/webXRCamera" {
  48570. import { Scene } from "babylonjs/scene";
  48571. import { Camera } from "babylonjs/Cameras/camera";
  48572. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48573. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48574. /**
  48575. * WebXR Camera which holds the views for the xrSession
  48576. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48577. */
  48578. export class WebXRCamera extends FreeCamera {
  48579. private _xrSessionManager;
  48580. private _firstFrame;
  48581. private _referenceQuaternion;
  48582. private _referencedPosition;
  48583. private _xrInvPositionCache;
  48584. private _xrInvQuaternionCache;
  48585. /**
  48586. * Should position compensation execute on first frame.
  48587. * This is used when copying the position from a native (non XR) camera
  48588. */
  48589. compensateOnFirstFrame: boolean;
  48590. /**
  48591. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48592. * @param name the name of the camera
  48593. * @param scene the scene to add the camera to
  48594. * @param _xrSessionManager a constructed xr session manager
  48595. */
  48596. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48597. /**
  48598. * Return the user's height, unrelated to the current ground.
  48599. * This will be the y position of this camera, when ground level is 0.
  48600. */
  48601. get realWorldHeight(): number;
  48602. /** @hidden */
  48603. _updateForDualEyeDebugging(): void;
  48604. /**
  48605. * Sets this camera's transformation based on a non-vr camera
  48606. * @param otherCamera the non-vr camera to copy the transformation from
  48607. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48608. */
  48609. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48610. /**
  48611. * Gets the current instance class name ("WebXRCamera").
  48612. * @returns the class name
  48613. */
  48614. getClassName(): string;
  48615. private _rotate180;
  48616. private _updateFromXRSession;
  48617. private _updateNumberOfRigCameras;
  48618. private _updateReferenceSpace;
  48619. private _updateReferenceSpaceOffset;
  48620. }
  48621. }
  48622. declare module "babylonjs/XR/webXRFeaturesManager" {
  48623. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48624. import { IDisposable } from "babylonjs/scene";
  48625. /**
  48626. * Defining the interface required for a (webxr) feature
  48627. */
  48628. export interface IWebXRFeature extends IDisposable {
  48629. /**
  48630. * Is this feature attached
  48631. */
  48632. attached: boolean;
  48633. /**
  48634. * Should auto-attach be disabled?
  48635. */
  48636. disableAutoAttach: boolean;
  48637. /**
  48638. * Attach the feature to the session
  48639. * Will usually be called by the features manager
  48640. *
  48641. * @param force should attachment be forced (even when already attached)
  48642. * @returns true if successful.
  48643. */
  48644. attach(force?: boolean): boolean;
  48645. /**
  48646. * Detach the feature from the session
  48647. * Will usually be called by the features manager
  48648. *
  48649. * @returns true if successful.
  48650. */
  48651. detach(): boolean;
  48652. /**
  48653. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48654. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48655. *
  48656. * @returns whether or not the feature is compatible in this environment
  48657. */
  48658. isCompatible(): boolean;
  48659. /**
  48660. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48661. */
  48662. xrNativeFeatureName?: string;
  48663. }
  48664. /**
  48665. * A list of the currently available features without referencing them
  48666. */
  48667. export class WebXRFeatureName {
  48668. /**
  48669. * The name of the anchor system feature
  48670. */
  48671. static ANCHOR_SYSTEM: string;
  48672. /**
  48673. * The name of the background remover feature
  48674. */
  48675. static BACKGROUND_REMOVER: string;
  48676. /**
  48677. * The name of the hit test feature
  48678. */
  48679. static HIT_TEST: string;
  48680. /**
  48681. * physics impostors for xr controllers feature
  48682. */
  48683. static PHYSICS_CONTROLLERS: string;
  48684. /**
  48685. * The name of the plane detection feature
  48686. */
  48687. static PLANE_DETECTION: string;
  48688. /**
  48689. * The name of the pointer selection feature
  48690. */
  48691. static POINTER_SELECTION: string;
  48692. /**
  48693. * The name of the teleportation feature
  48694. */
  48695. static TELEPORTATION: string;
  48696. }
  48697. /**
  48698. * Defining the constructor of a feature. Used to register the modules.
  48699. */
  48700. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48701. /**
  48702. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48703. * It is mainly used in AR sessions.
  48704. *
  48705. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48706. */
  48707. export class WebXRFeaturesManager implements IDisposable {
  48708. private _xrSessionManager;
  48709. private static readonly _AvailableFeatures;
  48710. private _features;
  48711. /**
  48712. * constructs a new features manages.
  48713. *
  48714. * @param _xrSessionManager an instance of WebXRSessionManager
  48715. */
  48716. constructor(_xrSessionManager: WebXRSessionManager);
  48717. /**
  48718. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48719. * Mainly used internally.
  48720. *
  48721. * @param featureName the name of the feature to register
  48722. * @param constructorFunction the function used to construct the module
  48723. * @param version the (babylon) version of the module
  48724. * @param stable is that a stable version of this module
  48725. */
  48726. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48727. /**
  48728. * Returns a constructor of a specific feature.
  48729. *
  48730. * @param featureName the name of the feature to construct
  48731. * @param version the version of the feature to load
  48732. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48733. * @param options optional options provided to the module.
  48734. * @returns a function that, when called, will return a new instance of this feature
  48735. */
  48736. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48737. /**
  48738. * Can be used to return the list of features currently registered
  48739. *
  48740. * @returns an Array of available features
  48741. */
  48742. static GetAvailableFeatures(): string[];
  48743. /**
  48744. * Gets the versions available for a specific feature
  48745. * @param featureName the name of the feature
  48746. * @returns an array with the available versions
  48747. */
  48748. static GetAvailableVersions(featureName: string): string[];
  48749. /**
  48750. * Return the latest unstable version of this feature
  48751. * @param featureName the name of the feature to search
  48752. * @returns the version number. if not found will return -1
  48753. */
  48754. static GetLatestVersionOfFeature(featureName: string): number;
  48755. /**
  48756. * Return the latest stable version of this feature
  48757. * @param featureName the name of the feature to search
  48758. * @returns the version number. if not found will return -1
  48759. */
  48760. static GetStableVersionOfFeature(featureName: string): number;
  48761. /**
  48762. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48763. * Can be used during a session to start a feature
  48764. * @param featureName the name of feature to attach
  48765. */
  48766. attachFeature(featureName: string): void;
  48767. /**
  48768. * Can be used inside a session or when the session ends to detach a specific feature
  48769. * @param featureName the name of the feature to detach
  48770. */
  48771. detachFeature(featureName: string): void;
  48772. /**
  48773. * Used to disable an already-enabled feature
  48774. * The feature will be disposed and will be recreated once enabled.
  48775. * @param featureName the feature to disable
  48776. * @returns true if disable was successful
  48777. */
  48778. disableFeature(featureName: string | {
  48779. Name: string;
  48780. }): boolean;
  48781. /**
  48782. * dispose this features manager
  48783. */
  48784. dispose(): void;
  48785. /**
  48786. * 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.
  48787. * 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.
  48788. *
  48789. * @param featureName the name of the feature to load or the class of the feature
  48790. * @param version optional version to load. if not provided the latest version will be enabled
  48791. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48792. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48793. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48794. * @returns a new constructed feature or throws an error if feature not found.
  48795. */
  48796. enableFeature(featureName: string | {
  48797. Name: string;
  48798. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48799. /**
  48800. * get the implementation of an enabled feature.
  48801. * @param featureName the name of the feature to load
  48802. * @returns the feature class, if found
  48803. */
  48804. getEnabledFeature(featureName: string): IWebXRFeature;
  48805. /**
  48806. * Get the list of enabled features
  48807. * @returns an array of enabled features
  48808. */
  48809. getEnabledFeatures(): string[];
  48810. /**
  48811. * This function will exten the session creation configuration object with enabled features.
  48812. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48813. * according to the defined "required" variable, provided during enableFeature call
  48814. * @param xrSessionInit the xr Session init object to extend
  48815. *
  48816. * @returns an extended XRSessionInit object
  48817. */
  48818. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  48819. }
  48820. }
  48821. declare module "babylonjs/XR/webXRExperienceHelper" {
  48822. import { Observable } from "babylonjs/Misc/observable";
  48823. import { IDisposable, Scene } from "babylonjs/scene";
  48824. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48825. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48826. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48827. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48828. /**
  48829. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48830. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48831. */
  48832. export class WebXRExperienceHelper implements IDisposable {
  48833. private scene;
  48834. private _nonVRCamera;
  48835. private _originalSceneAutoClear;
  48836. private _supported;
  48837. /**
  48838. * Camera used to render xr content
  48839. */
  48840. camera: WebXRCamera;
  48841. /** A features manager for this xr session */
  48842. featuresManager: WebXRFeaturesManager;
  48843. /**
  48844. * Observers registered here will be triggered after the camera's initial transformation is set
  48845. * This can be used to set a different ground level or an extra rotation.
  48846. *
  48847. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48848. * to the position set after this observable is done executing.
  48849. */
  48850. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48851. /**
  48852. * Fires when the state of the experience helper has changed
  48853. */
  48854. onStateChangedObservable: Observable<WebXRState>;
  48855. /** Session manager used to keep track of xr session */
  48856. sessionManager: WebXRSessionManager;
  48857. /**
  48858. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48859. */
  48860. state: WebXRState;
  48861. /**
  48862. * Creates a WebXRExperienceHelper
  48863. * @param scene The scene the helper should be created in
  48864. */
  48865. private constructor();
  48866. /**
  48867. * Creates the experience helper
  48868. * @param scene the scene to attach the experience helper to
  48869. * @returns a promise for the experience helper
  48870. */
  48871. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48872. /**
  48873. * Disposes of the experience helper
  48874. */
  48875. dispose(): void;
  48876. /**
  48877. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48878. * @param sessionMode options for the XR session
  48879. * @param referenceSpaceType frame of reference of the XR session
  48880. * @param renderTarget the output canvas that will be used to enter XR mode
  48881. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48882. * @returns promise that resolves after xr mode has entered
  48883. */
  48884. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48885. /**
  48886. * Exits XR mode and returns the scene to its original state
  48887. * @returns promise that resolves after xr mode has exited
  48888. */
  48889. exitXRAsync(): Promise<void>;
  48890. private _nonXRToXRCamera;
  48891. private _setState;
  48892. }
  48893. }
  48894. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48895. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48896. import { Observable } from "babylonjs/Misc/observable";
  48897. import { IDisposable } from "babylonjs/scene";
  48898. /**
  48899. * X-Y values for axes in WebXR
  48900. */
  48901. export interface IWebXRMotionControllerAxesValue {
  48902. /**
  48903. * The value of the x axis
  48904. */
  48905. x: number;
  48906. /**
  48907. * The value of the y-axis
  48908. */
  48909. y: number;
  48910. }
  48911. /**
  48912. * changed / previous values for the values of this component
  48913. */
  48914. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48915. /**
  48916. * current (this frame) value
  48917. */
  48918. current: T;
  48919. /**
  48920. * previous (last change) value
  48921. */
  48922. previous: T;
  48923. }
  48924. /**
  48925. * Represents changes in the component between current frame and last values recorded
  48926. */
  48927. export interface IWebXRMotionControllerComponentChanges {
  48928. /**
  48929. * will be populated with previous and current values if axes changed
  48930. */
  48931. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48932. /**
  48933. * will be populated with previous and current values if pressed changed
  48934. */
  48935. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48936. /**
  48937. * will be populated with previous and current values if touched changed
  48938. */
  48939. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48940. /**
  48941. * will be populated with previous and current values if value changed
  48942. */
  48943. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48944. }
  48945. /**
  48946. * This class represents a single component (for example button or thumbstick) of a motion controller
  48947. */
  48948. export class WebXRControllerComponent implements IDisposable {
  48949. /**
  48950. * the id of this component
  48951. */
  48952. id: string;
  48953. /**
  48954. * the type of the component
  48955. */
  48956. type: MotionControllerComponentType;
  48957. private _buttonIndex;
  48958. private _axesIndices;
  48959. private _axes;
  48960. private _changes;
  48961. private _currentValue;
  48962. private _hasChanges;
  48963. private _pressed;
  48964. private _touched;
  48965. /**
  48966. * button component type
  48967. */
  48968. static BUTTON_TYPE: MotionControllerComponentType;
  48969. /**
  48970. * squeeze component type
  48971. */
  48972. static SQUEEZE_TYPE: MotionControllerComponentType;
  48973. /**
  48974. * Thumbstick component type
  48975. */
  48976. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48977. /**
  48978. * Touchpad component type
  48979. */
  48980. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48981. /**
  48982. * trigger component type
  48983. */
  48984. static TRIGGER_TYPE: MotionControllerComponentType;
  48985. /**
  48986. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48987. * the axes data changes
  48988. */
  48989. onAxisValueChangedObservable: Observable<{
  48990. x: number;
  48991. y: number;
  48992. }>;
  48993. /**
  48994. * Observers registered here will be triggered when the state of a button changes
  48995. * State change is either pressed / touched / value
  48996. */
  48997. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48998. /**
  48999. * Creates a new component for a motion controller.
  49000. * It is created by the motion controller itself
  49001. *
  49002. * @param id the id of this component
  49003. * @param type the type of the component
  49004. * @param _buttonIndex index in the buttons array of the gamepad
  49005. * @param _axesIndices indices of the values in the axes array of the gamepad
  49006. */
  49007. constructor(
  49008. /**
  49009. * the id of this component
  49010. */
  49011. id: string,
  49012. /**
  49013. * the type of the component
  49014. */
  49015. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49016. /**
  49017. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49018. */
  49019. get axes(): IWebXRMotionControllerAxesValue;
  49020. /**
  49021. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49022. */
  49023. get changes(): IWebXRMotionControllerComponentChanges;
  49024. /**
  49025. * Return whether or not the component changed the last frame
  49026. */
  49027. get hasChanges(): boolean;
  49028. /**
  49029. * is the button currently pressed
  49030. */
  49031. get pressed(): boolean;
  49032. /**
  49033. * is the button currently touched
  49034. */
  49035. get touched(): boolean;
  49036. /**
  49037. * Get the current value of this component
  49038. */
  49039. get value(): number;
  49040. /**
  49041. * Dispose this component
  49042. */
  49043. dispose(): void;
  49044. /**
  49045. * Are there axes correlating to this component
  49046. * @return true is axes data is available
  49047. */
  49048. isAxes(): boolean;
  49049. /**
  49050. * Is this component a button (hence - pressable)
  49051. * @returns true if can be pressed
  49052. */
  49053. isButton(): boolean;
  49054. /**
  49055. * update this component using the gamepad object it is in. Called on every frame
  49056. * @param nativeController the native gamepad controller object
  49057. */
  49058. update(nativeController: IMinimalMotionControllerObject): void;
  49059. }
  49060. }
  49061. declare module "babylonjs/Loading/sceneLoader" {
  49062. import { Observable } from "babylonjs/Misc/observable";
  49063. import { Nullable } from "babylonjs/types";
  49064. import { Scene } from "babylonjs/scene";
  49065. import { Engine } from "babylonjs/Engines/engine";
  49066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49067. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49068. import { AssetContainer } from "babylonjs/assetContainer";
  49069. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49070. import { Skeleton } from "babylonjs/Bones/skeleton";
  49071. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49072. import { WebRequest } from "babylonjs/Misc/webRequest";
  49073. /**
  49074. * Interface used to represent data loading progression
  49075. */
  49076. export interface ISceneLoaderProgressEvent {
  49077. /**
  49078. * Defines if data length to load can be evaluated
  49079. */
  49080. readonly lengthComputable: boolean;
  49081. /**
  49082. * Defines the loaded data length
  49083. */
  49084. readonly loaded: number;
  49085. /**
  49086. * Defines the data length to load
  49087. */
  49088. readonly total: number;
  49089. }
  49090. /**
  49091. * Interface used by SceneLoader plugins to define supported file extensions
  49092. */
  49093. export interface ISceneLoaderPluginExtensions {
  49094. /**
  49095. * Defines the list of supported extensions
  49096. */
  49097. [extension: string]: {
  49098. isBinary: boolean;
  49099. };
  49100. }
  49101. /**
  49102. * Interface used by SceneLoader plugin factory
  49103. */
  49104. export interface ISceneLoaderPluginFactory {
  49105. /**
  49106. * Defines the name of the factory
  49107. */
  49108. name: string;
  49109. /**
  49110. * Function called to create a new plugin
  49111. * @return the new plugin
  49112. */
  49113. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49114. /**
  49115. * The callback that returns true if the data can be directly loaded.
  49116. * @param data string containing the file data
  49117. * @returns if the data can be loaded directly
  49118. */
  49119. canDirectLoad?(data: string): boolean;
  49120. }
  49121. /**
  49122. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49123. */
  49124. export interface ISceneLoaderPluginBase {
  49125. /**
  49126. * The friendly name of this plugin.
  49127. */
  49128. name: string;
  49129. /**
  49130. * The file extensions supported by this plugin.
  49131. */
  49132. extensions: string | ISceneLoaderPluginExtensions;
  49133. /**
  49134. * The callback called when loading from a url.
  49135. * @param scene scene loading this url
  49136. * @param url url to load
  49137. * @param onSuccess callback called when the file successfully loads
  49138. * @param onProgress callback called while file is loading (if the server supports this mode)
  49139. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49140. * @param onError callback called when the file fails to load
  49141. * @returns a file request object
  49142. */
  49143. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49144. /**
  49145. * The callback called when loading from a file object.
  49146. * @param scene scene loading this file
  49147. * @param file defines the file to load
  49148. * @param onSuccess defines the callback to call when data is loaded
  49149. * @param onProgress defines the callback to call during loading process
  49150. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49151. * @param onError defines the callback to call when an error occurs
  49152. * @returns a file request object
  49153. */
  49154. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49155. /**
  49156. * The callback that returns true if the data can be directly loaded.
  49157. * @param data string containing the file data
  49158. * @returns if the data can be loaded directly
  49159. */
  49160. canDirectLoad?(data: string): boolean;
  49161. /**
  49162. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49163. * @param scene scene loading this data
  49164. * @param data string containing the data
  49165. * @returns data to pass to the plugin
  49166. */
  49167. directLoad?(scene: Scene, data: string): any;
  49168. /**
  49169. * The callback that allows custom handling of the root url based on the response url.
  49170. * @param rootUrl the original root url
  49171. * @param responseURL the response url if available
  49172. * @returns the new root url
  49173. */
  49174. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49175. }
  49176. /**
  49177. * Interface used to define a SceneLoader plugin
  49178. */
  49179. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49180. /**
  49181. * Import meshes into a scene.
  49182. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49183. * @param scene The scene to import into
  49184. * @param data The data to import
  49185. * @param rootUrl The root url for scene and resources
  49186. * @param meshes The meshes array to import into
  49187. * @param particleSystems The particle systems array to import into
  49188. * @param skeletons The skeletons array to import into
  49189. * @param onError The callback when import fails
  49190. * @returns True if successful or false otherwise
  49191. */
  49192. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49193. /**
  49194. * Load into a scene.
  49195. * @param scene The scene to load into
  49196. * @param data The data to import
  49197. * @param rootUrl The root url for scene and resources
  49198. * @param onError The callback when import fails
  49199. * @returns True if successful or false otherwise
  49200. */
  49201. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49202. /**
  49203. * Load into an asset container.
  49204. * @param scene The scene to load into
  49205. * @param data The data to import
  49206. * @param rootUrl The root url for scene and resources
  49207. * @param onError The callback when import fails
  49208. * @returns The loaded asset container
  49209. */
  49210. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49211. }
  49212. /**
  49213. * Interface used to define an async SceneLoader plugin
  49214. */
  49215. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49216. /**
  49217. * Import meshes into a scene.
  49218. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49219. * @param scene The scene to import into
  49220. * @param data The data to import
  49221. * @param rootUrl The root url for scene and resources
  49222. * @param onProgress The callback when the load progresses
  49223. * @param fileName Defines the name of the file to load
  49224. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49225. */
  49226. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49227. meshes: AbstractMesh[];
  49228. particleSystems: IParticleSystem[];
  49229. skeletons: Skeleton[];
  49230. animationGroups: AnimationGroup[];
  49231. }>;
  49232. /**
  49233. * Load into a scene.
  49234. * @param scene The scene to load into
  49235. * @param data The data to import
  49236. * @param rootUrl The root url for scene and resources
  49237. * @param onProgress The callback when the load progresses
  49238. * @param fileName Defines the name of the file to load
  49239. * @returns Nothing
  49240. */
  49241. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49242. /**
  49243. * Load into an asset container.
  49244. * @param scene The scene to load into
  49245. * @param data The data to import
  49246. * @param rootUrl The root url for scene and resources
  49247. * @param onProgress The callback when the load progresses
  49248. * @param fileName Defines the name of the file to load
  49249. * @returns The loaded asset container
  49250. */
  49251. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49252. }
  49253. /**
  49254. * Mode that determines how to handle old animation groups before loading new ones.
  49255. */
  49256. export enum SceneLoaderAnimationGroupLoadingMode {
  49257. /**
  49258. * Reset all old animations to initial state then dispose them.
  49259. */
  49260. Clean = 0,
  49261. /**
  49262. * Stop all old animations.
  49263. */
  49264. Stop = 1,
  49265. /**
  49266. * Restart old animations from first frame.
  49267. */
  49268. Sync = 2,
  49269. /**
  49270. * Old animations remains untouched.
  49271. */
  49272. NoSync = 3
  49273. }
  49274. /**
  49275. * Defines a plugin registered by the SceneLoader
  49276. */
  49277. interface IRegisteredPlugin {
  49278. /**
  49279. * Defines the plugin to use
  49280. */
  49281. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49282. /**
  49283. * Defines if the plugin supports binary data
  49284. */
  49285. isBinary: boolean;
  49286. }
  49287. /**
  49288. * Class used to load scene from various file formats using registered plugins
  49289. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49290. */
  49291. export class SceneLoader {
  49292. /**
  49293. * No logging while loading
  49294. */
  49295. static readonly NO_LOGGING: number;
  49296. /**
  49297. * Minimal logging while loading
  49298. */
  49299. static readonly MINIMAL_LOGGING: number;
  49300. /**
  49301. * Summary logging while loading
  49302. */
  49303. static readonly SUMMARY_LOGGING: number;
  49304. /**
  49305. * Detailled logging while loading
  49306. */
  49307. static readonly DETAILED_LOGGING: number;
  49308. /**
  49309. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49310. */
  49311. static get ForceFullSceneLoadingForIncremental(): boolean;
  49312. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49313. /**
  49314. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49315. */
  49316. static get ShowLoadingScreen(): boolean;
  49317. static set ShowLoadingScreen(value: boolean);
  49318. /**
  49319. * Defines the current logging level (while loading the scene)
  49320. * @ignorenaming
  49321. */
  49322. static get loggingLevel(): number;
  49323. static set loggingLevel(value: number);
  49324. /**
  49325. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49326. */
  49327. static get CleanBoneMatrixWeights(): boolean;
  49328. static set CleanBoneMatrixWeights(value: boolean);
  49329. /**
  49330. * Event raised when a plugin is used to load a scene
  49331. */
  49332. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49333. private static _registeredPlugins;
  49334. private static _showingLoadingScreen;
  49335. /**
  49336. * Gets the default plugin (used to load Babylon files)
  49337. * @returns the .babylon plugin
  49338. */
  49339. static GetDefaultPlugin(): IRegisteredPlugin;
  49340. private static _GetPluginForExtension;
  49341. private static _GetPluginForDirectLoad;
  49342. private static _GetPluginForFilename;
  49343. private static _GetDirectLoad;
  49344. private static _LoadData;
  49345. private static _GetFileInfo;
  49346. /**
  49347. * Gets a plugin that can load the given extension
  49348. * @param extension defines the extension to load
  49349. * @returns a plugin or null if none works
  49350. */
  49351. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49352. /**
  49353. * Gets a boolean indicating that the given extension can be loaded
  49354. * @param extension defines the extension to load
  49355. * @returns true if the extension is supported
  49356. */
  49357. static IsPluginForExtensionAvailable(extension: string): boolean;
  49358. /**
  49359. * Adds a new plugin to the list of registered plugins
  49360. * @param plugin defines the plugin to add
  49361. */
  49362. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49363. /**
  49364. * Import meshes into a scene
  49365. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49366. * @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)
  49367. * @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)
  49368. * @param scene the instance of BABYLON.Scene to append to
  49369. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49370. * @param onProgress a callback with a progress event for each file being loaded
  49371. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49372. * @param pluginExtension the extension used to determine the plugin
  49373. * @returns The loaded plugin
  49374. */
  49375. 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>;
  49376. /**
  49377. * Import meshes into a scene
  49378. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49379. * @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)
  49380. * @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)
  49381. * @param scene the instance of BABYLON.Scene to append to
  49382. * @param onProgress a callback with a progress event for each file being loaded
  49383. * @param pluginExtension the extension used to determine the plugin
  49384. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49385. */
  49386. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49387. meshes: AbstractMesh[];
  49388. particleSystems: IParticleSystem[];
  49389. skeletons: Skeleton[];
  49390. animationGroups: AnimationGroup[];
  49391. }>;
  49392. /**
  49393. * Load a scene
  49394. * @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)
  49395. * @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)
  49396. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49397. * @param onSuccess a callback with the scene when import succeeds
  49398. * @param onProgress a callback with a progress event for each file being loaded
  49399. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49400. * @param pluginExtension the extension used to determine the plugin
  49401. * @returns The loaded plugin
  49402. */
  49403. 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>;
  49404. /**
  49405. * Load a scene
  49406. * @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)
  49407. * @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)
  49408. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49409. * @param onProgress a callback with a progress event for each file being loaded
  49410. * @param pluginExtension the extension used to determine the plugin
  49411. * @returns The loaded scene
  49412. */
  49413. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49414. /**
  49415. * Append a scene
  49416. * @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)
  49417. * @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)
  49418. * @param scene is the instance of BABYLON.Scene to append to
  49419. * @param onSuccess a callback with the scene when import succeeds
  49420. * @param onProgress a callback with a progress event for each file being loaded
  49421. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49422. * @param pluginExtension the extension used to determine the plugin
  49423. * @returns The loaded plugin
  49424. */
  49425. 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>;
  49426. /**
  49427. * Append a scene
  49428. * @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)
  49429. * @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)
  49430. * @param scene is the instance of BABYLON.Scene to append to
  49431. * @param onProgress a callback with a progress event for each file being loaded
  49432. * @param pluginExtension the extension used to determine the plugin
  49433. * @returns The given scene
  49434. */
  49435. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49436. /**
  49437. * Load a scene into an asset container
  49438. * @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)
  49439. * @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)
  49440. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49441. * @param onSuccess a callback with the scene when import succeeds
  49442. * @param onProgress a callback with a progress event for each file being loaded
  49443. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49444. * @param pluginExtension the extension used to determine the plugin
  49445. * @returns The loaded plugin
  49446. */
  49447. 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>;
  49448. /**
  49449. * Load a scene into an asset container
  49450. * @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)
  49451. * @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)
  49452. * @param scene is the instance of Scene to append to
  49453. * @param onProgress a callback with a progress event for each file being loaded
  49454. * @param pluginExtension the extension used to determine the plugin
  49455. * @returns The loaded asset container
  49456. */
  49457. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49458. /**
  49459. * Import animations from a file into a scene
  49460. * @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)
  49461. * @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)
  49462. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49463. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49464. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49465. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49466. * @param onSuccess a callback with the scene when import succeeds
  49467. * @param onProgress a callback with a progress event for each file being loaded
  49468. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49469. * @param pluginExtension the extension used to determine the plugin
  49470. */
  49471. 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;
  49472. /**
  49473. * Import animations from a file into a scene
  49474. * @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)
  49475. * @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)
  49476. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49477. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49478. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49479. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49480. * @param onSuccess a callback with the scene when import succeeds
  49481. * @param onProgress a callback with a progress event for each file being loaded
  49482. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49483. * @param pluginExtension the extension used to determine the plugin
  49484. * @returns the updated scene with imported animations
  49485. */
  49486. 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>;
  49487. }
  49488. }
  49489. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49490. import { IDisposable, Scene } from "babylonjs/scene";
  49491. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49492. import { Observable } from "babylonjs/Misc/observable";
  49493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49494. import { Nullable } from "babylonjs/types";
  49495. /**
  49496. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49497. */
  49498. export type MotionControllerHandedness = "none" | "left" | "right";
  49499. /**
  49500. * The type of components available in motion controllers.
  49501. * This is not the name of the component.
  49502. */
  49503. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49504. /**
  49505. * The state of a controller component
  49506. */
  49507. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49508. /**
  49509. * The schema of motion controller layout.
  49510. * No object will be initialized using this interface
  49511. * This is used just to define the profile.
  49512. */
  49513. export interface IMotionControllerLayout {
  49514. /**
  49515. * Path to load the assets. Usually relative to the base path
  49516. */
  49517. assetPath: string;
  49518. /**
  49519. * Available components (unsorted)
  49520. */
  49521. components: {
  49522. /**
  49523. * A map of component Ids
  49524. */
  49525. [componentId: string]: {
  49526. /**
  49527. * The type of input the component outputs
  49528. */
  49529. type: MotionControllerComponentType;
  49530. /**
  49531. * The indices of this component in the gamepad object
  49532. */
  49533. gamepadIndices: {
  49534. /**
  49535. * Index of button
  49536. */
  49537. button?: number;
  49538. /**
  49539. * If available, index of x-axis
  49540. */
  49541. xAxis?: number;
  49542. /**
  49543. * If available, index of y-axis
  49544. */
  49545. yAxis?: number;
  49546. };
  49547. /**
  49548. * The mesh's root node name
  49549. */
  49550. rootNodeName: string;
  49551. /**
  49552. * Animation definitions for this model
  49553. */
  49554. visualResponses: {
  49555. [stateKey: string]: {
  49556. /**
  49557. * What property will be animated
  49558. */
  49559. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49560. /**
  49561. * What states influence this visual response
  49562. */
  49563. states: MotionControllerComponentStateType[];
  49564. /**
  49565. * Type of animation - movement or visibility
  49566. */
  49567. valueNodeProperty: "transform" | "visibility";
  49568. /**
  49569. * Base node name to move. Its position will be calculated according to the min and max nodes
  49570. */
  49571. valueNodeName?: string;
  49572. /**
  49573. * Minimum movement node
  49574. */
  49575. minNodeName?: string;
  49576. /**
  49577. * Max movement node
  49578. */
  49579. maxNodeName?: string;
  49580. };
  49581. };
  49582. /**
  49583. * If touch enabled, what is the name of node to display user feedback
  49584. */
  49585. touchPointNodeName?: string;
  49586. };
  49587. };
  49588. /**
  49589. * Is it xr standard mapping or not
  49590. */
  49591. gamepadMapping: "" | "xr-standard";
  49592. /**
  49593. * Base root node of this entire model
  49594. */
  49595. rootNodeName: string;
  49596. /**
  49597. * Defines the main button component id
  49598. */
  49599. selectComponentId: string;
  49600. }
  49601. /**
  49602. * A definition for the layout map in the input profile
  49603. */
  49604. export interface IMotionControllerLayoutMap {
  49605. /**
  49606. * Layouts with handedness type as a key
  49607. */
  49608. [handedness: string]: IMotionControllerLayout;
  49609. }
  49610. /**
  49611. * The XR Input profile schema
  49612. * Profiles can be found here:
  49613. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49614. */
  49615. export interface IMotionControllerProfile {
  49616. /**
  49617. * fallback profiles for this profileId
  49618. */
  49619. fallbackProfileIds: string[];
  49620. /**
  49621. * The layout map, with handedness as key
  49622. */
  49623. layouts: IMotionControllerLayoutMap;
  49624. /**
  49625. * The id of this profile
  49626. * correlates to the profile(s) in the xrInput.profiles array
  49627. */
  49628. profileId: string;
  49629. }
  49630. /**
  49631. * A helper-interface for the 3 meshes needed for controller button animation
  49632. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49633. */
  49634. export interface IMotionControllerButtonMeshMap {
  49635. /**
  49636. * the mesh that defines the pressed value mesh position.
  49637. * This is used to find the max-position of this button
  49638. */
  49639. pressedMesh: AbstractMesh;
  49640. /**
  49641. * the mesh that defines the unpressed value mesh position.
  49642. * This is used to find the min (or initial) position of this button
  49643. */
  49644. unpressedMesh: AbstractMesh;
  49645. /**
  49646. * The mesh that will be changed when value changes
  49647. */
  49648. valueMesh: AbstractMesh;
  49649. }
  49650. /**
  49651. * A helper-interface for the 3 meshes needed for controller axis animation.
  49652. * This will be expanded when touchpad animations are fully supported
  49653. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49654. */
  49655. export interface IMotionControllerMeshMap {
  49656. /**
  49657. * the mesh that defines the maximum value mesh position.
  49658. */
  49659. maxMesh?: AbstractMesh;
  49660. /**
  49661. * the mesh that defines the minimum value mesh position.
  49662. */
  49663. minMesh?: AbstractMesh;
  49664. /**
  49665. * The mesh that will be changed when axis value changes
  49666. */
  49667. valueMesh: AbstractMesh;
  49668. }
  49669. /**
  49670. * The elements needed for change-detection of the gamepad objects in motion controllers
  49671. */
  49672. export interface IMinimalMotionControllerObject {
  49673. /**
  49674. * Available axes of this controller
  49675. */
  49676. axes: number[];
  49677. /**
  49678. * An array of available buttons
  49679. */
  49680. buttons: Array<{
  49681. /**
  49682. * Value of the button/trigger
  49683. */
  49684. value: number;
  49685. /**
  49686. * If the button/trigger is currently touched
  49687. */
  49688. touched: boolean;
  49689. /**
  49690. * If the button/trigger is currently pressed
  49691. */
  49692. pressed: boolean;
  49693. }>;
  49694. /**
  49695. * EXPERIMENTAL haptic support.
  49696. */
  49697. hapticActuators?: Array<{
  49698. pulse: (value: number, duration: number) => Promise<boolean>;
  49699. }>;
  49700. }
  49701. /**
  49702. * An Abstract Motion controller
  49703. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49704. * Each component has an observable to check for changes in value and state
  49705. */
  49706. export abstract class WebXRAbstractMotionController implements IDisposable {
  49707. protected scene: Scene;
  49708. protected layout: IMotionControllerLayout;
  49709. /**
  49710. * The gamepad object correlating to this controller
  49711. */
  49712. gamepadObject: IMinimalMotionControllerObject;
  49713. /**
  49714. * handedness (left/right/none) of this controller
  49715. */
  49716. handedness: MotionControllerHandedness;
  49717. private _initComponent;
  49718. private _modelReady;
  49719. /**
  49720. * A map of components (WebXRControllerComponent) in this motion controller
  49721. * Components have a ComponentType and can also have both button and axis definitions
  49722. */
  49723. readonly components: {
  49724. [id: string]: WebXRControllerComponent;
  49725. };
  49726. /**
  49727. * Disable the model's animation. Can be set at any time.
  49728. */
  49729. disableAnimation: boolean;
  49730. /**
  49731. * Observers registered here will be triggered when the model of this controller is done loading
  49732. */
  49733. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49734. /**
  49735. * The profile id of this motion controller
  49736. */
  49737. abstract profileId: string;
  49738. /**
  49739. * The root mesh of the model. It is null if the model was not yet initialized
  49740. */
  49741. rootMesh: Nullable<AbstractMesh>;
  49742. /**
  49743. * constructs a new abstract motion controller
  49744. * @param scene the scene to which the model of the controller will be added
  49745. * @param layout The profile layout to load
  49746. * @param gamepadObject The gamepad object correlating to this controller
  49747. * @param handedness handedness (left/right/none) of this controller
  49748. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49749. */
  49750. constructor(scene: Scene, layout: IMotionControllerLayout,
  49751. /**
  49752. * The gamepad object correlating to this controller
  49753. */
  49754. gamepadObject: IMinimalMotionControllerObject,
  49755. /**
  49756. * handedness (left/right/none) of this controller
  49757. */
  49758. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49759. /**
  49760. * Dispose this controller, the model mesh and all its components
  49761. */
  49762. dispose(): void;
  49763. /**
  49764. * Returns all components of specific type
  49765. * @param type the type to search for
  49766. * @return an array of components with this type
  49767. */
  49768. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49769. /**
  49770. * get a component based an its component id as defined in layout.components
  49771. * @param id the id of the component
  49772. * @returns the component correlates to the id or undefined if not found
  49773. */
  49774. getComponent(id: string): WebXRControllerComponent;
  49775. /**
  49776. * Get the list of components available in this motion controller
  49777. * @returns an array of strings correlating to available components
  49778. */
  49779. getComponentIds(): string[];
  49780. /**
  49781. * Get the first component of specific type
  49782. * @param type type of component to find
  49783. * @return a controller component or null if not found
  49784. */
  49785. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49786. /**
  49787. * Get the main (Select) component of this controller as defined in the layout
  49788. * @returns the main component of this controller
  49789. */
  49790. getMainComponent(): WebXRControllerComponent;
  49791. /**
  49792. * Loads the model correlating to this controller
  49793. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49794. * @returns A promise fulfilled with the result of the model loading
  49795. */
  49796. loadModel(): Promise<boolean>;
  49797. /**
  49798. * Update this model using the current XRFrame
  49799. * @param xrFrame the current xr frame to use and update the model
  49800. */
  49801. updateFromXRFrame(xrFrame: XRFrame): void;
  49802. /**
  49803. * Backwards compatibility due to a deeply-integrated typo
  49804. */
  49805. get handness(): XREye;
  49806. /**
  49807. * Pulse (vibrate) this controller
  49808. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49809. * Consecutive calls to this function will cancel the last pulse call
  49810. *
  49811. * @param value the strength of the pulse in 0.0...1.0 range
  49812. * @param duration Duration of the pulse in milliseconds
  49813. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49814. * @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
  49815. */
  49816. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49817. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49818. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49819. /**
  49820. * Moves the axis on the controller mesh based on its current state
  49821. * @param axis the index of the axis
  49822. * @param axisValue the value of the axis which determines the meshes new position
  49823. * @hidden
  49824. */
  49825. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49826. /**
  49827. * Update the model itself with the current frame data
  49828. * @param xrFrame the frame to use for updating the model mesh
  49829. */
  49830. protected updateModel(xrFrame: XRFrame): void;
  49831. /**
  49832. * Get the filename and path for this controller's model
  49833. * @returns a map of filename and path
  49834. */
  49835. protected abstract _getFilenameAndPath(): {
  49836. filename: string;
  49837. path: string;
  49838. };
  49839. /**
  49840. * This function is called before the mesh is loaded. It checks for loading constraints.
  49841. * For example, this function can check if the GLB loader is available
  49842. * If this function returns false, the generic controller will be loaded instead
  49843. * @returns Is the client ready to load the mesh
  49844. */
  49845. protected abstract _getModelLoadingConstraints(): boolean;
  49846. /**
  49847. * This function will be called after the model was successfully loaded and can be used
  49848. * for mesh transformations before it is available for the user
  49849. * @param meshes the loaded meshes
  49850. */
  49851. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49852. /**
  49853. * Set the root mesh for this controller. Important for the WebXR controller class
  49854. * @param meshes the loaded meshes
  49855. */
  49856. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49857. /**
  49858. * A function executed each frame that updates the mesh (if needed)
  49859. * @param xrFrame the current xrFrame
  49860. */
  49861. protected abstract _updateModel(xrFrame: XRFrame): void;
  49862. private _getGenericFilenameAndPath;
  49863. private _getGenericParentMesh;
  49864. }
  49865. }
  49866. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49867. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49869. import { Scene } from "babylonjs/scene";
  49870. /**
  49871. * A generic trigger-only motion controller for WebXR
  49872. */
  49873. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49874. /**
  49875. * Static version of the profile id of this controller
  49876. */
  49877. static ProfileId: string;
  49878. profileId: string;
  49879. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49880. protected _getFilenameAndPath(): {
  49881. filename: string;
  49882. path: string;
  49883. };
  49884. protected _getModelLoadingConstraints(): boolean;
  49885. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49886. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49887. protected _updateModel(): void;
  49888. }
  49889. }
  49890. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49891. import { Vector4 } from "babylonjs/Maths/math.vector";
  49892. import { Mesh } from "babylonjs/Meshes/mesh";
  49893. import { Scene } from "babylonjs/scene";
  49894. import { Nullable } from "babylonjs/types";
  49895. /**
  49896. * Class containing static functions to help procedurally build meshes
  49897. */
  49898. export class SphereBuilder {
  49899. /**
  49900. * Creates a sphere mesh
  49901. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49902. * * 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`)
  49903. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49904. * * 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
  49905. * * 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)
  49906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49909. * @param name defines the name of the mesh
  49910. * @param options defines the options used to create the mesh
  49911. * @param scene defines the hosting scene
  49912. * @returns the sphere mesh
  49913. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49914. */
  49915. static CreateSphere(name: string, options: {
  49916. segments?: number;
  49917. diameter?: number;
  49918. diameterX?: number;
  49919. diameterY?: number;
  49920. diameterZ?: number;
  49921. arc?: number;
  49922. slice?: number;
  49923. sideOrientation?: number;
  49924. frontUVs?: Vector4;
  49925. backUVs?: Vector4;
  49926. updatable?: boolean;
  49927. }, scene?: Nullable<Scene>): Mesh;
  49928. }
  49929. }
  49930. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49932. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49933. import { Scene } from "babylonjs/scene";
  49934. /**
  49935. * A profiled motion controller has its profile loaded from an online repository.
  49936. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49937. */
  49938. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49939. private _repositoryUrl;
  49940. private _buttonMeshMapping;
  49941. private _touchDots;
  49942. /**
  49943. * The profile ID of this controller. Will be populated when the controller initializes.
  49944. */
  49945. profileId: string;
  49946. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49947. dispose(): void;
  49948. protected _getFilenameAndPath(): {
  49949. filename: string;
  49950. path: string;
  49951. };
  49952. protected _getModelLoadingConstraints(): boolean;
  49953. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49954. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49955. protected _updateModel(_xrFrame: XRFrame): void;
  49956. }
  49957. }
  49958. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49959. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49960. import { Scene } from "babylonjs/scene";
  49961. /**
  49962. * A construction function type to create a new controller based on an xrInput object
  49963. */
  49964. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49965. /**
  49966. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49967. *
  49968. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49969. * it should be replaced with auto-loaded controllers.
  49970. *
  49971. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49972. */
  49973. export class WebXRMotionControllerManager {
  49974. private static _AvailableControllers;
  49975. private static _Fallbacks;
  49976. private static _ProfileLoadingPromises;
  49977. private static _ProfilesList;
  49978. /**
  49979. * The base URL of the online controller repository. Can be changed at any time.
  49980. */
  49981. static BaseRepositoryUrl: string;
  49982. /**
  49983. * Which repository gets priority - local or online
  49984. */
  49985. static PrioritizeOnlineRepository: boolean;
  49986. /**
  49987. * Use the online repository, or use only locally-defined controllers
  49988. */
  49989. static UseOnlineRepository: boolean;
  49990. /**
  49991. * Clear the cache used for profile loading and reload when requested again
  49992. */
  49993. static ClearProfilesCache(): void;
  49994. /**
  49995. * Register the default fallbacks.
  49996. * This function is called automatically when this file is imported.
  49997. */
  49998. static DefaultFallbacks(): void;
  49999. /**
  50000. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50001. * @param profileId the profile to which a fallback needs to be found
  50002. * @return an array with corresponding fallback profiles
  50003. */
  50004. static FindFallbackWithProfileId(profileId: string): string[];
  50005. /**
  50006. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50007. * The order of search:
  50008. *
  50009. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50010. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50011. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50012. * 4) return the generic trigger controller if none were found
  50013. *
  50014. * @param xrInput the xrInput to which a new controller is initialized
  50015. * @param scene the scene to which the model will be added
  50016. * @param forceProfile force a certain profile for this controller
  50017. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50018. */
  50019. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50020. /**
  50021. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50022. *
  50023. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50024. *
  50025. * @param type the profile type to register
  50026. * @param constructFunction the function to be called when loading this profile
  50027. */
  50028. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50029. /**
  50030. * Register a fallback to a specific profile.
  50031. * @param profileId the profileId that will receive the fallbacks
  50032. * @param fallbacks A list of fallback profiles
  50033. */
  50034. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50035. /**
  50036. * Will update the list of profiles available in the repository
  50037. * @return a promise that resolves to a map of profiles available online
  50038. */
  50039. static UpdateProfilesList(): Promise<{
  50040. [profile: string]: string;
  50041. }>;
  50042. private static _LoadProfileFromRepository;
  50043. private static _LoadProfilesFromAvailableControllers;
  50044. }
  50045. }
  50046. declare module "babylonjs/XR/webXRInputSource" {
  50047. import { Observable } from "babylonjs/Misc/observable";
  50048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50049. import { Ray } from "babylonjs/Culling/ray";
  50050. import { Scene } from "babylonjs/scene";
  50051. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50052. /**
  50053. * Configuration options for the WebXR controller creation
  50054. */
  50055. export interface IWebXRControllerOptions {
  50056. /**
  50057. * Should the controller mesh be animated when a user interacts with it
  50058. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50059. */
  50060. disableMotionControllerAnimation?: boolean;
  50061. /**
  50062. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50063. */
  50064. doNotLoadControllerMesh?: boolean;
  50065. /**
  50066. * Force a specific controller type for this controller.
  50067. * This can be used when creating your own profile or when testing different controllers
  50068. */
  50069. forceControllerProfile?: string;
  50070. /**
  50071. * Defines a rendering group ID for meshes that will be loaded.
  50072. * This is for the default controllers only.
  50073. */
  50074. renderingGroupId?: number;
  50075. }
  50076. /**
  50077. * Represents an XR controller
  50078. */
  50079. export class WebXRInputSource {
  50080. private _scene;
  50081. /** The underlying input source for the controller */
  50082. inputSource: XRInputSource;
  50083. private _options;
  50084. private _tmpVector;
  50085. private _uniqueId;
  50086. /**
  50087. * 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
  50088. */
  50089. grip?: AbstractMesh;
  50090. /**
  50091. * If available, this is the gamepad object related to this controller.
  50092. * Using this object it is possible to get click events and trackpad changes of the
  50093. * webxr controller that is currently being used.
  50094. */
  50095. motionController?: WebXRAbstractMotionController;
  50096. /**
  50097. * Event that fires when the controller is removed/disposed.
  50098. * The object provided as event data is this controller, after associated assets were disposed.
  50099. * uniqueId is still available.
  50100. */
  50101. onDisposeObservable: Observable<WebXRInputSource>;
  50102. /**
  50103. * Will be triggered when the mesh associated with the motion controller is done loading.
  50104. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50105. * A shortened version of controller -> motion controller -> on mesh loaded.
  50106. */
  50107. onMeshLoadedObservable: Observable<AbstractMesh>;
  50108. /**
  50109. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50110. */
  50111. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50112. /**
  50113. * Pointer which can be used to select objects or attach a visible laser to
  50114. */
  50115. pointer: AbstractMesh;
  50116. /**
  50117. * Creates the input source object
  50118. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50119. * @param _scene the scene which the controller should be associated to
  50120. * @param inputSource the underlying input source for the controller
  50121. * @param _options options for this controller creation
  50122. */
  50123. constructor(_scene: Scene,
  50124. /** The underlying input source for the controller */
  50125. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50126. /**
  50127. * Get this controllers unique id
  50128. */
  50129. get uniqueId(): string;
  50130. /**
  50131. * Disposes of the object
  50132. */
  50133. dispose(): void;
  50134. /**
  50135. * Gets a world space ray coming from the pointer or grip
  50136. * @param result the resulting ray
  50137. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50138. */
  50139. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50140. /**
  50141. * Updates the controller pose based on the given XRFrame
  50142. * @param xrFrame xr frame to update the pose with
  50143. * @param referenceSpace reference space to use
  50144. */
  50145. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50146. }
  50147. }
  50148. declare module "babylonjs/XR/webXRInput" {
  50149. import { Observable } from "babylonjs/Misc/observable";
  50150. import { IDisposable } from "babylonjs/scene";
  50151. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50152. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50153. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50154. /**
  50155. * The schema for initialization options of the XR Input class
  50156. */
  50157. export interface IWebXRInputOptions {
  50158. /**
  50159. * If set to true no model will be automatically loaded
  50160. */
  50161. doNotLoadControllerMeshes?: boolean;
  50162. /**
  50163. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50164. * If not found, the xr input profile data will be used.
  50165. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50166. */
  50167. forceInputProfile?: string;
  50168. /**
  50169. * Do not send a request to the controller repository to load the profile.
  50170. *
  50171. * Instead, use the controllers available in babylon itself.
  50172. */
  50173. disableOnlineControllerRepository?: boolean;
  50174. /**
  50175. * A custom URL for the controllers repository
  50176. */
  50177. customControllersRepositoryURL?: string;
  50178. /**
  50179. * Should the controller model's components not move according to the user input
  50180. */
  50181. disableControllerAnimation?: boolean;
  50182. /**
  50183. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50184. */
  50185. controllerOptions?: IWebXRControllerOptions;
  50186. }
  50187. /**
  50188. * XR input used to track XR inputs such as controllers/rays
  50189. */
  50190. export class WebXRInput implements IDisposable {
  50191. /**
  50192. * the xr session manager for this session
  50193. */
  50194. xrSessionManager: WebXRSessionManager;
  50195. /**
  50196. * the WebXR camera for this session. Mainly used for teleportation
  50197. */
  50198. xrCamera: WebXRCamera;
  50199. private readonly options;
  50200. /**
  50201. * XR controllers being tracked
  50202. */
  50203. controllers: Array<WebXRInputSource>;
  50204. private _frameObserver;
  50205. private _sessionEndedObserver;
  50206. private _sessionInitObserver;
  50207. /**
  50208. * Event when a controller has been connected/added
  50209. */
  50210. onControllerAddedObservable: Observable<WebXRInputSource>;
  50211. /**
  50212. * Event when a controller has been removed/disconnected
  50213. */
  50214. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50215. /**
  50216. * Initializes the WebXRInput
  50217. * @param xrSessionManager the xr session manager for this session
  50218. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50219. * @param options = initialization options for this xr input
  50220. */
  50221. constructor(
  50222. /**
  50223. * the xr session manager for this session
  50224. */
  50225. xrSessionManager: WebXRSessionManager,
  50226. /**
  50227. * the WebXR camera for this session. Mainly used for teleportation
  50228. */
  50229. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50230. private _onInputSourcesChange;
  50231. private _addAndRemoveControllers;
  50232. /**
  50233. * Disposes of the object
  50234. */
  50235. dispose(): void;
  50236. }
  50237. }
  50238. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50239. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50240. import { Observable, EventState } from "babylonjs/Misc/observable";
  50241. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50242. /**
  50243. * This is the base class for all WebXR features.
  50244. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50245. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50246. */
  50247. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50248. protected _xrSessionManager: WebXRSessionManager;
  50249. private _attached;
  50250. private _removeOnDetach;
  50251. /**
  50252. * Should auto-attach be disabled?
  50253. */
  50254. disableAutoAttach: boolean;
  50255. /**
  50256. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50257. */
  50258. xrNativeFeatureName: string;
  50259. /**
  50260. * Construct a new (abstract) WebXR feature
  50261. * @param _xrSessionManager the xr session manager for this feature
  50262. */
  50263. constructor(_xrSessionManager: WebXRSessionManager);
  50264. /**
  50265. * Is this feature attached
  50266. */
  50267. get attached(): boolean;
  50268. /**
  50269. * attach this feature
  50270. *
  50271. * @param force should attachment be forced (even when already attached)
  50272. * @returns true if successful, false is failed or already attached
  50273. */
  50274. attach(force?: boolean): boolean;
  50275. /**
  50276. * detach this feature.
  50277. *
  50278. * @returns true if successful, false if failed or already detached
  50279. */
  50280. detach(): boolean;
  50281. /**
  50282. * Dispose this feature and all of the resources attached
  50283. */
  50284. dispose(): void;
  50285. /**
  50286. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50287. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50288. *
  50289. * @returns whether or not the feature is compatible in this environment
  50290. */
  50291. isCompatible(): boolean;
  50292. /**
  50293. * This is used to register callbacks that will automatically be removed when detach is called.
  50294. * @param observable the observable to which the observer will be attached
  50295. * @param callback the callback to register
  50296. */
  50297. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50298. /**
  50299. * Code in this function will be executed on each xrFrame received from the browser.
  50300. * This function will not execute after the feature is detached.
  50301. * @param _xrFrame the current frame
  50302. */
  50303. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50304. }
  50305. }
  50306. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50307. import { IDisposable, Scene } from "babylonjs/scene";
  50308. import { Nullable } from "babylonjs/types";
  50309. import { Observable } from "babylonjs/Misc/observable";
  50310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50311. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50312. import { Camera } from "babylonjs/Cameras/camera";
  50313. /**
  50314. * Renders a layer on top of an existing scene
  50315. */
  50316. export class UtilityLayerRenderer implements IDisposable {
  50317. /** the original scene that will be rendered on top of */
  50318. originalScene: Scene;
  50319. private _pointerCaptures;
  50320. private _lastPointerEvents;
  50321. private static _DefaultUtilityLayer;
  50322. private static _DefaultKeepDepthUtilityLayer;
  50323. private _sharedGizmoLight;
  50324. private _renderCamera;
  50325. /**
  50326. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50327. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50328. * @returns the camera that is used when rendering the utility layer
  50329. */
  50330. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50331. /**
  50332. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50333. * @param cam the camera that should be used when rendering the utility layer
  50334. */
  50335. setRenderCamera(cam: Nullable<Camera>): void;
  50336. /**
  50337. * @hidden
  50338. * Light which used by gizmos to get light shading
  50339. */
  50340. _getSharedGizmoLight(): HemisphericLight;
  50341. /**
  50342. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50343. */
  50344. pickUtilitySceneFirst: boolean;
  50345. /**
  50346. * 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)
  50347. */
  50348. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50349. /**
  50350. * 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)
  50351. */
  50352. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50353. /**
  50354. * The scene that is rendered on top of the original scene
  50355. */
  50356. utilityLayerScene: Scene;
  50357. /**
  50358. * If the utility layer should automatically be rendered on top of existing scene
  50359. */
  50360. shouldRender: boolean;
  50361. /**
  50362. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50363. */
  50364. onlyCheckPointerDownEvents: boolean;
  50365. /**
  50366. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50367. */
  50368. processAllEvents: boolean;
  50369. /**
  50370. * Observable raised when the pointer move from the utility layer scene to the main scene
  50371. */
  50372. onPointerOutObservable: Observable<number>;
  50373. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50374. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50375. private _afterRenderObserver;
  50376. private _sceneDisposeObserver;
  50377. private _originalPointerObserver;
  50378. /**
  50379. * Instantiates a UtilityLayerRenderer
  50380. * @param originalScene the original scene that will be rendered on top of
  50381. * @param handleEvents boolean indicating if the utility layer should handle events
  50382. */
  50383. constructor(
  50384. /** the original scene that will be rendered on top of */
  50385. originalScene: Scene, handleEvents?: boolean);
  50386. private _notifyObservers;
  50387. /**
  50388. * Renders the utility layers scene on top of the original scene
  50389. */
  50390. render(): void;
  50391. /**
  50392. * Disposes of the renderer
  50393. */
  50394. dispose(): void;
  50395. private _updateCamera;
  50396. }
  50397. }
  50398. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50399. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50401. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50402. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50403. import { Scene } from "babylonjs/scene";
  50404. import { Nullable } from "babylonjs/types";
  50405. import { Color3 } from "babylonjs/Maths/math.color";
  50406. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50407. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50408. /**
  50409. * Options interface for the pointer selection module
  50410. */
  50411. export interface IWebXRControllerPointerSelectionOptions {
  50412. /**
  50413. * if provided, this scene will be used to render meshes.
  50414. */
  50415. customUtilityLayerScene?: Scene;
  50416. /**
  50417. * 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)
  50418. * If not disabled, the last picked point will be used to execute a pointer up event
  50419. * If disabled, pointer up event will be triggered right after the pointer down event.
  50420. * Used in screen and gaze target ray mode only
  50421. */
  50422. disablePointerUpOnTouchOut: boolean;
  50423. /**
  50424. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50425. */
  50426. forceGazeMode: boolean;
  50427. /**
  50428. * 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
  50429. * to start a new countdown to the pointer down event.
  50430. * Defaults to 1.
  50431. */
  50432. gazeModePointerMovedFactor?: number;
  50433. /**
  50434. * Different button type to use instead of the main component
  50435. */
  50436. overrideButtonId?: string;
  50437. /**
  50438. * use this rendering group id for the meshes (optional)
  50439. */
  50440. renderingGroupId?: number;
  50441. /**
  50442. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50443. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50444. * 3000 means 3 seconds between pointing at something and selecting it
  50445. */
  50446. timeToSelect?: number;
  50447. /**
  50448. * Should meshes created here be added to a utility layer or the main scene
  50449. */
  50450. useUtilityLayer?: boolean;
  50451. /**
  50452. * Optional WebXR camera to be used for gaze selection
  50453. */
  50454. gazeCamera?: WebXRCamera;
  50455. /**
  50456. * the xr input to use with this pointer selection
  50457. */
  50458. xrInput: WebXRInput;
  50459. }
  50460. /**
  50461. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50462. */
  50463. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50464. private readonly _options;
  50465. private static _idCounter;
  50466. private _attachController;
  50467. private _controllers;
  50468. private _scene;
  50469. private _tmpVectorForPickCompare;
  50470. /**
  50471. * The module's name
  50472. */
  50473. static readonly Name: string;
  50474. /**
  50475. * The (Babylon) version of this module.
  50476. * This is an integer representing the implementation version.
  50477. * This number does not correspond to the WebXR specs version
  50478. */
  50479. static readonly Version: number;
  50480. /**
  50481. * Disable lighting on the laser pointer (so it will always be visible)
  50482. */
  50483. disablePointerLighting: boolean;
  50484. /**
  50485. * Disable lighting on the selection mesh (so it will always be visible)
  50486. */
  50487. disableSelectionMeshLighting: boolean;
  50488. /**
  50489. * Should the laser pointer be displayed
  50490. */
  50491. displayLaserPointer: boolean;
  50492. /**
  50493. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50494. */
  50495. displaySelectionMesh: boolean;
  50496. /**
  50497. * This color will be set to the laser pointer when selection is triggered
  50498. */
  50499. laserPointerPickedColor: Color3;
  50500. /**
  50501. * Default color of the laser pointer
  50502. */
  50503. laserPointerDefaultColor: Color3;
  50504. /**
  50505. * default color of the selection ring
  50506. */
  50507. selectionMeshDefaultColor: Color3;
  50508. /**
  50509. * This color will be applied to the selection ring when selection is triggered
  50510. */
  50511. selectionMeshPickedColor: Color3;
  50512. /**
  50513. * Optional filter to be used for ray selection. This predicate shares behavior with
  50514. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50515. */
  50516. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50517. /**
  50518. * constructs a new background remover module
  50519. * @param _xrSessionManager the session manager for this module
  50520. * @param _options read-only options to be used in this module
  50521. */
  50522. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50523. /**
  50524. * attach this feature
  50525. * Will usually be called by the features manager
  50526. *
  50527. * @returns true if successful.
  50528. */
  50529. attach(): boolean;
  50530. /**
  50531. * detach this feature.
  50532. * Will usually be called by the features manager
  50533. *
  50534. * @returns true if successful.
  50535. */
  50536. detach(): boolean;
  50537. /**
  50538. * Will get the mesh under a specific pointer.
  50539. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50540. * @param controllerId the controllerId to check
  50541. * @returns The mesh under pointer or null if no mesh is under the pointer
  50542. */
  50543. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50544. /**
  50545. * Get the xr controller that correlates to the pointer id in the pointer event
  50546. *
  50547. * @param id the pointer id to search for
  50548. * @returns the controller that correlates to this id or null if not found
  50549. */
  50550. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50551. protected _onXRFrame(_xrFrame: XRFrame): void;
  50552. private _attachGazeMode;
  50553. private _attachScreenRayMode;
  50554. private _attachTrackedPointerRayMode;
  50555. private _convertNormalToDirectionOfRay;
  50556. private _detachController;
  50557. private _generateNewMeshPair;
  50558. private _pickingMoved;
  50559. private _updatePointerDistance;
  50560. /** @hidden */
  50561. get lasterPointerDefaultColor(): Color3;
  50562. }
  50563. }
  50564. declare module "babylonjs/XR/webXREnterExitUI" {
  50565. import { Nullable } from "babylonjs/types";
  50566. import { Observable } from "babylonjs/Misc/observable";
  50567. import { IDisposable, Scene } from "babylonjs/scene";
  50568. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50569. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50570. /**
  50571. * Button which can be used to enter a different mode of XR
  50572. */
  50573. export class WebXREnterExitUIButton {
  50574. /** button element */
  50575. element: HTMLElement;
  50576. /** XR initialization options for the button */
  50577. sessionMode: XRSessionMode;
  50578. /** Reference space type */
  50579. referenceSpaceType: XRReferenceSpaceType;
  50580. /**
  50581. * Creates a WebXREnterExitUIButton
  50582. * @param element button element
  50583. * @param sessionMode XR initialization session mode
  50584. * @param referenceSpaceType the type of reference space to be used
  50585. */
  50586. constructor(
  50587. /** button element */
  50588. element: HTMLElement,
  50589. /** XR initialization options for the button */
  50590. sessionMode: XRSessionMode,
  50591. /** Reference space type */
  50592. referenceSpaceType: XRReferenceSpaceType);
  50593. /**
  50594. * Extendable function which can be used to update the button's visuals when the state changes
  50595. * @param activeButton the current active button in the UI
  50596. */
  50597. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50598. }
  50599. /**
  50600. * Options to create the webXR UI
  50601. */
  50602. export class WebXREnterExitUIOptions {
  50603. /**
  50604. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50605. */
  50606. customButtons?: Array<WebXREnterExitUIButton>;
  50607. /**
  50608. * A reference space type to use when creating the default button.
  50609. * Default is local-floor
  50610. */
  50611. referenceSpaceType?: XRReferenceSpaceType;
  50612. /**
  50613. * Context to enter xr with
  50614. */
  50615. renderTarget?: Nullable<WebXRRenderTarget>;
  50616. /**
  50617. * A session mode to use when creating the default button.
  50618. * Default is immersive-vr
  50619. */
  50620. sessionMode?: XRSessionMode;
  50621. /**
  50622. * A list of optional features to init the session with
  50623. */
  50624. optionalFeatures?: string[];
  50625. /**
  50626. * A list of optional features to init the session with
  50627. */
  50628. requiredFeatures?: string[];
  50629. }
  50630. /**
  50631. * UI to allow the user to enter/exit XR mode
  50632. */
  50633. export class WebXREnterExitUI implements IDisposable {
  50634. private scene;
  50635. /** version of the options passed to this UI */
  50636. options: WebXREnterExitUIOptions;
  50637. private _activeButton;
  50638. private _buttons;
  50639. private _overlay;
  50640. /**
  50641. * Fired every time the active button is changed.
  50642. *
  50643. * When xr is entered via a button that launches xr that button will be the callback parameter
  50644. *
  50645. * When exiting xr the callback parameter will be null)
  50646. */
  50647. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50648. /**
  50649. *
  50650. * @param scene babylon scene object to use
  50651. * @param options (read-only) version of the options passed to this UI
  50652. */
  50653. private constructor();
  50654. /**
  50655. * Creates UI to allow the user to enter/exit XR mode
  50656. * @param scene the scene to add the ui to
  50657. * @param helper the xr experience helper to enter/exit xr with
  50658. * @param options options to configure the UI
  50659. * @returns the created ui
  50660. */
  50661. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50662. /**
  50663. * Disposes of the XR UI component
  50664. */
  50665. dispose(): void;
  50666. private _updateButtons;
  50667. }
  50668. }
  50669. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50670. import { Vector3 } from "babylonjs/Maths/math.vector";
  50671. import { Color4 } from "babylonjs/Maths/math.color";
  50672. import { Nullable } from "babylonjs/types";
  50673. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50674. import { Scene } from "babylonjs/scene";
  50675. /**
  50676. * Class containing static functions to help procedurally build meshes
  50677. */
  50678. export class LinesBuilder {
  50679. /**
  50680. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50681. * * 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
  50682. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50683. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50684. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50685. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50686. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50687. * * 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
  50688. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50691. * @param name defines the name of the new line system
  50692. * @param options defines the options used to create the line system
  50693. * @param scene defines the hosting scene
  50694. * @returns a new line system mesh
  50695. */
  50696. static CreateLineSystem(name: string, options: {
  50697. lines: Vector3[][];
  50698. updatable?: boolean;
  50699. instance?: Nullable<LinesMesh>;
  50700. colors?: Nullable<Color4[][]>;
  50701. useVertexAlpha?: boolean;
  50702. }, scene: Nullable<Scene>): LinesMesh;
  50703. /**
  50704. * Creates a line mesh
  50705. * 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
  50706. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50707. * * The parameter `points` is an array successive Vector3
  50708. * * 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
  50709. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50710. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50711. * * When updating an instance, remember that only point positions can change, not the number of points
  50712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50714. * @param name defines the name of the new line system
  50715. * @param options defines the options used to create the line system
  50716. * @param scene defines the hosting scene
  50717. * @returns a new line mesh
  50718. */
  50719. static CreateLines(name: string, options: {
  50720. points: Vector3[];
  50721. updatable?: boolean;
  50722. instance?: Nullable<LinesMesh>;
  50723. colors?: Color4[];
  50724. useVertexAlpha?: boolean;
  50725. }, scene?: Nullable<Scene>): LinesMesh;
  50726. /**
  50727. * Creates a dashed line mesh
  50728. * * 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
  50729. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50730. * * The parameter `points` is an array successive Vector3
  50731. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50732. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50733. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50734. * * 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
  50735. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50736. * * When updating an instance, remember that only point positions can change, not the number of points
  50737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50738. * @param name defines the name of the mesh
  50739. * @param options defines the options used to create the mesh
  50740. * @param scene defines the hosting scene
  50741. * @returns the dashed line mesh
  50742. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50743. */
  50744. static CreateDashedLines(name: string, options: {
  50745. points: Vector3[];
  50746. dashSize?: number;
  50747. gapSize?: number;
  50748. dashNb?: number;
  50749. updatable?: boolean;
  50750. instance?: LinesMesh;
  50751. useVertexAlpha?: boolean;
  50752. }, scene?: Nullable<Scene>): LinesMesh;
  50753. }
  50754. }
  50755. declare module "babylonjs/Misc/timer" {
  50756. import { Observable, Observer } from "babylonjs/Misc/observable";
  50757. import { Nullable } from "babylonjs/types";
  50758. import { IDisposable } from "babylonjs/scene";
  50759. /**
  50760. * Construction options for a timer
  50761. */
  50762. export interface ITimerOptions<T> {
  50763. /**
  50764. * Time-to-end
  50765. */
  50766. timeout: number;
  50767. /**
  50768. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50769. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50770. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50771. */
  50772. contextObservable: Observable<T>;
  50773. /**
  50774. * Optional parameters when adding an observer to the observable
  50775. */
  50776. observableParameters?: {
  50777. mask?: number;
  50778. insertFirst?: boolean;
  50779. scope?: any;
  50780. };
  50781. /**
  50782. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50783. */
  50784. breakCondition?: (data?: ITimerData<T>) => boolean;
  50785. /**
  50786. * Will be triggered when the time condition has met
  50787. */
  50788. onEnded?: (data: ITimerData<any>) => void;
  50789. /**
  50790. * Will be triggered when the break condition has met (prematurely ended)
  50791. */
  50792. onAborted?: (data: ITimerData<any>) => void;
  50793. /**
  50794. * Optional function to execute on each tick (or count)
  50795. */
  50796. onTick?: (data: ITimerData<any>) => void;
  50797. }
  50798. /**
  50799. * An interface defining the data sent by the timer
  50800. */
  50801. export interface ITimerData<T> {
  50802. /**
  50803. * When did it start
  50804. */
  50805. startTime: number;
  50806. /**
  50807. * Time now
  50808. */
  50809. currentTime: number;
  50810. /**
  50811. * Time passed since started
  50812. */
  50813. deltaTime: number;
  50814. /**
  50815. * How much is completed, in [0.0...1.0].
  50816. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50817. */
  50818. completeRate: number;
  50819. /**
  50820. * What the registered observable sent in the last count
  50821. */
  50822. payload: T;
  50823. }
  50824. /**
  50825. * The current state of the timer
  50826. */
  50827. export enum TimerState {
  50828. /**
  50829. * Timer initialized, not yet started
  50830. */
  50831. INIT = 0,
  50832. /**
  50833. * Timer started and counting
  50834. */
  50835. STARTED = 1,
  50836. /**
  50837. * Timer ended (whether aborted or time reached)
  50838. */
  50839. ENDED = 2
  50840. }
  50841. /**
  50842. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50843. *
  50844. * @param options options with which to initialize this timer
  50845. */
  50846. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50847. /**
  50848. * An advanced implementation of a timer class
  50849. */
  50850. export class AdvancedTimer<T = any> implements IDisposable {
  50851. /**
  50852. * Will notify each time the timer calculates the remaining time
  50853. */
  50854. onEachCountObservable: Observable<ITimerData<T>>;
  50855. /**
  50856. * Will trigger when the timer was aborted due to the break condition
  50857. */
  50858. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50859. /**
  50860. * Will trigger when the timer ended successfully
  50861. */
  50862. onTimerEndedObservable: Observable<ITimerData<T>>;
  50863. /**
  50864. * Will trigger when the timer state has changed
  50865. */
  50866. onStateChangedObservable: Observable<TimerState>;
  50867. private _observer;
  50868. private _contextObservable;
  50869. private _observableParameters;
  50870. private _startTime;
  50871. private _timer;
  50872. private _state;
  50873. private _breakCondition;
  50874. private _timeToEnd;
  50875. private _breakOnNextTick;
  50876. /**
  50877. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50878. * @param options construction options for this advanced timer
  50879. */
  50880. constructor(options: ITimerOptions<T>);
  50881. /**
  50882. * set a breaking condition for this timer. Default is to never break during count
  50883. * @param predicate the new break condition. Returns true to break, false otherwise
  50884. */
  50885. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50886. /**
  50887. * Reset ALL associated observables in this advanced timer
  50888. */
  50889. clearObservables(): void;
  50890. /**
  50891. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50892. *
  50893. * @param timeToEnd how much time to measure until timer ended
  50894. */
  50895. start(timeToEnd?: number): void;
  50896. /**
  50897. * Will force a stop on the next tick.
  50898. */
  50899. stop(): void;
  50900. /**
  50901. * Dispose this timer, clearing all resources
  50902. */
  50903. dispose(): void;
  50904. private _setState;
  50905. private _tick;
  50906. private _stop;
  50907. }
  50908. }
  50909. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50910. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50911. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50912. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50914. import { Vector3 } from "babylonjs/Maths/math.vector";
  50915. import { Material } from "babylonjs/Materials/material";
  50916. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50917. import { Scene } from "babylonjs/scene";
  50918. /**
  50919. * The options container for the teleportation module
  50920. */
  50921. export interface IWebXRTeleportationOptions {
  50922. /**
  50923. * if provided, this scene will be used to render meshes.
  50924. */
  50925. customUtilityLayerScene?: Scene;
  50926. /**
  50927. * Values to configure the default target mesh
  50928. */
  50929. defaultTargetMeshOptions?: {
  50930. /**
  50931. * Fill color of the teleportation area
  50932. */
  50933. teleportationFillColor?: string;
  50934. /**
  50935. * Border color for the teleportation area
  50936. */
  50937. teleportationBorderColor?: string;
  50938. /**
  50939. * Disable the mesh's animation sequence
  50940. */
  50941. disableAnimation?: boolean;
  50942. /**
  50943. * Disable lighting on the material or the ring and arrow
  50944. */
  50945. disableLighting?: boolean;
  50946. /**
  50947. * Override the default material of the torus and arrow
  50948. */
  50949. torusArrowMaterial?: Material;
  50950. };
  50951. /**
  50952. * A list of meshes to use as floor meshes.
  50953. * Meshes can be added and removed after initializing the feature using the
  50954. * addFloorMesh and removeFloorMesh functions
  50955. * If empty, rotation will still work
  50956. */
  50957. floorMeshes?: AbstractMesh[];
  50958. /**
  50959. * use this rendering group id for the meshes (optional)
  50960. */
  50961. renderingGroupId?: number;
  50962. /**
  50963. * Should teleportation move only to snap points
  50964. */
  50965. snapPointsOnly?: boolean;
  50966. /**
  50967. * An array of points to which the teleportation will snap to.
  50968. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50969. */
  50970. snapPositions?: Vector3[];
  50971. /**
  50972. * How close should the teleportation ray be in order to snap to position.
  50973. * Default to 0.8 units (meters)
  50974. */
  50975. snapToPositionRadius?: number;
  50976. /**
  50977. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50978. * If you want to support rotation, make sure your mesh has a direction indicator.
  50979. *
  50980. * When left untouched, the default mesh will be initialized.
  50981. */
  50982. teleportationTargetMesh?: AbstractMesh;
  50983. /**
  50984. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50985. */
  50986. timeToTeleport?: number;
  50987. /**
  50988. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50989. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50990. */
  50991. useMainComponentOnly?: boolean;
  50992. /**
  50993. * Should meshes created here be added to a utility layer or the main scene
  50994. */
  50995. useUtilityLayer?: boolean;
  50996. /**
  50997. * Babylon XR Input class for controller
  50998. */
  50999. xrInput: WebXRInput;
  51000. }
  51001. /**
  51002. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51003. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51004. * the input of the attached controllers.
  51005. */
  51006. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51007. private _options;
  51008. private _controllers;
  51009. private _currentTeleportationControllerId;
  51010. private _floorMeshes;
  51011. private _quadraticBezierCurve;
  51012. private _selectionFeature;
  51013. private _snapToPositions;
  51014. private _snappedToPoint;
  51015. private _teleportationRingMaterial?;
  51016. private _tmpRay;
  51017. private _tmpVector;
  51018. /**
  51019. * The module's name
  51020. */
  51021. static readonly Name: string;
  51022. /**
  51023. * The (Babylon) version of this module.
  51024. * This is an integer representing the implementation version.
  51025. * This number does not correspond to the webxr specs version
  51026. */
  51027. static readonly Version: number;
  51028. /**
  51029. * Is movement backwards enabled
  51030. */
  51031. backwardsMovementEnabled: boolean;
  51032. /**
  51033. * Distance to travel when moving backwards
  51034. */
  51035. backwardsTeleportationDistance: number;
  51036. /**
  51037. * The distance from the user to the inspection point in the direction of the controller
  51038. * A higher number will allow the user to move further
  51039. * defaults to 5 (meters, in xr units)
  51040. */
  51041. parabolicCheckRadius: number;
  51042. /**
  51043. * Should the module support parabolic ray on top of direct ray
  51044. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51045. * Very helpful when moving between floors / different heights
  51046. */
  51047. parabolicRayEnabled: boolean;
  51048. /**
  51049. * How much rotation should be applied when rotating right and left
  51050. */
  51051. rotationAngle: number;
  51052. /**
  51053. * Is rotation enabled when moving forward?
  51054. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51055. */
  51056. rotationEnabled: boolean;
  51057. /**
  51058. * constructs a new anchor system
  51059. * @param _xrSessionManager an instance of WebXRSessionManager
  51060. * @param _options configuration object for this feature
  51061. */
  51062. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51063. /**
  51064. * Get the snapPointsOnly flag
  51065. */
  51066. get snapPointsOnly(): boolean;
  51067. /**
  51068. * Sets the snapPointsOnly flag
  51069. * @param snapToPoints should teleportation be exclusively to snap points
  51070. */
  51071. set snapPointsOnly(snapToPoints: boolean);
  51072. /**
  51073. * Add a new mesh to the floor meshes array
  51074. * @param mesh the mesh to use as floor mesh
  51075. */
  51076. addFloorMesh(mesh: AbstractMesh): void;
  51077. /**
  51078. * Add a new snap-to point to fix teleportation to this position
  51079. * @param newSnapPoint The new Snap-To point
  51080. */
  51081. addSnapPoint(newSnapPoint: Vector3): void;
  51082. attach(): boolean;
  51083. detach(): boolean;
  51084. dispose(): void;
  51085. /**
  51086. * Remove a mesh from the floor meshes array
  51087. * @param mesh the mesh to remove
  51088. */
  51089. removeFloorMesh(mesh: AbstractMesh): void;
  51090. /**
  51091. * Remove a mesh from the floor meshes array using its name
  51092. * @param name the mesh name to remove
  51093. */
  51094. removeFloorMeshByName(name: string): void;
  51095. /**
  51096. * 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
  51097. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51098. * @returns was the point found and removed or not
  51099. */
  51100. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51101. /**
  51102. * This function sets a selection feature that will be disabled when
  51103. * the forward ray is shown and will be reattached when hidden.
  51104. * This is used to remove the selection rays when moving.
  51105. * @param selectionFeature the feature to disable when forward movement is enabled
  51106. */
  51107. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51108. protected _onXRFrame(_xrFrame: XRFrame): void;
  51109. private _attachController;
  51110. private _createDefaultTargetMesh;
  51111. private _detachController;
  51112. private _findClosestSnapPointWithRadius;
  51113. private _setTargetMeshPosition;
  51114. private _setTargetMeshVisibility;
  51115. private _showParabolicPath;
  51116. private _teleportForward;
  51117. }
  51118. }
  51119. declare module "babylonjs/XR/webXRDefaultExperience" {
  51120. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51121. import { Scene } from "babylonjs/scene";
  51122. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51123. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51124. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51125. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51127. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51128. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51129. /**
  51130. * Options for the default xr helper
  51131. */
  51132. export class WebXRDefaultExperienceOptions {
  51133. /**
  51134. * Enable or disable default UI to enter XR
  51135. */
  51136. disableDefaultUI?: boolean;
  51137. /**
  51138. * Should teleportation not initialize. defaults to false.
  51139. */
  51140. disableTeleportation?: boolean;
  51141. /**
  51142. * Floor meshes that will be used for teleport
  51143. */
  51144. floorMeshes?: Array<AbstractMesh>;
  51145. /**
  51146. * If set to true, the first frame will not be used to reset position
  51147. * The first frame is mainly used when copying transformation from the old camera
  51148. * Mainly used in AR
  51149. */
  51150. ignoreNativeCameraTransformation?: boolean;
  51151. /**
  51152. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51153. */
  51154. inputOptions?: IWebXRInputOptions;
  51155. /**
  51156. * optional configuration for the output canvas
  51157. */
  51158. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51159. /**
  51160. * optional UI options. This can be used among other to change session mode and reference space type
  51161. */
  51162. uiOptions?: WebXREnterExitUIOptions;
  51163. /**
  51164. * When loading teleportation and pointer select, use stable versions instead of latest.
  51165. */
  51166. useStablePlugins?: boolean;
  51167. /**
  51168. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51169. */
  51170. renderingGroupId?: number;
  51171. /**
  51172. * A list of optional features to init the session with
  51173. * If set to true, all features we support will be added
  51174. */
  51175. optionalFeatures?: boolean | string[];
  51176. }
  51177. /**
  51178. * Default experience which provides a similar setup to the previous webVRExperience
  51179. */
  51180. export class WebXRDefaultExperience {
  51181. /**
  51182. * Base experience
  51183. */
  51184. baseExperience: WebXRExperienceHelper;
  51185. /**
  51186. * Enables ui for entering/exiting xr
  51187. */
  51188. enterExitUI: WebXREnterExitUI;
  51189. /**
  51190. * Input experience extension
  51191. */
  51192. input: WebXRInput;
  51193. /**
  51194. * Enables laser pointer and selection
  51195. */
  51196. pointerSelection: WebXRControllerPointerSelection;
  51197. /**
  51198. * Default target xr should render to
  51199. */
  51200. renderTarget: WebXRRenderTarget;
  51201. /**
  51202. * Enables teleportation
  51203. */
  51204. teleportation: WebXRMotionControllerTeleportation;
  51205. private constructor();
  51206. /**
  51207. * Creates the default xr experience
  51208. * @param scene scene
  51209. * @param options options for basic configuration
  51210. * @returns resulting WebXRDefaultExperience
  51211. */
  51212. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51213. /**
  51214. * DIsposes of the experience helper
  51215. */
  51216. dispose(): void;
  51217. }
  51218. }
  51219. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51220. import { Observable } from "babylonjs/Misc/observable";
  51221. import { Nullable } from "babylonjs/types";
  51222. import { Camera } from "babylonjs/Cameras/camera";
  51223. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51224. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51225. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51226. import { Scene } from "babylonjs/scene";
  51227. import { Vector3 } from "babylonjs/Maths/math.vector";
  51228. import { Color3 } from "babylonjs/Maths/math.color";
  51229. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51231. import { Mesh } from "babylonjs/Meshes/mesh";
  51232. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51233. import { EasingFunction } from "babylonjs/Animations/easing";
  51234. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51235. import "babylonjs/Meshes/Builders/groundBuilder";
  51236. import "babylonjs/Meshes/Builders/torusBuilder";
  51237. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51238. import "babylonjs/Gamepads/gamepadSceneComponent";
  51239. import "babylonjs/Animations/animatable";
  51240. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51241. /**
  51242. * Options to modify the vr teleportation behavior.
  51243. */
  51244. export interface VRTeleportationOptions {
  51245. /**
  51246. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51247. */
  51248. floorMeshName?: string;
  51249. /**
  51250. * A list of meshes to be used as the teleportation floor. (default: empty)
  51251. */
  51252. floorMeshes?: Mesh[];
  51253. /**
  51254. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51255. */
  51256. teleportationMode?: number;
  51257. /**
  51258. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51259. */
  51260. teleportationTime?: number;
  51261. /**
  51262. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51263. */
  51264. teleportationSpeed?: number;
  51265. /**
  51266. * The easing function used in the animation or null for Linear. (default CircleEase)
  51267. */
  51268. easingFunction?: EasingFunction;
  51269. }
  51270. /**
  51271. * Options to modify the vr experience helper's behavior.
  51272. */
  51273. export interface VRExperienceHelperOptions extends WebVROptions {
  51274. /**
  51275. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51276. */
  51277. createDeviceOrientationCamera?: boolean;
  51278. /**
  51279. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51280. */
  51281. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51282. /**
  51283. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51284. */
  51285. laserToggle?: boolean;
  51286. /**
  51287. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51288. */
  51289. floorMeshes?: Mesh[];
  51290. /**
  51291. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51292. */
  51293. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51294. /**
  51295. * Defines if WebXR should be used instead of WebVR (if available)
  51296. */
  51297. useXR?: boolean;
  51298. }
  51299. /**
  51300. * Event containing information after VR has been entered
  51301. */
  51302. export class OnAfterEnteringVRObservableEvent {
  51303. /**
  51304. * If entering vr was successful
  51305. */
  51306. success: boolean;
  51307. }
  51308. /**
  51309. * Helps to quickly add VR support to an existing scene.
  51310. * See https://doc.babylonjs.com/how_to/webvr_helper
  51311. */
  51312. export class VRExperienceHelper {
  51313. /** Options to modify the vr experience helper's behavior. */
  51314. webVROptions: VRExperienceHelperOptions;
  51315. private _scene;
  51316. private _position;
  51317. private _btnVR;
  51318. private _btnVRDisplayed;
  51319. private _webVRsupported;
  51320. private _webVRready;
  51321. private _webVRrequesting;
  51322. private _webVRpresenting;
  51323. private _hasEnteredVR;
  51324. private _fullscreenVRpresenting;
  51325. private _inputElement;
  51326. private _webVRCamera;
  51327. private _vrDeviceOrientationCamera;
  51328. private _deviceOrientationCamera;
  51329. private _existingCamera;
  51330. private _onKeyDown;
  51331. private _onVrDisplayPresentChange;
  51332. private _onVRDisplayChanged;
  51333. private _onVRRequestPresentStart;
  51334. private _onVRRequestPresentComplete;
  51335. /**
  51336. * 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)
  51337. */
  51338. enableGazeEvenWhenNoPointerLock: boolean;
  51339. /**
  51340. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51341. */
  51342. exitVROnDoubleTap: boolean;
  51343. /**
  51344. * Observable raised right before entering VR.
  51345. */
  51346. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51347. /**
  51348. * Observable raised when entering VR has completed.
  51349. */
  51350. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51351. /**
  51352. * Observable raised when exiting VR.
  51353. */
  51354. onExitingVRObservable: Observable<VRExperienceHelper>;
  51355. /**
  51356. * Observable raised when controller mesh is loaded.
  51357. */
  51358. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51359. /** Return this.onEnteringVRObservable
  51360. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51361. */
  51362. get onEnteringVR(): Observable<VRExperienceHelper>;
  51363. /** Return this.onExitingVRObservable
  51364. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51365. */
  51366. get onExitingVR(): Observable<VRExperienceHelper>;
  51367. /** Return this.onControllerMeshLoadedObservable
  51368. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51369. */
  51370. get onControllerMeshLoaded(): Observable<WebVRController>;
  51371. private _rayLength;
  51372. private _useCustomVRButton;
  51373. private _teleportationRequested;
  51374. private _teleportActive;
  51375. private _floorMeshName;
  51376. private _floorMeshesCollection;
  51377. private _teleportationMode;
  51378. private _teleportationTime;
  51379. private _teleportationSpeed;
  51380. private _teleportationEasing;
  51381. private _rotationAllowed;
  51382. private _teleportBackwardsVector;
  51383. private _teleportationTarget;
  51384. private _isDefaultTeleportationTarget;
  51385. private _postProcessMove;
  51386. private _teleportationFillColor;
  51387. private _teleportationBorderColor;
  51388. private _rotationAngle;
  51389. private _haloCenter;
  51390. private _cameraGazer;
  51391. private _padSensibilityUp;
  51392. private _padSensibilityDown;
  51393. private _leftController;
  51394. private _rightController;
  51395. private _gazeColor;
  51396. private _laserColor;
  51397. private _pickedLaserColor;
  51398. private _pickedGazeColor;
  51399. /**
  51400. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51401. */
  51402. onNewMeshSelected: Observable<AbstractMesh>;
  51403. /**
  51404. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51405. * This observable will provide the mesh and the controller used to select the mesh
  51406. */
  51407. onMeshSelectedWithController: Observable<{
  51408. mesh: AbstractMesh;
  51409. controller: WebVRController;
  51410. }>;
  51411. /**
  51412. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51413. */
  51414. onNewMeshPicked: Observable<PickingInfo>;
  51415. private _circleEase;
  51416. /**
  51417. * Observable raised before camera teleportation
  51418. */
  51419. onBeforeCameraTeleport: Observable<Vector3>;
  51420. /**
  51421. * Observable raised after camera teleportation
  51422. */
  51423. onAfterCameraTeleport: Observable<Vector3>;
  51424. /**
  51425. * Observable raised when current selected mesh gets unselected
  51426. */
  51427. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51428. private _raySelectionPredicate;
  51429. /**
  51430. * To be optionaly changed by user to define custom ray selection
  51431. */
  51432. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51433. /**
  51434. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51435. */
  51436. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51437. /**
  51438. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51439. */
  51440. teleportationEnabled: boolean;
  51441. private _defaultHeight;
  51442. private _teleportationInitialized;
  51443. private _interactionsEnabled;
  51444. private _interactionsRequested;
  51445. private _displayGaze;
  51446. private _displayLaserPointer;
  51447. /**
  51448. * The mesh used to display where the user is going to teleport.
  51449. */
  51450. get teleportationTarget(): Mesh;
  51451. /**
  51452. * Sets the mesh to be used to display where the user is going to teleport.
  51453. */
  51454. set teleportationTarget(value: Mesh);
  51455. /**
  51456. * 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
  51457. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51458. * See https://doc.babylonjs.com/resources/baking_transformations
  51459. */
  51460. get gazeTrackerMesh(): Mesh;
  51461. set gazeTrackerMesh(value: Mesh);
  51462. /**
  51463. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51464. */
  51465. updateGazeTrackerScale: boolean;
  51466. /**
  51467. * If the gaze trackers color should be updated when selecting meshes
  51468. */
  51469. updateGazeTrackerColor: boolean;
  51470. /**
  51471. * If the controller laser color should be updated when selecting meshes
  51472. */
  51473. updateControllerLaserColor: boolean;
  51474. /**
  51475. * The gaze tracking mesh corresponding to the left controller
  51476. */
  51477. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51478. /**
  51479. * The gaze tracking mesh corresponding to the right controller
  51480. */
  51481. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51482. /**
  51483. * If the ray of the gaze should be displayed.
  51484. */
  51485. get displayGaze(): boolean;
  51486. /**
  51487. * Sets if the ray of the gaze should be displayed.
  51488. */
  51489. set displayGaze(value: boolean);
  51490. /**
  51491. * If the ray of the LaserPointer should be displayed.
  51492. */
  51493. get displayLaserPointer(): boolean;
  51494. /**
  51495. * Sets if the ray of the LaserPointer should be displayed.
  51496. */
  51497. set displayLaserPointer(value: boolean);
  51498. /**
  51499. * The deviceOrientationCamera used as the camera when not in VR.
  51500. */
  51501. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51502. /**
  51503. * Based on the current WebVR support, returns the current VR camera used.
  51504. */
  51505. get currentVRCamera(): Nullable<Camera>;
  51506. /**
  51507. * The webVRCamera which is used when in VR.
  51508. */
  51509. get webVRCamera(): WebVRFreeCamera;
  51510. /**
  51511. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51512. */
  51513. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51514. /**
  51515. * The html button that is used to trigger entering into VR.
  51516. */
  51517. get vrButton(): Nullable<HTMLButtonElement>;
  51518. private get _teleportationRequestInitiated();
  51519. /**
  51520. * Defines whether or not Pointer lock should be requested when switching to
  51521. * full screen.
  51522. */
  51523. requestPointerLockOnFullScreen: boolean;
  51524. /**
  51525. * If asking to force XR, this will be populated with the default xr experience
  51526. */
  51527. xr: WebXRDefaultExperience;
  51528. /**
  51529. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51530. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51531. */
  51532. xrTestDone: boolean;
  51533. /**
  51534. * Instantiates a VRExperienceHelper.
  51535. * Helps to quickly add VR support to an existing scene.
  51536. * @param scene The scene the VRExperienceHelper belongs to.
  51537. * @param webVROptions Options to modify the vr experience helper's behavior.
  51538. */
  51539. constructor(scene: Scene,
  51540. /** Options to modify the vr experience helper's behavior. */
  51541. webVROptions?: VRExperienceHelperOptions);
  51542. private completeVRInit;
  51543. private _onDefaultMeshLoaded;
  51544. private _onResize;
  51545. private _onFullscreenChange;
  51546. /**
  51547. * Gets a value indicating if we are currently in VR mode.
  51548. */
  51549. get isInVRMode(): boolean;
  51550. private onVrDisplayPresentChange;
  51551. private onVRDisplayChanged;
  51552. private moveButtonToBottomRight;
  51553. private displayVRButton;
  51554. private updateButtonVisibility;
  51555. private _cachedAngularSensibility;
  51556. /**
  51557. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51558. * Otherwise, will use the fullscreen API.
  51559. */
  51560. enterVR(): void;
  51561. /**
  51562. * Attempt to exit VR, or fullscreen.
  51563. */
  51564. exitVR(): void;
  51565. /**
  51566. * The position of the vr experience helper.
  51567. */
  51568. get position(): Vector3;
  51569. /**
  51570. * Sets the position of the vr experience helper.
  51571. */
  51572. set position(value: Vector3);
  51573. /**
  51574. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51575. */
  51576. enableInteractions(): void;
  51577. private get _noControllerIsActive();
  51578. private beforeRender;
  51579. private _isTeleportationFloor;
  51580. /**
  51581. * Adds a floor mesh to be used for teleportation.
  51582. * @param floorMesh the mesh to be used for teleportation.
  51583. */
  51584. addFloorMesh(floorMesh: Mesh): void;
  51585. /**
  51586. * Removes a floor mesh from being used for teleportation.
  51587. * @param floorMesh the mesh to be removed.
  51588. */
  51589. removeFloorMesh(floorMesh: Mesh): void;
  51590. /**
  51591. * Enables interactions and teleportation using the VR controllers and gaze.
  51592. * @param vrTeleportationOptions options to modify teleportation behavior.
  51593. */
  51594. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51595. private _onNewGamepadConnected;
  51596. private _tryEnableInteractionOnController;
  51597. private _onNewGamepadDisconnected;
  51598. private _enableInteractionOnController;
  51599. private _checkTeleportWithRay;
  51600. private _checkRotate;
  51601. private _checkTeleportBackwards;
  51602. private _enableTeleportationOnController;
  51603. private _createTeleportationCircles;
  51604. private _displayTeleportationTarget;
  51605. private _hideTeleportationTarget;
  51606. private _rotateCamera;
  51607. private _moveTeleportationSelectorTo;
  51608. private _workingVector;
  51609. private _workingQuaternion;
  51610. private _workingMatrix;
  51611. /**
  51612. * Time Constant Teleportation Mode
  51613. */
  51614. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51615. /**
  51616. * Speed Constant Teleportation Mode
  51617. */
  51618. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51619. /**
  51620. * Teleports the users feet to the desired location
  51621. * @param location The location where the user's feet should be placed
  51622. */
  51623. teleportCamera(location: Vector3): void;
  51624. private _convertNormalToDirectionOfRay;
  51625. private _castRayAndSelectObject;
  51626. private _notifySelectedMeshUnselected;
  51627. /**
  51628. * Permanently set new colors for the laser pointer
  51629. * @param color the new laser color
  51630. * @param pickedColor the new laser color when picked mesh detected
  51631. */
  51632. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51633. /**
  51634. * Set lighting enabled / disabled on the laser pointer of both controllers
  51635. * @param enabled should the lighting be enabled on the laser pointer
  51636. */
  51637. setLaserLightingState(enabled?: boolean): void;
  51638. /**
  51639. * Permanently set new colors for the gaze pointer
  51640. * @param color the new gaze color
  51641. * @param pickedColor the new gaze color when picked mesh detected
  51642. */
  51643. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51644. /**
  51645. * Sets the color of the laser ray from the vr controllers.
  51646. * @param color new color for the ray.
  51647. */
  51648. changeLaserColor(color: Color3): void;
  51649. /**
  51650. * Sets the color of the ray from the vr headsets gaze.
  51651. * @param color new color for the ray.
  51652. */
  51653. changeGazeColor(color: Color3): void;
  51654. /**
  51655. * Exits VR and disposes of the vr experience helper
  51656. */
  51657. dispose(): void;
  51658. /**
  51659. * Gets the name of the VRExperienceHelper class
  51660. * @returns "VRExperienceHelper"
  51661. */
  51662. getClassName(): string;
  51663. }
  51664. }
  51665. declare module "babylonjs/Cameras/VR/index" {
  51666. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51667. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51668. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51669. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51670. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51671. export * from "babylonjs/Cameras/VR/webVRCamera";
  51672. }
  51673. declare module "babylonjs/Cameras/RigModes/index" {
  51674. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51675. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51676. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51677. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51678. }
  51679. declare module "babylonjs/Cameras/index" {
  51680. export * from "babylonjs/Cameras/Inputs/index";
  51681. export * from "babylonjs/Cameras/cameraInputsManager";
  51682. export * from "babylonjs/Cameras/camera";
  51683. export * from "babylonjs/Cameras/targetCamera";
  51684. export * from "babylonjs/Cameras/freeCamera";
  51685. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51686. export * from "babylonjs/Cameras/touchCamera";
  51687. export * from "babylonjs/Cameras/arcRotateCamera";
  51688. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51689. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51690. export * from "babylonjs/Cameras/flyCamera";
  51691. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51692. export * from "babylonjs/Cameras/followCamera";
  51693. export * from "babylonjs/Cameras/followCameraInputsManager";
  51694. export * from "babylonjs/Cameras/gamepadCamera";
  51695. export * from "babylonjs/Cameras/Stereoscopic/index";
  51696. export * from "babylonjs/Cameras/universalCamera";
  51697. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51698. export * from "babylonjs/Cameras/VR/index";
  51699. export * from "babylonjs/Cameras/RigModes/index";
  51700. }
  51701. declare module "babylonjs/Collisions/index" {
  51702. export * from "babylonjs/Collisions/collider";
  51703. export * from "babylonjs/Collisions/collisionCoordinator";
  51704. export * from "babylonjs/Collisions/pickingInfo";
  51705. export * from "babylonjs/Collisions/intersectionInfo";
  51706. export * from "babylonjs/Collisions/meshCollisionData";
  51707. }
  51708. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51709. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51710. import { Vector3 } from "babylonjs/Maths/math.vector";
  51711. import { Ray } from "babylonjs/Culling/ray";
  51712. import { Plane } from "babylonjs/Maths/math.plane";
  51713. /**
  51714. * Contains an array of blocks representing the octree
  51715. */
  51716. export interface IOctreeContainer<T> {
  51717. /**
  51718. * Blocks within the octree
  51719. */
  51720. blocks: Array<OctreeBlock<T>>;
  51721. }
  51722. /**
  51723. * Class used to store a cell in an octree
  51724. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51725. */
  51726. export class OctreeBlock<T> {
  51727. /**
  51728. * Gets the content of the current block
  51729. */
  51730. entries: T[];
  51731. /**
  51732. * Gets the list of block children
  51733. */
  51734. blocks: Array<OctreeBlock<T>>;
  51735. private _depth;
  51736. private _maxDepth;
  51737. private _capacity;
  51738. private _minPoint;
  51739. private _maxPoint;
  51740. private _boundingVectors;
  51741. private _creationFunc;
  51742. /**
  51743. * Creates a new block
  51744. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51745. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51746. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51747. * @param depth defines the current depth of this block in the octree
  51748. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51749. * @param creationFunc defines a callback to call when an element is added to the block
  51750. */
  51751. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51752. /**
  51753. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51754. */
  51755. get capacity(): number;
  51756. /**
  51757. * Gets the minimum vector (in world space) of the block's bounding box
  51758. */
  51759. get minPoint(): Vector3;
  51760. /**
  51761. * Gets the maximum vector (in world space) of the block's bounding box
  51762. */
  51763. get maxPoint(): Vector3;
  51764. /**
  51765. * Add a new element to this block
  51766. * @param entry defines the element to add
  51767. */
  51768. addEntry(entry: T): void;
  51769. /**
  51770. * Remove an element from this block
  51771. * @param entry defines the element to remove
  51772. */
  51773. removeEntry(entry: T): void;
  51774. /**
  51775. * Add an array of elements to this block
  51776. * @param entries defines the array of elements to add
  51777. */
  51778. addEntries(entries: T[]): void;
  51779. /**
  51780. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51781. * @param frustumPlanes defines the frustum planes to test
  51782. * @param selection defines the array to store current content if selection is positive
  51783. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51784. */
  51785. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51786. /**
  51787. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51788. * @param sphereCenter defines the bounding sphere center
  51789. * @param sphereRadius defines the bounding sphere radius
  51790. * @param selection defines the array to store current content if selection is positive
  51791. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51792. */
  51793. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51794. /**
  51795. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51796. * @param ray defines the ray to test with
  51797. * @param selection defines the array to store current content if selection is positive
  51798. */
  51799. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51800. /**
  51801. * Subdivide the content into child blocks (this block will then be empty)
  51802. */
  51803. createInnerBlocks(): void;
  51804. /**
  51805. * @hidden
  51806. */
  51807. 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;
  51808. }
  51809. }
  51810. declare module "babylonjs/Culling/Octrees/octree" {
  51811. import { SmartArray } from "babylonjs/Misc/smartArray";
  51812. import { Vector3 } from "babylonjs/Maths/math.vector";
  51813. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51815. import { Ray } from "babylonjs/Culling/ray";
  51816. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51817. import { Plane } from "babylonjs/Maths/math.plane";
  51818. /**
  51819. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51820. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51821. */
  51822. export class Octree<T> {
  51823. /** 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.) */
  51824. maxDepth: number;
  51825. /**
  51826. * Blocks within the octree containing objects
  51827. */
  51828. blocks: Array<OctreeBlock<T>>;
  51829. /**
  51830. * Content stored in the octree
  51831. */
  51832. dynamicContent: T[];
  51833. private _maxBlockCapacity;
  51834. private _selectionContent;
  51835. private _creationFunc;
  51836. /**
  51837. * Creates a octree
  51838. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51839. * @param creationFunc function to be used to instatiate the octree
  51840. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51841. * @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.)
  51842. */
  51843. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51844. /** 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.) */
  51845. maxDepth?: number);
  51846. /**
  51847. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51848. * @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);
  51849. * @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);
  51850. * @param entries meshes to be added to the octree blocks
  51851. */
  51852. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51853. /**
  51854. * Adds a mesh to the octree
  51855. * @param entry Mesh to add to the octree
  51856. */
  51857. addMesh(entry: T): void;
  51858. /**
  51859. * Remove an element from the octree
  51860. * @param entry defines the element to remove
  51861. */
  51862. removeMesh(entry: T): void;
  51863. /**
  51864. * Selects an array of meshes within the frustum
  51865. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51866. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51867. * @returns array of meshes within the frustum
  51868. */
  51869. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51870. /**
  51871. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51872. * @param sphereCenter defines the bounding sphere center
  51873. * @param sphereRadius defines the bounding sphere radius
  51874. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51875. * @returns an array of objects that intersect the sphere
  51876. */
  51877. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51878. /**
  51879. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51880. * @param ray defines the ray to test with
  51881. * @returns array of intersected objects
  51882. */
  51883. intersectsRay(ray: Ray): SmartArray<T>;
  51884. /**
  51885. * Adds a mesh into the octree block if it intersects the block
  51886. */
  51887. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51888. /**
  51889. * Adds a submesh into the octree block if it intersects the block
  51890. */
  51891. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51892. }
  51893. }
  51894. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51895. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51896. import { Scene } from "babylonjs/scene";
  51897. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51899. import { Ray } from "babylonjs/Culling/ray";
  51900. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51901. import { Collider } from "babylonjs/Collisions/collider";
  51902. module "babylonjs/scene" {
  51903. interface Scene {
  51904. /**
  51905. * @hidden
  51906. * Backing Filed
  51907. */
  51908. _selectionOctree: Octree<AbstractMesh>;
  51909. /**
  51910. * Gets the octree used to boost mesh selection (picking)
  51911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51912. */
  51913. selectionOctree: Octree<AbstractMesh>;
  51914. /**
  51915. * Creates or updates the octree used to boost selection (picking)
  51916. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51917. * @param maxCapacity defines the maximum capacity per leaf
  51918. * @param maxDepth defines the maximum depth of the octree
  51919. * @returns an octree of AbstractMesh
  51920. */
  51921. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51922. }
  51923. }
  51924. module "babylonjs/Meshes/abstractMesh" {
  51925. interface AbstractMesh {
  51926. /**
  51927. * @hidden
  51928. * Backing Field
  51929. */
  51930. _submeshesOctree: Octree<SubMesh>;
  51931. /**
  51932. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51933. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51934. * @param maxCapacity defines the maximum size of each block (64 by default)
  51935. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51936. * @returns the new octree
  51937. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51938. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51939. */
  51940. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51941. }
  51942. }
  51943. /**
  51944. * Defines the octree scene component responsible to manage any octrees
  51945. * in a given scene.
  51946. */
  51947. export class OctreeSceneComponent {
  51948. /**
  51949. * The component name help to identify the component in the list of scene components.
  51950. */
  51951. readonly name: string;
  51952. /**
  51953. * The scene the component belongs to.
  51954. */
  51955. scene: Scene;
  51956. /**
  51957. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51958. */
  51959. readonly checksIsEnabled: boolean;
  51960. /**
  51961. * Creates a new instance of the component for the given scene
  51962. * @param scene Defines the scene to register the component in
  51963. */
  51964. constructor(scene: Scene);
  51965. /**
  51966. * Registers the component in a given scene
  51967. */
  51968. register(): void;
  51969. /**
  51970. * Return the list of active meshes
  51971. * @returns the list of active meshes
  51972. */
  51973. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51974. /**
  51975. * Return the list of active sub meshes
  51976. * @param mesh The mesh to get the candidates sub meshes from
  51977. * @returns the list of active sub meshes
  51978. */
  51979. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51980. private _tempRay;
  51981. /**
  51982. * Return the list of sub meshes intersecting with a given local ray
  51983. * @param mesh defines the mesh to find the submesh for
  51984. * @param localRay defines the ray in local space
  51985. * @returns the list of intersecting sub meshes
  51986. */
  51987. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51988. /**
  51989. * Return the list of sub meshes colliding with a collider
  51990. * @param mesh defines the mesh to find the submesh for
  51991. * @param collider defines the collider to evaluate the collision against
  51992. * @returns the list of colliding sub meshes
  51993. */
  51994. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51995. /**
  51996. * Rebuilds the elements related to this component in case of
  51997. * context lost for instance.
  51998. */
  51999. rebuild(): void;
  52000. /**
  52001. * Disposes the component and the associated ressources.
  52002. */
  52003. dispose(): void;
  52004. }
  52005. }
  52006. declare module "babylonjs/Culling/Octrees/index" {
  52007. export * from "babylonjs/Culling/Octrees/octree";
  52008. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52009. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52010. }
  52011. declare module "babylonjs/Culling/index" {
  52012. export * from "babylonjs/Culling/boundingBox";
  52013. export * from "babylonjs/Culling/boundingInfo";
  52014. export * from "babylonjs/Culling/boundingSphere";
  52015. export * from "babylonjs/Culling/Octrees/index";
  52016. export * from "babylonjs/Culling/ray";
  52017. }
  52018. declare module "babylonjs/Gizmos/gizmo" {
  52019. import { Nullable } from "babylonjs/types";
  52020. import { IDisposable } from "babylonjs/scene";
  52021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52022. import { Mesh } from "babylonjs/Meshes/mesh";
  52023. import { Node } from "babylonjs/node";
  52024. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52025. /**
  52026. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52027. */
  52028. export class Gizmo implements IDisposable {
  52029. /** The utility layer the gizmo will be added to */
  52030. gizmoLayer: UtilityLayerRenderer;
  52031. /**
  52032. * The root mesh of the gizmo
  52033. */
  52034. _rootMesh: Mesh;
  52035. private _attachedMesh;
  52036. private _attachedNode;
  52037. /**
  52038. * Ratio for the scale of the gizmo (Default: 1)
  52039. */
  52040. scaleRatio: number;
  52041. /**
  52042. * If a custom mesh has been set (Default: false)
  52043. */
  52044. protected _customMeshSet: boolean;
  52045. /**
  52046. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52047. * * When set, interactions will be enabled
  52048. */
  52049. get attachedMesh(): Nullable<AbstractMesh>;
  52050. set attachedMesh(value: Nullable<AbstractMesh>);
  52051. /**
  52052. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52053. * * When set, interactions will be enabled
  52054. */
  52055. get attachedNode(): Nullable<Node>;
  52056. set attachedNode(value: Nullable<Node>);
  52057. /**
  52058. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52059. * @param mesh The mesh to replace the default mesh of the gizmo
  52060. */
  52061. setCustomMesh(mesh: Mesh): void;
  52062. /**
  52063. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52064. */
  52065. updateGizmoRotationToMatchAttachedMesh: boolean;
  52066. /**
  52067. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52068. */
  52069. updateGizmoPositionToMatchAttachedMesh: boolean;
  52070. /**
  52071. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52072. */
  52073. updateScale: boolean;
  52074. protected _interactionsEnabled: boolean;
  52075. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52076. private _beforeRenderObserver;
  52077. private _tempVector;
  52078. /**
  52079. * Creates a gizmo
  52080. * @param gizmoLayer The utility layer the gizmo will be added to
  52081. */
  52082. constructor(
  52083. /** The utility layer the gizmo will be added to */
  52084. gizmoLayer?: UtilityLayerRenderer);
  52085. /**
  52086. * Updates the gizmo to match the attached mesh's position/rotation
  52087. */
  52088. protected _update(): void;
  52089. /**
  52090. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52091. * @param value Node, TransformNode or mesh
  52092. */
  52093. protected _matrixChanged(): void;
  52094. /**
  52095. * Disposes of the gizmo
  52096. */
  52097. dispose(): void;
  52098. }
  52099. }
  52100. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52101. import { Observable } from "babylonjs/Misc/observable";
  52102. import { Nullable } from "babylonjs/types";
  52103. import { Vector3 } from "babylonjs/Maths/math.vector";
  52104. import { Color3 } from "babylonjs/Maths/math.color";
  52105. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52106. import { Node } from "babylonjs/node";
  52107. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52108. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52109. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52110. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52111. import { Scene } from "babylonjs/scene";
  52112. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52113. /**
  52114. * Single plane drag gizmo
  52115. */
  52116. export class PlaneDragGizmo extends Gizmo {
  52117. /**
  52118. * Drag behavior responsible for the gizmos dragging interactions
  52119. */
  52120. dragBehavior: PointerDragBehavior;
  52121. private _pointerObserver;
  52122. /**
  52123. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52124. */
  52125. snapDistance: number;
  52126. /**
  52127. * Event that fires each time the gizmo snaps to a new location.
  52128. * * snapDistance is the the change in distance
  52129. */
  52130. onSnapObservable: Observable<{
  52131. snapDistance: number;
  52132. }>;
  52133. private _plane;
  52134. private _coloredMaterial;
  52135. private _hoverMaterial;
  52136. private _isEnabled;
  52137. private _parent;
  52138. /** @hidden */
  52139. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52140. /** @hidden */
  52141. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52142. /**
  52143. * Creates a PlaneDragGizmo
  52144. * @param gizmoLayer The utility layer the gizmo will be added to
  52145. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52146. * @param color The color of the gizmo
  52147. */
  52148. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52149. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52150. /**
  52151. * If the gizmo is enabled
  52152. */
  52153. set isEnabled(value: boolean);
  52154. get isEnabled(): boolean;
  52155. /**
  52156. * Disposes of the gizmo
  52157. */
  52158. dispose(): void;
  52159. }
  52160. }
  52161. declare module "babylonjs/Gizmos/positionGizmo" {
  52162. import { Observable } from "babylonjs/Misc/observable";
  52163. import { Nullable } from "babylonjs/types";
  52164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52165. import { Node } from "babylonjs/node";
  52166. import { Mesh } from "babylonjs/Meshes/mesh";
  52167. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52168. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52169. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52170. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52171. /**
  52172. * Gizmo that enables dragging a mesh along 3 axis
  52173. */
  52174. export class PositionGizmo extends Gizmo {
  52175. /**
  52176. * Internal gizmo used for interactions on the x axis
  52177. */
  52178. xGizmo: AxisDragGizmo;
  52179. /**
  52180. * Internal gizmo used for interactions on the y axis
  52181. */
  52182. yGizmo: AxisDragGizmo;
  52183. /**
  52184. * Internal gizmo used for interactions on the z axis
  52185. */
  52186. zGizmo: AxisDragGizmo;
  52187. /**
  52188. * Internal gizmo used for interactions on the yz plane
  52189. */
  52190. xPlaneGizmo: PlaneDragGizmo;
  52191. /**
  52192. * Internal gizmo used for interactions on the xz plane
  52193. */
  52194. yPlaneGizmo: PlaneDragGizmo;
  52195. /**
  52196. * Internal gizmo used for interactions on the xy plane
  52197. */
  52198. zPlaneGizmo: PlaneDragGizmo;
  52199. /**
  52200. * private variables
  52201. */
  52202. private _meshAttached;
  52203. private _nodeAttached;
  52204. private _updateGizmoRotationToMatchAttachedMesh;
  52205. private _snapDistance;
  52206. private _scaleRatio;
  52207. /** Fires an event when any of it's sub gizmos are dragged */
  52208. onDragStartObservable: Observable<unknown>;
  52209. /** Fires an event when any of it's sub gizmos are released from dragging */
  52210. onDragEndObservable: Observable<unknown>;
  52211. /**
  52212. * If set to true, planar drag is enabled
  52213. */
  52214. private _planarGizmoEnabled;
  52215. get attachedMesh(): Nullable<AbstractMesh>;
  52216. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52217. get attachedNode(): Nullable<Node>;
  52218. set attachedNode(node: Nullable<Node>);
  52219. /**
  52220. * Creates a PositionGizmo
  52221. * @param gizmoLayer The utility layer the gizmo will be added to
  52222. @param thickness display gizmo axis thickness
  52223. */
  52224. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52225. /**
  52226. * If the planar drag gizmo is enabled
  52227. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52228. */
  52229. set planarGizmoEnabled(value: boolean);
  52230. get planarGizmoEnabled(): boolean;
  52231. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52232. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52233. /**
  52234. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52235. */
  52236. set snapDistance(value: number);
  52237. get snapDistance(): number;
  52238. /**
  52239. * Ratio for the scale of the gizmo (Default: 1)
  52240. */
  52241. set scaleRatio(value: number);
  52242. get scaleRatio(): number;
  52243. /**
  52244. * Disposes of the gizmo
  52245. */
  52246. dispose(): void;
  52247. /**
  52248. * CustomMeshes are not supported by this gizmo
  52249. * @param mesh The mesh to replace the default mesh of the gizmo
  52250. */
  52251. setCustomMesh(mesh: Mesh): void;
  52252. }
  52253. }
  52254. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52255. import { Observable } from "babylonjs/Misc/observable";
  52256. import { Nullable } from "babylonjs/types";
  52257. import { Vector3 } from "babylonjs/Maths/math.vector";
  52258. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52259. import { Node } from "babylonjs/node";
  52260. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52261. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52262. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52263. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52264. import { Scene } from "babylonjs/scene";
  52265. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52266. import { Color3 } from "babylonjs/Maths/math.color";
  52267. /**
  52268. * Single axis drag gizmo
  52269. */
  52270. export class AxisDragGizmo extends Gizmo {
  52271. /**
  52272. * Drag behavior responsible for the gizmos dragging interactions
  52273. */
  52274. dragBehavior: PointerDragBehavior;
  52275. private _pointerObserver;
  52276. /**
  52277. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52278. */
  52279. snapDistance: number;
  52280. /**
  52281. * Event that fires each time the gizmo snaps to a new location.
  52282. * * snapDistance is the the change in distance
  52283. */
  52284. onSnapObservable: Observable<{
  52285. snapDistance: number;
  52286. }>;
  52287. private _isEnabled;
  52288. private _parent;
  52289. private _arrow;
  52290. private _coloredMaterial;
  52291. private _hoverMaterial;
  52292. /** @hidden */
  52293. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52294. /** @hidden */
  52295. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52296. /**
  52297. * Creates an AxisDragGizmo
  52298. * @param gizmoLayer The utility layer the gizmo will be added to
  52299. * @param dragAxis The axis which the gizmo will be able to drag on
  52300. * @param color The color of the gizmo
  52301. * @param thickness display gizmo axis thickness
  52302. */
  52303. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52304. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52305. /**
  52306. * If the gizmo is enabled
  52307. */
  52308. set isEnabled(value: boolean);
  52309. get isEnabled(): boolean;
  52310. /**
  52311. * Disposes of the gizmo
  52312. */
  52313. dispose(): void;
  52314. }
  52315. }
  52316. declare module "babylonjs/Debug/axesViewer" {
  52317. import { Vector3 } from "babylonjs/Maths/math.vector";
  52318. import { Nullable } from "babylonjs/types";
  52319. import { Scene } from "babylonjs/scene";
  52320. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52321. /**
  52322. * The Axes viewer will show 3 axes in a specific point in space
  52323. */
  52324. export class AxesViewer {
  52325. private _xAxis;
  52326. private _yAxis;
  52327. private _zAxis;
  52328. private _scaleLinesFactor;
  52329. private _instanced;
  52330. /**
  52331. * Gets the hosting scene
  52332. */
  52333. scene: Scene;
  52334. /**
  52335. * Gets or sets a number used to scale line length
  52336. */
  52337. scaleLines: number;
  52338. /** Gets the node hierarchy used to render x-axis */
  52339. get xAxis(): TransformNode;
  52340. /** Gets the node hierarchy used to render y-axis */
  52341. get yAxis(): TransformNode;
  52342. /** Gets the node hierarchy used to render z-axis */
  52343. get zAxis(): TransformNode;
  52344. /**
  52345. * Creates a new AxesViewer
  52346. * @param scene defines the hosting scene
  52347. * @param scaleLines defines a number used to scale line length (1 by default)
  52348. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52349. * @param xAxis defines the node hierarchy used to render the x-axis
  52350. * @param yAxis defines the node hierarchy used to render the y-axis
  52351. * @param zAxis defines the node hierarchy used to render the z-axis
  52352. */
  52353. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52354. /**
  52355. * Force the viewer to update
  52356. * @param position defines the position of the viewer
  52357. * @param xaxis defines the x axis of the viewer
  52358. * @param yaxis defines the y axis of the viewer
  52359. * @param zaxis defines the z axis of the viewer
  52360. */
  52361. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52362. /**
  52363. * Creates an instance of this axes viewer.
  52364. * @returns a new axes viewer with instanced meshes
  52365. */
  52366. createInstance(): AxesViewer;
  52367. /** Releases resources */
  52368. dispose(): void;
  52369. private static _SetRenderingGroupId;
  52370. }
  52371. }
  52372. declare module "babylonjs/Debug/boneAxesViewer" {
  52373. import { Nullable } from "babylonjs/types";
  52374. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52375. import { Vector3 } from "babylonjs/Maths/math.vector";
  52376. import { Mesh } from "babylonjs/Meshes/mesh";
  52377. import { Bone } from "babylonjs/Bones/bone";
  52378. import { Scene } from "babylonjs/scene";
  52379. /**
  52380. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52381. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52382. */
  52383. export class BoneAxesViewer extends AxesViewer {
  52384. /**
  52385. * Gets or sets the target mesh where to display the axes viewer
  52386. */
  52387. mesh: Nullable<Mesh>;
  52388. /**
  52389. * Gets or sets the target bone where to display the axes viewer
  52390. */
  52391. bone: Nullable<Bone>;
  52392. /** Gets current position */
  52393. pos: Vector3;
  52394. /** Gets direction of X axis */
  52395. xaxis: Vector3;
  52396. /** Gets direction of Y axis */
  52397. yaxis: Vector3;
  52398. /** Gets direction of Z axis */
  52399. zaxis: Vector3;
  52400. /**
  52401. * Creates a new BoneAxesViewer
  52402. * @param scene defines the hosting scene
  52403. * @param bone defines the target bone
  52404. * @param mesh defines the target mesh
  52405. * @param scaleLines defines a scaling factor for line length (1 by default)
  52406. */
  52407. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52408. /**
  52409. * Force the viewer to update
  52410. */
  52411. update(): void;
  52412. /** Releases resources */
  52413. dispose(): void;
  52414. }
  52415. }
  52416. declare module "babylonjs/Debug/debugLayer" {
  52417. import { Scene } from "babylonjs/scene";
  52418. /**
  52419. * Interface used to define scene explorer extensibility option
  52420. */
  52421. export interface IExplorerExtensibilityOption {
  52422. /**
  52423. * Define the option label
  52424. */
  52425. label: string;
  52426. /**
  52427. * Defines the action to execute on click
  52428. */
  52429. action: (entity: any) => void;
  52430. }
  52431. /**
  52432. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52433. */
  52434. export interface IExplorerExtensibilityGroup {
  52435. /**
  52436. * Defines a predicate to test if a given type mut be extended
  52437. */
  52438. predicate: (entity: any) => boolean;
  52439. /**
  52440. * Gets the list of options added to a type
  52441. */
  52442. entries: IExplorerExtensibilityOption[];
  52443. }
  52444. /**
  52445. * Interface used to define the options to use to create the Inspector
  52446. */
  52447. export interface IInspectorOptions {
  52448. /**
  52449. * Display in overlay mode (default: false)
  52450. */
  52451. overlay?: boolean;
  52452. /**
  52453. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52454. */
  52455. globalRoot?: HTMLElement;
  52456. /**
  52457. * Display the Scene explorer
  52458. */
  52459. showExplorer?: boolean;
  52460. /**
  52461. * Display the property inspector
  52462. */
  52463. showInspector?: boolean;
  52464. /**
  52465. * Display in embed mode (both panes on the right)
  52466. */
  52467. embedMode?: boolean;
  52468. /**
  52469. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52470. */
  52471. handleResize?: boolean;
  52472. /**
  52473. * Allow the panes to popup (default: true)
  52474. */
  52475. enablePopup?: boolean;
  52476. /**
  52477. * Allow the panes to be closed by users (default: true)
  52478. */
  52479. enableClose?: boolean;
  52480. /**
  52481. * Optional list of extensibility entries
  52482. */
  52483. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52484. /**
  52485. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52486. */
  52487. inspectorURL?: string;
  52488. /**
  52489. * Optional initial tab (default to DebugLayerTab.Properties)
  52490. */
  52491. initialTab?: DebugLayerTab;
  52492. }
  52493. module "babylonjs/scene" {
  52494. interface Scene {
  52495. /**
  52496. * @hidden
  52497. * Backing field
  52498. */
  52499. _debugLayer: DebugLayer;
  52500. /**
  52501. * Gets the debug layer (aka Inspector) associated with the scene
  52502. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52503. */
  52504. debugLayer: DebugLayer;
  52505. }
  52506. }
  52507. /**
  52508. * Enum of inspector action tab
  52509. */
  52510. export enum DebugLayerTab {
  52511. /**
  52512. * Properties tag (default)
  52513. */
  52514. Properties = 0,
  52515. /**
  52516. * Debug tab
  52517. */
  52518. Debug = 1,
  52519. /**
  52520. * Statistics tab
  52521. */
  52522. Statistics = 2,
  52523. /**
  52524. * Tools tab
  52525. */
  52526. Tools = 3,
  52527. /**
  52528. * Settings tab
  52529. */
  52530. Settings = 4
  52531. }
  52532. /**
  52533. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52534. * what is happening in your scene
  52535. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52536. */
  52537. export class DebugLayer {
  52538. /**
  52539. * Define the url to get the inspector script from.
  52540. * By default it uses the babylonjs CDN.
  52541. * @ignoreNaming
  52542. */
  52543. static InspectorURL: string;
  52544. private _scene;
  52545. private BJSINSPECTOR;
  52546. private _onPropertyChangedObservable?;
  52547. /**
  52548. * Observable triggered when a property is changed through the inspector.
  52549. */
  52550. get onPropertyChangedObservable(): any;
  52551. /**
  52552. * Instantiates a new debug layer.
  52553. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52554. * what is happening in your scene
  52555. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52556. * @param scene Defines the scene to inspect
  52557. */
  52558. constructor(scene: Scene);
  52559. /** Creates the inspector window. */
  52560. private _createInspector;
  52561. /**
  52562. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52563. * @param entity defines the entity to select
  52564. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52565. */
  52566. select(entity: any, lineContainerTitles?: string | string[]): void;
  52567. /** Get the inspector from bundle or global */
  52568. private _getGlobalInspector;
  52569. /**
  52570. * Get if the inspector is visible or not.
  52571. * @returns true if visible otherwise, false
  52572. */
  52573. isVisible(): boolean;
  52574. /**
  52575. * Hide the inspector and close its window.
  52576. */
  52577. hide(): void;
  52578. /**
  52579. * Update the scene in the inspector
  52580. */
  52581. setAsActiveScene(): void;
  52582. /**
  52583. * Launch the debugLayer.
  52584. * @param config Define the configuration of the inspector
  52585. * @return a promise fulfilled when the debug layer is visible
  52586. */
  52587. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52588. }
  52589. }
  52590. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52591. import { Nullable } from "babylonjs/types";
  52592. import { Scene } from "babylonjs/scene";
  52593. import { Vector4 } from "babylonjs/Maths/math.vector";
  52594. import { Color4 } from "babylonjs/Maths/math.color";
  52595. import { Mesh } from "babylonjs/Meshes/mesh";
  52596. /**
  52597. * Class containing static functions to help procedurally build meshes
  52598. */
  52599. export class BoxBuilder {
  52600. /**
  52601. * Creates a box mesh
  52602. * * The parameter `size` sets the size (float) of each box side (default 1)
  52603. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52604. * * 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)
  52605. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52609. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52610. * @param name defines the name of the mesh
  52611. * @param options defines the options used to create the mesh
  52612. * @param scene defines the hosting scene
  52613. * @returns the box mesh
  52614. */
  52615. static CreateBox(name: string, options: {
  52616. size?: number;
  52617. width?: number;
  52618. height?: number;
  52619. depth?: number;
  52620. faceUV?: Vector4[];
  52621. faceColors?: Color4[];
  52622. sideOrientation?: number;
  52623. frontUVs?: Vector4;
  52624. backUVs?: Vector4;
  52625. wrap?: boolean;
  52626. topBaseAt?: number;
  52627. bottomBaseAt?: number;
  52628. updatable?: boolean;
  52629. }, scene?: Nullable<Scene>): Mesh;
  52630. }
  52631. }
  52632. declare module "babylonjs/Debug/physicsViewer" {
  52633. import { Nullable } from "babylonjs/types";
  52634. import { Scene } from "babylonjs/scene";
  52635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52636. import { Mesh } from "babylonjs/Meshes/mesh";
  52637. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52638. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52639. /**
  52640. * Used to show the physics impostor around the specific mesh
  52641. */
  52642. export class PhysicsViewer {
  52643. /** @hidden */
  52644. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52645. /** @hidden */
  52646. protected _meshes: Array<Nullable<AbstractMesh>>;
  52647. /** @hidden */
  52648. protected _scene: Nullable<Scene>;
  52649. /** @hidden */
  52650. protected _numMeshes: number;
  52651. /** @hidden */
  52652. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52653. private _renderFunction;
  52654. private _utilityLayer;
  52655. private _debugBoxMesh;
  52656. private _debugSphereMesh;
  52657. private _debugCylinderMesh;
  52658. private _debugMaterial;
  52659. private _debugMeshMeshes;
  52660. /**
  52661. * Creates a new PhysicsViewer
  52662. * @param scene defines the hosting scene
  52663. */
  52664. constructor(scene: Scene);
  52665. /** @hidden */
  52666. protected _updateDebugMeshes(): void;
  52667. /**
  52668. * Renders a specified physic impostor
  52669. * @param impostor defines the impostor to render
  52670. * @param targetMesh defines the mesh represented by the impostor
  52671. * @returns the new debug mesh used to render the impostor
  52672. */
  52673. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52674. /**
  52675. * Hides a specified physic impostor
  52676. * @param impostor defines the impostor to hide
  52677. */
  52678. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52679. private _getDebugMaterial;
  52680. private _getDebugBoxMesh;
  52681. private _getDebugSphereMesh;
  52682. private _getDebugCylinderMesh;
  52683. private _getDebugMeshMesh;
  52684. private _getDebugMesh;
  52685. /** Releases all resources */
  52686. dispose(): void;
  52687. }
  52688. }
  52689. declare module "babylonjs/Debug/rayHelper" {
  52690. import { Nullable } from "babylonjs/types";
  52691. import { Ray } from "babylonjs/Culling/ray";
  52692. import { Vector3 } from "babylonjs/Maths/math.vector";
  52693. import { Color3 } from "babylonjs/Maths/math.color";
  52694. import { Scene } from "babylonjs/scene";
  52695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52696. import "babylonjs/Meshes/Builders/linesBuilder";
  52697. /**
  52698. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52699. * in order to better appreciate the issue one might have.
  52700. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52701. */
  52702. export class RayHelper {
  52703. /**
  52704. * Defines the ray we are currently tryin to visualize.
  52705. */
  52706. ray: Nullable<Ray>;
  52707. private _renderPoints;
  52708. private _renderLine;
  52709. private _renderFunction;
  52710. private _scene;
  52711. private _updateToMeshFunction;
  52712. private _attachedToMesh;
  52713. private _meshSpaceDirection;
  52714. private _meshSpaceOrigin;
  52715. /**
  52716. * Helper function to create a colored helper in a scene in one line.
  52717. * @param ray Defines the ray we are currently tryin to visualize
  52718. * @param scene Defines the scene the ray is used in
  52719. * @param color Defines the color we want to see the ray in
  52720. * @returns The newly created ray helper.
  52721. */
  52722. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52723. /**
  52724. * Instantiate a new ray helper.
  52725. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52726. * in order to better appreciate the issue one might have.
  52727. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52728. * @param ray Defines the ray we are currently tryin to visualize
  52729. */
  52730. constructor(ray: Ray);
  52731. /**
  52732. * Shows the ray we are willing to debug.
  52733. * @param scene Defines the scene the ray needs to be rendered in
  52734. * @param color Defines the color the ray needs to be rendered in
  52735. */
  52736. show(scene: Scene, color?: Color3): void;
  52737. /**
  52738. * Hides the ray we are debugging.
  52739. */
  52740. hide(): void;
  52741. private _render;
  52742. /**
  52743. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52744. * @param mesh Defines the mesh we want the helper attached to
  52745. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52746. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52747. * @param length Defines the length of the ray
  52748. */
  52749. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52750. /**
  52751. * Detach the ray helper from the mesh it has previously been attached to.
  52752. */
  52753. detachFromMesh(): void;
  52754. private _updateToMesh;
  52755. /**
  52756. * Dispose the helper and release its associated resources.
  52757. */
  52758. dispose(): void;
  52759. }
  52760. }
  52761. declare module "babylonjs/Debug/ISkeletonViewer" {
  52762. /**
  52763. * Defines the options associated with the creation of a SkeletonViewer.
  52764. */
  52765. export interface ISkeletonViewerOptions {
  52766. /** Should the system pause animations before building the Viewer? */
  52767. pauseAnimations: boolean;
  52768. /** Should the system return the skeleton to rest before building? */
  52769. returnToRest: boolean;
  52770. /** public Display Mode of the Viewer */
  52771. displayMode: number;
  52772. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52773. displayOptions: ISkeletonViewerDisplayOptions;
  52774. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52775. computeBonesUsingShaders: boolean;
  52776. }
  52777. /**
  52778. * Defines how to display the various bone meshes for the viewer.
  52779. */
  52780. export interface ISkeletonViewerDisplayOptions {
  52781. /** How far down to start tapering the bone spurs */
  52782. midStep?: number;
  52783. /** How big is the midStep? */
  52784. midStepFactor?: number;
  52785. /** Base for the Sphere Size */
  52786. sphereBaseSize?: number;
  52787. /** The ratio of the sphere to the longest bone in units */
  52788. sphereScaleUnit?: number;
  52789. /** Ratio for the Sphere Size */
  52790. sphereFactor?: number;
  52791. }
  52792. }
  52793. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52794. import { Nullable } from "babylonjs/types";
  52795. import { Scene } from "babylonjs/scene";
  52796. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52797. import { Color4 } from "babylonjs/Maths/math.color";
  52798. import { Mesh } from "babylonjs/Meshes/mesh";
  52799. /**
  52800. * Class containing static functions to help procedurally build meshes
  52801. */
  52802. export class RibbonBuilder {
  52803. /**
  52804. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52805. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52806. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52807. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52808. * * 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
  52809. * * 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
  52810. * * 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
  52811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52814. * * 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
  52815. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52816. * * 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
  52817. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52819. * @param name defines the name of the mesh
  52820. * @param options defines the options used to create the mesh
  52821. * @param scene defines the hosting scene
  52822. * @returns the ribbon mesh
  52823. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52824. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52825. */
  52826. static CreateRibbon(name: string, options: {
  52827. pathArray: Vector3[][];
  52828. closeArray?: boolean;
  52829. closePath?: boolean;
  52830. offset?: number;
  52831. updatable?: boolean;
  52832. sideOrientation?: number;
  52833. frontUVs?: Vector4;
  52834. backUVs?: Vector4;
  52835. instance?: Mesh;
  52836. invertUV?: boolean;
  52837. uvs?: Vector2[];
  52838. colors?: Color4[];
  52839. }, scene?: Nullable<Scene>): Mesh;
  52840. }
  52841. }
  52842. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52843. import { Nullable } from "babylonjs/types";
  52844. import { Scene } from "babylonjs/scene";
  52845. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52846. import { Mesh } from "babylonjs/Meshes/mesh";
  52847. /**
  52848. * Class containing static functions to help procedurally build meshes
  52849. */
  52850. export class ShapeBuilder {
  52851. /**
  52852. * 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.
  52853. * * 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.
  52854. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52855. * * 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.
  52856. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52857. * * 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
  52858. * * 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
  52859. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52864. * @param name defines the name of the mesh
  52865. * @param options defines the options used to create the mesh
  52866. * @param scene defines the hosting scene
  52867. * @returns the extruded shape mesh
  52868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52870. */
  52871. static ExtrudeShape(name: string, options: {
  52872. shape: Vector3[];
  52873. path: Vector3[];
  52874. scale?: number;
  52875. rotation?: number;
  52876. cap?: number;
  52877. updatable?: boolean;
  52878. sideOrientation?: number;
  52879. frontUVs?: Vector4;
  52880. backUVs?: Vector4;
  52881. instance?: Mesh;
  52882. invertUV?: boolean;
  52883. }, scene?: Nullable<Scene>): Mesh;
  52884. /**
  52885. * Creates an custom extruded shape mesh.
  52886. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52887. * * 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.
  52888. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52889. * * 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
  52890. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52891. * * 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
  52892. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52893. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52894. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52895. * * 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
  52896. * * 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
  52897. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52902. * @param name defines the name of the mesh
  52903. * @param options defines the options used to create the mesh
  52904. * @param scene defines the hosting scene
  52905. * @returns the custom extruded shape mesh
  52906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52907. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52909. */
  52910. static ExtrudeShapeCustom(name: string, options: {
  52911. shape: Vector3[];
  52912. path: Vector3[];
  52913. scaleFunction?: any;
  52914. rotationFunction?: any;
  52915. ribbonCloseArray?: boolean;
  52916. ribbonClosePath?: boolean;
  52917. cap?: number;
  52918. updatable?: boolean;
  52919. sideOrientation?: number;
  52920. frontUVs?: Vector4;
  52921. backUVs?: Vector4;
  52922. instance?: Mesh;
  52923. invertUV?: boolean;
  52924. }, scene?: Nullable<Scene>): Mesh;
  52925. private static _ExtrudeShapeGeneric;
  52926. }
  52927. }
  52928. declare module "babylonjs/Debug/skeletonViewer" {
  52929. import { Color3 } from "babylonjs/Maths/math.color";
  52930. import { Scene } from "babylonjs/scene";
  52931. import { Nullable } from "babylonjs/types";
  52932. import { Skeleton } from "babylonjs/Bones/skeleton";
  52933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52934. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52935. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52936. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52937. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  52938. /**
  52939. * Class used to render a debug view of a given skeleton
  52940. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52941. */
  52942. export class SkeletonViewer {
  52943. /** defines the skeleton to render */
  52944. skeleton: Skeleton;
  52945. /** defines the mesh attached to the skeleton */
  52946. mesh: AbstractMesh;
  52947. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52948. autoUpdateBonesMatrices: boolean;
  52949. /** defines the rendering group id to use with the viewer */
  52950. renderingGroupId: number;
  52951. /** is the options for the viewer */
  52952. options: Partial<ISkeletonViewerOptions>;
  52953. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  52954. static readonly DISPLAY_LINES: number;
  52955. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  52956. static readonly DISPLAY_SPHERES: number;
  52957. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  52958. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  52959. /** If SkeletonViewer scene scope. */
  52960. private _scene;
  52961. /** Gets or sets the color used to render the skeleton */
  52962. color: Color3;
  52963. /** Array of the points of the skeleton fo the line view. */
  52964. private _debugLines;
  52965. /** The SkeletonViewers Mesh. */
  52966. private _debugMesh;
  52967. /** If SkeletonViewer is enabled. */
  52968. private _isEnabled;
  52969. /** If SkeletonViewer is ready. */
  52970. private _ready;
  52971. /** SkeletonViewer render observable. */
  52972. private _obs;
  52973. /** The Utility Layer to render the gizmos in. */
  52974. private _utilityLayer;
  52975. /** Gets the Scene. */
  52976. get scene(): Scene;
  52977. /** Gets the utilityLayer. */
  52978. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  52979. /** Checks Ready Status. */
  52980. get isReady(): Boolean;
  52981. /** Sets Ready Status. */
  52982. set ready(value: boolean);
  52983. /** Gets the debugMesh */
  52984. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  52985. /** Sets the debugMesh */
  52986. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  52987. /** Gets the material */
  52988. get material(): StandardMaterial;
  52989. /** Sets the material */
  52990. set material(value: StandardMaterial);
  52991. /**
  52992. * Creates a new SkeletonViewer
  52993. * @param skeleton defines the skeleton to render
  52994. * @param mesh defines the mesh attached to the skeleton
  52995. * @param scene defines the hosting scene
  52996. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52997. * @param renderingGroupId defines the rendering group id to use with the viewer
  52998. * @param options All of the extra constructor options for the SkeletonViewer
  52999. */
  53000. constructor(
  53001. /** defines the skeleton to render */
  53002. skeleton: Skeleton,
  53003. /** defines the mesh attached to the skeleton */
  53004. mesh: AbstractMesh,
  53005. /** The Scene scope*/
  53006. scene: Scene,
  53007. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53008. autoUpdateBonesMatrices?: boolean,
  53009. /** defines the rendering group id to use with the viewer */
  53010. renderingGroupId?: number,
  53011. /** is the options for the viewer */
  53012. options?: Partial<ISkeletonViewerOptions>);
  53013. /** The Dynamic bindings for the update functions */
  53014. private _bindObs;
  53015. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53016. update(): void;
  53017. /** Gets or sets a boolean indicating if the viewer is enabled */
  53018. set isEnabled(value: boolean);
  53019. get isEnabled(): boolean;
  53020. private _getBonePosition;
  53021. private _getLinesForBonesWithLength;
  53022. private _getLinesForBonesNoLength;
  53023. /** function to revert the mesh and scene back to the initial state. */
  53024. private _revert;
  53025. /** function to build and bind sphere joint points and spur bone representations. */
  53026. private _buildSpheresAndSpurs;
  53027. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53028. private _displayLinesUpdate;
  53029. /** Release associated resources */
  53030. dispose(): void;
  53031. }
  53032. }
  53033. declare module "babylonjs/Debug/index" {
  53034. export * from "babylonjs/Debug/axesViewer";
  53035. export * from "babylonjs/Debug/boneAxesViewer";
  53036. export * from "babylonjs/Debug/debugLayer";
  53037. export * from "babylonjs/Debug/physicsViewer";
  53038. export * from "babylonjs/Debug/rayHelper";
  53039. export * from "babylonjs/Debug/skeletonViewer";
  53040. export * from "babylonjs/Debug/ISkeletonViewer";
  53041. }
  53042. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53043. /**
  53044. * Enum for Device Types
  53045. */
  53046. export enum DeviceType {
  53047. /** Generic */
  53048. Generic = 0,
  53049. /** Keyboard */
  53050. Keyboard = 1,
  53051. /** Mouse */
  53052. Mouse = 2,
  53053. /** Touch Pointers */
  53054. Touch = 3,
  53055. /** PS4 Dual Shock */
  53056. DualShock = 4,
  53057. /** Xbox */
  53058. Xbox = 5,
  53059. /** Switch Controller */
  53060. Switch = 6
  53061. }
  53062. /**
  53063. * Enum for All Pointers (Touch/Mouse)
  53064. */
  53065. export enum PointerInput {
  53066. /** Horizontal Axis */
  53067. Horizontal = 0,
  53068. /** Vertical Axis */
  53069. Vertical = 1,
  53070. /** Left Click or Touch */
  53071. LeftClick = 2,
  53072. /** Middle Click */
  53073. MiddleClick = 3,
  53074. /** Right Click */
  53075. RightClick = 4,
  53076. /** Browser Back */
  53077. BrowserBack = 5,
  53078. /** Browser Forward */
  53079. BrowserForward = 6
  53080. }
  53081. /**
  53082. * Enum for Dual Shock Gamepad
  53083. */
  53084. export enum DualShockInput {
  53085. /** Cross */
  53086. Cross = 0,
  53087. /** Circle */
  53088. Circle = 1,
  53089. /** Square */
  53090. Square = 2,
  53091. /** Triangle */
  53092. Triangle = 3,
  53093. /** L1 */
  53094. L1 = 4,
  53095. /** R1 */
  53096. R1 = 5,
  53097. /** L2 */
  53098. L2 = 6,
  53099. /** R2 */
  53100. R2 = 7,
  53101. /** Share */
  53102. Share = 8,
  53103. /** Options */
  53104. Options = 9,
  53105. /** L3 */
  53106. L3 = 10,
  53107. /** R3 */
  53108. R3 = 11,
  53109. /** DPadUp */
  53110. DPadUp = 12,
  53111. /** DPadDown */
  53112. DPadDown = 13,
  53113. /** DPadLeft */
  53114. DPadLeft = 14,
  53115. /** DRight */
  53116. DPadRight = 15,
  53117. /** Home */
  53118. Home = 16,
  53119. /** TouchPad */
  53120. TouchPad = 17,
  53121. /** LStickXAxis */
  53122. LStickXAxis = 18,
  53123. /** LStickYAxis */
  53124. LStickYAxis = 19,
  53125. /** RStickXAxis */
  53126. RStickXAxis = 20,
  53127. /** RStickYAxis */
  53128. RStickYAxis = 21
  53129. }
  53130. /**
  53131. * Enum for Xbox Gamepad
  53132. */
  53133. export enum XboxInput {
  53134. /** A */
  53135. A = 0,
  53136. /** B */
  53137. B = 1,
  53138. /** X */
  53139. X = 2,
  53140. /** Y */
  53141. Y = 3,
  53142. /** LB */
  53143. LB = 4,
  53144. /** RB */
  53145. RB = 5,
  53146. /** LT */
  53147. LT = 6,
  53148. /** RT */
  53149. RT = 7,
  53150. /** Back */
  53151. Back = 8,
  53152. /** Start */
  53153. Start = 9,
  53154. /** LS */
  53155. LS = 10,
  53156. /** RS */
  53157. RS = 11,
  53158. /** DPadUp */
  53159. DPadUp = 12,
  53160. /** DPadDown */
  53161. DPadDown = 13,
  53162. /** DPadLeft */
  53163. DPadLeft = 14,
  53164. /** DRight */
  53165. DPadRight = 15,
  53166. /** Home */
  53167. Home = 16,
  53168. /** LStickXAxis */
  53169. LStickXAxis = 17,
  53170. /** LStickYAxis */
  53171. LStickYAxis = 18,
  53172. /** RStickXAxis */
  53173. RStickXAxis = 19,
  53174. /** RStickYAxis */
  53175. RStickYAxis = 20
  53176. }
  53177. /**
  53178. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53179. */
  53180. export enum SwitchInput {
  53181. /** B */
  53182. B = 0,
  53183. /** A */
  53184. A = 1,
  53185. /** Y */
  53186. Y = 2,
  53187. /** X */
  53188. X = 3,
  53189. /** L */
  53190. L = 4,
  53191. /** R */
  53192. R = 5,
  53193. /** ZL */
  53194. ZL = 6,
  53195. /** ZR */
  53196. ZR = 7,
  53197. /** Minus */
  53198. Minus = 8,
  53199. /** Plus */
  53200. Plus = 9,
  53201. /** LS */
  53202. LS = 10,
  53203. /** RS */
  53204. RS = 11,
  53205. /** DPadUp */
  53206. DPadUp = 12,
  53207. /** DPadDown */
  53208. DPadDown = 13,
  53209. /** DPadLeft */
  53210. DPadLeft = 14,
  53211. /** DRight */
  53212. DPadRight = 15,
  53213. /** Home */
  53214. Home = 16,
  53215. /** Capture */
  53216. Capture = 17,
  53217. /** LStickXAxis */
  53218. LStickXAxis = 18,
  53219. /** LStickYAxis */
  53220. LStickYAxis = 19,
  53221. /** RStickXAxis */
  53222. RStickXAxis = 20,
  53223. /** RStickYAxis */
  53224. RStickYAxis = 21
  53225. }
  53226. }
  53227. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53228. import { Engine } from "babylonjs/Engines/engine";
  53229. import { IDisposable } from "babylonjs/scene";
  53230. import { Nullable } from "babylonjs/types";
  53231. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53232. /**
  53233. * This class will take all inputs from Keyboard, Pointer, and
  53234. * any Gamepads and provide a polling system that all devices
  53235. * will use. This class assumes that there will only be one
  53236. * pointer device and one keyboard.
  53237. */
  53238. export class DeviceInputSystem implements IDisposable {
  53239. /**
  53240. * Callback to be triggered when a device is connected
  53241. */
  53242. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53243. /**
  53244. * Callback to be triggered when a device is disconnected
  53245. */
  53246. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53247. /**
  53248. * Callback to be triggered when event driven input is updated
  53249. */
  53250. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53251. private _inputs;
  53252. private _gamepads;
  53253. private _keyboardActive;
  53254. private _pointerActive;
  53255. private _elementToAttachTo;
  53256. private _keyboardDownEvent;
  53257. private _keyboardUpEvent;
  53258. private _pointerMoveEvent;
  53259. private _pointerDownEvent;
  53260. private _pointerUpEvent;
  53261. private _gamepadConnectedEvent;
  53262. private _gamepadDisconnectedEvent;
  53263. private static _MAX_KEYCODES;
  53264. private static _MAX_POINTER_INPUTS;
  53265. private constructor();
  53266. /**
  53267. * Creates a new DeviceInputSystem instance
  53268. * @param engine Engine to pull input element from
  53269. * @returns The new instance
  53270. */
  53271. static Create(engine: Engine): DeviceInputSystem;
  53272. /**
  53273. * Checks for current device input value, given an id and input index
  53274. * @param deviceName Id of connected device
  53275. * @param inputIndex Index of device input
  53276. * @returns Current value of input
  53277. */
  53278. /**
  53279. * Checks for current device input value, given an id and input index
  53280. * @param deviceType Enum specifiying device type
  53281. * @param deviceSlot "Slot" or index that device is referenced in
  53282. * @param inputIndex Id of input to be checked
  53283. * @returns Current value of input
  53284. */
  53285. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  53286. /**
  53287. * Dispose of all the eventlisteners
  53288. */
  53289. dispose(): void;
  53290. /**
  53291. * Add device and inputs to device array
  53292. * @param deviceType Enum specifiying device type
  53293. * @param deviceSlot "Slot" or index that device is referenced in
  53294. * @param numberOfInputs Number of input entries to create for given device
  53295. */
  53296. private _registerDevice;
  53297. /**
  53298. * Given a specific device name, remove that device from the device map
  53299. * @param deviceType Enum specifiying device type
  53300. * @param deviceSlot "Slot" or index that device is referenced in
  53301. */
  53302. private _unregisterDevice;
  53303. /**
  53304. * Handle all actions that come from keyboard interaction
  53305. */
  53306. private _handleKeyActions;
  53307. /**
  53308. * Handle all actions that come from pointer interaction
  53309. */
  53310. private _handlePointerActions;
  53311. /**
  53312. * Handle all actions that come from gamepad interaction
  53313. */
  53314. private _handleGamepadActions;
  53315. /**
  53316. * Update all non-event based devices with each frame
  53317. * @param deviceType Enum specifiying device type
  53318. * @param deviceSlot "Slot" or index that device is referenced in
  53319. * @param inputIndex Id of input to be checked
  53320. */
  53321. private _updateDevice;
  53322. /**
  53323. * Gets DeviceType from the device name
  53324. * @param deviceName Name of Device from DeviceInputSystem
  53325. * @returns DeviceType enum value
  53326. */
  53327. private _getGamepadDeviceType;
  53328. }
  53329. }
  53330. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53331. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53332. /**
  53333. * Type to handle enforcement of inputs
  53334. */
  53335. 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;
  53336. }
  53337. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53338. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53339. import { Engine } from "babylonjs/Engines/engine";
  53340. import { IDisposable } from "babylonjs/scene";
  53341. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53342. import { Nullable } from "babylonjs/types";
  53343. import { Observable } from "babylonjs/Misc/observable";
  53344. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53345. /**
  53346. * Class that handles all input for a specific device
  53347. */
  53348. export class DeviceSource<T extends DeviceType> {
  53349. /** Type of device */
  53350. readonly deviceType: DeviceType;
  53351. /** "Slot" or index that device is referenced in */
  53352. readonly deviceSlot: number;
  53353. /**
  53354. * Observable to handle device input changes per device
  53355. */
  53356. readonly onInputChangedObservable: Observable<{
  53357. inputIndex: DeviceInput<T>;
  53358. previousState: Nullable<number>;
  53359. currentState: Nullable<number>;
  53360. }>;
  53361. private readonly _deviceInputSystem;
  53362. /**
  53363. * Default Constructor
  53364. * @param deviceInputSystem Reference to DeviceInputSystem
  53365. * @param deviceType Type of device
  53366. * @param deviceSlot "Slot" or index that device is referenced in
  53367. */
  53368. constructor(deviceInputSystem: DeviceInputSystem,
  53369. /** Type of device */
  53370. deviceType: DeviceType,
  53371. /** "Slot" or index that device is referenced in */
  53372. deviceSlot?: number);
  53373. /**
  53374. * Get input for specific input
  53375. * @param inputIndex index of specific input on device
  53376. * @returns Input value from DeviceInputSystem
  53377. */
  53378. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53379. }
  53380. /**
  53381. * Class to keep track of devices
  53382. */
  53383. export class DeviceSourceManager implements IDisposable {
  53384. /**
  53385. * Observable to be triggered when before a device is connected
  53386. */
  53387. readonly onBeforeDeviceConnectedObservable: Observable<{
  53388. deviceType: DeviceType;
  53389. deviceSlot: number;
  53390. }>;
  53391. /**
  53392. * Observable to be triggered when before a device is disconnected
  53393. */
  53394. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53395. deviceType: DeviceType;
  53396. deviceSlot: number;
  53397. }>;
  53398. /**
  53399. * Observable to be triggered when after a device is connected
  53400. */
  53401. readonly onAfterDeviceConnectedObservable: Observable<{
  53402. deviceType: DeviceType;
  53403. deviceSlot: number;
  53404. }>;
  53405. /**
  53406. * Observable to be triggered when after a device is disconnected
  53407. */
  53408. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53409. deviceType: DeviceType;
  53410. deviceSlot: number;
  53411. }>;
  53412. private readonly _devices;
  53413. private readonly _firstDevice;
  53414. private readonly _deviceInputSystem;
  53415. /**
  53416. * Default Constructor
  53417. * @param engine engine to pull input element from
  53418. */
  53419. constructor(engine: Engine);
  53420. /**
  53421. * Gets a DeviceSource, given a type and slot
  53422. * @param deviceType Enum specifying device type
  53423. * @param deviceSlot "Slot" or index that device is referenced in
  53424. * @returns DeviceSource object
  53425. */
  53426. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53427. /**
  53428. * Gets an array of DeviceSource objects for a given device type
  53429. * @param deviceType Enum specifying device type
  53430. * @returns Array of DeviceSource objects
  53431. */
  53432. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53433. /**
  53434. * Dispose of DeviceInputSystem and other parts
  53435. */
  53436. dispose(): void;
  53437. /**
  53438. * Function to add device name to device list
  53439. * @param deviceType Enum specifying device type
  53440. * @param deviceSlot "Slot" or index that device is referenced in
  53441. */
  53442. private _addDevice;
  53443. /**
  53444. * Function to remove device name to device list
  53445. * @param deviceType Enum specifying device type
  53446. * @param deviceSlot "Slot" or index that device is referenced in
  53447. */
  53448. private _removeDevice;
  53449. /**
  53450. * Updates array storing first connected device of each type
  53451. * @param type Type of Device
  53452. */
  53453. private _updateFirstDevices;
  53454. }
  53455. }
  53456. declare module "babylonjs/DeviceInput/index" {
  53457. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53458. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53459. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53460. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53461. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53462. }
  53463. declare module "babylonjs/Engines/nullEngine" {
  53464. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53465. import { Engine } from "babylonjs/Engines/engine";
  53466. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53467. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53468. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53469. import { Effect } from "babylonjs/Materials/effect";
  53470. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53471. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53472. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53473. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53474. /**
  53475. * Options to create the null engine
  53476. */
  53477. export class NullEngineOptions {
  53478. /**
  53479. * Render width (Default: 512)
  53480. */
  53481. renderWidth: number;
  53482. /**
  53483. * Render height (Default: 256)
  53484. */
  53485. renderHeight: number;
  53486. /**
  53487. * Texture size (Default: 512)
  53488. */
  53489. textureSize: number;
  53490. /**
  53491. * If delta time between frames should be constant
  53492. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53493. */
  53494. deterministicLockstep: boolean;
  53495. /**
  53496. * Maximum about of steps between frames (Default: 4)
  53497. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53498. */
  53499. lockstepMaxSteps: number;
  53500. /**
  53501. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53502. */
  53503. useHighPrecisionMatrix?: boolean;
  53504. }
  53505. /**
  53506. * The null engine class provides support for headless version of babylon.js.
  53507. * This can be used in server side scenario or for testing purposes
  53508. */
  53509. export class NullEngine extends Engine {
  53510. private _options;
  53511. /**
  53512. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53513. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53514. * @returns true if engine is in deterministic lock step mode
  53515. */
  53516. isDeterministicLockStep(): boolean;
  53517. /**
  53518. * Gets the max steps when engine is running in deterministic lock step
  53519. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53520. * @returns the max steps
  53521. */
  53522. getLockstepMaxSteps(): number;
  53523. /**
  53524. * Gets the current hardware scaling level.
  53525. * By default the hardware scaling level is computed from the window device ratio.
  53526. * 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.
  53527. * @returns a number indicating the current hardware scaling level
  53528. */
  53529. getHardwareScalingLevel(): number;
  53530. constructor(options?: NullEngineOptions);
  53531. /**
  53532. * Creates a vertex buffer
  53533. * @param vertices the data for the vertex buffer
  53534. * @returns the new WebGL static buffer
  53535. */
  53536. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53537. /**
  53538. * Creates a new index buffer
  53539. * @param indices defines the content of the index buffer
  53540. * @param updatable defines if the index buffer must be updatable
  53541. * @returns a new webGL buffer
  53542. */
  53543. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53544. /**
  53545. * Clear the current render buffer or the current render target (if any is set up)
  53546. * @param color defines the color to use
  53547. * @param backBuffer defines if the back buffer must be cleared
  53548. * @param depth defines if the depth buffer must be cleared
  53549. * @param stencil defines if the stencil buffer must be cleared
  53550. */
  53551. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53552. /**
  53553. * Gets the current render width
  53554. * @param useScreen defines if screen size must be used (or the current render target if any)
  53555. * @returns a number defining the current render width
  53556. */
  53557. getRenderWidth(useScreen?: boolean): number;
  53558. /**
  53559. * Gets the current render height
  53560. * @param useScreen defines if screen size must be used (or the current render target if any)
  53561. * @returns a number defining the current render height
  53562. */
  53563. getRenderHeight(useScreen?: boolean): number;
  53564. /**
  53565. * Set the WebGL's viewport
  53566. * @param viewport defines the viewport element to be used
  53567. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53568. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53569. */
  53570. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53571. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53572. /**
  53573. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53574. * @param pipelineContext defines the pipeline context to use
  53575. * @param uniformsNames defines the list of uniform names
  53576. * @returns an array of webGL uniform locations
  53577. */
  53578. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53579. /**
  53580. * Gets the lsit of active attributes for a given webGL program
  53581. * @param pipelineContext defines the pipeline context to use
  53582. * @param attributesNames defines the list of attribute names to get
  53583. * @returns an array of indices indicating the offset of each attribute
  53584. */
  53585. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53586. /**
  53587. * Binds an effect to the webGL context
  53588. * @param effect defines the effect to bind
  53589. */
  53590. bindSamplers(effect: Effect): void;
  53591. /**
  53592. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53593. * @param effect defines the effect to activate
  53594. */
  53595. enableEffect(effect: Effect): void;
  53596. /**
  53597. * Set various states to the webGL context
  53598. * @param culling defines backface culling state
  53599. * @param zOffset defines the value to apply to zOffset (0 by default)
  53600. * @param force defines if states must be applied even if cache is up to date
  53601. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53602. */
  53603. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53604. /**
  53605. * Set the value of an uniform to an array of int32
  53606. * @param uniform defines the webGL uniform location where to store the value
  53607. * @param array defines the array of int32 to store
  53608. */
  53609. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53610. /**
  53611. * Set the value of an uniform to an array of int32 (stored as vec2)
  53612. * @param uniform defines the webGL uniform location where to store the value
  53613. * @param array defines the array of int32 to store
  53614. */
  53615. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53616. /**
  53617. * Set the value of an uniform to an array of int32 (stored as vec3)
  53618. * @param uniform defines the webGL uniform location where to store the value
  53619. * @param array defines the array of int32 to store
  53620. */
  53621. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53622. /**
  53623. * Set the value of an uniform to an array of int32 (stored as vec4)
  53624. * @param uniform defines the webGL uniform location where to store the value
  53625. * @param array defines the array of int32 to store
  53626. */
  53627. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53628. /**
  53629. * Set the value of an uniform to an array of float32
  53630. * @param uniform defines the webGL uniform location where to store the value
  53631. * @param array defines the array of float32 to store
  53632. */
  53633. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53634. /**
  53635. * Set the value of an uniform to an array of float32 (stored as vec2)
  53636. * @param uniform defines the webGL uniform location where to store the value
  53637. * @param array defines the array of float32 to store
  53638. */
  53639. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53640. /**
  53641. * Set the value of an uniform to an array of float32 (stored as vec3)
  53642. * @param uniform defines the webGL uniform location where to store the value
  53643. * @param array defines the array of float32 to store
  53644. */
  53645. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53646. /**
  53647. * Set the value of an uniform to an array of float32 (stored as vec4)
  53648. * @param uniform defines the webGL uniform location where to store the value
  53649. * @param array defines the array of float32 to store
  53650. */
  53651. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53652. /**
  53653. * Set the value of an uniform to an array of number
  53654. * @param uniform defines the webGL uniform location where to store the value
  53655. * @param array defines the array of number to store
  53656. */
  53657. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53658. /**
  53659. * Set the value of an uniform to an array of number (stored as vec2)
  53660. * @param uniform defines the webGL uniform location where to store the value
  53661. * @param array defines the array of number to store
  53662. */
  53663. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53664. /**
  53665. * Set the value of an uniform to an array of number (stored as vec3)
  53666. * @param uniform defines the webGL uniform location where to store the value
  53667. * @param array defines the array of number to store
  53668. */
  53669. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53670. /**
  53671. * Set the value of an uniform to an array of number (stored as vec4)
  53672. * @param uniform defines the webGL uniform location where to store the value
  53673. * @param array defines the array of number to store
  53674. */
  53675. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53676. /**
  53677. * Set the value of an uniform to an array of float32 (stored as matrices)
  53678. * @param uniform defines the webGL uniform location where to store the value
  53679. * @param matrices defines the array of float32 to store
  53680. */
  53681. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53682. /**
  53683. * Set the value of an uniform to a matrix (3x3)
  53684. * @param uniform defines the webGL uniform location where to store the value
  53685. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53686. */
  53687. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53688. /**
  53689. * Set the value of an uniform to a matrix (2x2)
  53690. * @param uniform defines the webGL uniform location where to store the value
  53691. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53692. */
  53693. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53694. /**
  53695. * Set the value of an uniform to a number (float)
  53696. * @param uniform defines the webGL uniform location where to store the value
  53697. * @param value defines the float number to store
  53698. */
  53699. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53700. /**
  53701. * Set the value of an uniform to a vec2
  53702. * @param uniform defines the webGL uniform location where to store the value
  53703. * @param x defines the 1st component of the value
  53704. * @param y defines the 2nd component of the value
  53705. */
  53706. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53707. /**
  53708. * Set the value of an uniform to a vec3
  53709. * @param uniform defines the webGL uniform location where to store the value
  53710. * @param x defines the 1st component of the value
  53711. * @param y defines the 2nd component of the value
  53712. * @param z defines the 3rd component of the value
  53713. */
  53714. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53715. /**
  53716. * Set the value of an uniform to a boolean
  53717. * @param uniform defines the webGL uniform location where to store the value
  53718. * @param bool defines the boolean to store
  53719. */
  53720. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53721. /**
  53722. * Set the value of an uniform to a vec4
  53723. * @param uniform defines the webGL uniform location where to store the value
  53724. * @param x defines the 1st component of the value
  53725. * @param y defines the 2nd component of the value
  53726. * @param z defines the 3rd component of the value
  53727. * @param w defines the 4th component of the value
  53728. */
  53729. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53730. /**
  53731. * Sets the current alpha mode
  53732. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53733. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53734. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53735. */
  53736. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53737. /**
  53738. * Bind webGl buffers directly to the webGL context
  53739. * @param vertexBuffers defines the vertex buffer to bind
  53740. * @param indexBuffer defines the index buffer to bind
  53741. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53742. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53743. * @param effect defines the effect associated with the vertex buffer
  53744. */
  53745. bindBuffers(vertexBuffers: {
  53746. [key: string]: VertexBuffer;
  53747. }, indexBuffer: DataBuffer, effect: Effect): void;
  53748. /**
  53749. * Force the entire cache to be cleared
  53750. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53751. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53752. */
  53753. wipeCaches(bruteForce?: boolean): void;
  53754. /**
  53755. * Send a draw order
  53756. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53757. * @param indexStart defines the starting index
  53758. * @param indexCount defines the number of index to draw
  53759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53760. */
  53761. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53762. /**
  53763. * Draw a list of indexed primitives
  53764. * @param fillMode defines the primitive to use
  53765. * @param indexStart defines the starting index
  53766. * @param indexCount defines the number of index to draw
  53767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53768. */
  53769. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53770. /**
  53771. * Draw a list of unindexed primitives
  53772. * @param fillMode defines the primitive to use
  53773. * @param verticesStart defines the index of first vertex to draw
  53774. * @param verticesCount defines the count of vertices to draw
  53775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53776. */
  53777. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53778. /** @hidden */
  53779. _createTexture(): WebGLTexture;
  53780. /** @hidden */
  53781. _releaseTexture(texture: InternalTexture): void;
  53782. /**
  53783. * Usually called from Texture.ts.
  53784. * Passed information to create a WebGLTexture
  53785. * @param urlArg defines a value which contains one of the following:
  53786. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53787. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53788. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53789. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53790. * @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)
  53791. * @param scene needed for loading to the correct scene
  53792. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53793. * @param onLoad optional callback to be called upon successful completion
  53794. * @param onError optional callback to be called upon failure
  53795. * @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
  53796. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53797. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53798. * @param forcedExtension defines the extension to use to pick the right loader
  53799. * @param mimeType defines an optional mime type
  53800. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53801. */
  53802. 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;
  53803. /**
  53804. * Creates a new render target texture
  53805. * @param size defines the size of the texture
  53806. * @param options defines the options used to create the texture
  53807. * @returns a new render target texture stored in an InternalTexture
  53808. */
  53809. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53810. /**
  53811. * Update the sampling mode of a given texture
  53812. * @param samplingMode defines the required sampling mode
  53813. * @param texture defines the texture to update
  53814. */
  53815. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53816. /**
  53817. * Binds the frame buffer to the specified texture.
  53818. * @param texture The texture to render to or null for the default canvas
  53819. * @param faceIndex The face of the texture to render to in case of cube texture
  53820. * @param requiredWidth The width of the target to render to
  53821. * @param requiredHeight The height of the target to render to
  53822. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53823. * @param lodLevel defines le lod level to bind to the frame buffer
  53824. */
  53825. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53826. /**
  53827. * Unbind the current render target texture from the webGL context
  53828. * @param texture defines the render target texture to unbind
  53829. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53830. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53831. */
  53832. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53833. /**
  53834. * Creates a dynamic vertex buffer
  53835. * @param vertices the data for the dynamic vertex buffer
  53836. * @returns the new WebGL dynamic buffer
  53837. */
  53838. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53839. /**
  53840. * Update the content of a dynamic texture
  53841. * @param texture defines the texture to update
  53842. * @param canvas defines the canvas containing the source
  53843. * @param invertY defines if data must be stored with Y axis inverted
  53844. * @param premulAlpha defines if alpha is stored as premultiplied
  53845. * @param format defines the format of the data
  53846. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53847. */
  53848. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53849. /**
  53850. * Gets a boolean indicating if all created effects are ready
  53851. * @returns true if all effects are ready
  53852. */
  53853. areAllEffectsReady(): boolean;
  53854. /**
  53855. * @hidden
  53856. * Get the current error code of the webGL context
  53857. * @returns the error code
  53858. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53859. */
  53860. getError(): number;
  53861. /** @hidden */
  53862. _getUnpackAlignement(): number;
  53863. /** @hidden */
  53864. _unpackFlipY(value: boolean): void;
  53865. /**
  53866. * Update a dynamic index buffer
  53867. * @param indexBuffer defines the target index buffer
  53868. * @param indices defines the data to update
  53869. * @param offset defines the offset in the target index buffer where update should start
  53870. */
  53871. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53872. /**
  53873. * Updates a dynamic vertex buffer.
  53874. * @param vertexBuffer the vertex buffer to update
  53875. * @param vertices the data used to update the vertex buffer
  53876. * @param byteOffset the byte offset of the data (optional)
  53877. * @param byteLength the byte length of the data (optional)
  53878. */
  53879. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  53880. /** @hidden */
  53881. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  53882. /** @hidden */
  53883. _bindTexture(channel: number, texture: InternalTexture): void;
  53884. protected _deleteBuffer(buffer: WebGLBuffer): void;
  53885. /**
  53886. * 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
  53887. */
  53888. releaseEffects(): void;
  53889. displayLoadingUI(): void;
  53890. hideLoadingUI(): void;
  53891. /** @hidden */
  53892. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53893. /** @hidden */
  53894. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53895. /** @hidden */
  53896. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53897. /** @hidden */
  53898. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53899. }
  53900. }
  53901. declare module "babylonjs/Instrumentation/timeToken" {
  53902. import { Nullable } from "babylonjs/types";
  53903. /**
  53904. * @hidden
  53905. **/
  53906. export class _TimeToken {
  53907. _startTimeQuery: Nullable<WebGLQuery>;
  53908. _endTimeQuery: Nullable<WebGLQuery>;
  53909. _timeElapsedQuery: Nullable<WebGLQuery>;
  53910. _timeElapsedQueryEnded: boolean;
  53911. }
  53912. }
  53913. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  53914. import { Nullable, int } from "babylonjs/types";
  53915. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  53916. /** @hidden */
  53917. export class _OcclusionDataStorage {
  53918. /** @hidden */
  53919. occlusionInternalRetryCounter: number;
  53920. /** @hidden */
  53921. isOcclusionQueryInProgress: boolean;
  53922. /** @hidden */
  53923. isOccluded: boolean;
  53924. /** @hidden */
  53925. occlusionRetryCount: number;
  53926. /** @hidden */
  53927. occlusionType: number;
  53928. /** @hidden */
  53929. occlusionQueryAlgorithmType: number;
  53930. }
  53931. module "babylonjs/Engines/engine" {
  53932. interface Engine {
  53933. /**
  53934. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53935. * @return the new query
  53936. */
  53937. createQuery(): WebGLQuery;
  53938. /**
  53939. * Delete and release a webGL query
  53940. * @param query defines the query to delete
  53941. * @return the current engine
  53942. */
  53943. deleteQuery(query: WebGLQuery): Engine;
  53944. /**
  53945. * Check if a given query has resolved and got its value
  53946. * @param query defines the query to check
  53947. * @returns true if the query got its value
  53948. */
  53949. isQueryResultAvailable(query: WebGLQuery): boolean;
  53950. /**
  53951. * Gets the value of a given query
  53952. * @param query defines the query to check
  53953. * @returns the value of the query
  53954. */
  53955. getQueryResult(query: WebGLQuery): number;
  53956. /**
  53957. * Initiates an occlusion query
  53958. * @param algorithmType defines the algorithm to use
  53959. * @param query defines the query to use
  53960. * @returns the current engine
  53961. * @see https://doc.babylonjs.com/features/occlusionquery
  53962. */
  53963. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53964. /**
  53965. * Ends an occlusion query
  53966. * @see https://doc.babylonjs.com/features/occlusionquery
  53967. * @param algorithmType defines the algorithm to use
  53968. * @returns the current engine
  53969. */
  53970. endOcclusionQuery(algorithmType: number): Engine;
  53971. /**
  53972. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53973. * Please note that only one query can be issued at a time
  53974. * @returns a time token used to track the time span
  53975. */
  53976. startTimeQuery(): Nullable<_TimeToken>;
  53977. /**
  53978. * Ends a time query
  53979. * @param token defines the token used to measure the time span
  53980. * @returns the time spent (in ns)
  53981. */
  53982. endTimeQuery(token: _TimeToken): int;
  53983. /** @hidden */
  53984. _currentNonTimestampToken: Nullable<_TimeToken>;
  53985. /** @hidden */
  53986. _createTimeQuery(): WebGLQuery;
  53987. /** @hidden */
  53988. _deleteTimeQuery(query: WebGLQuery): void;
  53989. /** @hidden */
  53990. _getGlAlgorithmType(algorithmType: number): number;
  53991. /** @hidden */
  53992. _getTimeQueryResult(query: WebGLQuery): any;
  53993. /** @hidden */
  53994. _getTimeQueryAvailability(query: WebGLQuery): any;
  53995. }
  53996. }
  53997. module "babylonjs/Meshes/abstractMesh" {
  53998. interface AbstractMesh {
  53999. /**
  54000. * Backing filed
  54001. * @hidden
  54002. */
  54003. __occlusionDataStorage: _OcclusionDataStorage;
  54004. /**
  54005. * Access property
  54006. * @hidden
  54007. */
  54008. _occlusionDataStorage: _OcclusionDataStorage;
  54009. /**
  54010. * 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.
  54011. * The default value is -1 which means don't break the query and wait till the result
  54012. * @see https://doc.babylonjs.com/features/occlusionquery
  54013. */
  54014. occlusionRetryCount: number;
  54015. /**
  54016. * 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:
  54017. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54018. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54019. * * 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.
  54020. * @see https://doc.babylonjs.com/features/occlusionquery
  54021. */
  54022. occlusionType: number;
  54023. /**
  54024. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54025. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54026. * * 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.
  54027. * @see https://doc.babylonjs.com/features/occlusionquery
  54028. */
  54029. occlusionQueryAlgorithmType: number;
  54030. /**
  54031. * 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
  54032. * @see https://doc.babylonjs.com/features/occlusionquery
  54033. */
  54034. isOccluded: boolean;
  54035. /**
  54036. * Flag to check the progress status of the query
  54037. * @see https://doc.babylonjs.com/features/occlusionquery
  54038. */
  54039. isOcclusionQueryInProgress: boolean;
  54040. }
  54041. }
  54042. }
  54043. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54044. import { Nullable } from "babylonjs/types";
  54045. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54046. /** @hidden */
  54047. export var _forceTransformFeedbackToBundle: boolean;
  54048. module "babylonjs/Engines/engine" {
  54049. interface Engine {
  54050. /**
  54051. * Creates a webGL transform feedback object
  54052. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54053. * @returns the webGL transform feedback object
  54054. */
  54055. createTransformFeedback(): WebGLTransformFeedback;
  54056. /**
  54057. * Delete a webGL transform feedback object
  54058. * @param value defines the webGL transform feedback object to delete
  54059. */
  54060. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54061. /**
  54062. * Bind a webGL transform feedback object to the webgl context
  54063. * @param value defines the webGL transform feedback object to bind
  54064. */
  54065. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54066. /**
  54067. * Begins a transform feedback operation
  54068. * @param usePoints defines if points or triangles must be used
  54069. */
  54070. beginTransformFeedback(usePoints: boolean): void;
  54071. /**
  54072. * Ends a transform feedback operation
  54073. */
  54074. endTransformFeedback(): void;
  54075. /**
  54076. * Specify the varyings to use with transform feedback
  54077. * @param program defines the associated webGL program
  54078. * @param value defines the list of strings representing the varying names
  54079. */
  54080. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54081. /**
  54082. * Bind a webGL buffer for a transform feedback operation
  54083. * @param value defines the webGL buffer to bind
  54084. */
  54085. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54086. }
  54087. }
  54088. }
  54089. declare module "babylonjs/Engines/Extensions/engine.views" {
  54090. import { Camera } from "babylonjs/Cameras/camera";
  54091. import { Nullable } from "babylonjs/types";
  54092. /**
  54093. * Class used to define an additional view for the engine
  54094. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54095. */
  54096. export class EngineView {
  54097. /** Defines the canvas where to render the view */
  54098. target: HTMLCanvasElement;
  54099. /** Defines an optional camera used to render the view (will use active camera else) */
  54100. camera?: Camera;
  54101. }
  54102. module "babylonjs/Engines/engine" {
  54103. interface Engine {
  54104. /**
  54105. * Gets or sets the HTML element to use for attaching events
  54106. */
  54107. inputElement: Nullable<HTMLElement>;
  54108. /**
  54109. * Gets the current engine view
  54110. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54111. */
  54112. activeView: Nullable<EngineView>;
  54113. /** Gets or sets the list of views */
  54114. views: EngineView[];
  54115. /**
  54116. * Register a new child canvas
  54117. * @param canvas defines the canvas to register
  54118. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54119. * @returns the associated view
  54120. */
  54121. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54122. /**
  54123. * Remove a registered child canvas
  54124. * @param canvas defines the canvas to remove
  54125. * @returns the current engine
  54126. */
  54127. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54128. }
  54129. }
  54130. }
  54131. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54132. import { Nullable } from "babylonjs/types";
  54133. module "babylonjs/Engines/engine" {
  54134. interface Engine {
  54135. /** @hidden */
  54136. _excludedCompressedTextures: string[];
  54137. /** @hidden */
  54138. _textureFormatInUse: string;
  54139. /**
  54140. * Gets the list of texture formats supported
  54141. */
  54142. readonly texturesSupported: Array<string>;
  54143. /**
  54144. * Gets the texture format in use
  54145. */
  54146. readonly textureFormatInUse: Nullable<string>;
  54147. /**
  54148. * Set the compressed texture extensions or file names to skip.
  54149. *
  54150. * @param skippedFiles defines the list of those texture files you want to skip
  54151. * Example: [".dds", ".env", "myfile.png"]
  54152. */
  54153. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54154. /**
  54155. * Set the compressed texture format to use, based on the formats you have, and the formats
  54156. * supported by the hardware / browser.
  54157. *
  54158. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54159. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54160. * to API arguments needed to compressed textures. This puts the burden on the container
  54161. * generator to house the arcane code for determining these for current & future formats.
  54162. *
  54163. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54164. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54165. *
  54166. * Note: The result of this call is not taken into account when a texture is base64.
  54167. *
  54168. * @param formatsAvailable defines the list of those format families you have created
  54169. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54170. *
  54171. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54172. * @returns The extension selected.
  54173. */
  54174. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54175. }
  54176. }
  54177. }
  54178. declare module "babylonjs/Engines/Extensions/index" {
  54179. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54180. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54181. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54182. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54183. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54184. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54185. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54186. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54187. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54188. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54189. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54190. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54191. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54192. export * from "babylonjs/Engines/Extensions/engine.views";
  54193. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54194. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54195. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54196. }
  54197. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54198. import { Nullable } from "babylonjs/types";
  54199. /**
  54200. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54201. */
  54202. export interface CubeMapInfo {
  54203. /**
  54204. * The pixel array for the front face.
  54205. * This is stored in format, left to right, up to down format.
  54206. */
  54207. front: Nullable<ArrayBufferView>;
  54208. /**
  54209. * The pixel array for the back face.
  54210. * This is stored in format, left to right, up to down format.
  54211. */
  54212. back: Nullable<ArrayBufferView>;
  54213. /**
  54214. * The pixel array for the left face.
  54215. * This is stored in format, left to right, up to down format.
  54216. */
  54217. left: Nullable<ArrayBufferView>;
  54218. /**
  54219. * The pixel array for the right face.
  54220. * This is stored in format, left to right, up to down format.
  54221. */
  54222. right: Nullable<ArrayBufferView>;
  54223. /**
  54224. * The pixel array for the up face.
  54225. * This is stored in format, left to right, up to down format.
  54226. */
  54227. up: Nullable<ArrayBufferView>;
  54228. /**
  54229. * The pixel array for the down face.
  54230. * This is stored in format, left to right, up to down format.
  54231. */
  54232. down: Nullable<ArrayBufferView>;
  54233. /**
  54234. * The size of the cubemap stored.
  54235. *
  54236. * Each faces will be size * size pixels.
  54237. */
  54238. size: number;
  54239. /**
  54240. * The format of the texture.
  54241. *
  54242. * RGBA, RGB.
  54243. */
  54244. format: number;
  54245. /**
  54246. * The type of the texture data.
  54247. *
  54248. * UNSIGNED_INT, FLOAT.
  54249. */
  54250. type: number;
  54251. /**
  54252. * Specifies whether the texture is in gamma space.
  54253. */
  54254. gammaSpace: boolean;
  54255. }
  54256. /**
  54257. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54258. */
  54259. export class PanoramaToCubeMapTools {
  54260. private static FACE_LEFT;
  54261. private static FACE_RIGHT;
  54262. private static FACE_FRONT;
  54263. private static FACE_BACK;
  54264. private static FACE_DOWN;
  54265. private static FACE_UP;
  54266. /**
  54267. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54268. *
  54269. * @param float32Array The source data.
  54270. * @param inputWidth The width of the input panorama.
  54271. * @param inputHeight The height of the input panorama.
  54272. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54273. * @return The cubemap data
  54274. */
  54275. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54276. private static CreateCubemapTexture;
  54277. private static CalcProjectionSpherical;
  54278. }
  54279. }
  54280. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54281. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54283. import { Nullable } from "babylonjs/types";
  54284. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54285. /**
  54286. * Helper class dealing with the extraction of spherical polynomial dataArray
  54287. * from a cube map.
  54288. */
  54289. export class CubeMapToSphericalPolynomialTools {
  54290. private static FileFaces;
  54291. /**
  54292. * Converts a texture to the according Spherical Polynomial data.
  54293. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54294. *
  54295. * @param texture The texture to extract the information from.
  54296. * @return The Spherical Polynomial data.
  54297. */
  54298. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54299. /**
  54300. * Converts a cubemap to the according Spherical Polynomial data.
  54301. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54302. *
  54303. * @param cubeInfo The Cube map to extract the information from.
  54304. * @return The Spherical Polynomial data.
  54305. */
  54306. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54307. }
  54308. }
  54309. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54310. import { Nullable } from "babylonjs/types";
  54311. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54312. module "babylonjs/Materials/Textures/baseTexture" {
  54313. interface BaseTexture {
  54314. /**
  54315. * Get the polynomial representation of the texture data.
  54316. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54317. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54318. */
  54319. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54320. }
  54321. }
  54322. }
  54323. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54324. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54325. /** @hidden */
  54326. export var rgbdEncodePixelShader: {
  54327. name: string;
  54328. shader: string;
  54329. };
  54330. }
  54331. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54333. /** @hidden */
  54334. export var rgbdDecodePixelShader: {
  54335. name: string;
  54336. shader: string;
  54337. };
  54338. }
  54339. declare module "babylonjs/Misc/environmentTextureTools" {
  54340. import { Nullable } from "babylonjs/types";
  54341. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54344. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54345. import "babylonjs/Engines/Extensions/engine.readTexture";
  54346. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54347. import "babylonjs/Shaders/rgbdEncode.fragment";
  54348. import "babylonjs/Shaders/rgbdDecode.fragment";
  54349. /**
  54350. * Raw texture data and descriptor sufficient for WebGL texture upload
  54351. */
  54352. export interface EnvironmentTextureInfo {
  54353. /**
  54354. * Version of the environment map
  54355. */
  54356. version: number;
  54357. /**
  54358. * Width of image
  54359. */
  54360. width: number;
  54361. /**
  54362. * Irradiance information stored in the file.
  54363. */
  54364. irradiance: any;
  54365. /**
  54366. * Specular information stored in the file.
  54367. */
  54368. specular: any;
  54369. }
  54370. /**
  54371. * Defines One Image in the file. It requires only the position in the file
  54372. * as well as the length.
  54373. */
  54374. interface BufferImageData {
  54375. /**
  54376. * Length of the image data.
  54377. */
  54378. length: number;
  54379. /**
  54380. * Position of the data from the null terminator delimiting the end of the JSON.
  54381. */
  54382. position: number;
  54383. }
  54384. /**
  54385. * Defines the specular data enclosed in the file.
  54386. * This corresponds to the version 1 of the data.
  54387. */
  54388. export interface EnvironmentTextureSpecularInfoV1 {
  54389. /**
  54390. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54391. */
  54392. specularDataPosition?: number;
  54393. /**
  54394. * This contains all the images data needed to reconstruct the cubemap.
  54395. */
  54396. mipmaps: Array<BufferImageData>;
  54397. /**
  54398. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54399. */
  54400. lodGenerationScale: number;
  54401. }
  54402. /**
  54403. * Sets of helpers addressing the serialization and deserialization of environment texture
  54404. * stored in a BabylonJS env file.
  54405. * Those files are usually stored as .env files.
  54406. */
  54407. export class EnvironmentTextureTools {
  54408. /**
  54409. * Magic number identifying the env file.
  54410. */
  54411. private static _MagicBytes;
  54412. /**
  54413. * Gets the environment info from an env file.
  54414. * @param data The array buffer containing the .env bytes.
  54415. * @returns the environment file info (the json header) if successfully parsed.
  54416. */
  54417. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54418. /**
  54419. * Creates an environment texture from a loaded cube texture.
  54420. * @param texture defines the cube texture to convert in env file
  54421. * @return a promise containing the environment data if succesfull.
  54422. */
  54423. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54424. /**
  54425. * Creates a JSON representation of the spherical data.
  54426. * @param texture defines the texture containing the polynomials
  54427. * @return the JSON representation of the spherical info
  54428. */
  54429. private static _CreateEnvTextureIrradiance;
  54430. /**
  54431. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54432. * @param data the image data
  54433. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54434. * @return the views described by info providing access to the underlying buffer
  54435. */
  54436. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54437. /**
  54438. * Uploads the texture info contained in the env file to the GPU.
  54439. * @param texture defines the internal texture to upload to
  54440. * @param data defines the data to load
  54441. * @param info defines the texture info retrieved through the GetEnvInfo method
  54442. * @returns a promise
  54443. */
  54444. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54445. private static _OnImageReadyAsync;
  54446. /**
  54447. * Uploads the levels of image data to the GPU.
  54448. * @param texture defines the internal texture to upload to
  54449. * @param imageData defines the array buffer views of image data [mipmap][face]
  54450. * @returns a promise
  54451. */
  54452. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54453. /**
  54454. * Uploads spherical polynomials information to the texture.
  54455. * @param texture defines the texture we are trying to upload the information to
  54456. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54457. */
  54458. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54459. /** @hidden */
  54460. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54461. }
  54462. }
  54463. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54464. /**
  54465. * Class used to inline functions in shader code
  54466. */
  54467. export class ShaderCodeInliner {
  54468. private static readonly _RegexpFindFunctionNameAndType;
  54469. private _sourceCode;
  54470. private _functionDescr;
  54471. private _numMaxIterations;
  54472. /** Gets or sets the token used to mark the functions to inline */
  54473. inlineToken: string;
  54474. /** Gets or sets the debug mode */
  54475. debug: boolean;
  54476. /** Gets the code after the inlining process */
  54477. get code(): string;
  54478. /**
  54479. * Initializes the inliner
  54480. * @param sourceCode shader code source to inline
  54481. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54482. */
  54483. constructor(sourceCode: string, numMaxIterations?: number);
  54484. /**
  54485. * Start the processing of the shader code
  54486. */
  54487. processCode(): void;
  54488. private _collectFunctions;
  54489. private _processInlining;
  54490. private _extractBetweenMarkers;
  54491. private _skipWhitespaces;
  54492. private _removeComments;
  54493. private _replaceFunctionCallsByCode;
  54494. private _findBackward;
  54495. private _escapeRegExp;
  54496. private _replaceNames;
  54497. }
  54498. }
  54499. declare module "babylonjs/Engines/nativeEngine" {
  54500. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54501. import { Engine } from "babylonjs/Engines/engine";
  54502. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54505. import { Effect } from "babylonjs/Materials/effect";
  54506. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54507. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54508. import { IColor4Like } from "babylonjs/Maths/math.like";
  54509. import { Scene } from "babylonjs/scene";
  54510. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54511. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54512. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54513. /**
  54514. * Container for accessors for natively-stored mesh data buffers.
  54515. */
  54516. class NativeDataBuffer extends DataBuffer {
  54517. /**
  54518. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54519. */
  54520. nativeIndexBuffer?: any;
  54521. /**
  54522. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54523. */
  54524. nativeVertexBuffer?: any;
  54525. }
  54526. /** @hidden */
  54527. class NativeTexture extends InternalTexture {
  54528. getInternalTexture(): InternalTexture;
  54529. getViewCount(): number;
  54530. }
  54531. /** @hidden */
  54532. export class NativeEngine extends Engine {
  54533. private readonly _native;
  54534. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54535. private readonly INVALID_HANDLE;
  54536. getHardwareScalingLevel(): number;
  54537. constructor();
  54538. dispose(): void;
  54539. /**
  54540. * Can be used to override the current requestAnimationFrame requester.
  54541. * @hidden
  54542. */
  54543. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54544. /**
  54545. * Override default engine behavior.
  54546. * @param color
  54547. * @param backBuffer
  54548. * @param depth
  54549. * @param stencil
  54550. */
  54551. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54552. /**
  54553. * Gets host document
  54554. * @returns the host document object
  54555. */
  54556. getHostDocument(): Nullable<Document>;
  54557. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54558. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54559. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54560. recordVertexArrayObject(vertexBuffers: {
  54561. [key: string]: VertexBuffer;
  54562. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54563. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54564. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54565. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54566. /**
  54567. * Draw a list of indexed primitives
  54568. * @param fillMode defines the primitive to use
  54569. * @param indexStart defines the starting index
  54570. * @param indexCount defines the number of index to draw
  54571. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54572. */
  54573. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54574. /**
  54575. * Draw a list of unindexed primitives
  54576. * @param fillMode defines the primitive to use
  54577. * @param verticesStart defines the index of first vertex to draw
  54578. * @param verticesCount defines the count of vertices to draw
  54579. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54580. */
  54581. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54582. createPipelineContext(): IPipelineContext;
  54583. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54584. /** @hidden */
  54585. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54586. /** @hidden */
  54587. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54588. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54589. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54590. protected _setProgram(program: WebGLProgram): void;
  54591. _releaseEffect(effect: Effect): void;
  54592. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54593. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54594. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54595. bindSamplers(effect: Effect): void;
  54596. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54597. getRenderWidth(useScreen?: boolean): number;
  54598. getRenderHeight(useScreen?: boolean): number;
  54599. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54600. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54601. /**
  54602. * Set the z offset to apply to current rendering
  54603. * @param value defines the offset to apply
  54604. */
  54605. setZOffset(value: number): void;
  54606. /**
  54607. * Gets the current value of the zOffset
  54608. * @returns the current zOffset state
  54609. */
  54610. getZOffset(): number;
  54611. /**
  54612. * Enable or disable depth buffering
  54613. * @param enable defines the state to set
  54614. */
  54615. setDepthBuffer(enable: boolean): void;
  54616. /**
  54617. * Gets a boolean indicating if depth writing is enabled
  54618. * @returns the current depth writing state
  54619. */
  54620. getDepthWrite(): boolean;
  54621. /**
  54622. * Enable or disable depth writing
  54623. * @param enable defines the state to set
  54624. */
  54625. setDepthWrite(enable: boolean): void;
  54626. /**
  54627. * Enable or disable color writing
  54628. * @param enable defines the state to set
  54629. */
  54630. setColorWrite(enable: boolean): void;
  54631. /**
  54632. * Gets a boolean indicating if color writing is enabled
  54633. * @returns the current color writing state
  54634. */
  54635. getColorWrite(): boolean;
  54636. /**
  54637. * Sets alpha constants used by some alpha blending modes
  54638. * @param r defines the red component
  54639. * @param g defines the green component
  54640. * @param b defines the blue component
  54641. * @param a defines the alpha component
  54642. */
  54643. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54644. /**
  54645. * Sets the current alpha mode
  54646. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54647. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54648. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54649. */
  54650. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54651. /**
  54652. * Gets the current alpha mode
  54653. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54654. * @returns the current alpha mode
  54655. */
  54656. getAlphaMode(): number;
  54657. setInt(uniform: WebGLUniformLocation, int: number): void;
  54658. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54659. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54660. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54661. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54662. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54663. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54664. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54665. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54666. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54667. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54668. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54669. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54670. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54671. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54672. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54673. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54674. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54675. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54676. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54677. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54678. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54679. wipeCaches(bruteForce?: boolean): void;
  54680. _createTexture(): WebGLTexture;
  54681. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54682. /**
  54683. * Usually called from Texture.ts.
  54684. * Passed information to create a WebGLTexture
  54685. * @param url defines a value which contains one of the following:
  54686. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54687. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54688. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54689. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54690. * @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)
  54691. * @param scene needed for loading to the correct scene
  54692. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54693. * @param onLoad optional callback to be called upon successful completion
  54694. * @param onError optional callback to be called upon failure
  54695. * @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
  54696. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54697. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54698. * @param forcedExtension defines the extension to use to pick the right loader
  54699. * @param mimeType defines an optional mime type
  54700. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54701. */
  54702. 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;
  54703. /**
  54704. * Creates a cube texture
  54705. * @param rootUrl defines the url where the files to load is located
  54706. * @param scene defines the current scene
  54707. * @param files defines the list of files to load (1 per face)
  54708. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54709. * @param onLoad defines an optional callback raised when the texture is loaded
  54710. * @param onError defines an optional callback raised if there is an issue to load the texture
  54711. * @param format defines the format of the data
  54712. * @param forcedExtension defines the extension to use to pick the right loader
  54713. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54714. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54715. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54716. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54717. * @returns the cube texture as an InternalTexture
  54718. */
  54719. 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;
  54720. private _getSamplingFilter;
  54721. private static _GetNativeTextureFormat;
  54722. createRenderTargetTexture(size: number | {
  54723. width: number;
  54724. height: number;
  54725. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54726. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54727. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54728. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54729. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54730. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54731. /**
  54732. * Updates a dynamic vertex buffer.
  54733. * @param vertexBuffer the vertex buffer to update
  54734. * @param data the data used to update the vertex buffer
  54735. * @param byteOffset the byte offset of the data (optional)
  54736. * @param byteLength the byte length of the data (optional)
  54737. */
  54738. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54739. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54740. private _updateAnisotropicLevel;
  54741. private _getAddressMode;
  54742. /** @hidden */
  54743. _bindTexture(channel: number, texture: InternalTexture): void;
  54744. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54745. releaseEffects(): void;
  54746. /** @hidden */
  54747. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54748. /** @hidden */
  54749. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54750. /** @hidden */
  54751. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54752. /** @hidden */
  54753. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54754. }
  54755. }
  54756. declare module "babylonjs/Engines/index" {
  54757. export * from "babylonjs/Engines/constants";
  54758. export * from "babylonjs/Engines/engineCapabilities";
  54759. export * from "babylonjs/Engines/instancingAttributeInfo";
  54760. export * from "babylonjs/Engines/thinEngine";
  54761. export * from "babylonjs/Engines/engine";
  54762. export * from "babylonjs/Engines/engineStore";
  54763. export * from "babylonjs/Engines/nullEngine";
  54764. export * from "babylonjs/Engines/Extensions/index";
  54765. export * from "babylonjs/Engines/IPipelineContext";
  54766. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54767. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54768. export * from "babylonjs/Engines/nativeEngine";
  54769. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54770. export * from "babylonjs/Engines/performanceConfigurator";
  54771. }
  54772. declare module "babylonjs/Events/clipboardEvents" {
  54773. /**
  54774. * Gather the list of clipboard event types as constants.
  54775. */
  54776. export class ClipboardEventTypes {
  54777. /**
  54778. * The clipboard event is fired when a copy command is active (pressed).
  54779. */
  54780. static readonly COPY: number;
  54781. /**
  54782. * The clipboard event is fired when a cut command is active (pressed).
  54783. */
  54784. static readonly CUT: number;
  54785. /**
  54786. * The clipboard event is fired when a paste command is active (pressed).
  54787. */
  54788. static readonly PASTE: number;
  54789. }
  54790. /**
  54791. * This class is used to store clipboard related info for the onClipboardObservable event.
  54792. */
  54793. export class ClipboardInfo {
  54794. /**
  54795. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54796. */
  54797. type: number;
  54798. /**
  54799. * Defines the related dom event
  54800. */
  54801. event: ClipboardEvent;
  54802. /**
  54803. *Creates an instance of ClipboardInfo.
  54804. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54805. * @param event Defines the related dom event
  54806. */
  54807. constructor(
  54808. /**
  54809. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54810. */
  54811. type: number,
  54812. /**
  54813. * Defines the related dom event
  54814. */
  54815. event: ClipboardEvent);
  54816. /**
  54817. * Get the clipboard event's type from the keycode.
  54818. * @param keyCode Defines the keyCode for the current keyboard event.
  54819. * @return {number}
  54820. */
  54821. static GetTypeFromCharacter(keyCode: number): number;
  54822. }
  54823. }
  54824. declare module "babylonjs/Events/index" {
  54825. export * from "babylonjs/Events/keyboardEvents";
  54826. export * from "babylonjs/Events/pointerEvents";
  54827. export * from "babylonjs/Events/clipboardEvents";
  54828. }
  54829. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54830. import { Scene } from "babylonjs/scene";
  54831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54832. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54833. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54834. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54835. /**
  54836. * Google Daydream controller
  54837. */
  54838. export class DaydreamController extends WebVRController {
  54839. /**
  54840. * Base Url for the controller model.
  54841. */
  54842. static MODEL_BASE_URL: string;
  54843. /**
  54844. * File name for the controller model.
  54845. */
  54846. static MODEL_FILENAME: string;
  54847. /**
  54848. * Gamepad Id prefix used to identify Daydream Controller.
  54849. */
  54850. static readonly GAMEPAD_ID_PREFIX: string;
  54851. /**
  54852. * Creates a new DaydreamController from a gamepad
  54853. * @param vrGamepad the gamepad that the controller should be created from
  54854. */
  54855. constructor(vrGamepad: any);
  54856. /**
  54857. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54858. * @param scene scene in which to add meshes
  54859. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54860. */
  54861. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54862. /**
  54863. * Called once for each button that changed state since the last frame
  54864. * @param buttonIdx Which button index changed
  54865. * @param state New state of the button
  54866. * @param changes Which properties on the state changed since last frame
  54867. */
  54868. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54869. }
  54870. }
  54871. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54872. import { Scene } from "babylonjs/scene";
  54873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54874. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54875. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54876. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54877. /**
  54878. * Gear VR Controller
  54879. */
  54880. export class GearVRController extends WebVRController {
  54881. /**
  54882. * Base Url for the controller model.
  54883. */
  54884. static MODEL_BASE_URL: string;
  54885. /**
  54886. * File name for the controller model.
  54887. */
  54888. static MODEL_FILENAME: string;
  54889. /**
  54890. * Gamepad Id prefix used to identify this controller.
  54891. */
  54892. static readonly GAMEPAD_ID_PREFIX: string;
  54893. private readonly _buttonIndexToObservableNameMap;
  54894. /**
  54895. * Creates a new GearVRController from a gamepad
  54896. * @param vrGamepad the gamepad that the controller should be created from
  54897. */
  54898. constructor(vrGamepad: any);
  54899. /**
  54900. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54901. * @param scene scene in which to add meshes
  54902. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54903. */
  54904. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54905. /**
  54906. * Called once for each button that changed state since the last frame
  54907. * @param buttonIdx Which button index changed
  54908. * @param state New state of the button
  54909. * @param changes Which properties on the state changed since last frame
  54910. */
  54911. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54912. }
  54913. }
  54914. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54915. import { Scene } from "babylonjs/scene";
  54916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54917. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54918. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54919. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54920. /**
  54921. * Generic Controller
  54922. */
  54923. export class GenericController extends WebVRController {
  54924. /**
  54925. * Base Url for the controller model.
  54926. */
  54927. static readonly MODEL_BASE_URL: string;
  54928. /**
  54929. * File name for the controller model.
  54930. */
  54931. static readonly MODEL_FILENAME: string;
  54932. /**
  54933. * Creates a new GenericController from a gamepad
  54934. * @param vrGamepad the gamepad that the controller should be created from
  54935. */
  54936. constructor(vrGamepad: any);
  54937. /**
  54938. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54939. * @param scene scene in which to add meshes
  54940. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54941. */
  54942. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54943. /**
  54944. * Called once for each button that changed state since the last frame
  54945. * @param buttonIdx Which button index changed
  54946. * @param state New state of the button
  54947. * @param changes Which properties on the state changed since last frame
  54948. */
  54949. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54950. }
  54951. }
  54952. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54953. import { Observable } from "babylonjs/Misc/observable";
  54954. import { Scene } from "babylonjs/scene";
  54955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54956. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54957. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54958. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54959. /**
  54960. * Oculus Touch Controller
  54961. */
  54962. export class OculusTouchController extends WebVRController {
  54963. /**
  54964. * Base Url for the controller model.
  54965. */
  54966. static MODEL_BASE_URL: string;
  54967. /**
  54968. * File name for the left controller model.
  54969. */
  54970. static MODEL_LEFT_FILENAME: string;
  54971. /**
  54972. * File name for the right controller model.
  54973. */
  54974. static MODEL_RIGHT_FILENAME: string;
  54975. /**
  54976. * Base Url for the Quest controller model.
  54977. */
  54978. static QUEST_MODEL_BASE_URL: string;
  54979. /**
  54980. * @hidden
  54981. * If the controllers are running on a device that needs the updated Quest controller models
  54982. */
  54983. static _IsQuest: boolean;
  54984. /**
  54985. * Fired when the secondary trigger on this controller is modified
  54986. */
  54987. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54988. /**
  54989. * Fired when the thumb rest on this controller is modified
  54990. */
  54991. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54992. /**
  54993. * Creates a new OculusTouchController from a gamepad
  54994. * @param vrGamepad the gamepad that the controller should be created from
  54995. */
  54996. constructor(vrGamepad: any);
  54997. /**
  54998. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54999. * @param scene scene in which to add meshes
  55000. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55001. */
  55002. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55003. /**
  55004. * Fired when the A button on this controller is modified
  55005. */
  55006. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55007. /**
  55008. * Fired when the B button on this controller is modified
  55009. */
  55010. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55011. /**
  55012. * Fired when the X button on this controller is modified
  55013. */
  55014. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55015. /**
  55016. * Fired when the Y button on this controller is modified
  55017. */
  55018. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55019. /**
  55020. * Called once for each button that changed state since the last frame
  55021. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55022. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55023. * 2) secondary trigger (same)
  55024. * 3) A (right) X (left), touch, pressed = value
  55025. * 4) B / Y
  55026. * 5) thumb rest
  55027. * @param buttonIdx Which button index changed
  55028. * @param state New state of the button
  55029. * @param changes Which properties on the state changed since last frame
  55030. */
  55031. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55032. }
  55033. }
  55034. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55035. import { Scene } from "babylonjs/scene";
  55036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55037. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55038. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55039. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55040. import { Observable } from "babylonjs/Misc/observable";
  55041. /**
  55042. * Vive Controller
  55043. */
  55044. export class ViveController extends WebVRController {
  55045. /**
  55046. * Base Url for the controller model.
  55047. */
  55048. static MODEL_BASE_URL: string;
  55049. /**
  55050. * File name for the controller model.
  55051. */
  55052. static MODEL_FILENAME: string;
  55053. /**
  55054. * Creates a new ViveController from a gamepad
  55055. * @param vrGamepad the gamepad that the controller should be created from
  55056. */
  55057. constructor(vrGamepad: any);
  55058. /**
  55059. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55060. * @param scene scene in which to add meshes
  55061. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55062. */
  55063. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55064. /**
  55065. * Fired when the left button on this controller is modified
  55066. */
  55067. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55068. /**
  55069. * Fired when the right button on this controller is modified
  55070. */
  55071. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55072. /**
  55073. * Fired when the menu button on this controller is modified
  55074. */
  55075. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55076. /**
  55077. * Called once for each button that changed state since the last frame
  55078. * Vive mapping:
  55079. * 0: touchpad
  55080. * 1: trigger
  55081. * 2: left AND right buttons
  55082. * 3: menu button
  55083. * @param buttonIdx Which button index changed
  55084. * @param state New state of the button
  55085. * @param changes Which properties on the state changed since last frame
  55086. */
  55087. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55088. }
  55089. }
  55090. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55091. import { Observable } from "babylonjs/Misc/observable";
  55092. import { Scene } from "babylonjs/scene";
  55093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55094. import { Ray } from "babylonjs/Culling/ray";
  55095. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55096. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55097. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55098. /**
  55099. * Defines the WindowsMotionController object that the state of the windows motion controller
  55100. */
  55101. export class WindowsMotionController extends WebVRController {
  55102. /**
  55103. * The base url used to load the left and right controller models
  55104. */
  55105. static MODEL_BASE_URL: string;
  55106. /**
  55107. * The name of the left controller model file
  55108. */
  55109. static MODEL_LEFT_FILENAME: string;
  55110. /**
  55111. * The name of the right controller model file
  55112. */
  55113. static MODEL_RIGHT_FILENAME: string;
  55114. /**
  55115. * The controller name prefix for this controller type
  55116. */
  55117. static readonly GAMEPAD_ID_PREFIX: string;
  55118. /**
  55119. * The controller id pattern for this controller type
  55120. */
  55121. private static readonly GAMEPAD_ID_PATTERN;
  55122. private _loadedMeshInfo;
  55123. protected readonly _mapping: {
  55124. buttons: string[];
  55125. buttonMeshNames: {
  55126. trigger: string;
  55127. menu: string;
  55128. grip: string;
  55129. thumbstick: string;
  55130. trackpad: string;
  55131. };
  55132. buttonObservableNames: {
  55133. trigger: string;
  55134. menu: string;
  55135. grip: string;
  55136. thumbstick: string;
  55137. trackpad: string;
  55138. };
  55139. axisMeshNames: string[];
  55140. pointingPoseMeshName: string;
  55141. };
  55142. /**
  55143. * Fired when the trackpad on this controller is clicked
  55144. */
  55145. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55146. /**
  55147. * Fired when the trackpad on this controller is modified
  55148. */
  55149. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55150. /**
  55151. * The current x and y values of this controller's trackpad
  55152. */
  55153. trackpad: StickValues;
  55154. /**
  55155. * Creates a new WindowsMotionController from a gamepad
  55156. * @param vrGamepad the gamepad that the controller should be created from
  55157. */
  55158. constructor(vrGamepad: any);
  55159. /**
  55160. * Fired when the trigger on this controller is modified
  55161. */
  55162. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55163. /**
  55164. * Fired when the menu button on this controller is modified
  55165. */
  55166. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55167. /**
  55168. * Fired when the grip button on this controller is modified
  55169. */
  55170. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55171. /**
  55172. * Fired when the thumbstick button on this controller is modified
  55173. */
  55174. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55175. /**
  55176. * Fired when the touchpad button on this controller is modified
  55177. */
  55178. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55179. /**
  55180. * Fired when the touchpad values on this controller are modified
  55181. */
  55182. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55183. protected _updateTrackpad(): void;
  55184. /**
  55185. * Called once per frame by the engine.
  55186. */
  55187. update(): void;
  55188. /**
  55189. * Called once for each button that changed state since the last frame
  55190. * @param buttonIdx Which button index changed
  55191. * @param state New state of the button
  55192. * @param changes Which properties on the state changed since last frame
  55193. */
  55194. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55195. /**
  55196. * Moves the buttons on the controller mesh based on their current state
  55197. * @param buttonName the name of the button to move
  55198. * @param buttonValue the value of the button which determines the buttons new position
  55199. */
  55200. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55201. /**
  55202. * Moves the axis on the controller mesh based on its current state
  55203. * @param axis the index of the axis
  55204. * @param axisValue the value of the axis which determines the meshes new position
  55205. * @hidden
  55206. */
  55207. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55208. /**
  55209. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55210. * @param scene scene in which to add meshes
  55211. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55212. */
  55213. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55214. /**
  55215. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55216. * can be transformed by button presses and axes values, based on this._mapping.
  55217. *
  55218. * @param scene scene in which the meshes exist
  55219. * @param meshes list of meshes that make up the controller model to process
  55220. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55221. */
  55222. private processModel;
  55223. private createMeshInfo;
  55224. /**
  55225. * Gets the ray of the controller in the direction the controller is pointing
  55226. * @param length the length the resulting ray should be
  55227. * @returns a ray in the direction the controller is pointing
  55228. */
  55229. getForwardRay(length?: number): Ray;
  55230. /**
  55231. * Disposes of the controller
  55232. */
  55233. dispose(): void;
  55234. }
  55235. /**
  55236. * This class represents a new windows motion controller in XR.
  55237. */
  55238. export class XRWindowsMotionController extends WindowsMotionController {
  55239. /**
  55240. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55241. */
  55242. protected readonly _mapping: {
  55243. buttons: string[];
  55244. buttonMeshNames: {
  55245. trigger: string;
  55246. menu: string;
  55247. grip: string;
  55248. thumbstick: string;
  55249. trackpad: string;
  55250. };
  55251. buttonObservableNames: {
  55252. trigger: string;
  55253. menu: string;
  55254. grip: string;
  55255. thumbstick: string;
  55256. trackpad: string;
  55257. };
  55258. axisMeshNames: string[];
  55259. pointingPoseMeshName: string;
  55260. };
  55261. /**
  55262. * Construct a new XR-Based windows motion controller
  55263. *
  55264. * @param gamepadInfo the gamepad object from the browser
  55265. */
  55266. constructor(gamepadInfo: any);
  55267. /**
  55268. * holds the thumbstick values (X,Y)
  55269. */
  55270. thumbstickValues: StickValues;
  55271. /**
  55272. * Fired when the thumbstick on this controller is clicked
  55273. */
  55274. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55275. /**
  55276. * Fired when the thumbstick on this controller is modified
  55277. */
  55278. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55279. /**
  55280. * Fired when the touchpad button on this controller is modified
  55281. */
  55282. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55283. /**
  55284. * Fired when the touchpad values on this controller are modified
  55285. */
  55286. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55287. /**
  55288. * Fired when the thumbstick button on this controller is modified
  55289. * here to prevent breaking changes
  55290. */
  55291. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55292. /**
  55293. * updating the thumbstick(!) and not the trackpad.
  55294. * This is named this way due to the difference between WebVR and XR and to avoid
  55295. * changing the parent class.
  55296. */
  55297. protected _updateTrackpad(): void;
  55298. /**
  55299. * Disposes the class with joy
  55300. */
  55301. dispose(): void;
  55302. }
  55303. }
  55304. declare module "babylonjs/Gamepads/Controllers/index" {
  55305. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55306. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55307. export * from "babylonjs/Gamepads/Controllers/genericController";
  55308. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55309. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55310. export * from "babylonjs/Gamepads/Controllers/viveController";
  55311. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55312. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55313. }
  55314. declare module "babylonjs/Gamepads/index" {
  55315. export * from "babylonjs/Gamepads/Controllers/index";
  55316. export * from "babylonjs/Gamepads/gamepad";
  55317. export * from "babylonjs/Gamepads/gamepadManager";
  55318. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55319. export * from "babylonjs/Gamepads/xboxGamepad";
  55320. export * from "babylonjs/Gamepads/dualShockGamepad";
  55321. }
  55322. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55323. import { Scene } from "babylonjs/scene";
  55324. import { Vector4 } from "babylonjs/Maths/math.vector";
  55325. import { Color4 } from "babylonjs/Maths/math.color";
  55326. import { Mesh } from "babylonjs/Meshes/mesh";
  55327. import { Nullable } from "babylonjs/types";
  55328. /**
  55329. * Class containing static functions to help procedurally build meshes
  55330. */
  55331. export class PolyhedronBuilder {
  55332. /**
  55333. * Creates a polyhedron mesh
  55334. * * 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
  55335. * * The parameter `size` (positive float, default 1) sets the polygon size
  55336. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55337. * * 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`
  55338. * * 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
  55339. * * 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)`)
  55340. * * 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
  55341. * * 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
  55342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55345. * @param name defines the name of the mesh
  55346. * @param options defines the options used to create the mesh
  55347. * @param scene defines the hosting scene
  55348. * @returns the polyhedron mesh
  55349. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55350. */
  55351. static CreatePolyhedron(name: string, options: {
  55352. type?: number;
  55353. size?: number;
  55354. sizeX?: number;
  55355. sizeY?: number;
  55356. sizeZ?: number;
  55357. custom?: any;
  55358. faceUV?: Vector4[];
  55359. faceColors?: Color4[];
  55360. flat?: boolean;
  55361. updatable?: boolean;
  55362. sideOrientation?: number;
  55363. frontUVs?: Vector4;
  55364. backUVs?: Vector4;
  55365. }, scene?: Nullable<Scene>): Mesh;
  55366. }
  55367. }
  55368. declare module "babylonjs/Gizmos/scaleGizmo" {
  55369. import { Observable } from "babylonjs/Misc/observable";
  55370. import { Nullable } from "babylonjs/types";
  55371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55372. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55373. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55374. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55375. import { Node } from "babylonjs/node";
  55376. /**
  55377. * Gizmo that enables scaling a mesh along 3 axis
  55378. */
  55379. export class ScaleGizmo extends Gizmo {
  55380. /**
  55381. * Internal gizmo used for interactions on the x axis
  55382. */
  55383. xGizmo: AxisScaleGizmo;
  55384. /**
  55385. * Internal gizmo used for interactions on the y axis
  55386. */
  55387. yGizmo: AxisScaleGizmo;
  55388. /**
  55389. * Internal gizmo used for interactions on the z axis
  55390. */
  55391. zGizmo: AxisScaleGizmo;
  55392. /**
  55393. * Internal gizmo used to scale all axis equally
  55394. */
  55395. uniformScaleGizmo: AxisScaleGizmo;
  55396. private _meshAttached;
  55397. private _nodeAttached;
  55398. private _updateGizmoRotationToMatchAttachedMesh;
  55399. private _snapDistance;
  55400. private _scaleRatio;
  55401. private _uniformScalingMesh;
  55402. private _octahedron;
  55403. private _sensitivity;
  55404. /** Fires an event when any of it's sub gizmos are dragged */
  55405. onDragStartObservable: Observable<unknown>;
  55406. /** Fires an event when any of it's sub gizmos are released from dragging */
  55407. onDragEndObservable: Observable<unknown>;
  55408. get attachedMesh(): Nullable<AbstractMesh>;
  55409. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55410. get attachedNode(): Nullable<Node>;
  55411. set attachedNode(node: Nullable<Node>);
  55412. /**
  55413. * Creates a ScaleGizmo
  55414. * @param gizmoLayer The utility layer the gizmo will be added to
  55415. * @param thickness display gizmo axis thickness
  55416. */
  55417. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55418. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55419. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55420. /**
  55421. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55422. */
  55423. set snapDistance(value: number);
  55424. get snapDistance(): number;
  55425. /**
  55426. * Ratio for the scale of the gizmo (Default: 1)
  55427. */
  55428. set scaleRatio(value: number);
  55429. get scaleRatio(): number;
  55430. /**
  55431. * Sensitivity factor for dragging (Default: 1)
  55432. */
  55433. set sensitivity(value: number);
  55434. get sensitivity(): number;
  55435. /**
  55436. * Disposes of the gizmo
  55437. */
  55438. dispose(): void;
  55439. }
  55440. }
  55441. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55442. import { Observable } from "babylonjs/Misc/observable";
  55443. import { Nullable } from "babylonjs/types";
  55444. import { Vector3 } from "babylonjs/Maths/math.vector";
  55445. import { Node } from "babylonjs/node";
  55446. import { Mesh } from "babylonjs/Meshes/mesh";
  55447. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55448. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55449. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55450. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55451. import { Color3 } from "babylonjs/Maths/math.color";
  55452. /**
  55453. * Single axis scale gizmo
  55454. */
  55455. export class AxisScaleGizmo extends Gizmo {
  55456. /**
  55457. * Drag behavior responsible for the gizmos dragging interactions
  55458. */
  55459. dragBehavior: PointerDragBehavior;
  55460. private _pointerObserver;
  55461. /**
  55462. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55463. */
  55464. snapDistance: number;
  55465. /**
  55466. * Event that fires each time the gizmo snaps to a new location.
  55467. * * snapDistance is the the change in distance
  55468. */
  55469. onSnapObservable: Observable<{
  55470. snapDistance: number;
  55471. }>;
  55472. /**
  55473. * If the scaling operation should be done on all axis (default: false)
  55474. */
  55475. uniformScaling: boolean;
  55476. /**
  55477. * Custom sensitivity value for the drag strength
  55478. */
  55479. sensitivity: number;
  55480. private _isEnabled;
  55481. private _parent;
  55482. private _arrow;
  55483. private _coloredMaterial;
  55484. private _hoverMaterial;
  55485. /**
  55486. * Creates an AxisScaleGizmo
  55487. * @param gizmoLayer The utility layer the gizmo will be added to
  55488. * @param dragAxis The axis which the gizmo will be able to scale on
  55489. * @param color The color of the gizmo
  55490. * @param thickness display gizmo axis thickness
  55491. */
  55492. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55493. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55494. /**
  55495. * If the gizmo is enabled
  55496. */
  55497. set isEnabled(value: boolean);
  55498. get isEnabled(): boolean;
  55499. /**
  55500. * Disposes of the gizmo
  55501. */
  55502. dispose(): void;
  55503. /**
  55504. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55505. * @param mesh The mesh to replace the default mesh of the gizmo
  55506. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55507. */
  55508. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55509. }
  55510. }
  55511. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55512. import { Observable } from "babylonjs/Misc/observable";
  55513. import { Nullable } from "babylonjs/types";
  55514. import { Vector3 } from "babylonjs/Maths/math.vector";
  55515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55516. import { Mesh } from "babylonjs/Meshes/mesh";
  55517. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55518. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55519. import { Color3 } from "babylonjs/Maths/math.color";
  55520. import "babylonjs/Meshes/Builders/boxBuilder";
  55521. /**
  55522. * Bounding box gizmo
  55523. */
  55524. export class BoundingBoxGizmo extends Gizmo {
  55525. private _lineBoundingBox;
  55526. private _rotateSpheresParent;
  55527. private _scaleBoxesParent;
  55528. private _boundingDimensions;
  55529. private _renderObserver;
  55530. private _pointerObserver;
  55531. private _scaleDragSpeed;
  55532. private _tmpQuaternion;
  55533. private _tmpVector;
  55534. private _tmpRotationMatrix;
  55535. /**
  55536. * 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)
  55537. */
  55538. ignoreChildren: boolean;
  55539. /**
  55540. * 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)
  55541. */
  55542. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55543. /**
  55544. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55545. */
  55546. rotationSphereSize: number;
  55547. /**
  55548. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55549. */
  55550. scaleBoxSize: number;
  55551. /**
  55552. * 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)
  55553. */
  55554. fixedDragMeshScreenSize: boolean;
  55555. /**
  55556. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55557. */
  55558. fixedDragMeshScreenSizeDistanceFactor: number;
  55559. /**
  55560. * Fired when a rotation sphere or scale box is dragged
  55561. */
  55562. onDragStartObservable: Observable<{}>;
  55563. /**
  55564. * Fired when a scale box is dragged
  55565. */
  55566. onScaleBoxDragObservable: Observable<{}>;
  55567. /**
  55568. * Fired when a scale box drag is ended
  55569. */
  55570. onScaleBoxDragEndObservable: Observable<{}>;
  55571. /**
  55572. * Fired when a rotation sphere is dragged
  55573. */
  55574. onRotationSphereDragObservable: Observable<{}>;
  55575. /**
  55576. * Fired when a rotation sphere drag is ended
  55577. */
  55578. onRotationSphereDragEndObservable: Observable<{}>;
  55579. /**
  55580. * 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)
  55581. */
  55582. scalePivot: Nullable<Vector3>;
  55583. /**
  55584. * Mesh used as a pivot to rotate the attached node
  55585. */
  55586. private _anchorMesh;
  55587. private _existingMeshScale;
  55588. private _dragMesh;
  55589. private pointerDragBehavior;
  55590. private coloredMaterial;
  55591. private hoverColoredMaterial;
  55592. /**
  55593. * Sets the color of the bounding box gizmo
  55594. * @param color the color to set
  55595. */
  55596. setColor(color: Color3): void;
  55597. /**
  55598. * Creates an BoundingBoxGizmo
  55599. * @param gizmoLayer The utility layer the gizmo will be added to
  55600. * @param color The color of the gizmo
  55601. */
  55602. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55603. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55604. private _selectNode;
  55605. /**
  55606. * Updates the bounding box information for the Gizmo
  55607. */
  55608. updateBoundingBox(): void;
  55609. private _updateRotationSpheres;
  55610. private _updateScaleBoxes;
  55611. /**
  55612. * Enables rotation on the specified axis and disables rotation on the others
  55613. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55614. */
  55615. setEnabledRotationAxis(axis: string): void;
  55616. /**
  55617. * Enables/disables scaling
  55618. * @param enable if scaling should be enabled
  55619. * @param homogeneousScaling defines if scaling should only be homogeneous
  55620. */
  55621. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55622. private _updateDummy;
  55623. /**
  55624. * Enables a pointer drag behavior on the bounding box of the gizmo
  55625. */
  55626. enableDragBehavior(): void;
  55627. /**
  55628. * Disposes of the gizmo
  55629. */
  55630. dispose(): void;
  55631. /**
  55632. * 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)
  55633. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55634. * @returns the bounding box mesh with the passed in mesh as a child
  55635. */
  55636. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55637. /**
  55638. * CustomMeshes are not supported by this gizmo
  55639. * @param mesh The mesh to replace the default mesh of the gizmo
  55640. */
  55641. setCustomMesh(mesh: Mesh): void;
  55642. }
  55643. }
  55644. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55645. import { Observable } from "babylonjs/Misc/observable";
  55646. import { Nullable } from "babylonjs/types";
  55647. import { Vector3 } from "babylonjs/Maths/math.vector";
  55648. import { Color3 } from "babylonjs/Maths/math.color";
  55649. import { Node } from "babylonjs/node";
  55650. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55651. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55652. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55653. import "babylonjs/Meshes/Builders/linesBuilder";
  55654. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55655. /**
  55656. * Single plane rotation gizmo
  55657. */
  55658. export class PlaneRotationGizmo extends Gizmo {
  55659. /**
  55660. * Drag behavior responsible for the gizmos dragging interactions
  55661. */
  55662. dragBehavior: PointerDragBehavior;
  55663. private _pointerObserver;
  55664. /**
  55665. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55666. */
  55667. snapDistance: number;
  55668. /**
  55669. * Event that fires each time the gizmo snaps to a new location.
  55670. * * snapDistance is the the change in distance
  55671. */
  55672. onSnapObservable: Observable<{
  55673. snapDistance: number;
  55674. }>;
  55675. private _isEnabled;
  55676. private _parent;
  55677. /**
  55678. * Creates a PlaneRotationGizmo
  55679. * @param gizmoLayer The utility layer the gizmo will be added to
  55680. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55681. * @param color The color of the gizmo
  55682. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55683. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55684. * @param thickness display gizmo axis thickness
  55685. */
  55686. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55687. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55688. /**
  55689. * If the gizmo is enabled
  55690. */
  55691. set isEnabled(value: boolean);
  55692. get isEnabled(): boolean;
  55693. /**
  55694. * Disposes of the gizmo
  55695. */
  55696. dispose(): void;
  55697. }
  55698. }
  55699. declare module "babylonjs/Gizmos/rotationGizmo" {
  55700. import { Observable } from "babylonjs/Misc/observable";
  55701. import { Nullable } from "babylonjs/types";
  55702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55703. import { Mesh } from "babylonjs/Meshes/mesh";
  55704. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55705. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55706. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55707. import { Node } from "babylonjs/node";
  55708. /**
  55709. * Gizmo that enables rotating a mesh along 3 axis
  55710. */
  55711. export class RotationGizmo extends Gizmo {
  55712. /**
  55713. * Internal gizmo used for interactions on the x axis
  55714. */
  55715. xGizmo: PlaneRotationGizmo;
  55716. /**
  55717. * Internal gizmo used for interactions on the y axis
  55718. */
  55719. yGizmo: PlaneRotationGizmo;
  55720. /**
  55721. * Internal gizmo used for interactions on the z axis
  55722. */
  55723. zGizmo: PlaneRotationGizmo;
  55724. /** Fires an event when any of it's sub gizmos are dragged */
  55725. onDragStartObservable: Observable<unknown>;
  55726. /** Fires an event when any of it's sub gizmos are released from dragging */
  55727. onDragEndObservable: Observable<unknown>;
  55728. private _meshAttached;
  55729. private _nodeAttached;
  55730. get attachedMesh(): Nullable<AbstractMesh>;
  55731. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55732. get attachedNode(): Nullable<Node>;
  55733. set attachedNode(node: Nullable<Node>);
  55734. /**
  55735. * Creates a RotationGizmo
  55736. * @param gizmoLayer The utility layer the gizmo will be added to
  55737. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55738. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55739. * @param thickness display gizmo axis thickness
  55740. */
  55741. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55742. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55743. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55744. /**
  55745. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55746. */
  55747. set snapDistance(value: number);
  55748. get snapDistance(): number;
  55749. /**
  55750. * Ratio for the scale of the gizmo (Default: 1)
  55751. */
  55752. set scaleRatio(value: number);
  55753. get scaleRatio(): number;
  55754. /**
  55755. * Disposes of the gizmo
  55756. */
  55757. dispose(): void;
  55758. /**
  55759. * CustomMeshes are not supported by this gizmo
  55760. * @param mesh The mesh to replace the default mesh of the gizmo
  55761. */
  55762. setCustomMesh(mesh: Mesh): void;
  55763. }
  55764. }
  55765. declare module "babylonjs/Gizmos/gizmoManager" {
  55766. import { Observable } from "babylonjs/Misc/observable";
  55767. import { Nullable } from "babylonjs/types";
  55768. import { Scene, IDisposable } from "babylonjs/scene";
  55769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55770. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55771. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55772. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55773. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55774. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55775. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55776. /**
  55777. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55778. */
  55779. export class GizmoManager implements IDisposable {
  55780. private scene;
  55781. /**
  55782. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55783. */
  55784. gizmos: {
  55785. positionGizmo: Nullable<PositionGizmo>;
  55786. rotationGizmo: Nullable<RotationGizmo>;
  55787. scaleGizmo: Nullable<ScaleGizmo>;
  55788. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55789. };
  55790. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55791. clearGizmoOnEmptyPointerEvent: boolean;
  55792. /** Fires an event when the manager is attached to a mesh */
  55793. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55794. private _gizmosEnabled;
  55795. private _pointerObserver;
  55796. private _attachedMesh;
  55797. private _boundingBoxColor;
  55798. private _defaultUtilityLayer;
  55799. private _defaultKeepDepthUtilityLayer;
  55800. private _thickness;
  55801. /**
  55802. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55803. */
  55804. boundingBoxDragBehavior: SixDofDragBehavior;
  55805. /**
  55806. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55807. */
  55808. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55809. /**
  55810. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55811. */
  55812. usePointerToAttachGizmos: boolean;
  55813. /**
  55814. * Utility layer that the bounding box gizmo belongs to
  55815. */
  55816. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55817. /**
  55818. * Utility layer that all gizmos besides bounding box belong to
  55819. */
  55820. get utilityLayer(): UtilityLayerRenderer;
  55821. /**
  55822. * Instatiates a gizmo manager
  55823. * @param scene the scene to overlay the gizmos on top of
  55824. * @param thickness display gizmo axis thickness
  55825. */
  55826. constructor(scene: Scene, thickness?: number);
  55827. /**
  55828. * Attaches a set of gizmos to the specified mesh
  55829. * @param mesh The mesh the gizmo's should be attached to
  55830. */
  55831. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55832. /**
  55833. * If the position gizmo is enabled
  55834. */
  55835. set positionGizmoEnabled(value: boolean);
  55836. get positionGizmoEnabled(): boolean;
  55837. /**
  55838. * If the rotation gizmo is enabled
  55839. */
  55840. set rotationGizmoEnabled(value: boolean);
  55841. get rotationGizmoEnabled(): boolean;
  55842. /**
  55843. * If the scale gizmo is enabled
  55844. */
  55845. set scaleGizmoEnabled(value: boolean);
  55846. get scaleGizmoEnabled(): boolean;
  55847. /**
  55848. * If the boundingBox gizmo is enabled
  55849. */
  55850. set boundingBoxGizmoEnabled(value: boolean);
  55851. get boundingBoxGizmoEnabled(): boolean;
  55852. /**
  55853. * Disposes of the gizmo manager
  55854. */
  55855. dispose(): void;
  55856. }
  55857. }
  55858. declare module "babylonjs/Lights/directionalLight" {
  55859. import { Camera } from "babylonjs/Cameras/camera";
  55860. import { Scene } from "babylonjs/scene";
  55861. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55863. import { Light } from "babylonjs/Lights/light";
  55864. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55865. import { Effect } from "babylonjs/Materials/effect";
  55866. /**
  55867. * A directional light is defined by a direction (what a surprise!).
  55868. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55869. * 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.
  55870. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55871. */
  55872. export class DirectionalLight extends ShadowLight {
  55873. private _shadowFrustumSize;
  55874. /**
  55875. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55876. */
  55877. get shadowFrustumSize(): number;
  55878. /**
  55879. * Specifies a fix frustum size for the shadow generation.
  55880. */
  55881. set shadowFrustumSize(value: number);
  55882. private _shadowOrthoScale;
  55883. /**
  55884. * Gets the shadow projection scale against the optimal computed one.
  55885. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55886. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55887. */
  55888. get shadowOrthoScale(): number;
  55889. /**
  55890. * Sets the shadow projection scale against the optimal computed one.
  55891. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55892. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55893. */
  55894. set shadowOrthoScale(value: number);
  55895. /**
  55896. * Automatically compute the projection matrix to best fit (including all the casters)
  55897. * on each frame.
  55898. */
  55899. autoUpdateExtends: boolean;
  55900. /**
  55901. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55902. * on each frame. autoUpdateExtends must be set to true for this to work
  55903. */
  55904. autoCalcShadowZBounds: boolean;
  55905. private _orthoLeft;
  55906. private _orthoRight;
  55907. private _orthoTop;
  55908. private _orthoBottom;
  55909. /**
  55910. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55911. * The directional light is emitted from everywhere in the given direction.
  55912. * It can cast shadows.
  55913. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55914. * @param name The friendly name of the light
  55915. * @param direction The direction of the light
  55916. * @param scene The scene the light belongs to
  55917. */
  55918. constructor(name: string, direction: Vector3, scene: Scene);
  55919. /**
  55920. * Returns the string "DirectionalLight".
  55921. * @return The class name
  55922. */
  55923. getClassName(): string;
  55924. /**
  55925. * Returns the integer 1.
  55926. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55927. */
  55928. getTypeID(): number;
  55929. /**
  55930. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55931. * Returns the DirectionalLight Shadow projection matrix.
  55932. */
  55933. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55934. /**
  55935. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55936. * Returns the DirectionalLight Shadow projection matrix.
  55937. */
  55938. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55939. /**
  55940. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55941. * Returns the DirectionalLight Shadow projection matrix.
  55942. */
  55943. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55944. protected _buildUniformLayout(): void;
  55945. /**
  55946. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55947. * @param effect The effect to update
  55948. * @param lightIndex The index of the light in the effect to update
  55949. * @returns The directional light
  55950. */
  55951. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55952. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55953. /**
  55954. * Gets the minZ used for shadow according to both the scene and the light.
  55955. *
  55956. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55957. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55958. * @param activeCamera The camera we are returning the min for
  55959. * @returns the depth min z
  55960. */
  55961. getDepthMinZ(activeCamera: Camera): number;
  55962. /**
  55963. * Gets the maxZ used for shadow according to both the scene and the light.
  55964. *
  55965. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55966. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55967. * @param activeCamera The camera we are returning the max for
  55968. * @returns the depth max z
  55969. */
  55970. getDepthMaxZ(activeCamera: Camera): number;
  55971. /**
  55972. * Prepares the list of defines specific to the light type.
  55973. * @param defines the list of defines
  55974. * @param lightIndex defines the index of the light for the effect
  55975. */
  55976. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55977. }
  55978. }
  55979. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55980. import { Mesh } from "babylonjs/Meshes/mesh";
  55981. /**
  55982. * Class containing static functions to help procedurally build meshes
  55983. */
  55984. export class HemisphereBuilder {
  55985. /**
  55986. * Creates a hemisphere mesh
  55987. * @param name defines the name of the mesh
  55988. * @param options defines the options used to create the mesh
  55989. * @param scene defines the hosting scene
  55990. * @returns the hemisphere mesh
  55991. */
  55992. static CreateHemisphere(name: string, options: {
  55993. segments?: number;
  55994. diameter?: number;
  55995. sideOrientation?: number;
  55996. }, scene: any): Mesh;
  55997. }
  55998. }
  55999. declare module "babylonjs/Lights/spotLight" {
  56000. import { Nullable } from "babylonjs/types";
  56001. import { Scene } from "babylonjs/scene";
  56002. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56004. import { Effect } from "babylonjs/Materials/effect";
  56005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56006. import { Light } from "babylonjs/Lights/light";
  56007. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56008. /**
  56009. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56010. * These values define a cone of light starting from the position, emitting toward the direction.
  56011. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56012. * and the exponent defines the speed of the decay of the light with distance (reach).
  56013. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56014. */
  56015. export class SpotLight extends ShadowLight {
  56016. private _angle;
  56017. private _innerAngle;
  56018. private _cosHalfAngle;
  56019. private _lightAngleScale;
  56020. private _lightAngleOffset;
  56021. /**
  56022. * Gets the cone angle of the spot light in Radians.
  56023. */
  56024. get angle(): number;
  56025. /**
  56026. * Sets the cone angle of the spot light in Radians.
  56027. */
  56028. set angle(value: number);
  56029. /**
  56030. * Only used in gltf falloff mode, this defines the angle where
  56031. * the directional falloff will start before cutting at angle which could be seen
  56032. * as outer angle.
  56033. */
  56034. get innerAngle(): number;
  56035. /**
  56036. * Only used in gltf falloff mode, this defines the angle where
  56037. * the directional falloff will start before cutting at angle which could be seen
  56038. * as outer angle.
  56039. */
  56040. set innerAngle(value: number);
  56041. private _shadowAngleScale;
  56042. /**
  56043. * Allows scaling the angle of the light for shadow generation only.
  56044. */
  56045. get shadowAngleScale(): number;
  56046. /**
  56047. * Allows scaling the angle of the light for shadow generation only.
  56048. */
  56049. set shadowAngleScale(value: number);
  56050. /**
  56051. * The light decay speed with the distance from the emission spot.
  56052. */
  56053. exponent: number;
  56054. private _projectionTextureMatrix;
  56055. /**
  56056. * Allows reading the projecton texture
  56057. */
  56058. get projectionTextureMatrix(): Matrix;
  56059. protected _projectionTextureLightNear: number;
  56060. /**
  56061. * Gets the near clip of the Spotlight for texture projection.
  56062. */
  56063. get projectionTextureLightNear(): number;
  56064. /**
  56065. * Sets the near clip of the Spotlight for texture projection.
  56066. */
  56067. set projectionTextureLightNear(value: number);
  56068. protected _projectionTextureLightFar: number;
  56069. /**
  56070. * Gets the far clip of the Spotlight for texture projection.
  56071. */
  56072. get projectionTextureLightFar(): number;
  56073. /**
  56074. * Sets the far clip of the Spotlight for texture projection.
  56075. */
  56076. set projectionTextureLightFar(value: number);
  56077. protected _projectionTextureUpDirection: Vector3;
  56078. /**
  56079. * Gets the Up vector of the Spotlight for texture projection.
  56080. */
  56081. get projectionTextureUpDirection(): Vector3;
  56082. /**
  56083. * Sets the Up vector of the Spotlight for texture projection.
  56084. */
  56085. set projectionTextureUpDirection(value: Vector3);
  56086. private _projectionTexture;
  56087. /**
  56088. * Gets the projection texture of the light.
  56089. */
  56090. get projectionTexture(): Nullable<BaseTexture>;
  56091. /**
  56092. * Sets the projection texture of the light.
  56093. */
  56094. set projectionTexture(value: Nullable<BaseTexture>);
  56095. private _projectionTextureViewLightDirty;
  56096. private _projectionTextureProjectionLightDirty;
  56097. private _projectionTextureDirty;
  56098. private _projectionTextureViewTargetVector;
  56099. private _projectionTextureViewLightMatrix;
  56100. private _projectionTextureProjectionLightMatrix;
  56101. private _projectionTextureScalingMatrix;
  56102. /**
  56103. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56104. * It can cast shadows.
  56105. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56106. * @param name The light friendly name
  56107. * @param position The position of the spot light in the scene
  56108. * @param direction The direction of the light in the scene
  56109. * @param angle The cone angle of the light in Radians
  56110. * @param exponent The light decay speed with the distance from the emission spot
  56111. * @param scene The scene the lights belongs to
  56112. */
  56113. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56114. /**
  56115. * Returns the string "SpotLight".
  56116. * @returns the class name
  56117. */
  56118. getClassName(): string;
  56119. /**
  56120. * Returns the integer 2.
  56121. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56122. */
  56123. getTypeID(): number;
  56124. /**
  56125. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56126. */
  56127. protected _setDirection(value: Vector3): void;
  56128. /**
  56129. * Overrides the position setter to recompute the projection texture view light Matrix.
  56130. */
  56131. protected _setPosition(value: Vector3): void;
  56132. /**
  56133. * 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.
  56134. * Returns the SpotLight.
  56135. */
  56136. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56137. protected _computeProjectionTextureViewLightMatrix(): void;
  56138. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56139. /**
  56140. * Main function for light texture projection matrix computing.
  56141. */
  56142. protected _computeProjectionTextureMatrix(): void;
  56143. protected _buildUniformLayout(): void;
  56144. private _computeAngleValues;
  56145. /**
  56146. * Sets the passed Effect "effect" with the Light textures.
  56147. * @param effect The effect to update
  56148. * @param lightIndex The index of the light in the effect to update
  56149. * @returns The light
  56150. */
  56151. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56152. /**
  56153. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56154. * @param effect The effect to update
  56155. * @param lightIndex The index of the light in the effect to update
  56156. * @returns The spot light
  56157. */
  56158. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56159. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56160. /**
  56161. * Disposes the light and the associated resources.
  56162. */
  56163. dispose(): void;
  56164. /**
  56165. * Prepares the list of defines specific to the light type.
  56166. * @param defines the list of defines
  56167. * @param lightIndex defines the index of the light for the effect
  56168. */
  56169. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56170. }
  56171. }
  56172. declare module "babylonjs/Gizmos/lightGizmo" {
  56173. import { Nullable } from "babylonjs/types";
  56174. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56175. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56176. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56177. import { Light } from "babylonjs/Lights/light";
  56178. /**
  56179. * Gizmo that enables viewing a light
  56180. */
  56181. export class LightGizmo extends Gizmo {
  56182. private _lightMesh;
  56183. private _material;
  56184. private _cachedPosition;
  56185. private _cachedForward;
  56186. private _attachedMeshParent;
  56187. /**
  56188. * Creates a LightGizmo
  56189. * @param gizmoLayer The utility layer the gizmo will be added to
  56190. */
  56191. constructor(gizmoLayer?: UtilityLayerRenderer);
  56192. private _light;
  56193. /**
  56194. * The light that the gizmo is attached to
  56195. */
  56196. set light(light: Nullable<Light>);
  56197. get light(): Nullable<Light>;
  56198. /**
  56199. * Gets the material used to render the light gizmo
  56200. */
  56201. get material(): StandardMaterial;
  56202. /**
  56203. * @hidden
  56204. * Updates the gizmo to match the attached mesh's position/rotation
  56205. */
  56206. protected _update(): void;
  56207. private static _Scale;
  56208. /**
  56209. * Creates the lines for a light mesh
  56210. */
  56211. private static _CreateLightLines;
  56212. /**
  56213. * Disposes of the light gizmo
  56214. */
  56215. dispose(): void;
  56216. private static _CreateHemisphericLightMesh;
  56217. private static _CreatePointLightMesh;
  56218. private static _CreateSpotLightMesh;
  56219. private static _CreateDirectionalLightMesh;
  56220. }
  56221. }
  56222. declare module "babylonjs/Gizmos/index" {
  56223. export * from "babylonjs/Gizmos/axisDragGizmo";
  56224. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56225. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56226. export * from "babylonjs/Gizmos/gizmo";
  56227. export * from "babylonjs/Gizmos/gizmoManager";
  56228. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56229. export * from "babylonjs/Gizmos/positionGizmo";
  56230. export * from "babylonjs/Gizmos/rotationGizmo";
  56231. export * from "babylonjs/Gizmos/scaleGizmo";
  56232. export * from "babylonjs/Gizmos/lightGizmo";
  56233. export * from "babylonjs/Gizmos/planeDragGizmo";
  56234. }
  56235. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56236. /** @hidden */
  56237. export var backgroundFragmentDeclaration: {
  56238. name: string;
  56239. shader: string;
  56240. };
  56241. }
  56242. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56243. /** @hidden */
  56244. export var backgroundUboDeclaration: {
  56245. name: string;
  56246. shader: string;
  56247. };
  56248. }
  56249. declare module "babylonjs/Shaders/background.fragment" {
  56250. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56251. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56252. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56253. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56254. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56255. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56256. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56257. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56258. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56259. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56260. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56261. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56262. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56263. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56264. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56265. /** @hidden */
  56266. export var backgroundPixelShader: {
  56267. name: string;
  56268. shader: string;
  56269. };
  56270. }
  56271. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56272. /** @hidden */
  56273. export var backgroundVertexDeclaration: {
  56274. name: string;
  56275. shader: string;
  56276. };
  56277. }
  56278. declare module "babylonjs/Shaders/background.vertex" {
  56279. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56280. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56282. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56283. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56284. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56285. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56286. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56287. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56288. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56289. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56291. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56292. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56293. /** @hidden */
  56294. export var backgroundVertexShader: {
  56295. name: string;
  56296. shader: string;
  56297. };
  56298. }
  56299. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56300. import { Nullable, int, float } from "babylonjs/types";
  56301. import { Scene } from "babylonjs/scene";
  56302. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56303. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56305. import { Mesh } from "babylonjs/Meshes/mesh";
  56306. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56307. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56308. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56310. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56311. import { Color3 } from "babylonjs/Maths/math.color";
  56312. import "babylonjs/Shaders/background.fragment";
  56313. import "babylonjs/Shaders/background.vertex";
  56314. /**
  56315. * Background material used to create an efficient environement around your scene.
  56316. */
  56317. export class BackgroundMaterial extends PushMaterial {
  56318. /**
  56319. * Standard reflectance value at parallel view angle.
  56320. */
  56321. static StandardReflectance0: number;
  56322. /**
  56323. * Standard reflectance value at grazing angle.
  56324. */
  56325. static StandardReflectance90: number;
  56326. protected _primaryColor: Color3;
  56327. /**
  56328. * Key light Color (multiply against the environement texture)
  56329. */
  56330. primaryColor: Color3;
  56331. protected __perceptualColor: Nullable<Color3>;
  56332. /**
  56333. * Experimental Internal Use Only.
  56334. *
  56335. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56336. * This acts as a helper to set the primary color to a more "human friendly" value.
  56337. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56338. * output color as close as possible from the chosen value.
  56339. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56340. * part of lighting setup.)
  56341. */
  56342. get _perceptualColor(): Nullable<Color3>;
  56343. set _perceptualColor(value: Nullable<Color3>);
  56344. protected _primaryColorShadowLevel: float;
  56345. /**
  56346. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56347. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56348. */
  56349. get primaryColorShadowLevel(): float;
  56350. set primaryColorShadowLevel(value: float);
  56351. protected _primaryColorHighlightLevel: float;
  56352. /**
  56353. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56354. * The primary color is used at the level chosen to define what the white area would look.
  56355. */
  56356. get primaryColorHighlightLevel(): float;
  56357. set primaryColorHighlightLevel(value: float);
  56358. protected _reflectionTexture: Nullable<BaseTexture>;
  56359. /**
  56360. * Reflection Texture used in the material.
  56361. * Should be author in a specific way for the best result (refer to the documentation).
  56362. */
  56363. reflectionTexture: Nullable<BaseTexture>;
  56364. protected _reflectionBlur: float;
  56365. /**
  56366. * Reflection Texture level of blur.
  56367. *
  56368. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56369. * texture twice.
  56370. */
  56371. reflectionBlur: float;
  56372. protected _diffuseTexture: Nullable<BaseTexture>;
  56373. /**
  56374. * Diffuse Texture used in the material.
  56375. * Should be author in a specific way for the best result (refer to the documentation).
  56376. */
  56377. diffuseTexture: Nullable<BaseTexture>;
  56378. protected _shadowLights: Nullable<IShadowLight[]>;
  56379. /**
  56380. * Specify the list of lights casting shadow on the material.
  56381. * All scene shadow lights will be included if null.
  56382. */
  56383. shadowLights: Nullable<IShadowLight[]>;
  56384. protected _shadowLevel: float;
  56385. /**
  56386. * Helps adjusting the shadow to a softer level if required.
  56387. * 0 means black shadows and 1 means no shadows.
  56388. */
  56389. shadowLevel: float;
  56390. protected _sceneCenter: Vector3;
  56391. /**
  56392. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56393. * It is usually zero but might be interesting to modify according to your setup.
  56394. */
  56395. sceneCenter: Vector3;
  56396. protected _opacityFresnel: boolean;
  56397. /**
  56398. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56399. * This helps ensuring a nice transition when the camera goes under the ground.
  56400. */
  56401. opacityFresnel: boolean;
  56402. protected _reflectionFresnel: boolean;
  56403. /**
  56404. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56405. * This helps adding a mirror texture on the ground.
  56406. */
  56407. reflectionFresnel: boolean;
  56408. protected _reflectionFalloffDistance: number;
  56409. /**
  56410. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56411. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56412. */
  56413. reflectionFalloffDistance: number;
  56414. protected _reflectionAmount: number;
  56415. /**
  56416. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56417. */
  56418. reflectionAmount: number;
  56419. protected _reflectionReflectance0: number;
  56420. /**
  56421. * This specifies the weight of the reflection at grazing angle.
  56422. */
  56423. reflectionReflectance0: number;
  56424. protected _reflectionReflectance90: number;
  56425. /**
  56426. * This specifies the weight of the reflection at a perpendicular point of view.
  56427. */
  56428. reflectionReflectance90: number;
  56429. /**
  56430. * Sets the reflection reflectance fresnel values according to the default standard
  56431. * empirically know to work well :-)
  56432. */
  56433. set reflectionStandardFresnelWeight(value: number);
  56434. protected _useRGBColor: boolean;
  56435. /**
  56436. * Helps to directly use the maps channels instead of their level.
  56437. */
  56438. useRGBColor: boolean;
  56439. protected _enableNoise: boolean;
  56440. /**
  56441. * This helps reducing the banding effect that could occur on the background.
  56442. */
  56443. enableNoise: boolean;
  56444. /**
  56445. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56446. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56447. * Recommended to be keep at 1.0 except for special cases.
  56448. */
  56449. get fovMultiplier(): number;
  56450. set fovMultiplier(value: number);
  56451. private _fovMultiplier;
  56452. /**
  56453. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56454. */
  56455. useEquirectangularFOV: boolean;
  56456. private _maxSimultaneousLights;
  56457. /**
  56458. * Number of Simultaneous lights allowed on the material.
  56459. */
  56460. maxSimultaneousLights: int;
  56461. private _shadowOnly;
  56462. /**
  56463. * Make the material only render shadows
  56464. */
  56465. shadowOnly: boolean;
  56466. /**
  56467. * Default configuration related to image processing available in the Background Material.
  56468. */
  56469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56470. /**
  56471. * Keep track of the image processing observer to allow dispose and replace.
  56472. */
  56473. private _imageProcessingObserver;
  56474. /**
  56475. * Attaches a new image processing configuration to the PBR Material.
  56476. * @param configuration (if null the scene configuration will be use)
  56477. */
  56478. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56479. /**
  56480. * Gets the image processing configuration used either in this material.
  56481. */
  56482. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56483. /**
  56484. * Sets the Default image processing configuration used either in the this material.
  56485. *
  56486. * If sets to null, the scene one is in use.
  56487. */
  56488. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56489. /**
  56490. * Gets wether the color curves effect is enabled.
  56491. */
  56492. get cameraColorCurvesEnabled(): boolean;
  56493. /**
  56494. * Sets wether the color curves effect is enabled.
  56495. */
  56496. set cameraColorCurvesEnabled(value: boolean);
  56497. /**
  56498. * Gets wether the color grading effect is enabled.
  56499. */
  56500. get cameraColorGradingEnabled(): boolean;
  56501. /**
  56502. * Gets wether the color grading effect is enabled.
  56503. */
  56504. set cameraColorGradingEnabled(value: boolean);
  56505. /**
  56506. * Gets wether tonemapping is enabled or not.
  56507. */
  56508. get cameraToneMappingEnabled(): boolean;
  56509. /**
  56510. * Sets wether tonemapping is enabled or not
  56511. */
  56512. set cameraToneMappingEnabled(value: boolean);
  56513. /**
  56514. * The camera exposure used on this material.
  56515. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56516. * This corresponds to a photographic exposure.
  56517. */
  56518. get cameraExposure(): float;
  56519. /**
  56520. * The camera exposure used on this material.
  56521. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56522. * This corresponds to a photographic exposure.
  56523. */
  56524. set cameraExposure(value: float);
  56525. /**
  56526. * Gets The camera contrast used on this material.
  56527. */
  56528. get cameraContrast(): float;
  56529. /**
  56530. * Sets The camera contrast used on this material.
  56531. */
  56532. set cameraContrast(value: float);
  56533. /**
  56534. * Gets the Color Grading 2D Lookup Texture.
  56535. */
  56536. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56537. /**
  56538. * Sets the Color Grading 2D Lookup Texture.
  56539. */
  56540. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56541. /**
  56542. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56543. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56544. * 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;
  56545. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56546. */
  56547. get cameraColorCurves(): Nullable<ColorCurves>;
  56548. /**
  56549. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56550. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56551. * 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;
  56552. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56553. */
  56554. set cameraColorCurves(value: Nullable<ColorCurves>);
  56555. /**
  56556. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56557. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56558. */
  56559. switchToBGR: boolean;
  56560. private _renderTargets;
  56561. private _reflectionControls;
  56562. private _white;
  56563. private _primaryShadowColor;
  56564. private _primaryHighlightColor;
  56565. /**
  56566. * Instantiates a Background Material in the given scene
  56567. * @param name The friendly name of the material
  56568. * @param scene The scene to add the material to
  56569. */
  56570. constructor(name: string, scene: Scene);
  56571. /**
  56572. * Gets a boolean indicating that current material needs to register RTT
  56573. */
  56574. get hasRenderTargetTextures(): boolean;
  56575. /**
  56576. * The entire material has been created in order to prevent overdraw.
  56577. * @returns false
  56578. */
  56579. needAlphaTesting(): boolean;
  56580. /**
  56581. * The entire material has been created in order to prevent overdraw.
  56582. * @returns true if blending is enable
  56583. */
  56584. needAlphaBlending(): boolean;
  56585. /**
  56586. * Checks wether the material is ready to be rendered for a given mesh.
  56587. * @param mesh The mesh to render
  56588. * @param subMesh The submesh to check against
  56589. * @param useInstances Specify wether or not the material is used with instances
  56590. * @returns true if all the dependencies are ready (Textures, Effects...)
  56591. */
  56592. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56593. /**
  56594. * Compute the primary color according to the chosen perceptual color.
  56595. */
  56596. private _computePrimaryColorFromPerceptualColor;
  56597. /**
  56598. * Compute the highlights and shadow colors according to their chosen levels.
  56599. */
  56600. private _computePrimaryColors;
  56601. /**
  56602. * Build the uniform buffer used in the material.
  56603. */
  56604. buildUniformLayout(): void;
  56605. /**
  56606. * Unbind the material.
  56607. */
  56608. unbind(): void;
  56609. /**
  56610. * Bind only the world matrix to the material.
  56611. * @param world The world matrix to bind.
  56612. */
  56613. bindOnlyWorldMatrix(world: Matrix): void;
  56614. /**
  56615. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56616. * @param world The world matrix to bind.
  56617. * @param subMesh The submesh to bind for.
  56618. */
  56619. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56620. /**
  56621. * Checks to see if a texture is used in the material.
  56622. * @param texture - Base texture to use.
  56623. * @returns - Boolean specifying if a texture is used in the material.
  56624. */
  56625. hasTexture(texture: BaseTexture): boolean;
  56626. /**
  56627. * Dispose the material.
  56628. * @param forceDisposeEffect Force disposal of the associated effect.
  56629. * @param forceDisposeTextures Force disposal of the associated textures.
  56630. */
  56631. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56632. /**
  56633. * Clones the material.
  56634. * @param name The cloned name.
  56635. * @returns The cloned material.
  56636. */
  56637. clone(name: string): BackgroundMaterial;
  56638. /**
  56639. * Serializes the current material to its JSON representation.
  56640. * @returns The JSON representation.
  56641. */
  56642. serialize(): any;
  56643. /**
  56644. * Gets the class name of the material
  56645. * @returns "BackgroundMaterial"
  56646. */
  56647. getClassName(): string;
  56648. /**
  56649. * Parse a JSON input to create back a background material.
  56650. * @param source The JSON data to parse
  56651. * @param scene The scene to create the parsed material in
  56652. * @param rootUrl The root url of the assets the material depends upon
  56653. * @returns the instantiated BackgroundMaterial.
  56654. */
  56655. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56656. }
  56657. }
  56658. declare module "babylonjs/Helpers/environmentHelper" {
  56659. import { Observable } from "babylonjs/Misc/observable";
  56660. import { Nullable } from "babylonjs/types";
  56661. import { Scene } from "babylonjs/scene";
  56662. import { Vector3 } from "babylonjs/Maths/math.vector";
  56663. import { Color3 } from "babylonjs/Maths/math.color";
  56664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56665. import { Mesh } from "babylonjs/Meshes/mesh";
  56666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56667. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56668. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56669. import "babylonjs/Meshes/Builders/planeBuilder";
  56670. import "babylonjs/Meshes/Builders/boxBuilder";
  56671. /**
  56672. * Represents the different options available during the creation of
  56673. * a Environment helper.
  56674. *
  56675. * This can control the default ground, skybox and image processing setup of your scene.
  56676. */
  56677. export interface IEnvironmentHelperOptions {
  56678. /**
  56679. * Specifies whether or not to create a ground.
  56680. * True by default.
  56681. */
  56682. createGround: boolean;
  56683. /**
  56684. * Specifies the ground size.
  56685. * 15 by default.
  56686. */
  56687. groundSize: number;
  56688. /**
  56689. * The texture used on the ground for the main color.
  56690. * Comes from the BabylonJS CDN by default.
  56691. *
  56692. * Remarks: Can be either a texture or a url.
  56693. */
  56694. groundTexture: string | BaseTexture;
  56695. /**
  56696. * The color mixed in the ground texture by default.
  56697. * BabylonJS clearColor by default.
  56698. */
  56699. groundColor: Color3;
  56700. /**
  56701. * Specifies the ground opacity.
  56702. * 1 by default.
  56703. */
  56704. groundOpacity: number;
  56705. /**
  56706. * Enables the ground to receive shadows.
  56707. * True by default.
  56708. */
  56709. enableGroundShadow: boolean;
  56710. /**
  56711. * Helps preventing the shadow to be fully black on the ground.
  56712. * 0.5 by default.
  56713. */
  56714. groundShadowLevel: number;
  56715. /**
  56716. * Creates a mirror texture attach to the ground.
  56717. * false by default.
  56718. */
  56719. enableGroundMirror: boolean;
  56720. /**
  56721. * Specifies the ground mirror size ratio.
  56722. * 0.3 by default as the default kernel is 64.
  56723. */
  56724. groundMirrorSizeRatio: number;
  56725. /**
  56726. * Specifies the ground mirror blur kernel size.
  56727. * 64 by default.
  56728. */
  56729. groundMirrorBlurKernel: number;
  56730. /**
  56731. * Specifies the ground mirror visibility amount.
  56732. * 1 by default
  56733. */
  56734. groundMirrorAmount: number;
  56735. /**
  56736. * Specifies the ground mirror reflectance weight.
  56737. * This uses the standard weight of the background material to setup the fresnel effect
  56738. * of the mirror.
  56739. * 1 by default.
  56740. */
  56741. groundMirrorFresnelWeight: number;
  56742. /**
  56743. * Specifies the ground mirror Falloff distance.
  56744. * This can helps reducing the size of the reflection.
  56745. * 0 by Default.
  56746. */
  56747. groundMirrorFallOffDistance: number;
  56748. /**
  56749. * Specifies the ground mirror texture type.
  56750. * Unsigned Int by Default.
  56751. */
  56752. groundMirrorTextureType: number;
  56753. /**
  56754. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56755. * the shown objects.
  56756. */
  56757. groundYBias: number;
  56758. /**
  56759. * Specifies whether or not to create a skybox.
  56760. * True by default.
  56761. */
  56762. createSkybox: boolean;
  56763. /**
  56764. * Specifies the skybox size.
  56765. * 20 by default.
  56766. */
  56767. skyboxSize: number;
  56768. /**
  56769. * The texture used on the skybox for the main color.
  56770. * Comes from the BabylonJS CDN by default.
  56771. *
  56772. * Remarks: Can be either a texture or a url.
  56773. */
  56774. skyboxTexture: string | BaseTexture;
  56775. /**
  56776. * The color mixed in the skybox texture by default.
  56777. * BabylonJS clearColor by default.
  56778. */
  56779. skyboxColor: Color3;
  56780. /**
  56781. * The background rotation around the Y axis of the scene.
  56782. * This helps aligning the key lights of your scene with the background.
  56783. * 0 by default.
  56784. */
  56785. backgroundYRotation: number;
  56786. /**
  56787. * Compute automatically the size of the elements to best fit with the scene.
  56788. */
  56789. sizeAuto: boolean;
  56790. /**
  56791. * Default position of the rootMesh if autoSize is not true.
  56792. */
  56793. rootPosition: Vector3;
  56794. /**
  56795. * Sets up the image processing in the scene.
  56796. * true by default.
  56797. */
  56798. setupImageProcessing: boolean;
  56799. /**
  56800. * The texture used as your environment texture in the scene.
  56801. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56802. *
  56803. * Remarks: Can be either a texture or a url.
  56804. */
  56805. environmentTexture: string | BaseTexture;
  56806. /**
  56807. * The value of the exposure to apply to the scene.
  56808. * 0.6 by default if setupImageProcessing is true.
  56809. */
  56810. cameraExposure: number;
  56811. /**
  56812. * The value of the contrast to apply to the scene.
  56813. * 1.6 by default if setupImageProcessing is true.
  56814. */
  56815. cameraContrast: number;
  56816. /**
  56817. * Specifies whether or not tonemapping should be enabled in the scene.
  56818. * true by default if setupImageProcessing is true.
  56819. */
  56820. toneMappingEnabled: boolean;
  56821. }
  56822. /**
  56823. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56824. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56825. * It also helps with the default setup of your imageProcessing configuration.
  56826. */
  56827. export class EnvironmentHelper {
  56828. /**
  56829. * Default ground texture URL.
  56830. */
  56831. private static _groundTextureCDNUrl;
  56832. /**
  56833. * Default skybox texture URL.
  56834. */
  56835. private static _skyboxTextureCDNUrl;
  56836. /**
  56837. * Default environment texture URL.
  56838. */
  56839. private static _environmentTextureCDNUrl;
  56840. /**
  56841. * Creates the default options for the helper.
  56842. */
  56843. private static _getDefaultOptions;
  56844. private _rootMesh;
  56845. /**
  56846. * Gets the root mesh created by the helper.
  56847. */
  56848. get rootMesh(): Mesh;
  56849. private _skybox;
  56850. /**
  56851. * Gets the skybox created by the helper.
  56852. */
  56853. get skybox(): Nullable<Mesh>;
  56854. private _skyboxTexture;
  56855. /**
  56856. * Gets the skybox texture created by the helper.
  56857. */
  56858. get skyboxTexture(): Nullable<BaseTexture>;
  56859. private _skyboxMaterial;
  56860. /**
  56861. * Gets the skybox material created by the helper.
  56862. */
  56863. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56864. private _ground;
  56865. /**
  56866. * Gets the ground mesh created by the helper.
  56867. */
  56868. get ground(): Nullable<Mesh>;
  56869. private _groundTexture;
  56870. /**
  56871. * Gets the ground texture created by the helper.
  56872. */
  56873. get groundTexture(): Nullable<BaseTexture>;
  56874. private _groundMirror;
  56875. /**
  56876. * Gets the ground mirror created by the helper.
  56877. */
  56878. get groundMirror(): Nullable<MirrorTexture>;
  56879. /**
  56880. * Gets the ground mirror render list to helps pushing the meshes
  56881. * you wish in the ground reflection.
  56882. */
  56883. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56884. private _groundMaterial;
  56885. /**
  56886. * Gets the ground material created by the helper.
  56887. */
  56888. get groundMaterial(): Nullable<BackgroundMaterial>;
  56889. /**
  56890. * Stores the creation options.
  56891. */
  56892. private readonly _scene;
  56893. private _options;
  56894. /**
  56895. * This observable will be notified with any error during the creation of the environment,
  56896. * mainly texture creation errors.
  56897. */
  56898. onErrorObservable: Observable<{
  56899. message?: string;
  56900. exception?: any;
  56901. }>;
  56902. /**
  56903. * constructor
  56904. * @param options Defines the options we want to customize the helper
  56905. * @param scene The scene to add the material to
  56906. */
  56907. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56908. /**
  56909. * Updates the background according to the new options
  56910. * @param options
  56911. */
  56912. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56913. /**
  56914. * Sets the primary color of all the available elements.
  56915. * @param color the main color to affect to the ground and the background
  56916. */
  56917. setMainColor(color: Color3): void;
  56918. /**
  56919. * Setup the image processing according to the specified options.
  56920. */
  56921. private _setupImageProcessing;
  56922. /**
  56923. * Setup the environment texture according to the specified options.
  56924. */
  56925. private _setupEnvironmentTexture;
  56926. /**
  56927. * Setup the background according to the specified options.
  56928. */
  56929. private _setupBackground;
  56930. /**
  56931. * Get the scene sizes according to the setup.
  56932. */
  56933. private _getSceneSize;
  56934. /**
  56935. * Setup the ground according to the specified options.
  56936. */
  56937. private _setupGround;
  56938. /**
  56939. * Setup the ground material according to the specified options.
  56940. */
  56941. private _setupGroundMaterial;
  56942. /**
  56943. * Setup the ground diffuse texture according to the specified options.
  56944. */
  56945. private _setupGroundDiffuseTexture;
  56946. /**
  56947. * Setup the ground mirror texture according to the specified options.
  56948. */
  56949. private _setupGroundMirrorTexture;
  56950. /**
  56951. * Setup the ground to receive the mirror texture.
  56952. */
  56953. private _setupMirrorInGroundMaterial;
  56954. /**
  56955. * Setup the skybox according to the specified options.
  56956. */
  56957. private _setupSkybox;
  56958. /**
  56959. * Setup the skybox material according to the specified options.
  56960. */
  56961. private _setupSkyboxMaterial;
  56962. /**
  56963. * Setup the skybox reflection texture according to the specified options.
  56964. */
  56965. private _setupSkyboxReflectionTexture;
  56966. private _errorHandler;
  56967. /**
  56968. * Dispose all the elements created by the Helper.
  56969. */
  56970. dispose(): void;
  56971. }
  56972. }
  56973. declare module "babylonjs/Helpers/photoDome" {
  56974. import { Observable } from "babylonjs/Misc/observable";
  56975. import { Nullable } from "babylonjs/types";
  56976. import { Scene } from "babylonjs/scene";
  56977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56978. import { Mesh } from "babylonjs/Meshes/mesh";
  56979. import { Texture } from "babylonjs/Materials/Textures/texture";
  56980. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56981. import "babylonjs/Meshes/Builders/sphereBuilder";
  56982. /**
  56983. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56984. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56985. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56986. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56987. */
  56988. export class PhotoDome extends TransformNode {
  56989. /**
  56990. * Define the image as a Monoscopic panoramic 360 image.
  56991. */
  56992. static readonly MODE_MONOSCOPIC: number;
  56993. /**
  56994. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56995. */
  56996. static readonly MODE_TOPBOTTOM: number;
  56997. /**
  56998. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56999. */
  57000. static readonly MODE_SIDEBYSIDE: number;
  57001. private _useDirectMapping;
  57002. /**
  57003. * The texture being displayed on the sphere
  57004. */
  57005. protected _photoTexture: Texture;
  57006. /**
  57007. * Gets or sets the texture being displayed on the sphere
  57008. */
  57009. get photoTexture(): Texture;
  57010. set photoTexture(value: Texture);
  57011. /**
  57012. * Observable raised when an error occured while loading the 360 image
  57013. */
  57014. onLoadErrorObservable: Observable<string>;
  57015. /**
  57016. * The skybox material
  57017. */
  57018. protected _material: BackgroundMaterial;
  57019. /**
  57020. * The surface used for the skybox
  57021. */
  57022. protected _mesh: Mesh;
  57023. /**
  57024. * Gets the mesh used for the skybox.
  57025. */
  57026. get mesh(): Mesh;
  57027. /**
  57028. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57029. * Also see the options.resolution property.
  57030. */
  57031. get fovMultiplier(): number;
  57032. set fovMultiplier(value: number);
  57033. private _imageMode;
  57034. /**
  57035. * Gets or set the current video mode for the video. It can be:
  57036. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  57037. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57038. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57039. */
  57040. get imageMode(): number;
  57041. set imageMode(value: number);
  57042. /**
  57043. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  57044. * @param name Element's name, child elements will append suffixes for their own names.
  57045. * @param urlsOfPhoto defines the url of the photo to display
  57046. * @param options defines an object containing optional or exposed sub element properties
  57047. * @param onError defines a callback called when an error occured while loading the texture
  57048. */
  57049. constructor(name: string, urlOfPhoto: string, options: {
  57050. resolution?: number;
  57051. size?: number;
  57052. useDirectMapping?: boolean;
  57053. faceForward?: boolean;
  57054. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57055. private _onBeforeCameraRenderObserver;
  57056. private _changeImageMode;
  57057. /**
  57058. * Releases resources associated with this node.
  57059. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57060. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57061. */
  57062. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57063. }
  57064. }
  57065. declare module "babylonjs/Misc/rgbdTextureTools" {
  57066. import "babylonjs/Shaders/rgbdDecode.fragment";
  57067. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57068. import { Texture } from "babylonjs/Materials/Textures/texture";
  57069. /**
  57070. * Class used to host RGBD texture specific utilities
  57071. */
  57072. export class RGBDTextureTools {
  57073. /**
  57074. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57075. * @param texture the texture to expand.
  57076. */
  57077. static ExpandRGBDTexture(texture: Texture): void;
  57078. }
  57079. }
  57080. declare module "babylonjs/Misc/brdfTextureTools" {
  57081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57082. import { Scene } from "babylonjs/scene";
  57083. /**
  57084. * Class used to host texture specific utilities
  57085. */
  57086. export class BRDFTextureTools {
  57087. /**
  57088. * Prevents texture cache collision
  57089. */
  57090. private static _instanceNumber;
  57091. /**
  57092. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57093. * @param scene defines the hosting scene
  57094. * @returns the environment BRDF texture
  57095. */
  57096. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57097. private static _environmentBRDFBase64Texture;
  57098. }
  57099. }
  57100. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57101. import { Nullable } from "babylonjs/types";
  57102. import { Color3 } from "babylonjs/Maths/math.color";
  57103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57105. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57106. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57107. import { Engine } from "babylonjs/Engines/engine";
  57108. import { Scene } from "babylonjs/scene";
  57109. /**
  57110. * @hidden
  57111. */
  57112. export interface IMaterialClearCoatDefines {
  57113. CLEARCOAT: boolean;
  57114. CLEARCOAT_DEFAULTIOR: boolean;
  57115. CLEARCOAT_TEXTURE: boolean;
  57116. CLEARCOAT_TEXTUREDIRECTUV: number;
  57117. CLEARCOAT_BUMP: boolean;
  57118. CLEARCOAT_BUMPDIRECTUV: number;
  57119. CLEARCOAT_TINT: boolean;
  57120. CLEARCOAT_TINT_TEXTURE: boolean;
  57121. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57122. /** @hidden */
  57123. _areTexturesDirty: boolean;
  57124. }
  57125. /**
  57126. * Define the code related to the clear coat parameters of the pbr material.
  57127. */
  57128. export class PBRClearCoatConfiguration {
  57129. /**
  57130. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57131. * The default fits with a polyurethane material.
  57132. */
  57133. private static readonly _DefaultIndexOfRefraction;
  57134. private _isEnabled;
  57135. /**
  57136. * Defines if the clear coat is enabled in the material.
  57137. */
  57138. isEnabled: boolean;
  57139. /**
  57140. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57141. */
  57142. intensity: number;
  57143. /**
  57144. * Defines the clear coat layer roughness.
  57145. */
  57146. roughness: number;
  57147. private _indexOfRefraction;
  57148. /**
  57149. * Defines the index of refraction of the clear coat.
  57150. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57151. * The default fits with a polyurethane material.
  57152. * Changing the default value is more performance intensive.
  57153. */
  57154. indexOfRefraction: number;
  57155. private _texture;
  57156. /**
  57157. * Stores the clear coat values in a texture.
  57158. */
  57159. texture: Nullable<BaseTexture>;
  57160. private _bumpTexture;
  57161. /**
  57162. * Define the clear coat specific bump texture.
  57163. */
  57164. bumpTexture: Nullable<BaseTexture>;
  57165. private _isTintEnabled;
  57166. /**
  57167. * Defines if the clear coat tint is enabled in the material.
  57168. */
  57169. isTintEnabled: boolean;
  57170. /**
  57171. * Defines the clear coat tint of the material.
  57172. * This is only use if tint is enabled
  57173. */
  57174. tintColor: Color3;
  57175. /**
  57176. * Defines the distance at which the tint color should be found in the
  57177. * clear coat media.
  57178. * This is only use if tint is enabled
  57179. */
  57180. tintColorAtDistance: number;
  57181. /**
  57182. * Defines the clear coat layer thickness.
  57183. * This is only use if tint is enabled
  57184. */
  57185. tintThickness: number;
  57186. private _tintTexture;
  57187. /**
  57188. * Stores the clear tint values in a texture.
  57189. * rgb is tint
  57190. * a is a thickness factor
  57191. */
  57192. tintTexture: Nullable<BaseTexture>;
  57193. /** @hidden */
  57194. private _internalMarkAllSubMeshesAsTexturesDirty;
  57195. /** @hidden */
  57196. _markAllSubMeshesAsTexturesDirty(): void;
  57197. /**
  57198. * Instantiate a new istance of clear coat configuration.
  57199. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57200. */
  57201. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57202. /**
  57203. * Gets wehter the submesh is ready to be used or not.
  57204. * @param defines the list of "defines" to update.
  57205. * @param scene defines the scene the material belongs to.
  57206. * @param engine defines the engine the material belongs to.
  57207. * @param disableBumpMap defines wether the material disables bump or not.
  57208. * @returns - boolean indicating that the submesh is ready or not.
  57209. */
  57210. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57211. /**
  57212. * Checks to see if a texture is used in the material.
  57213. * @param defines the list of "defines" to update.
  57214. * @param scene defines the scene to the material belongs to.
  57215. */
  57216. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57217. /**
  57218. * Binds the material data.
  57219. * @param uniformBuffer defines the Uniform buffer to fill in.
  57220. * @param scene defines the scene the material belongs to.
  57221. * @param engine defines the engine the material belongs to.
  57222. * @param disableBumpMap defines wether the material disables bump or not.
  57223. * @param isFrozen defines wether the material is frozen or not.
  57224. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57225. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57226. */
  57227. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57228. /**
  57229. * Checks to see if a texture is used in the material.
  57230. * @param texture - Base texture to use.
  57231. * @returns - Boolean specifying if a texture is used in the material.
  57232. */
  57233. hasTexture(texture: BaseTexture): boolean;
  57234. /**
  57235. * Returns an array of the actively used textures.
  57236. * @param activeTextures Array of BaseTextures
  57237. */
  57238. getActiveTextures(activeTextures: BaseTexture[]): void;
  57239. /**
  57240. * Returns the animatable textures.
  57241. * @param animatables Array of animatable textures.
  57242. */
  57243. getAnimatables(animatables: IAnimatable[]): void;
  57244. /**
  57245. * Disposes the resources of the material.
  57246. * @param forceDisposeTextures - Forces the disposal of all textures.
  57247. */
  57248. dispose(forceDisposeTextures?: boolean): void;
  57249. /**
  57250. * Get the current class name of the texture useful for serialization or dynamic coding.
  57251. * @returns "PBRClearCoatConfiguration"
  57252. */
  57253. getClassName(): string;
  57254. /**
  57255. * Add fallbacks to the effect fallbacks list.
  57256. * @param defines defines the Base texture to use.
  57257. * @param fallbacks defines the current fallback list.
  57258. * @param currentRank defines the current fallback rank.
  57259. * @returns the new fallback rank.
  57260. */
  57261. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57262. /**
  57263. * Add the required uniforms to the current list.
  57264. * @param uniforms defines the current uniform list.
  57265. */
  57266. static AddUniforms(uniforms: string[]): void;
  57267. /**
  57268. * Add the required samplers to the current list.
  57269. * @param samplers defines the current sampler list.
  57270. */
  57271. static AddSamplers(samplers: string[]): void;
  57272. /**
  57273. * Add the required uniforms to the current buffer.
  57274. * @param uniformBuffer defines the current uniform buffer.
  57275. */
  57276. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57277. /**
  57278. * Makes a duplicate of the current configuration into another one.
  57279. * @param clearCoatConfiguration define the config where to copy the info
  57280. */
  57281. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57282. /**
  57283. * Serializes this clear coat configuration.
  57284. * @returns - An object with the serialized config.
  57285. */
  57286. serialize(): any;
  57287. /**
  57288. * Parses a anisotropy Configuration from a serialized object.
  57289. * @param source - Serialized object.
  57290. * @param scene Defines the scene we are parsing for
  57291. * @param rootUrl Defines the rootUrl to load from
  57292. */
  57293. parse(source: any, scene: Scene, rootUrl: string): void;
  57294. }
  57295. }
  57296. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57297. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57299. import { Vector2 } from "babylonjs/Maths/math.vector";
  57300. import { Scene } from "babylonjs/scene";
  57301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57302. import { Nullable } from "babylonjs/types";
  57303. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57304. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57305. /**
  57306. * @hidden
  57307. */
  57308. export interface IMaterialAnisotropicDefines {
  57309. ANISOTROPIC: boolean;
  57310. ANISOTROPIC_TEXTURE: boolean;
  57311. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57312. MAINUV1: boolean;
  57313. _areTexturesDirty: boolean;
  57314. _needUVs: boolean;
  57315. }
  57316. /**
  57317. * Define the code related to the anisotropic parameters of the pbr material.
  57318. */
  57319. export class PBRAnisotropicConfiguration {
  57320. private _isEnabled;
  57321. /**
  57322. * Defines if the anisotropy is enabled in the material.
  57323. */
  57324. isEnabled: boolean;
  57325. /**
  57326. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57327. */
  57328. intensity: number;
  57329. /**
  57330. * Defines if the effect is along the tangents, bitangents or in between.
  57331. * By default, the effect is "strectching" the highlights along the tangents.
  57332. */
  57333. direction: Vector2;
  57334. private _texture;
  57335. /**
  57336. * Stores the anisotropy values in a texture.
  57337. * rg is direction (like normal from -1 to 1)
  57338. * b is a intensity
  57339. */
  57340. texture: Nullable<BaseTexture>;
  57341. /** @hidden */
  57342. private _internalMarkAllSubMeshesAsTexturesDirty;
  57343. /** @hidden */
  57344. _markAllSubMeshesAsTexturesDirty(): void;
  57345. /**
  57346. * Instantiate a new istance of anisotropy configuration.
  57347. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57348. */
  57349. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57350. /**
  57351. * Specifies that the submesh is ready to be used.
  57352. * @param defines the list of "defines" to update.
  57353. * @param scene defines the scene the material belongs to.
  57354. * @returns - boolean indicating that the submesh is ready or not.
  57355. */
  57356. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57357. /**
  57358. * Checks to see if a texture is used in the material.
  57359. * @param defines the list of "defines" to update.
  57360. * @param mesh the mesh we are preparing the defines for.
  57361. * @param scene defines the scene the material belongs to.
  57362. */
  57363. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57364. /**
  57365. * Binds the material data.
  57366. * @param uniformBuffer defines the Uniform buffer to fill in.
  57367. * @param scene defines the scene the material belongs to.
  57368. * @param isFrozen defines wether the material is frozen or not.
  57369. */
  57370. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57371. /**
  57372. * Checks to see if a texture is used in the material.
  57373. * @param texture - Base texture to use.
  57374. * @returns - Boolean specifying if a texture is used in the material.
  57375. */
  57376. hasTexture(texture: BaseTexture): boolean;
  57377. /**
  57378. * Returns an array of the actively used textures.
  57379. * @param activeTextures Array of BaseTextures
  57380. */
  57381. getActiveTextures(activeTextures: BaseTexture[]): void;
  57382. /**
  57383. * Returns the animatable textures.
  57384. * @param animatables Array of animatable textures.
  57385. */
  57386. getAnimatables(animatables: IAnimatable[]): void;
  57387. /**
  57388. * Disposes the resources of the material.
  57389. * @param forceDisposeTextures - Forces the disposal of all textures.
  57390. */
  57391. dispose(forceDisposeTextures?: boolean): void;
  57392. /**
  57393. * Get the current class name of the texture useful for serialization or dynamic coding.
  57394. * @returns "PBRAnisotropicConfiguration"
  57395. */
  57396. getClassName(): string;
  57397. /**
  57398. * Add fallbacks to the effect fallbacks list.
  57399. * @param defines defines the Base texture to use.
  57400. * @param fallbacks defines the current fallback list.
  57401. * @param currentRank defines the current fallback rank.
  57402. * @returns the new fallback rank.
  57403. */
  57404. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57405. /**
  57406. * Add the required uniforms to the current list.
  57407. * @param uniforms defines the current uniform list.
  57408. */
  57409. static AddUniforms(uniforms: string[]): void;
  57410. /**
  57411. * Add the required uniforms to the current buffer.
  57412. * @param uniformBuffer defines the current uniform buffer.
  57413. */
  57414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57415. /**
  57416. * Add the required samplers to the current list.
  57417. * @param samplers defines the current sampler list.
  57418. */
  57419. static AddSamplers(samplers: string[]): void;
  57420. /**
  57421. * Makes a duplicate of the current configuration into another one.
  57422. * @param anisotropicConfiguration define the config where to copy the info
  57423. */
  57424. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57425. /**
  57426. * Serializes this anisotropy configuration.
  57427. * @returns - An object with the serialized config.
  57428. */
  57429. serialize(): any;
  57430. /**
  57431. * Parses a anisotropy Configuration from a serialized object.
  57432. * @param source - Serialized object.
  57433. * @param scene Defines the scene we are parsing for
  57434. * @param rootUrl Defines the rootUrl to load from
  57435. */
  57436. parse(source: any, scene: Scene, rootUrl: string): void;
  57437. }
  57438. }
  57439. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57440. import { Scene } from "babylonjs/scene";
  57441. /**
  57442. * @hidden
  57443. */
  57444. export interface IMaterialBRDFDefines {
  57445. BRDF_V_HEIGHT_CORRELATED: boolean;
  57446. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57447. SPHERICAL_HARMONICS: boolean;
  57448. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57449. /** @hidden */
  57450. _areMiscDirty: boolean;
  57451. }
  57452. /**
  57453. * Define the code related to the BRDF parameters of the pbr material.
  57454. */
  57455. export class PBRBRDFConfiguration {
  57456. /**
  57457. * Default value used for the energy conservation.
  57458. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57459. */
  57460. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57461. /**
  57462. * Default value used for the Smith Visibility Height Correlated mode.
  57463. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57464. */
  57465. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57466. /**
  57467. * Default value used for the IBL diffuse part.
  57468. * This can help switching back to the polynomials mode globally which is a tiny bit
  57469. * less GPU intensive at the drawback of a lower quality.
  57470. */
  57471. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57472. /**
  57473. * Default value used for activating energy conservation for the specular workflow.
  57474. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57475. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57476. */
  57477. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57478. private _useEnergyConservation;
  57479. /**
  57480. * Defines if the material uses energy conservation.
  57481. */
  57482. useEnergyConservation: boolean;
  57483. private _useSmithVisibilityHeightCorrelated;
  57484. /**
  57485. * LEGACY Mode set to false
  57486. * Defines if the material uses height smith correlated visibility term.
  57487. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57488. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57489. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57490. * Not relying on height correlated will also disable energy conservation.
  57491. */
  57492. useSmithVisibilityHeightCorrelated: boolean;
  57493. private _useSphericalHarmonics;
  57494. /**
  57495. * LEGACY Mode set to false
  57496. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57497. * diffuse part of the IBL.
  57498. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57499. * to the ground truth.
  57500. */
  57501. useSphericalHarmonics: boolean;
  57502. private _useSpecularGlossinessInputEnergyConservation;
  57503. /**
  57504. * Defines if the material uses energy conservation, when the specular workflow is active.
  57505. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57506. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57507. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57508. */
  57509. useSpecularGlossinessInputEnergyConservation: boolean;
  57510. /** @hidden */
  57511. private _internalMarkAllSubMeshesAsMiscDirty;
  57512. /** @hidden */
  57513. _markAllSubMeshesAsMiscDirty(): void;
  57514. /**
  57515. * Instantiate a new istance of clear coat configuration.
  57516. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57517. */
  57518. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57519. /**
  57520. * Checks to see if a texture is used in the material.
  57521. * @param defines the list of "defines" to update.
  57522. */
  57523. prepareDefines(defines: IMaterialBRDFDefines): void;
  57524. /**
  57525. * Get the current class name of the texture useful for serialization or dynamic coding.
  57526. * @returns "PBRClearCoatConfiguration"
  57527. */
  57528. getClassName(): string;
  57529. /**
  57530. * Makes a duplicate of the current configuration into another one.
  57531. * @param brdfConfiguration define the config where to copy the info
  57532. */
  57533. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57534. /**
  57535. * Serializes this BRDF configuration.
  57536. * @returns - An object with the serialized config.
  57537. */
  57538. serialize(): any;
  57539. /**
  57540. * Parses a anisotropy Configuration from a serialized object.
  57541. * @param source - Serialized object.
  57542. * @param scene Defines the scene we are parsing for
  57543. * @param rootUrl Defines the rootUrl to load from
  57544. */
  57545. parse(source: any, scene: Scene, rootUrl: string): void;
  57546. }
  57547. }
  57548. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57549. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57550. import { Color3 } from "babylonjs/Maths/math.color";
  57551. import { Scene } from "babylonjs/scene";
  57552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57553. import { Nullable } from "babylonjs/types";
  57554. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57555. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57556. /**
  57557. * @hidden
  57558. */
  57559. export interface IMaterialSheenDefines {
  57560. SHEEN: boolean;
  57561. SHEEN_TEXTURE: boolean;
  57562. SHEEN_TEXTUREDIRECTUV: number;
  57563. SHEEN_LINKWITHALBEDO: boolean;
  57564. SHEEN_ROUGHNESS: boolean;
  57565. SHEEN_ALBEDOSCALING: boolean;
  57566. /** @hidden */
  57567. _areTexturesDirty: boolean;
  57568. }
  57569. /**
  57570. * Define the code related to the Sheen parameters of the pbr material.
  57571. */
  57572. export class PBRSheenConfiguration {
  57573. private _isEnabled;
  57574. /**
  57575. * Defines if the material uses sheen.
  57576. */
  57577. isEnabled: boolean;
  57578. private _linkSheenWithAlbedo;
  57579. /**
  57580. * Defines if the sheen is linked to the sheen color.
  57581. */
  57582. linkSheenWithAlbedo: boolean;
  57583. /**
  57584. * Defines the sheen intensity.
  57585. */
  57586. intensity: number;
  57587. /**
  57588. * Defines the sheen color.
  57589. */
  57590. color: Color3;
  57591. private _texture;
  57592. /**
  57593. * Stores the sheen tint values in a texture.
  57594. * rgb is tint
  57595. * a is a intensity or roughness if roughness has been defined
  57596. */
  57597. texture: Nullable<BaseTexture>;
  57598. private _roughness;
  57599. /**
  57600. * Defines the sheen roughness.
  57601. * It is not taken into account if linkSheenWithAlbedo is true.
  57602. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57603. */
  57604. roughness: Nullable<number>;
  57605. private _albedoScaling;
  57606. /**
  57607. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57608. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57609. * making it easier to setup and tweak the effect
  57610. */
  57611. albedoScaling: boolean;
  57612. /** @hidden */
  57613. private _internalMarkAllSubMeshesAsTexturesDirty;
  57614. /** @hidden */
  57615. _markAllSubMeshesAsTexturesDirty(): void;
  57616. /**
  57617. * Instantiate a new istance of clear coat configuration.
  57618. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57619. */
  57620. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57621. /**
  57622. * Specifies that the submesh is ready to be used.
  57623. * @param defines the list of "defines" to update.
  57624. * @param scene defines the scene the material belongs to.
  57625. * @returns - boolean indicating that the submesh is ready or not.
  57626. */
  57627. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57628. /**
  57629. * Checks to see if a texture is used in the material.
  57630. * @param defines the list of "defines" to update.
  57631. * @param scene defines the scene the material belongs to.
  57632. */
  57633. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57634. /**
  57635. * Binds the material data.
  57636. * @param uniformBuffer defines the Uniform buffer to fill in.
  57637. * @param scene defines the scene the material belongs to.
  57638. * @param isFrozen defines wether the material is frozen or not.
  57639. */
  57640. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57641. /**
  57642. * Checks to see if a texture is used in the material.
  57643. * @param texture - Base texture to use.
  57644. * @returns - Boolean specifying if a texture is used in the material.
  57645. */
  57646. hasTexture(texture: BaseTexture): boolean;
  57647. /**
  57648. * Returns an array of the actively used textures.
  57649. * @param activeTextures Array of BaseTextures
  57650. */
  57651. getActiveTextures(activeTextures: BaseTexture[]): void;
  57652. /**
  57653. * Returns the animatable textures.
  57654. * @param animatables Array of animatable textures.
  57655. */
  57656. getAnimatables(animatables: IAnimatable[]): void;
  57657. /**
  57658. * Disposes the resources of the material.
  57659. * @param forceDisposeTextures - Forces the disposal of all textures.
  57660. */
  57661. dispose(forceDisposeTextures?: boolean): void;
  57662. /**
  57663. * Get the current class name of the texture useful for serialization or dynamic coding.
  57664. * @returns "PBRSheenConfiguration"
  57665. */
  57666. getClassName(): string;
  57667. /**
  57668. * Add fallbacks to the effect fallbacks list.
  57669. * @param defines defines the Base texture to use.
  57670. * @param fallbacks defines the current fallback list.
  57671. * @param currentRank defines the current fallback rank.
  57672. * @returns the new fallback rank.
  57673. */
  57674. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57675. /**
  57676. * Add the required uniforms to the current list.
  57677. * @param uniforms defines the current uniform list.
  57678. */
  57679. static AddUniforms(uniforms: string[]): void;
  57680. /**
  57681. * Add the required uniforms to the current buffer.
  57682. * @param uniformBuffer defines the current uniform buffer.
  57683. */
  57684. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57685. /**
  57686. * Add the required samplers to the current list.
  57687. * @param samplers defines the current sampler list.
  57688. */
  57689. static AddSamplers(samplers: string[]): void;
  57690. /**
  57691. * Makes a duplicate of the current configuration into another one.
  57692. * @param sheenConfiguration define the config where to copy the info
  57693. */
  57694. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57695. /**
  57696. * Serializes this BRDF configuration.
  57697. * @returns - An object with the serialized config.
  57698. */
  57699. serialize(): any;
  57700. /**
  57701. * Parses a anisotropy Configuration from a serialized object.
  57702. * @param source - Serialized object.
  57703. * @param scene Defines the scene we are parsing for
  57704. * @param rootUrl Defines the rootUrl to load from
  57705. */
  57706. parse(source: any, scene: Scene, rootUrl: string): void;
  57707. }
  57708. }
  57709. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57710. import { Nullable } from "babylonjs/types";
  57711. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57712. import { Color3 } from "babylonjs/Maths/math.color";
  57713. import { SmartArray } from "babylonjs/Misc/smartArray";
  57714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57715. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57716. import { Effect } from "babylonjs/Materials/effect";
  57717. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57718. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57719. import { Engine } from "babylonjs/Engines/engine";
  57720. import { Scene } from "babylonjs/scene";
  57721. /**
  57722. * @hidden
  57723. */
  57724. export interface IMaterialSubSurfaceDefines {
  57725. SUBSURFACE: boolean;
  57726. SS_REFRACTION: boolean;
  57727. SS_TRANSLUCENCY: boolean;
  57728. SS_SCATTERING: boolean;
  57729. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57730. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57731. SS_REFRACTIONMAP_3D: boolean;
  57732. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57733. SS_LODINREFRACTIONALPHA: boolean;
  57734. SS_GAMMAREFRACTION: boolean;
  57735. SS_RGBDREFRACTION: boolean;
  57736. SS_LINEARSPECULARREFRACTION: boolean;
  57737. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57738. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57739. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57740. /** @hidden */
  57741. _areTexturesDirty: boolean;
  57742. }
  57743. /**
  57744. * Define the code related to the sub surface parameters of the pbr material.
  57745. */
  57746. export class PBRSubSurfaceConfiguration {
  57747. private _isRefractionEnabled;
  57748. /**
  57749. * Defines if the refraction is enabled in the material.
  57750. */
  57751. isRefractionEnabled: boolean;
  57752. private _isTranslucencyEnabled;
  57753. /**
  57754. * Defines if the translucency is enabled in the material.
  57755. */
  57756. isTranslucencyEnabled: boolean;
  57757. private _isScatteringEnabled;
  57758. /**
  57759. * Defines if the sub surface scattering is enabled in the material.
  57760. */
  57761. isScatteringEnabled: boolean;
  57762. private _scatteringDiffusionProfileIndex;
  57763. /**
  57764. * Diffusion profile for subsurface scattering.
  57765. * Useful for better scattering in the skins or foliages.
  57766. */
  57767. get scatteringDiffusionProfile(): Nullable<Color3>;
  57768. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57769. /**
  57770. * Defines the refraction intensity of the material.
  57771. * The refraction when enabled replaces the Diffuse part of the material.
  57772. * The intensity helps transitionning between diffuse and refraction.
  57773. */
  57774. refractionIntensity: number;
  57775. /**
  57776. * Defines the translucency intensity of the material.
  57777. * When translucency has been enabled, this defines how much of the "translucency"
  57778. * is addded to the diffuse part of the material.
  57779. */
  57780. translucencyIntensity: number;
  57781. /**
  57782. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57783. */
  57784. useAlbedoToTintRefraction: boolean;
  57785. private _thicknessTexture;
  57786. /**
  57787. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57788. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57789. * 0 would mean minimumThickness
  57790. * 1 would mean maximumThickness
  57791. * The other channels might be use as a mask to vary the different effects intensity.
  57792. */
  57793. thicknessTexture: Nullable<BaseTexture>;
  57794. private _refractionTexture;
  57795. /**
  57796. * Defines the texture to use for refraction.
  57797. */
  57798. refractionTexture: Nullable<BaseTexture>;
  57799. private _indexOfRefraction;
  57800. /**
  57801. * Index of refraction of the material base layer.
  57802. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57803. *
  57804. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57805. *
  57806. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57807. */
  57808. indexOfRefraction: number;
  57809. private _volumeIndexOfRefraction;
  57810. /**
  57811. * Index of refraction of the material's volume.
  57812. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57813. *
  57814. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57815. * the volume will use the same IOR as the surface.
  57816. */
  57817. get volumeIndexOfRefraction(): number;
  57818. set volumeIndexOfRefraction(value: number);
  57819. private _invertRefractionY;
  57820. /**
  57821. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57822. */
  57823. invertRefractionY: boolean;
  57824. private _linkRefractionWithTransparency;
  57825. /**
  57826. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57827. * Materials half opaque for instance using refraction could benefit from this control.
  57828. */
  57829. linkRefractionWithTransparency: boolean;
  57830. /**
  57831. * Defines the minimum thickness stored in the thickness map.
  57832. * If no thickness map is defined, this value will be used to simulate thickness.
  57833. */
  57834. minimumThickness: number;
  57835. /**
  57836. * Defines the maximum thickness stored in the thickness map.
  57837. */
  57838. maximumThickness: number;
  57839. /**
  57840. * Defines the volume tint of the material.
  57841. * This is used for both translucency and scattering.
  57842. */
  57843. tintColor: Color3;
  57844. /**
  57845. * Defines the distance at which the tint color should be found in the media.
  57846. * This is used for refraction only.
  57847. */
  57848. tintColorAtDistance: number;
  57849. /**
  57850. * Defines how far each channel transmit through the media.
  57851. * It is defined as a color to simplify it selection.
  57852. */
  57853. diffusionDistance: Color3;
  57854. private _useMaskFromThicknessTexture;
  57855. /**
  57856. * Stores the intensity of the different subsurface effects in the thickness texture.
  57857. * * the green channel is the translucency intensity.
  57858. * * the blue channel is the scattering intensity.
  57859. * * the alpha channel is the refraction intensity.
  57860. */
  57861. useMaskFromThicknessTexture: boolean;
  57862. private _scene;
  57863. /** @hidden */
  57864. private _internalMarkAllSubMeshesAsTexturesDirty;
  57865. private _internalMarkScenePrePassDirty;
  57866. /** @hidden */
  57867. _markAllSubMeshesAsTexturesDirty(): void;
  57868. /** @hidden */
  57869. _markScenePrePassDirty(): void;
  57870. /**
  57871. * Instantiate a new istance of sub surface configuration.
  57872. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57873. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57874. * @param scene The scene
  57875. */
  57876. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57877. /**
  57878. * Gets wehter the submesh is ready to be used or not.
  57879. * @param defines the list of "defines" to update.
  57880. * @param scene defines the scene the material belongs to.
  57881. * @returns - boolean indicating that the submesh is ready or not.
  57882. */
  57883. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57884. /**
  57885. * Checks to see if a texture is used in the material.
  57886. * @param defines the list of "defines" to update.
  57887. * @param scene defines the scene to the material belongs to.
  57888. */
  57889. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57890. /**
  57891. * Binds the material data.
  57892. * @param uniformBuffer defines the Uniform buffer to fill in.
  57893. * @param scene defines the scene the material belongs to.
  57894. * @param engine defines the engine the material belongs to.
  57895. * @param isFrozen defines whether the material is frozen or not.
  57896. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57897. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57898. */
  57899. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57900. /**
  57901. * Unbinds the material from the mesh.
  57902. * @param activeEffect defines the effect that should be unbound from.
  57903. * @returns true if unbound, otherwise false
  57904. */
  57905. unbind(activeEffect: Effect): boolean;
  57906. /**
  57907. * Returns the texture used for refraction or null if none is used.
  57908. * @param scene defines the scene the material belongs to.
  57909. * @returns - Refraction texture if present. If no refraction texture and refraction
  57910. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57911. */
  57912. private _getRefractionTexture;
  57913. /**
  57914. * Returns true if alpha blending should be disabled.
  57915. */
  57916. get disableAlphaBlending(): boolean;
  57917. /**
  57918. * Fills the list of render target textures.
  57919. * @param renderTargets the list of render targets to update
  57920. */
  57921. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57922. /**
  57923. * Checks to see if a texture is used in the material.
  57924. * @param texture - Base texture to use.
  57925. * @returns - Boolean specifying if a texture is used in the material.
  57926. */
  57927. hasTexture(texture: BaseTexture): boolean;
  57928. /**
  57929. * Gets a boolean indicating that current material needs to register RTT
  57930. * @returns true if this uses a render target otherwise false.
  57931. */
  57932. hasRenderTargetTextures(): boolean;
  57933. /**
  57934. * Returns an array of the actively used textures.
  57935. * @param activeTextures Array of BaseTextures
  57936. */
  57937. getActiveTextures(activeTextures: BaseTexture[]): void;
  57938. /**
  57939. * Returns the animatable textures.
  57940. * @param animatables Array of animatable textures.
  57941. */
  57942. getAnimatables(animatables: IAnimatable[]): void;
  57943. /**
  57944. * Disposes the resources of the material.
  57945. * @param forceDisposeTextures - Forces the disposal of all textures.
  57946. */
  57947. dispose(forceDisposeTextures?: boolean): void;
  57948. /**
  57949. * Get the current class name of the texture useful for serialization or dynamic coding.
  57950. * @returns "PBRSubSurfaceConfiguration"
  57951. */
  57952. getClassName(): string;
  57953. /**
  57954. * Add fallbacks to the effect fallbacks list.
  57955. * @param defines defines the Base texture to use.
  57956. * @param fallbacks defines the current fallback list.
  57957. * @param currentRank defines the current fallback rank.
  57958. * @returns the new fallback rank.
  57959. */
  57960. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57961. /**
  57962. * Add the required uniforms to the current list.
  57963. * @param uniforms defines the current uniform list.
  57964. */
  57965. static AddUniforms(uniforms: string[]): void;
  57966. /**
  57967. * Add the required samplers to the current list.
  57968. * @param samplers defines the current sampler list.
  57969. */
  57970. static AddSamplers(samplers: string[]): void;
  57971. /**
  57972. * Add the required uniforms to the current buffer.
  57973. * @param uniformBuffer defines the current uniform buffer.
  57974. */
  57975. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57976. /**
  57977. * Makes a duplicate of the current configuration into another one.
  57978. * @param configuration define the config where to copy the info
  57979. */
  57980. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57981. /**
  57982. * Serializes this Sub Surface configuration.
  57983. * @returns - An object with the serialized config.
  57984. */
  57985. serialize(): any;
  57986. /**
  57987. * Parses a anisotropy Configuration from a serialized object.
  57988. * @param source - Serialized object.
  57989. * @param scene Defines the scene we are parsing for
  57990. * @param rootUrl Defines the rootUrl to load from
  57991. */
  57992. parse(source: any, scene: Scene, rootUrl: string): void;
  57993. }
  57994. }
  57995. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57996. /** @hidden */
  57997. export var pbrFragmentDeclaration: {
  57998. name: string;
  57999. shader: string;
  58000. };
  58001. }
  58002. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58003. /** @hidden */
  58004. export var pbrUboDeclaration: {
  58005. name: string;
  58006. shader: string;
  58007. };
  58008. }
  58009. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58010. /** @hidden */
  58011. export var pbrFragmentExtraDeclaration: {
  58012. name: string;
  58013. shader: string;
  58014. };
  58015. }
  58016. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58017. /** @hidden */
  58018. export var pbrFragmentSamplersDeclaration: {
  58019. name: string;
  58020. shader: string;
  58021. };
  58022. }
  58023. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58024. /** @hidden */
  58025. export var importanceSampling: {
  58026. name: string;
  58027. shader: string;
  58028. };
  58029. }
  58030. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58031. /** @hidden */
  58032. export var pbrHelperFunctions: {
  58033. name: string;
  58034. shader: string;
  58035. };
  58036. }
  58037. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58038. /** @hidden */
  58039. export var harmonicsFunctions: {
  58040. name: string;
  58041. shader: string;
  58042. };
  58043. }
  58044. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58045. /** @hidden */
  58046. export var pbrDirectLightingSetupFunctions: {
  58047. name: string;
  58048. shader: string;
  58049. };
  58050. }
  58051. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58052. /** @hidden */
  58053. export var pbrDirectLightingFalloffFunctions: {
  58054. name: string;
  58055. shader: string;
  58056. };
  58057. }
  58058. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58059. /** @hidden */
  58060. export var pbrBRDFFunctions: {
  58061. name: string;
  58062. shader: string;
  58063. };
  58064. }
  58065. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58066. /** @hidden */
  58067. export var hdrFilteringFunctions: {
  58068. name: string;
  58069. shader: string;
  58070. };
  58071. }
  58072. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58073. /** @hidden */
  58074. export var pbrDirectLightingFunctions: {
  58075. name: string;
  58076. shader: string;
  58077. };
  58078. }
  58079. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58080. /** @hidden */
  58081. export var pbrIBLFunctions: {
  58082. name: string;
  58083. shader: string;
  58084. };
  58085. }
  58086. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58087. /** @hidden */
  58088. export var pbrBlockAlbedoOpacity: {
  58089. name: string;
  58090. shader: string;
  58091. };
  58092. }
  58093. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58094. /** @hidden */
  58095. export var pbrBlockReflectivity: {
  58096. name: string;
  58097. shader: string;
  58098. };
  58099. }
  58100. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58101. /** @hidden */
  58102. export var pbrBlockAmbientOcclusion: {
  58103. name: string;
  58104. shader: string;
  58105. };
  58106. }
  58107. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58108. /** @hidden */
  58109. export var pbrBlockAlphaFresnel: {
  58110. name: string;
  58111. shader: string;
  58112. };
  58113. }
  58114. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58115. /** @hidden */
  58116. export var pbrBlockAnisotropic: {
  58117. name: string;
  58118. shader: string;
  58119. };
  58120. }
  58121. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58122. /** @hidden */
  58123. export var pbrBlockReflection: {
  58124. name: string;
  58125. shader: string;
  58126. };
  58127. }
  58128. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58129. /** @hidden */
  58130. export var pbrBlockSheen: {
  58131. name: string;
  58132. shader: string;
  58133. };
  58134. }
  58135. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58136. /** @hidden */
  58137. export var pbrBlockClearcoat: {
  58138. name: string;
  58139. shader: string;
  58140. };
  58141. }
  58142. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58143. /** @hidden */
  58144. export var pbrBlockSubSurface: {
  58145. name: string;
  58146. shader: string;
  58147. };
  58148. }
  58149. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58150. /** @hidden */
  58151. export var pbrBlockNormalGeometric: {
  58152. name: string;
  58153. shader: string;
  58154. };
  58155. }
  58156. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58157. /** @hidden */
  58158. export var pbrBlockNormalFinal: {
  58159. name: string;
  58160. shader: string;
  58161. };
  58162. }
  58163. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58164. /** @hidden */
  58165. export var pbrBlockLightmapInit: {
  58166. name: string;
  58167. shader: string;
  58168. };
  58169. }
  58170. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58171. /** @hidden */
  58172. export var pbrBlockGeometryInfo: {
  58173. name: string;
  58174. shader: string;
  58175. };
  58176. }
  58177. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58178. /** @hidden */
  58179. export var pbrBlockReflectance0: {
  58180. name: string;
  58181. shader: string;
  58182. };
  58183. }
  58184. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58185. /** @hidden */
  58186. export var pbrBlockReflectance: {
  58187. name: string;
  58188. shader: string;
  58189. };
  58190. }
  58191. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58192. /** @hidden */
  58193. export var pbrBlockDirectLighting: {
  58194. name: string;
  58195. shader: string;
  58196. };
  58197. }
  58198. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58199. /** @hidden */
  58200. export var pbrBlockFinalLitComponents: {
  58201. name: string;
  58202. shader: string;
  58203. };
  58204. }
  58205. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58206. /** @hidden */
  58207. export var pbrBlockFinalUnlitComponents: {
  58208. name: string;
  58209. shader: string;
  58210. };
  58211. }
  58212. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58213. /** @hidden */
  58214. export var pbrBlockFinalColorComposition: {
  58215. name: string;
  58216. shader: string;
  58217. };
  58218. }
  58219. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58220. /** @hidden */
  58221. export var pbrBlockImageProcessing: {
  58222. name: string;
  58223. shader: string;
  58224. };
  58225. }
  58226. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58227. /** @hidden */
  58228. export var pbrDebug: {
  58229. name: string;
  58230. shader: string;
  58231. };
  58232. }
  58233. declare module "babylonjs/Shaders/pbr.fragment" {
  58234. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58235. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58236. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58237. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58238. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58239. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58240. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58241. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58242. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58243. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58244. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58245. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58246. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58247. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58248. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58249. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58250. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58251. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58252. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58253. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58254. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58255. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58256. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58257. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58258. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58259. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58260. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58261. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58262. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58263. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58264. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58265. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58266. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58267. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58268. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58269. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58270. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58271. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58272. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58273. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58274. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58275. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58276. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58277. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58278. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58279. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58280. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58281. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58282. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58283. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58284. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58285. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58286. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58287. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58288. /** @hidden */
  58289. export var pbrPixelShader: {
  58290. name: string;
  58291. shader: string;
  58292. };
  58293. }
  58294. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58295. /** @hidden */
  58296. export var pbrVertexDeclaration: {
  58297. name: string;
  58298. shader: string;
  58299. };
  58300. }
  58301. declare module "babylonjs/Shaders/pbr.vertex" {
  58302. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58303. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58304. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58305. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58306. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58307. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58308. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58309. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58310. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58311. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58312. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58313. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58314. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58315. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58316. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58317. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58318. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58319. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58320. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58321. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58322. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58323. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58324. /** @hidden */
  58325. export var pbrVertexShader: {
  58326. name: string;
  58327. shader: string;
  58328. };
  58329. }
  58330. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58331. import { Nullable } from "babylonjs/types";
  58332. import { Scene } from "babylonjs/scene";
  58333. import { Matrix } from "babylonjs/Maths/math.vector";
  58334. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58336. import { Mesh } from "babylonjs/Meshes/mesh";
  58337. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58338. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58339. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58340. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58341. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58342. import { Color3 } from "babylonjs/Maths/math.color";
  58343. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58344. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58345. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58346. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58347. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58348. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58349. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58350. import "babylonjs/Shaders/pbr.fragment";
  58351. import "babylonjs/Shaders/pbr.vertex";
  58352. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58353. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58354. /**
  58355. * Manages the defines for the PBR Material.
  58356. * @hidden
  58357. */
  58358. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58359. PBR: boolean;
  58360. NUM_SAMPLES: string;
  58361. REALTIME_FILTERING: boolean;
  58362. MAINUV1: boolean;
  58363. MAINUV2: boolean;
  58364. UV1: boolean;
  58365. UV2: boolean;
  58366. ALBEDO: boolean;
  58367. GAMMAALBEDO: boolean;
  58368. ALBEDODIRECTUV: number;
  58369. VERTEXCOLOR: boolean;
  58370. DETAIL: boolean;
  58371. DETAILDIRECTUV: number;
  58372. DETAIL_NORMALBLENDMETHOD: number;
  58373. AMBIENT: boolean;
  58374. AMBIENTDIRECTUV: number;
  58375. AMBIENTINGRAYSCALE: boolean;
  58376. OPACITY: boolean;
  58377. VERTEXALPHA: boolean;
  58378. OPACITYDIRECTUV: number;
  58379. OPACITYRGB: boolean;
  58380. ALPHATEST: boolean;
  58381. DEPTHPREPASS: boolean;
  58382. ALPHABLEND: boolean;
  58383. ALPHAFROMALBEDO: boolean;
  58384. ALPHATESTVALUE: string;
  58385. SPECULAROVERALPHA: boolean;
  58386. RADIANCEOVERALPHA: boolean;
  58387. ALPHAFRESNEL: boolean;
  58388. LINEARALPHAFRESNEL: boolean;
  58389. PREMULTIPLYALPHA: boolean;
  58390. EMISSIVE: boolean;
  58391. EMISSIVEDIRECTUV: number;
  58392. REFLECTIVITY: boolean;
  58393. REFLECTIVITYDIRECTUV: number;
  58394. SPECULARTERM: boolean;
  58395. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58396. MICROSURFACEAUTOMATIC: boolean;
  58397. LODBASEDMICROSFURACE: boolean;
  58398. MICROSURFACEMAP: boolean;
  58399. MICROSURFACEMAPDIRECTUV: number;
  58400. METALLICWORKFLOW: boolean;
  58401. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58402. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58403. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58404. AOSTOREINMETALMAPRED: boolean;
  58405. METALLIC_REFLECTANCE: boolean;
  58406. METALLIC_REFLECTANCEDIRECTUV: number;
  58407. ENVIRONMENTBRDF: boolean;
  58408. ENVIRONMENTBRDF_RGBD: boolean;
  58409. NORMAL: boolean;
  58410. TANGENT: boolean;
  58411. BUMP: boolean;
  58412. BUMPDIRECTUV: number;
  58413. OBJECTSPACE_NORMALMAP: boolean;
  58414. PARALLAX: boolean;
  58415. PARALLAXOCCLUSION: boolean;
  58416. NORMALXYSCALE: boolean;
  58417. LIGHTMAP: boolean;
  58418. LIGHTMAPDIRECTUV: number;
  58419. USELIGHTMAPASSHADOWMAP: boolean;
  58420. GAMMALIGHTMAP: boolean;
  58421. RGBDLIGHTMAP: boolean;
  58422. REFLECTION: boolean;
  58423. REFLECTIONMAP_3D: boolean;
  58424. REFLECTIONMAP_SPHERICAL: boolean;
  58425. REFLECTIONMAP_PLANAR: boolean;
  58426. REFLECTIONMAP_CUBIC: boolean;
  58427. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58428. REFLECTIONMAP_PROJECTION: boolean;
  58429. REFLECTIONMAP_SKYBOX: boolean;
  58430. REFLECTIONMAP_EXPLICIT: boolean;
  58431. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58432. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58433. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58434. INVERTCUBICMAP: boolean;
  58435. USESPHERICALFROMREFLECTIONMAP: boolean;
  58436. USEIRRADIANCEMAP: boolean;
  58437. SPHERICAL_HARMONICS: boolean;
  58438. USESPHERICALINVERTEX: boolean;
  58439. REFLECTIONMAP_OPPOSITEZ: boolean;
  58440. LODINREFLECTIONALPHA: boolean;
  58441. GAMMAREFLECTION: boolean;
  58442. RGBDREFLECTION: boolean;
  58443. LINEARSPECULARREFLECTION: boolean;
  58444. RADIANCEOCCLUSION: boolean;
  58445. HORIZONOCCLUSION: boolean;
  58446. INSTANCES: boolean;
  58447. THIN_INSTANCES: boolean;
  58448. PREPASS: boolean;
  58449. SCENE_MRT_COUNT: number;
  58450. NUM_BONE_INFLUENCERS: number;
  58451. BonesPerMesh: number;
  58452. BONETEXTURE: boolean;
  58453. NONUNIFORMSCALING: boolean;
  58454. MORPHTARGETS: boolean;
  58455. MORPHTARGETS_NORMAL: boolean;
  58456. MORPHTARGETS_TANGENT: boolean;
  58457. MORPHTARGETS_UV: boolean;
  58458. NUM_MORPH_INFLUENCERS: number;
  58459. IMAGEPROCESSING: boolean;
  58460. VIGNETTE: boolean;
  58461. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58462. VIGNETTEBLENDMODEOPAQUE: boolean;
  58463. TONEMAPPING: boolean;
  58464. TONEMAPPING_ACES: boolean;
  58465. CONTRAST: boolean;
  58466. COLORCURVES: boolean;
  58467. COLORGRADING: boolean;
  58468. COLORGRADING3D: boolean;
  58469. SAMPLER3DGREENDEPTH: boolean;
  58470. SAMPLER3DBGRMAP: boolean;
  58471. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58472. EXPOSURE: boolean;
  58473. MULTIVIEW: boolean;
  58474. USEPHYSICALLIGHTFALLOFF: boolean;
  58475. USEGLTFLIGHTFALLOFF: boolean;
  58476. TWOSIDEDLIGHTING: boolean;
  58477. SHADOWFLOAT: boolean;
  58478. CLIPPLANE: boolean;
  58479. CLIPPLANE2: boolean;
  58480. CLIPPLANE3: boolean;
  58481. CLIPPLANE4: boolean;
  58482. CLIPPLANE5: boolean;
  58483. CLIPPLANE6: boolean;
  58484. POINTSIZE: boolean;
  58485. FOG: boolean;
  58486. LOGARITHMICDEPTH: boolean;
  58487. FORCENORMALFORWARD: boolean;
  58488. SPECULARAA: boolean;
  58489. CLEARCOAT: boolean;
  58490. CLEARCOAT_DEFAULTIOR: boolean;
  58491. CLEARCOAT_TEXTURE: boolean;
  58492. CLEARCOAT_TEXTUREDIRECTUV: number;
  58493. CLEARCOAT_BUMP: boolean;
  58494. CLEARCOAT_BUMPDIRECTUV: number;
  58495. CLEARCOAT_TINT: boolean;
  58496. CLEARCOAT_TINT_TEXTURE: boolean;
  58497. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58498. ANISOTROPIC: boolean;
  58499. ANISOTROPIC_TEXTURE: boolean;
  58500. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58501. BRDF_V_HEIGHT_CORRELATED: boolean;
  58502. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58503. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58504. SHEEN: boolean;
  58505. SHEEN_TEXTURE: boolean;
  58506. SHEEN_TEXTUREDIRECTUV: number;
  58507. SHEEN_LINKWITHALBEDO: boolean;
  58508. SHEEN_ROUGHNESS: boolean;
  58509. SHEEN_ALBEDOSCALING: boolean;
  58510. SUBSURFACE: boolean;
  58511. SS_REFRACTION: boolean;
  58512. SS_TRANSLUCENCY: boolean;
  58513. SS_SCATTERING: boolean;
  58514. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58515. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58516. SS_REFRACTIONMAP_3D: boolean;
  58517. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58518. SS_LODINREFRACTIONALPHA: boolean;
  58519. SS_GAMMAREFRACTION: boolean;
  58520. SS_RGBDREFRACTION: boolean;
  58521. SS_LINEARSPECULARREFRACTION: boolean;
  58522. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58523. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58524. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58525. UNLIT: boolean;
  58526. DEBUGMODE: number;
  58527. /**
  58528. * Initializes the PBR Material defines.
  58529. */
  58530. constructor();
  58531. /**
  58532. * Resets the PBR Material defines.
  58533. */
  58534. reset(): void;
  58535. }
  58536. /**
  58537. * The Physically based material base class of BJS.
  58538. *
  58539. * This offers the main features of a standard PBR material.
  58540. * For more information, please refer to the documentation :
  58541. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58542. */
  58543. export abstract class PBRBaseMaterial extends PushMaterial {
  58544. /**
  58545. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58546. */
  58547. static readonly PBRMATERIAL_OPAQUE: number;
  58548. /**
  58549. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58550. */
  58551. static readonly PBRMATERIAL_ALPHATEST: number;
  58552. /**
  58553. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58554. */
  58555. static readonly PBRMATERIAL_ALPHABLEND: number;
  58556. /**
  58557. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58558. * They are also discarded below the alpha cutoff threshold to improve performances.
  58559. */
  58560. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58561. /**
  58562. * Defines the default value of how much AO map is occluding the analytical lights
  58563. * (point spot...).
  58564. */
  58565. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58566. /**
  58567. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58568. */
  58569. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58570. /**
  58571. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58572. * to enhance interoperability with other engines.
  58573. */
  58574. static readonly LIGHTFALLOFF_GLTF: number;
  58575. /**
  58576. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58577. * to enhance interoperability with other materials.
  58578. */
  58579. static readonly LIGHTFALLOFF_STANDARD: number;
  58580. /**
  58581. * Intensity of the direct lights e.g. the four lights available in your scene.
  58582. * This impacts both the direct diffuse and specular highlights.
  58583. */
  58584. protected _directIntensity: number;
  58585. /**
  58586. * Intensity of the emissive part of the material.
  58587. * This helps controlling the emissive effect without modifying the emissive color.
  58588. */
  58589. protected _emissiveIntensity: number;
  58590. /**
  58591. * Intensity of the environment e.g. how much the environment will light the object
  58592. * either through harmonics for rough material or through the refelction for shiny ones.
  58593. */
  58594. protected _environmentIntensity: number;
  58595. /**
  58596. * This is a special control allowing the reduction of the specular highlights coming from the
  58597. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58598. */
  58599. protected _specularIntensity: number;
  58600. /**
  58601. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58602. */
  58603. private _lightingInfos;
  58604. /**
  58605. * Debug Control allowing disabling the bump map on this material.
  58606. */
  58607. protected _disableBumpMap: boolean;
  58608. /**
  58609. * AKA Diffuse Texture in standard nomenclature.
  58610. */
  58611. protected _albedoTexture: Nullable<BaseTexture>;
  58612. /**
  58613. * AKA Occlusion Texture in other nomenclature.
  58614. */
  58615. protected _ambientTexture: Nullable<BaseTexture>;
  58616. /**
  58617. * AKA Occlusion Texture Intensity in other nomenclature.
  58618. */
  58619. protected _ambientTextureStrength: number;
  58620. /**
  58621. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58622. * 1 means it completely occludes it
  58623. * 0 mean it has no impact
  58624. */
  58625. protected _ambientTextureImpactOnAnalyticalLights: number;
  58626. /**
  58627. * Stores the alpha values in a texture.
  58628. */
  58629. protected _opacityTexture: Nullable<BaseTexture>;
  58630. /**
  58631. * Stores the reflection values in a texture.
  58632. */
  58633. protected _reflectionTexture: Nullable<BaseTexture>;
  58634. /**
  58635. * Stores the emissive values in a texture.
  58636. */
  58637. protected _emissiveTexture: Nullable<BaseTexture>;
  58638. /**
  58639. * AKA Specular texture in other nomenclature.
  58640. */
  58641. protected _reflectivityTexture: Nullable<BaseTexture>;
  58642. /**
  58643. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58644. */
  58645. protected _metallicTexture: Nullable<BaseTexture>;
  58646. /**
  58647. * Specifies the metallic scalar of the metallic/roughness workflow.
  58648. * Can also be used to scale the metalness values of the metallic texture.
  58649. */
  58650. protected _metallic: Nullable<number>;
  58651. /**
  58652. * Specifies the roughness scalar of the metallic/roughness workflow.
  58653. * Can also be used to scale the roughness values of the metallic texture.
  58654. */
  58655. protected _roughness: Nullable<number>;
  58656. /**
  58657. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58658. * By default the indexOfrefraction is used to compute F0;
  58659. *
  58660. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58661. *
  58662. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58663. * F90 = metallicReflectanceColor;
  58664. */
  58665. protected _metallicF0Factor: number;
  58666. /**
  58667. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58668. * By default the F90 is always 1;
  58669. *
  58670. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58671. *
  58672. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58673. * F90 = metallicReflectanceColor;
  58674. */
  58675. protected _metallicReflectanceColor: Color3;
  58676. /**
  58677. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58678. * This is multiply against the scalar values defined in the material.
  58679. */
  58680. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58681. /**
  58682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58684. */
  58685. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58686. /**
  58687. * Stores surface normal data used to displace a mesh in a texture.
  58688. */
  58689. protected _bumpTexture: Nullable<BaseTexture>;
  58690. /**
  58691. * Stores the pre-calculated light information of a mesh in a texture.
  58692. */
  58693. protected _lightmapTexture: Nullable<BaseTexture>;
  58694. /**
  58695. * The color of a material in ambient lighting.
  58696. */
  58697. protected _ambientColor: Color3;
  58698. /**
  58699. * AKA Diffuse Color in other nomenclature.
  58700. */
  58701. protected _albedoColor: Color3;
  58702. /**
  58703. * AKA Specular Color in other nomenclature.
  58704. */
  58705. protected _reflectivityColor: Color3;
  58706. /**
  58707. * The color applied when light is reflected from a material.
  58708. */
  58709. protected _reflectionColor: Color3;
  58710. /**
  58711. * The color applied when light is emitted from a material.
  58712. */
  58713. protected _emissiveColor: Color3;
  58714. /**
  58715. * AKA Glossiness in other nomenclature.
  58716. */
  58717. protected _microSurface: number;
  58718. /**
  58719. * Specifies that the material will use the light map as a show map.
  58720. */
  58721. protected _useLightmapAsShadowmap: boolean;
  58722. /**
  58723. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58724. * makes the reflect vector face the model (under horizon).
  58725. */
  58726. protected _useHorizonOcclusion: boolean;
  58727. /**
  58728. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58729. * too much the area relying on ambient texture to define their ambient occlusion.
  58730. */
  58731. protected _useRadianceOcclusion: boolean;
  58732. /**
  58733. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58734. */
  58735. protected _useAlphaFromAlbedoTexture: boolean;
  58736. /**
  58737. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58738. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58739. */
  58740. protected _useSpecularOverAlpha: boolean;
  58741. /**
  58742. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58743. */
  58744. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58745. /**
  58746. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58747. */
  58748. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58749. /**
  58750. * Specifies if the metallic texture contains the roughness information in its green channel.
  58751. */
  58752. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58753. /**
  58754. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58755. */
  58756. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58757. /**
  58758. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58759. */
  58760. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58761. /**
  58762. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58763. */
  58764. protected _useAmbientInGrayScale: boolean;
  58765. /**
  58766. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58767. * The material will try to infer what glossiness each pixel should be.
  58768. */
  58769. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58770. /**
  58771. * Defines the falloff type used in this material.
  58772. * It by default is Physical.
  58773. */
  58774. protected _lightFalloff: number;
  58775. /**
  58776. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58777. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58778. */
  58779. protected _useRadianceOverAlpha: boolean;
  58780. /**
  58781. * Allows using an object space normal map (instead of tangent space).
  58782. */
  58783. protected _useObjectSpaceNormalMap: boolean;
  58784. /**
  58785. * Allows using the bump map in parallax mode.
  58786. */
  58787. protected _useParallax: boolean;
  58788. /**
  58789. * Allows using the bump map in parallax occlusion mode.
  58790. */
  58791. protected _useParallaxOcclusion: boolean;
  58792. /**
  58793. * Controls the scale bias of the parallax mode.
  58794. */
  58795. protected _parallaxScaleBias: number;
  58796. /**
  58797. * If sets to true, disables all the lights affecting the material.
  58798. */
  58799. protected _disableLighting: boolean;
  58800. /**
  58801. * Number of Simultaneous lights allowed on the material.
  58802. */
  58803. protected _maxSimultaneousLights: number;
  58804. /**
  58805. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58806. */
  58807. protected _invertNormalMapX: boolean;
  58808. /**
  58809. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58810. */
  58811. protected _invertNormalMapY: boolean;
  58812. /**
  58813. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58814. */
  58815. protected _twoSidedLighting: boolean;
  58816. /**
  58817. * Defines the alpha limits in alpha test mode.
  58818. */
  58819. protected _alphaCutOff: number;
  58820. /**
  58821. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58822. */
  58823. protected _forceAlphaTest: boolean;
  58824. /**
  58825. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58826. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58827. */
  58828. protected _useAlphaFresnel: boolean;
  58829. /**
  58830. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58831. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58832. */
  58833. protected _useLinearAlphaFresnel: boolean;
  58834. /**
  58835. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58836. * from cos thetav and roughness:
  58837. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58838. */
  58839. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58840. /**
  58841. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58842. */
  58843. protected _forceIrradianceInFragment: boolean;
  58844. private _realTimeFiltering;
  58845. /**
  58846. * Enables realtime filtering on the texture.
  58847. */
  58848. get realTimeFiltering(): boolean;
  58849. set realTimeFiltering(b: boolean);
  58850. private _realTimeFilteringQuality;
  58851. /**
  58852. * Quality switch for realtime filtering
  58853. */
  58854. get realTimeFilteringQuality(): number;
  58855. set realTimeFilteringQuality(n: number);
  58856. /**
  58857. * Can this material render to several textures at once
  58858. */
  58859. get canRenderToMRT(): boolean;
  58860. /**
  58861. * Force normal to face away from face.
  58862. */
  58863. protected _forceNormalForward: boolean;
  58864. /**
  58865. * Enables specular anti aliasing in the PBR shader.
  58866. * It will both interacts on the Geometry for analytical and IBL lighting.
  58867. * It also prefilter the roughness map based on the bump values.
  58868. */
  58869. protected _enableSpecularAntiAliasing: boolean;
  58870. /**
  58871. * Default configuration related to image processing available in the PBR Material.
  58872. */
  58873. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58874. /**
  58875. * Keep track of the image processing observer to allow dispose and replace.
  58876. */
  58877. private _imageProcessingObserver;
  58878. /**
  58879. * Attaches a new image processing configuration to the PBR Material.
  58880. * @param configuration
  58881. */
  58882. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58883. /**
  58884. * Stores the available render targets.
  58885. */
  58886. private _renderTargets;
  58887. /**
  58888. * Sets the global ambient color for the material used in lighting calculations.
  58889. */
  58890. private _globalAmbientColor;
  58891. /**
  58892. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58893. */
  58894. private _useLogarithmicDepth;
  58895. /**
  58896. * If set to true, no lighting calculations will be applied.
  58897. */
  58898. private _unlit;
  58899. private _debugMode;
  58900. /**
  58901. * @hidden
  58902. * This is reserved for the inspector.
  58903. * Defines the material debug mode.
  58904. * It helps seeing only some components of the material while troubleshooting.
  58905. */
  58906. debugMode: number;
  58907. /**
  58908. * @hidden
  58909. * This is reserved for the inspector.
  58910. * Specify from where on screen the debug mode should start.
  58911. * The value goes from -1 (full screen) to 1 (not visible)
  58912. * It helps with side by side comparison against the final render
  58913. * This defaults to -1
  58914. */
  58915. private debugLimit;
  58916. /**
  58917. * @hidden
  58918. * This is reserved for the inspector.
  58919. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58920. * You can use the factor to better multiply the final value.
  58921. */
  58922. private debugFactor;
  58923. /**
  58924. * Defines the clear coat layer parameters for the material.
  58925. */
  58926. readonly clearCoat: PBRClearCoatConfiguration;
  58927. /**
  58928. * Defines the anisotropic parameters for the material.
  58929. */
  58930. readonly anisotropy: PBRAnisotropicConfiguration;
  58931. /**
  58932. * Defines the BRDF parameters for the material.
  58933. */
  58934. readonly brdf: PBRBRDFConfiguration;
  58935. /**
  58936. * Defines the Sheen parameters for the material.
  58937. */
  58938. readonly sheen: PBRSheenConfiguration;
  58939. /**
  58940. * Defines the SubSurface parameters for the material.
  58941. */
  58942. readonly subSurface: PBRSubSurfaceConfiguration;
  58943. /**
  58944. * Defines the detail map parameters for the material.
  58945. */
  58946. readonly detailMap: DetailMapConfiguration;
  58947. protected _rebuildInParallel: boolean;
  58948. /**
  58949. * Instantiates a new PBRMaterial instance.
  58950. *
  58951. * @param name The material name
  58952. * @param scene The scene the material will be use in.
  58953. */
  58954. constructor(name: string, scene: Scene);
  58955. /**
  58956. * Gets a boolean indicating that current material needs to register RTT
  58957. */
  58958. get hasRenderTargetTextures(): boolean;
  58959. /**
  58960. * Gets the name of the material class.
  58961. */
  58962. getClassName(): string;
  58963. /**
  58964. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58965. */
  58966. get useLogarithmicDepth(): boolean;
  58967. /**
  58968. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58969. */
  58970. set useLogarithmicDepth(value: boolean);
  58971. /**
  58972. * Returns true if alpha blending should be disabled.
  58973. */
  58974. protected get _disableAlphaBlending(): boolean;
  58975. /**
  58976. * Specifies whether or not this material should be rendered in alpha blend mode.
  58977. */
  58978. needAlphaBlending(): boolean;
  58979. /**
  58980. * Specifies whether or not this material should be rendered in alpha test mode.
  58981. */
  58982. needAlphaTesting(): boolean;
  58983. /**
  58984. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58985. */
  58986. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58987. /**
  58988. * Gets the texture used for the alpha test.
  58989. */
  58990. getAlphaTestTexture(): Nullable<BaseTexture>;
  58991. /**
  58992. * Specifies that the submesh is ready to be used.
  58993. * @param mesh - BJS mesh.
  58994. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58995. * @param useInstances - Specifies that instances should be used.
  58996. * @returns - boolean indicating that the submesh is ready or not.
  58997. */
  58998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58999. /**
  59000. * Specifies if the material uses metallic roughness workflow.
  59001. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59002. */
  59003. isMetallicWorkflow(): boolean;
  59004. private _prepareEffect;
  59005. private _prepareDefines;
  59006. /**
  59007. * Force shader compilation
  59008. */
  59009. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59010. /**
  59011. * Initializes the uniform buffer layout for the shader.
  59012. */
  59013. buildUniformLayout(): void;
  59014. /**
  59015. * Unbinds the material from the mesh
  59016. */
  59017. unbind(): void;
  59018. /**
  59019. * Binds the submesh data.
  59020. * @param world - The world matrix.
  59021. * @param mesh - The BJS mesh.
  59022. * @param subMesh - A submesh of the BJS mesh.
  59023. */
  59024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59025. /**
  59026. * Returns the animatable textures.
  59027. * @returns - Array of animatable textures.
  59028. */
  59029. getAnimatables(): IAnimatable[];
  59030. /**
  59031. * Returns the texture used for reflections.
  59032. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59033. */
  59034. private _getReflectionTexture;
  59035. /**
  59036. * Returns an array of the actively used textures.
  59037. * @returns - Array of BaseTextures
  59038. */
  59039. getActiveTextures(): BaseTexture[];
  59040. /**
  59041. * Checks to see if a texture is used in the material.
  59042. * @param texture - Base texture to use.
  59043. * @returns - Boolean specifying if a texture is used in the material.
  59044. */
  59045. hasTexture(texture: BaseTexture): boolean;
  59046. /**
  59047. * Sets the required values to the prepass renderer.
  59048. * @param prePassRenderer defines the prepass renderer to setup
  59049. */
  59050. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59051. /**
  59052. * Disposes the resources of the material.
  59053. * @param forceDisposeEffect - Forces the disposal of effects.
  59054. * @param forceDisposeTextures - Forces the disposal of all textures.
  59055. */
  59056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59057. }
  59058. }
  59059. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59060. import { Nullable } from "babylonjs/types";
  59061. import { Scene } from "babylonjs/scene";
  59062. import { Color3 } from "babylonjs/Maths/math.color";
  59063. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59064. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59065. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59066. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59067. /**
  59068. * The Physically based material of BJS.
  59069. *
  59070. * This offers the main features of a standard PBR material.
  59071. * For more information, please refer to the documentation :
  59072. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59073. */
  59074. export class PBRMaterial extends PBRBaseMaterial {
  59075. /**
  59076. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59077. */
  59078. static readonly PBRMATERIAL_OPAQUE: number;
  59079. /**
  59080. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59081. */
  59082. static readonly PBRMATERIAL_ALPHATEST: number;
  59083. /**
  59084. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59085. */
  59086. static readonly PBRMATERIAL_ALPHABLEND: number;
  59087. /**
  59088. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59089. * They are also discarded below the alpha cutoff threshold to improve performances.
  59090. */
  59091. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59092. /**
  59093. * Defines the default value of how much AO map is occluding the analytical lights
  59094. * (point spot...).
  59095. */
  59096. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59097. /**
  59098. * Intensity of the direct lights e.g. the four lights available in your scene.
  59099. * This impacts both the direct diffuse and specular highlights.
  59100. */
  59101. directIntensity: number;
  59102. /**
  59103. * Intensity of the emissive part of the material.
  59104. * This helps controlling the emissive effect without modifying the emissive color.
  59105. */
  59106. emissiveIntensity: number;
  59107. /**
  59108. * Intensity of the environment e.g. how much the environment will light the object
  59109. * either through harmonics for rough material or through the refelction for shiny ones.
  59110. */
  59111. environmentIntensity: number;
  59112. /**
  59113. * This is a special control allowing the reduction of the specular highlights coming from the
  59114. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59115. */
  59116. specularIntensity: number;
  59117. /**
  59118. * Debug Control allowing disabling the bump map on this material.
  59119. */
  59120. disableBumpMap: boolean;
  59121. /**
  59122. * AKA Diffuse Texture in standard nomenclature.
  59123. */
  59124. albedoTexture: BaseTexture;
  59125. /**
  59126. * AKA Occlusion Texture in other nomenclature.
  59127. */
  59128. ambientTexture: BaseTexture;
  59129. /**
  59130. * AKA Occlusion Texture Intensity in other nomenclature.
  59131. */
  59132. ambientTextureStrength: number;
  59133. /**
  59134. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59135. * 1 means it completely occludes it
  59136. * 0 mean it has no impact
  59137. */
  59138. ambientTextureImpactOnAnalyticalLights: number;
  59139. /**
  59140. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59141. */
  59142. opacityTexture: BaseTexture;
  59143. /**
  59144. * Stores the reflection values in a texture.
  59145. */
  59146. reflectionTexture: Nullable<BaseTexture>;
  59147. /**
  59148. * Stores the emissive values in a texture.
  59149. */
  59150. emissiveTexture: BaseTexture;
  59151. /**
  59152. * AKA Specular texture in other nomenclature.
  59153. */
  59154. reflectivityTexture: BaseTexture;
  59155. /**
  59156. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59157. */
  59158. metallicTexture: BaseTexture;
  59159. /**
  59160. * Specifies the metallic scalar of the metallic/roughness workflow.
  59161. * Can also be used to scale the metalness values of the metallic texture.
  59162. */
  59163. metallic: Nullable<number>;
  59164. /**
  59165. * Specifies the roughness scalar of the metallic/roughness workflow.
  59166. * Can also be used to scale the roughness values of the metallic texture.
  59167. */
  59168. roughness: Nullable<number>;
  59169. /**
  59170. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59171. * By default the indexOfrefraction is used to compute F0;
  59172. *
  59173. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59174. *
  59175. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59176. * F90 = metallicReflectanceColor;
  59177. */
  59178. metallicF0Factor: number;
  59179. /**
  59180. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59181. * By default the F90 is always 1;
  59182. *
  59183. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59184. *
  59185. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59186. * F90 = metallicReflectanceColor;
  59187. */
  59188. metallicReflectanceColor: Color3;
  59189. /**
  59190. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59191. * This is multiply against the scalar values defined in the material.
  59192. */
  59193. metallicReflectanceTexture: Nullable<BaseTexture>;
  59194. /**
  59195. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59196. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59197. */
  59198. microSurfaceTexture: BaseTexture;
  59199. /**
  59200. * Stores surface normal data used to displace a mesh in a texture.
  59201. */
  59202. bumpTexture: BaseTexture;
  59203. /**
  59204. * Stores the pre-calculated light information of a mesh in a texture.
  59205. */
  59206. lightmapTexture: BaseTexture;
  59207. /**
  59208. * Stores the refracted light information in a texture.
  59209. */
  59210. get refractionTexture(): Nullable<BaseTexture>;
  59211. set refractionTexture(value: Nullable<BaseTexture>);
  59212. /**
  59213. * The color of a material in ambient lighting.
  59214. */
  59215. ambientColor: Color3;
  59216. /**
  59217. * AKA Diffuse Color in other nomenclature.
  59218. */
  59219. albedoColor: Color3;
  59220. /**
  59221. * AKA Specular Color in other nomenclature.
  59222. */
  59223. reflectivityColor: Color3;
  59224. /**
  59225. * The color reflected from the material.
  59226. */
  59227. reflectionColor: Color3;
  59228. /**
  59229. * The color emitted from the material.
  59230. */
  59231. emissiveColor: Color3;
  59232. /**
  59233. * AKA Glossiness in other nomenclature.
  59234. */
  59235. microSurface: number;
  59236. /**
  59237. * Index of refraction of the material base layer.
  59238. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59239. *
  59240. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59241. *
  59242. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59243. */
  59244. get indexOfRefraction(): number;
  59245. set indexOfRefraction(value: number);
  59246. /**
  59247. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59248. */
  59249. get invertRefractionY(): boolean;
  59250. set invertRefractionY(value: boolean);
  59251. /**
  59252. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59253. * Materials half opaque for instance using refraction could benefit from this control.
  59254. */
  59255. get linkRefractionWithTransparency(): boolean;
  59256. set linkRefractionWithTransparency(value: boolean);
  59257. /**
  59258. * If true, the light map contains occlusion information instead of lighting info.
  59259. */
  59260. useLightmapAsShadowmap: boolean;
  59261. /**
  59262. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59263. */
  59264. useAlphaFromAlbedoTexture: boolean;
  59265. /**
  59266. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59267. */
  59268. forceAlphaTest: boolean;
  59269. /**
  59270. * Defines the alpha limits in alpha test mode.
  59271. */
  59272. alphaCutOff: number;
  59273. /**
  59274. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59275. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59276. */
  59277. useSpecularOverAlpha: boolean;
  59278. /**
  59279. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59280. */
  59281. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59282. /**
  59283. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59284. */
  59285. useRoughnessFromMetallicTextureAlpha: boolean;
  59286. /**
  59287. * Specifies if the metallic texture contains the roughness information in its green channel.
  59288. */
  59289. useRoughnessFromMetallicTextureGreen: boolean;
  59290. /**
  59291. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59292. */
  59293. useMetallnessFromMetallicTextureBlue: boolean;
  59294. /**
  59295. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59296. */
  59297. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59298. /**
  59299. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59300. */
  59301. useAmbientInGrayScale: boolean;
  59302. /**
  59303. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59304. * The material will try to infer what glossiness each pixel should be.
  59305. */
  59306. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59307. /**
  59308. * BJS is using an harcoded light falloff based on a manually sets up range.
  59309. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59310. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59311. */
  59312. get usePhysicalLightFalloff(): boolean;
  59313. /**
  59314. * BJS is using an harcoded light falloff based on a manually sets up range.
  59315. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59316. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59317. */
  59318. set usePhysicalLightFalloff(value: boolean);
  59319. /**
  59320. * In order to support the falloff compatibility with gltf, a special mode has been added
  59321. * to reproduce the gltf light falloff.
  59322. */
  59323. get useGLTFLightFalloff(): boolean;
  59324. /**
  59325. * In order to support the falloff compatibility with gltf, a special mode has been added
  59326. * to reproduce the gltf light falloff.
  59327. */
  59328. set useGLTFLightFalloff(value: boolean);
  59329. /**
  59330. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59331. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59332. */
  59333. useRadianceOverAlpha: boolean;
  59334. /**
  59335. * Allows using an object space normal map (instead of tangent space).
  59336. */
  59337. useObjectSpaceNormalMap: boolean;
  59338. /**
  59339. * Allows using the bump map in parallax mode.
  59340. */
  59341. useParallax: boolean;
  59342. /**
  59343. * Allows using the bump map in parallax occlusion mode.
  59344. */
  59345. useParallaxOcclusion: boolean;
  59346. /**
  59347. * Controls the scale bias of the parallax mode.
  59348. */
  59349. parallaxScaleBias: number;
  59350. /**
  59351. * If sets to true, disables all the lights affecting the material.
  59352. */
  59353. disableLighting: boolean;
  59354. /**
  59355. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59356. */
  59357. forceIrradianceInFragment: boolean;
  59358. /**
  59359. * Number of Simultaneous lights allowed on the material.
  59360. */
  59361. maxSimultaneousLights: number;
  59362. /**
  59363. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59364. */
  59365. invertNormalMapX: boolean;
  59366. /**
  59367. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59368. */
  59369. invertNormalMapY: boolean;
  59370. /**
  59371. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59372. */
  59373. twoSidedLighting: boolean;
  59374. /**
  59375. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59376. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59377. */
  59378. useAlphaFresnel: boolean;
  59379. /**
  59380. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59381. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59382. */
  59383. useLinearAlphaFresnel: boolean;
  59384. /**
  59385. * Let user defines the brdf lookup texture used for IBL.
  59386. * A default 8bit version is embedded but you could point at :
  59387. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59388. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59389. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59390. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59391. */
  59392. environmentBRDFTexture: Nullable<BaseTexture>;
  59393. /**
  59394. * Force normal to face away from face.
  59395. */
  59396. forceNormalForward: boolean;
  59397. /**
  59398. * Enables specular anti aliasing in the PBR shader.
  59399. * It will both interacts on the Geometry for analytical and IBL lighting.
  59400. * It also prefilter the roughness map based on the bump values.
  59401. */
  59402. enableSpecularAntiAliasing: boolean;
  59403. /**
  59404. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59405. * makes the reflect vector face the model (under horizon).
  59406. */
  59407. useHorizonOcclusion: boolean;
  59408. /**
  59409. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59410. * too much the area relying on ambient texture to define their ambient occlusion.
  59411. */
  59412. useRadianceOcclusion: boolean;
  59413. /**
  59414. * If set to true, no lighting calculations will be applied.
  59415. */
  59416. unlit: boolean;
  59417. /**
  59418. * Gets the image processing configuration used either in this material.
  59419. */
  59420. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59421. /**
  59422. * Sets the Default image processing configuration used either in the this material.
  59423. *
  59424. * If sets to null, the scene one is in use.
  59425. */
  59426. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59427. /**
  59428. * Gets wether the color curves effect is enabled.
  59429. */
  59430. get cameraColorCurvesEnabled(): boolean;
  59431. /**
  59432. * Sets wether the color curves effect is enabled.
  59433. */
  59434. set cameraColorCurvesEnabled(value: boolean);
  59435. /**
  59436. * Gets wether the color grading effect is enabled.
  59437. */
  59438. get cameraColorGradingEnabled(): boolean;
  59439. /**
  59440. * Gets wether the color grading effect is enabled.
  59441. */
  59442. set cameraColorGradingEnabled(value: boolean);
  59443. /**
  59444. * Gets wether tonemapping is enabled or not.
  59445. */
  59446. get cameraToneMappingEnabled(): boolean;
  59447. /**
  59448. * Sets wether tonemapping is enabled or not
  59449. */
  59450. set cameraToneMappingEnabled(value: boolean);
  59451. /**
  59452. * The camera exposure used on this material.
  59453. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59454. * This corresponds to a photographic exposure.
  59455. */
  59456. get cameraExposure(): number;
  59457. /**
  59458. * The camera exposure used on this material.
  59459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59460. * This corresponds to a photographic exposure.
  59461. */
  59462. set cameraExposure(value: number);
  59463. /**
  59464. * Gets The camera contrast used on this material.
  59465. */
  59466. get cameraContrast(): number;
  59467. /**
  59468. * Sets The camera contrast used on this material.
  59469. */
  59470. set cameraContrast(value: number);
  59471. /**
  59472. * Gets the Color Grading 2D Lookup Texture.
  59473. */
  59474. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59475. /**
  59476. * Sets the Color Grading 2D Lookup Texture.
  59477. */
  59478. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59479. /**
  59480. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59481. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59482. * 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;
  59483. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59484. */
  59485. get cameraColorCurves(): Nullable<ColorCurves>;
  59486. /**
  59487. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59488. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59489. * 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;
  59490. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59491. */
  59492. set cameraColorCurves(value: Nullable<ColorCurves>);
  59493. /**
  59494. * Instantiates a new PBRMaterial instance.
  59495. *
  59496. * @param name The material name
  59497. * @param scene The scene the material will be use in.
  59498. */
  59499. constructor(name: string, scene: Scene);
  59500. /**
  59501. * Returns the name of this material class.
  59502. */
  59503. getClassName(): string;
  59504. /**
  59505. * Makes a duplicate of the current material.
  59506. * @param name - name to use for the new material.
  59507. */
  59508. clone(name: string): PBRMaterial;
  59509. /**
  59510. * Serializes this PBR Material.
  59511. * @returns - An object with the serialized material.
  59512. */
  59513. serialize(): any;
  59514. /**
  59515. * Parses a PBR Material from a serialized object.
  59516. * @param source - Serialized object.
  59517. * @param scene - BJS scene instance.
  59518. * @param rootUrl - url for the scene object
  59519. * @returns - PBRMaterial
  59520. */
  59521. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59522. }
  59523. }
  59524. declare module "babylonjs/Misc/dds" {
  59525. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59527. import { Nullable } from "babylonjs/types";
  59528. import { Scene } from "babylonjs/scene";
  59529. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59530. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59531. /**
  59532. * Direct draw surface info
  59533. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59534. */
  59535. export interface DDSInfo {
  59536. /**
  59537. * Width of the texture
  59538. */
  59539. width: number;
  59540. /**
  59541. * Width of the texture
  59542. */
  59543. height: number;
  59544. /**
  59545. * Number of Mipmaps for the texture
  59546. * @see https://en.wikipedia.org/wiki/Mipmap
  59547. */
  59548. mipmapCount: number;
  59549. /**
  59550. * If the textures format is a known fourCC format
  59551. * @see https://www.fourcc.org/
  59552. */
  59553. isFourCC: boolean;
  59554. /**
  59555. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59556. */
  59557. isRGB: boolean;
  59558. /**
  59559. * If the texture is a lumincance format
  59560. */
  59561. isLuminance: boolean;
  59562. /**
  59563. * If this is a cube texture
  59564. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59565. */
  59566. isCube: boolean;
  59567. /**
  59568. * If the texture is a compressed format eg. FOURCC_DXT1
  59569. */
  59570. isCompressed: boolean;
  59571. /**
  59572. * The dxgiFormat of the texture
  59573. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59574. */
  59575. dxgiFormat: number;
  59576. /**
  59577. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59578. */
  59579. textureType: number;
  59580. /**
  59581. * Sphericle polynomial created for the dds texture
  59582. */
  59583. sphericalPolynomial?: SphericalPolynomial;
  59584. }
  59585. /**
  59586. * Class used to provide DDS decompression tools
  59587. */
  59588. export class DDSTools {
  59589. /**
  59590. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59591. */
  59592. static StoreLODInAlphaChannel: boolean;
  59593. /**
  59594. * Gets DDS information from an array buffer
  59595. * @param data defines the array buffer view to read data from
  59596. * @returns the DDS information
  59597. */
  59598. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59599. private static _FloatView;
  59600. private static _Int32View;
  59601. private static _ToHalfFloat;
  59602. private static _FromHalfFloat;
  59603. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59604. private static _GetHalfFloatRGBAArrayBuffer;
  59605. private static _GetFloatRGBAArrayBuffer;
  59606. private static _GetFloatAsUIntRGBAArrayBuffer;
  59607. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59608. private static _GetRGBAArrayBuffer;
  59609. private static _ExtractLongWordOrder;
  59610. private static _GetRGBArrayBuffer;
  59611. private static _GetLuminanceArrayBuffer;
  59612. /**
  59613. * Uploads DDS Levels to a Babylon Texture
  59614. * @hidden
  59615. */
  59616. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59617. }
  59618. module "babylonjs/Engines/thinEngine" {
  59619. interface ThinEngine {
  59620. /**
  59621. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59622. * @param rootUrl defines the url where the file to load is located
  59623. * @param scene defines the current scene
  59624. * @param lodScale defines scale to apply to the mip map selection
  59625. * @param lodOffset defines offset to apply to the mip map selection
  59626. * @param onLoad defines an optional callback raised when the texture is loaded
  59627. * @param onError defines an optional callback raised if there is an issue to load the texture
  59628. * @param format defines the format of the data
  59629. * @param forcedExtension defines the extension to use to pick the right loader
  59630. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59631. * @returns the cube texture as an InternalTexture
  59632. */
  59633. 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;
  59634. }
  59635. }
  59636. }
  59637. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59638. import { Nullable } from "babylonjs/types";
  59639. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59640. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59641. /**
  59642. * Implementation of the DDS Texture Loader.
  59643. * @hidden
  59644. */
  59645. export class _DDSTextureLoader implements IInternalTextureLoader {
  59646. /**
  59647. * Defines wether the loader supports cascade loading the different faces.
  59648. */
  59649. readonly supportCascades: boolean;
  59650. /**
  59651. * This returns if the loader support the current file information.
  59652. * @param extension defines the file extension of the file being loaded
  59653. * @returns true if the loader can load the specified file
  59654. */
  59655. canLoad(extension: string): boolean;
  59656. /**
  59657. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59658. * @param data contains the texture data
  59659. * @param texture defines the BabylonJS internal texture
  59660. * @param createPolynomials will be true if polynomials have been requested
  59661. * @param onLoad defines the callback to trigger once the texture is ready
  59662. * @param onError defines the callback to trigger in case of error
  59663. */
  59664. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59665. /**
  59666. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59667. * @param data contains the texture data
  59668. * @param texture defines the BabylonJS internal texture
  59669. * @param callback defines the method to call once ready to upload
  59670. */
  59671. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59672. }
  59673. }
  59674. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59675. import { Nullable } from "babylonjs/types";
  59676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59677. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59678. /**
  59679. * Implementation of the ENV Texture Loader.
  59680. * @hidden
  59681. */
  59682. export class _ENVTextureLoader implements IInternalTextureLoader {
  59683. /**
  59684. * Defines wether the loader supports cascade loading the different faces.
  59685. */
  59686. readonly supportCascades: boolean;
  59687. /**
  59688. * This returns if the loader support the current file information.
  59689. * @param extension defines the file extension of the file being loaded
  59690. * @returns true if the loader can load the specified file
  59691. */
  59692. canLoad(extension: string): boolean;
  59693. /**
  59694. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59695. * @param data contains the texture data
  59696. * @param texture defines the BabylonJS internal texture
  59697. * @param createPolynomials will be true if polynomials have been requested
  59698. * @param onLoad defines the callback to trigger once the texture is ready
  59699. * @param onError defines the callback to trigger in case of error
  59700. */
  59701. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59702. /**
  59703. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59704. * @param data contains the texture data
  59705. * @param texture defines the BabylonJS internal texture
  59706. * @param callback defines the method to call once ready to upload
  59707. */
  59708. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59709. }
  59710. }
  59711. declare module "babylonjs/Misc/khronosTextureContainer" {
  59712. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59713. /**
  59714. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59715. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59716. */
  59717. export class KhronosTextureContainer {
  59718. /** contents of the KTX container file */
  59719. data: ArrayBufferView;
  59720. private static HEADER_LEN;
  59721. private static COMPRESSED_2D;
  59722. private static COMPRESSED_3D;
  59723. private static TEX_2D;
  59724. private static TEX_3D;
  59725. /**
  59726. * Gets the openGL type
  59727. */
  59728. glType: number;
  59729. /**
  59730. * Gets the openGL type size
  59731. */
  59732. glTypeSize: number;
  59733. /**
  59734. * Gets the openGL format
  59735. */
  59736. glFormat: number;
  59737. /**
  59738. * Gets the openGL internal format
  59739. */
  59740. glInternalFormat: number;
  59741. /**
  59742. * Gets the base internal format
  59743. */
  59744. glBaseInternalFormat: number;
  59745. /**
  59746. * Gets image width in pixel
  59747. */
  59748. pixelWidth: number;
  59749. /**
  59750. * Gets image height in pixel
  59751. */
  59752. pixelHeight: number;
  59753. /**
  59754. * Gets image depth in pixels
  59755. */
  59756. pixelDepth: number;
  59757. /**
  59758. * Gets the number of array elements
  59759. */
  59760. numberOfArrayElements: number;
  59761. /**
  59762. * Gets the number of faces
  59763. */
  59764. numberOfFaces: number;
  59765. /**
  59766. * Gets the number of mipmap levels
  59767. */
  59768. numberOfMipmapLevels: number;
  59769. /**
  59770. * Gets the bytes of key value data
  59771. */
  59772. bytesOfKeyValueData: number;
  59773. /**
  59774. * Gets the load type
  59775. */
  59776. loadType: number;
  59777. /**
  59778. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59779. */
  59780. isInvalid: boolean;
  59781. /**
  59782. * Creates a new KhronosTextureContainer
  59783. * @param data contents of the KTX container file
  59784. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59785. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59786. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59787. */
  59788. constructor(
  59789. /** contents of the KTX container file */
  59790. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59791. /**
  59792. * Uploads KTX content to a Babylon Texture.
  59793. * It is assumed that the texture has already been created & is currently bound
  59794. * @hidden
  59795. */
  59796. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59797. private _upload2DCompressedLevels;
  59798. /**
  59799. * Checks if the given data starts with a KTX file identifier.
  59800. * @param data the data to check
  59801. * @returns true if the data is a KTX file or false otherwise
  59802. */
  59803. static IsValid(data: ArrayBufferView): boolean;
  59804. }
  59805. }
  59806. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59807. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59808. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59809. /**
  59810. * Class for loading KTX2 files
  59811. * !!! Experimental Extension Subject to Changes !!!
  59812. * @hidden
  59813. */
  59814. export class KhronosTextureContainer2 {
  59815. private static _ModulePromise;
  59816. private static _TranscodeFormat;
  59817. constructor(engine: ThinEngine);
  59818. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59819. private _determineTranscodeFormat;
  59820. /**
  59821. * Checks if the given data starts with a KTX2 file identifier.
  59822. * @param data the data to check
  59823. * @returns true if the data is a KTX2 file or false otherwise
  59824. */
  59825. static IsValid(data: ArrayBufferView): boolean;
  59826. }
  59827. }
  59828. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59829. import { Nullable } from "babylonjs/types";
  59830. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59831. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59832. /**
  59833. * Implementation of the KTX Texture Loader.
  59834. * @hidden
  59835. */
  59836. export class _KTXTextureLoader implements IInternalTextureLoader {
  59837. /**
  59838. * Defines wether the loader supports cascade loading the different faces.
  59839. */
  59840. readonly supportCascades: boolean;
  59841. /**
  59842. * This returns if the loader support the current file information.
  59843. * @param extension defines the file extension of the file being loaded
  59844. * @param mimeType defines the optional mime type of the file being loaded
  59845. * @returns true if the loader can load the specified file
  59846. */
  59847. canLoad(extension: string, mimeType?: string): boolean;
  59848. /**
  59849. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59850. * @param data contains the texture data
  59851. * @param texture defines the BabylonJS internal texture
  59852. * @param createPolynomials will be true if polynomials have been requested
  59853. * @param onLoad defines the callback to trigger once the texture is ready
  59854. * @param onError defines the callback to trigger in case of error
  59855. */
  59856. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59857. /**
  59858. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59859. * @param data contains the texture data
  59860. * @param texture defines the BabylonJS internal texture
  59861. * @param callback defines the method to call once ready to upload
  59862. */
  59863. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59864. }
  59865. }
  59866. declare module "babylonjs/Helpers/sceneHelpers" {
  59867. import { Nullable } from "babylonjs/types";
  59868. import { Mesh } from "babylonjs/Meshes/mesh";
  59869. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59870. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59871. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59872. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59873. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59874. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59875. import "babylonjs/Meshes/Builders/boxBuilder";
  59876. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59877. /** @hidden */
  59878. export var _forceSceneHelpersToBundle: boolean;
  59879. module "babylonjs/scene" {
  59880. interface Scene {
  59881. /**
  59882. * Creates a default light for the scene.
  59883. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59884. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59885. */
  59886. createDefaultLight(replace?: boolean): void;
  59887. /**
  59888. * Creates a default camera for the scene.
  59889. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59890. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59891. * @param replace has default false, when true replaces the active camera in the scene
  59892. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59893. */
  59894. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59895. /**
  59896. * Creates a default camera and a default light.
  59897. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59898. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59899. * @param replace has the default false, when true replaces the active camera/light in the scene
  59900. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59901. */
  59902. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59903. /**
  59904. * Creates a new sky box
  59905. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59906. * @param environmentTexture defines the texture to use as environment texture
  59907. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59908. * @param scale defines the overall scale of the skybox
  59909. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59910. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59911. * @returns a new mesh holding the sky box
  59912. */
  59913. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59914. /**
  59915. * Creates a new environment
  59916. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59917. * @param options defines the options you can use to configure the environment
  59918. * @returns the new EnvironmentHelper
  59919. */
  59920. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59921. /**
  59922. * Creates a new VREXperienceHelper
  59923. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59924. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59925. * @returns a new VREXperienceHelper
  59926. */
  59927. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59928. /**
  59929. * Creates a new WebXRDefaultExperience
  59930. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59931. * @param options experience options
  59932. * @returns a promise for a new WebXRDefaultExperience
  59933. */
  59934. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59935. }
  59936. }
  59937. }
  59938. declare module "babylonjs/Helpers/videoDome" {
  59939. import { Scene } from "babylonjs/scene";
  59940. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59941. import { Mesh } from "babylonjs/Meshes/mesh";
  59942. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59943. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59944. import "babylonjs/Meshes/Builders/sphereBuilder";
  59945. /**
  59946. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59947. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59948. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59949. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59950. */
  59951. export class VideoDome extends TransformNode {
  59952. /**
  59953. * Define the video source as a Monoscopic panoramic 360 video.
  59954. */
  59955. static readonly MODE_MONOSCOPIC: number;
  59956. /**
  59957. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59958. */
  59959. static readonly MODE_TOPBOTTOM: number;
  59960. /**
  59961. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59962. */
  59963. static readonly MODE_SIDEBYSIDE: number;
  59964. private _halfDome;
  59965. private _useDirectMapping;
  59966. /**
  59967. * The video texture being displayed on the sphere
  59968. */
  59969. protected _videoTexture: VideoTexture;
  59970. /**
  59971. * Gets the video texture being displayed on the sphere
  59972. */
  59973. get videoTexture(): VideoTexture;
  59974. /**
  59975. * The skybox material
  59976. */
  59977. protected _material: BackgroundMaterial;
  59978. /**
  59979. * The surface used for the video dome
  59980. */
  59981. protected _mesh: Mesh;
  59982. /**
  59983. * Gets the mesh used for the video dome.
  59984. */
  59985. get mesh(): Mesh;
  59986. /**
  59987. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59988. */
  59989. private _halfDomeMask;
  59990. /**
  59991. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59992. * Also see the options.resolution property.
  59993. */
  59994. get fovMultiplier(): number;
  59995. set fovMultiplier(value: number);
  59996. private _videoMode;
  59997. /**
  59998. * Gets or set the current video mode for the video. It can be:
  59999. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  60000. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60001. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60002. */
  60003. get videoMode(): number;
  60004. set videoMode(value: number);
  60005. /**
  60006. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  60007. *
  60008. */
  60009. get halfDome(): boolean;
  60010. /**
  60011. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60012. */
  60013. set halfDome(enabled: boolean);
  60014. /**
  60015. * Oberserver used in Stereoscopic VR Mode.
  60016. */
  60017. private _onBeforeCameraRenderObserver;
  60018. /**
  60019. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  60020. * @param name Element's name, child elements will append suffixes for their own names.
  60021. * @param urlsOrVideo defines the url(s) or the video element to use
  60022. * @param options An object containing optional or exposed sub element properties
  60023. */
  60024. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  60025. resolution?: number;
  60026. clickToPlay?: boolean;
  60027. autoPlay?: boolean;
  60028. loop?: boolean;
  60029. size?: number;
  60030. poster?: string;
  60031. faceForward?: boolean;
  60032. useDirectMapping?: boolean;
  60033. halfDomeMode?: boolean;
  60034. }, scene: Scene);
  60035. private _changeVideoMode;
  60036. /**
  60037. * Releases resources associated with this node.
  60038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60040. */
  60041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60042. }
  60043. }
  60044. declare module "babylonjs/Helpers/index" {
  60045. export * from "babylonjs/Helpers/environmentHelper";
  60046. export * from "babylonjs/Helpers/photoDome";
  60047. export * from "babylonjs/Helpers/sceneHelpers";
  60048. export * from "babylonjs/Helpers/videoDome";
  60049. }
  60050. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60051. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60052. import { IDisposable } from "babylonjs/scene";
  60053. import { Engine } from "babylonjs/Engines/engine";
  60054. /**
  60055. * This class can be used to get instrumentation data from a Babylon engine
  60056. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60057. */
  60058. export class EngineInstrumentation implements IDisposable {
  60059. /**
  60060. * Define the instrumented engine.
  60061. */
  60062. engine: Engine;
  60063. private _captureGPUFrameTime;
  60064. private _gpuFrameTimeToken;
  60065. private _gpuFrameTime;
  60066. private _captureShaderCompilationTime;
  60067. private _shaderCompilationTime;
  60068. private _onBeginFrameObserver;
  60069. private _onEndFrameObserver;
  60070. private _onBeforeShaderCompilationObserver;
  60071. private _onAfterShaderCompilationObserver;
  60072. /**
  60073. * Gets the perf counter used for GPU frame time
  60074. */
  60075. get gpuFrameTimeCounter(): PerfCounter;
  60076. /**
  60077. * Gets the GPU frame time capture status
  60078. */
  60079. get captureGPUFrameTime(): boolean;
  60080. /**
  60081. * Enable or disable the GPU frame time capture
  60082. */
  60083. set captureGPUFrameTime(value: boolean);
  60084. /**
  60085. * Gets the perf counter used for shader compilation time
  60086. */
  60087. get shaderCompilationTimeCounter(): PerfCounter;
  60088. /**
  60089. * Gets the shader compilation time capture status
  60090. */
  60091. get captureShaderCompilationTime(): boolean;
  60092. /**
  60093. * Enable or disable the shader compilation time capture
  60094. */
  60095. set captureShaderCompilationTime(value: boolean);
  60096. /**
  60097. * Instantiates a new engine instrumentation.
  60098. * This class can be used to get instrumentation data from a Babylon engine
  60099. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60100. * @param engine Defines the engine to instrument
  60101. */
  60102. constructor(
  60103. /**
  60104. * Define the instrumented engine.
  60105. */
  60106. engine: Engine);
  60107. /**
  60108. * Dispose and release associated resources.
  60109. */
  60110. dispose(): void;
  60111. }
  60112. }
  60113. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60114. import { Scene, IDisposable } from "babylonjs/scene";
  60115. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60116. /**
  60117. * This class can be used to get instrumentation data from a Babylon engine
  60118. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60119. */
  60120. export class SceneInstrumentation implements IDisposable {
  60121. /**
  60122. * Defines the scene to instrument
  60123. */
  60124. scene: Scene;
  60125. private _captureActiveMeshesEvaluationTime;
  60126. private _activeMeshesEvaluationTime;
  60127. private _captureRenderTargetsRenderTime;
  60128. private _renderTargetsRenderTime;
  60129. private _captureFrameTime;
  60130. private _frameTime;
  60131. private _captureRenderTime;
  60132. private _renderTime;
  60133. private _captureInterFrameTime;
  60134. private _interFrameTime;
  60135. private _captureParticlesRenderTime;
  60136. private _particlesRenderTime;
  60137. private _captureSpritesRenderTime;
  60138. private _spritesRenderTime;
  60139. private _capturePhysicsTime;
  60140. private _physicsTime;
  60141. private _captureAnimationsTime;
  60142. private _animationsTime;
  60143. private _captureCameraRenderTime;
  60144. private _cameraRenderTime;
  60145. private _onBeforeActiveMeshesEvaluationObserver;
  60146. private _onAfterActiveMeshesEvaluationObserver;
  60147. private _onBeforeRenderTargetsRenderObserver;
  60148. private _onAfterRenderTargetsRenderObserver;
  60149. private _onAfterRenderObserver;
  60150. private _onBeforeDrawPhaseObserver;
  60151. private _onAfterDrawPhaseObserver;
  60152. private _onBeforeAnimationsObserver;
  60153. private _onBeforeParticlesRenderingObserver;
  60154. private _onAfterParticlesRenderingObserver;
  60155. private _onBeforeSpritesRenderingObserver;
  60156. private _onAfterSpritesRenderingObserver;
  60157. private _onBeforePhysicsObserver;
  60158. private _onAfterPhysicsObserver;
  60159. private _onAfterAnimationsObserver;
  60160. private _onBeforeCameraRenderObserver;
  60161. private _onAfterCameraRenderObserver;
  60162. /**
  60163. * Gets the perf counter used for active meshes evaluation time
  60164. */
  60165. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60166. /**
  60167. * Gets the active meshes evaluation time capture status
  60168. */
  60169. get captureActiveMeshesEvaluationTime(): boolean;
  60170. /**
  60171. * Enable or disable the active meshes evaluation time capture
  60172. */
  60173. set captureActiveMeshesEvaluationTime(value: boolean);
  60174. /**
  60175. * Gets the perf counter used for render targets render time
  60176. */
  60177. get renderTargetsRenderTimeCounter(): PerfCounter;
  60178. /**
  60179. * Gets the render targets render time capture status
  60180. */
  60181. get captureRenderTargetsRenderTime(): boolean;
  60182. /**
  60183. * Enable or disable the render targets render time capture
  60184. */
  60185. set captureRenderTargetsRenderTime(value: boolean);
  60186. /**
  60187. * Gets the perf counter used for particles render time
  60188. */
  60189. get particlesRenderTimeCounter(): PerfCounter;
  60190. /**
  60191. * Gets the particles render time capture status
  60192. */
  60193. get captureParticlesRenderTime(): boolean;
  60194. /**
  60195. * Enable or disable the particles render time capture
  60196. */
  60197. set captureParticlesRenderTime(value: boolean);
  60198. /**
  60199. * Gets the perf counter used for sprites render time
  60200. */
  60201. get spritesRenderTimeCounter(): PerfCounter;
  60202. /**
  60203. * Gets the sprites render time capture status
  60204. */
  60205. get captureSpritesRenderTime(): boolean;
  60206. /**
  60207. * Enable or disable the sprites render time capture
  60208. */
  60209. set captureSpritesRenderTime(value: boolean);
  60210. /**
  60211. * Gets the perf counter used for physics time
  60212. */
  60213. get physicsTimeCounter(): PerfCounter;
  60214. /**
  60215. * Gets the physics time capture status
  60216. */
  60217. get capturePhysicsTime(): boolean;
  60218. /**
  60219. * Enable or disable the physics time capture
  60220. */
  60221. set capturePhysicsTime(value: boolean);
  60222. /**
  60223. * Gets the perf counter used for animations time
  60224. */
  60225. get animationsTimeCounter(): PerfCounter;
  60226. /**
  60227. * Gets the animations time capture status
  60228. */
  60229. get captureAnimationsTime(): boolean;
  60230. /**
  60231. * Enable or disable the animations time capture
  60232. */
  60233. set captureAnimationsTime(value: boolean);
  60234. /**
  60235. * Gets the perf counter used for frame time capture
  60236. */
  60237. get frameTimeCounter(): PerfCounter;
  60238. /**
  60239. * Gets the frame time capture status
  60240. */
  60241. get captureFrameTime(): boolean;
  60242. /**
  60243. * Enable or disable the frame time capture
  60244. */
  60245. set captureFrameTime(value: boolean);
  60246. /**
  60247. * Gets the perf counter used for inter-frames time capture
  60248. */
  60249. get interFrameTimeCounter(): PerfCounter;
  60250. /**
  60251. * Gets the inter-frames time capture status
  60252. */
  60253. get captureInterFrameTime(): boolean;
  60254. /**
  60255. * Enable or disable the inter-frames time capture
  60256. */
  60257. set captureInterFrameTime(value: boolean);
  60258. /**
  60259. * Gets the perf counter used for render time capture
  60260. */
  60261. get renderTimeCounter(): PerfCounter;
  60262. /**
  60263. * Gets the render time capture status
  60264. */
  60265. get captureRenderTime(): boolean;
  60266. /**
  60267. * Enable or disable the render time capture
  60268. */
  60269. set captureRenderTime(value: boolean);
  60270. /**
  60271. * Gets the perf counter used for camera render time capture
  60272. */
  60273. get cameraRenderTimeCounter(): PerfCounter;
  60274. /**
  60275. * Gets the camera render time capture status
  60276. */
  60277. get captureCameraRenderTime(): boolean;
  60278. /**
  60279. * Enable or disable the camera render time capture
  60280. */
  60281. set captureCameraRenderTime(value: boolean);
  60282. /**
  60283. * Gets the perf counter used for draw calls
  60284. */
  60285. get drawCallsCounter(): PerfCounter;
  60286. /**
  60287. * Instantiates a new scene instrumentation.
  60288. * This class can be used to get instrumentation data from a Babylon engine
  60289. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60290. * @param scene Defines the scene to instrument
  60291. */
  60292. constructor(
  60293. /**
  60294. * Defines the scene to instrument
  60295. */
  60296. scene: Scene);
  60297. /**
  60298. * Dispose and release associated resources.
  60299. */
  60300. dispose(): void;
  60301. }
  60302. }
  60303. declare module "babylonjs/Instrumentation/index" {
  60304. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60305. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60306. export * from "babylonjs/Instrumentation/timeToken";
  60307. }
  60308. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60309. /** @hidden */
  60310. export var glowMapGenerationPixelShader: {
  60311. name: string;
  60312. shader: string;
  60313. };
  60314. }
  60315. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60316. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60319. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60320. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60321. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60322. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60323. /** @hidden */
  60324. export var glowMapGenerationVertexShader: {
  60325. name: string;
  60326. shader: string;
  60327. };
  60328. }
  60329. declare module "babylonjs/Layers/effectLayer" {
  60330. import { Observable } from "babylonjs/Misc/observable";
  60331. import { Nullable } from "babylonjs/types";
  60332. import { Camera } from "babylonjs/Cameras/camera";
  60333. import { Scene } from "babylonjs/scene";
  60334. import { ISize } from "babylonjs/Maths/math.size";
  60335. import { Color4 } from "babylonjs/Maths/math.color";
  60336. import { Engine } from "babylonjs/Engines/engine";
  60337. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60339. import { Mesh } from "babylonjs/Meshes/mesh";
  60340. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60341. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60342. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60343. import { Effect } from "babylonjs/Materials/effect";
  60344. import { Material } from "babylonjs/Materials/material";
  60345. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60346. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60347. /**
  60348. * Effect layer options. This helps customizing the behaviour
  60349. * of the effect layer.
  60350. */
  60351. export interface IEffectLayerOptions {
  60352. /**
  60353. * Multiplication factor apply to the canvas size to compute the render target size
  60354. * used to generated the objects (the smaller the faster).
  60355. */
  60356. mainTextureRatio: number;
  60357. /**
  60358. * Enforces a fixed size texture to ensure effect stability across devices.
  60359. */
  60360. mainTextureFixedSize?: number;
  60361. /**
  60362. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60363. */
  60364. alphaBlendingMode: number;
  60365. /**
  60366. * The camera attached to the layer.
  60367. */
  60368. camera: Nullable<Camera>;
  60369. /**
  60370. * The rendering group to draw the layer in.
  60371. */
  60372. renderingGroupId: number;
  60373. }
  60374. /**
  60375. * The effect layer Helps adding post process effect blended with the main pass.
  60376. *
  60377. * This can be for instance use to generate glow or higlight effects on the scene.
  60378. *
  60379. * The effect layer class can not be used directly and is intented to inherited from to be
  60380. * customized per effects.
  60381. */
  60382. export abstract class EffectLayer {
  60383. private _vertexBuffers;
  60384. private _indexBuffer;
  60385. private _cachedDefines;
  60386. private _effectLayerMapGenerationEffect;
  60387. private _effectLayerOptions;
  60388. private _mergeEffect;
  60389. protected _scene: Scene;
  60390. protected _engine: Engine;
  60391. protected _maxSize: number;
  60392. protected _mainTextureDesiredSize: ISize;
  60393. protected _mainTexture: RenderTargetTexture;
  60394. protected _shouldRender: boolean;
  60395. protected _postProcesses: PostProcess[];
  60396. protected _textures: BaseTexture[];
  60397. protected _emissiveTextureAndColor: {
  60398. texture: Nullable<BaseTexture>;
  60399. color: Color4;
  60400. };
  60401. /**
  60402. * The name of the layer
  60403. */
  60404. name: string;
  60405. /**
  60406. * The clear color of the texture used to generate the glow map.
  60407. */
  60408. neutralColor: Color4;
  60409. /**
  60410. * Specifies whether the highlight layer is enabled or not.
  60411. */
  60412. isEnabled: boolean;
  60413. /**
  60414. * Gets the camera attached to the layer.
  60415. */
  60416. get camera(): Nullable<Camera>;
  60417. /**
  60418. * Gets the rendering group id the layer should render in.
  60419. */
  60420. get renderingGroupId(): number;
  60421. set renderingGroupId(renderingGroupId: number);
  60422. /**
  60423. * An event triggered when the effect layer has been disposed.
  60424. */
  60425. onDisposeObservable: Observable<EffectLayer>;
  60426. /**
  60427. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60428. */
  60429. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60430. /**
  60431. * An event triggered when the generated texture is being merged in the scene.
  60432. */
  60433. onBeforeComposeObservable: Observable<EffectLayer>;
  60434. /**
  60435. * An event triggered when the mesh is rendered into the effect render target.
  60436. */
  60437. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60438. /**
  60439. * An event triggered after the mesh has been rendered into the effect render target.
  60440. */
  60441. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60442. /**
  60443. * An event triggered when the generated texture has been merged in the scene.
  60444. */
  60445. onAfterComposeObservable: Observable<EffectLayer>;
  60446. /**
  60447. * An event triggered when the efffect layer changes its size.
  60448. */
  60449. onSizeChangedObservable: Observable<EffectLayer>;
  60450. /** @hidden */
  60451. static _SceneComponentInitialization: (scene: Scene) => void;
  60452. /**
  60453. * Instantiates a new effect Layer and references it in the scene.
  60454. * @param name The name of the layer
  60455. * @param scene The scene to use the layer in
  60456. */
  60457. constructor(
  60458. /** The Friendly of the effect in the scene */
  60459. name: string, scene: Scene);
  60460. /**
  60461. * Get the effect name of the layer.
  60462. * @return The effect name
  60463. */
  60464. abstract getEffectName(): string;
  60465. /**
  60466. * Checks for the readiness of the element composing the layer.
  60467. * @param subMesh the mesh to check for
  60468. * @param useInstances specify whether or not to use instances to render the mesh
  60469. * @return true if ready otherwise, false
  60470. */
  60471. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60472. /**
  60473. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60474. * @returns true if the effect requires stencil during the main canvas render pass.
  60475. */
  60476. abstract needStencil(): boolean;
  60477. /**
  60478. * Create the merge effect. This is the shader use to blit the information back
  60479. * to the main canvas at the end of the scene rendering.
  60480. * @returns The effect containing the shader used to merge the effect on the main canvas
  60481. */
  60482. protected abstract _createMergeEffect(): Effect;
  60483. /**
  60484. * Creates the render target textures and post processes used in the effect layer.
  60485. */
  60486. protected abstract _createTextureAndPostProcesses(): void;
  60487. /**
  60488. * Implementation specific of rendering the generating effect on the main canvas.
  60489. * @param effect The effect used to render through
  60490. */
  60491. protected abstract _internalRender(effect: Effect): void;
  60492. /**
  60493. * Sets the required values for both the emissive texture and and the main color.
  60494. */
  60495. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60496. /**
  60497. * Free any resources and references associated to a mesh.
  60498. * Internal use
  60499. * @param mesh The mesh to free.
  60500. */
  60501. abstract _disposeMesh(mesh: Mesh): void;
  60502. /**
  60503. * Serializes this layer (Glow or Highlight for example)
  60504. * @returns a serialized layer object
  60505. */
  60506. abstract serialize?(): any;
  60507. /**
  60508. * Initializes the effect layer with the required options.
  60509. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60510. */
  60511. protected _init(options: Partial<IEffectLayerOptions>): void;
  60512. /**
  60513. * Generates the index buffer of the full screen quad blending to the main canvas.
  60514. */
  60515. private _generateIndexBuffer;
  60516. /**
  60517. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60518. */
  60519. private _generateVertexBuffer;
  60520. /**
  60521. * Sets the main texture desired size which is the closest power of two
  60522. * of the engine canvas size.
  60523. */
  60524. private _setMainTextureSize;
  60525. /**
  60526. * Creates the main texture for the effect layer.
  60527. */
  60528. protected _createMainTexture(): void;
  60529. /**
  60530. * Adds specific effects defines.
  60531. * @param defines The defines to add specifics to.
  60532. */
  60533. protected _addCustomEffectDefines(defines: string[]): void;
  60534. /**
  60535. * Checks for the readiness of the element composing the layer.
  60536. * @param subMesh the mesh to check for
  60537. * @param useInstances specify whether or not to use instances to render the mesh
  60538. * @param emissiveTexture the associated emissive texture used to generate the glow
  60539. * @return true if ready otherwise, false
  60540. */
  60541. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60542. /**
  60543. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60544. */
  60545. render(): void;
  60546. /**
  60547. * Determine if a given mesh will be used in the current effect.
  60548. * @param mesh mesh to test
  60549. * @returns true if the mesh will be used
  60550. */
  60551. hasMesh(mesh: AbstractMesh): boolean;
  60552. /**
  60553. * Returns true if the layer contains information to display, otherwise false.
  60554. * @returns true if the glow layer should be rendered
  60555. */
  60556. shouldRender(): boolean;
  60557. /**
  60558. * Returns true if the mesh should render, otherwise false.
  60559. * @param mesh The mesh to render
  60560. * @returns true if it should render otherwise false
  60561. */
  60562. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60563. /**
  60564. * Returns true if the mesh can be rendered, otherwise false.
  60565. * @param mesh The mesh to render
  60566. * @param material The material used on the mesh
  60567. * @returns true if it can be rendered otherwise false
  60568. */
  60569. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60570. /**
  60571. * Returns true if the mesh should render, otherwise false.
  60572. * @param mesh The mesh to render
  60573. * @returns true if it should render otherwise false
  60574. */
  60575. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60576. /**
  60577. * Renders the submesh passed in parameter to the generation map.
  60578. */
  60579. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60580. /**
  60581. * Defines whether the current material of the mesh should be use to render the effect.
  60582. * @param mesh defines the current mesh to render
  60583. */
  60584. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60585. /**
  60586. * Rebuild the required buffers.
  60587. * @hidden Internal use only.
  60588. */
  60589. _rebuild(): void;
  60590. /**
  60591. * Dispose only the render target textures and post process.
  60592. */
  60593. private _disposeTextureAndPostProcesses;
  60594. /**
  60595. * Dispose the highlight layer and free resources.
  60596. */
  60597. dispose(): void;
  60598. /**
  60599. * Gets the class name of the effect layer
  60600. * @returns the string with the class name of the effect layer
  60601. */
  60602. getClassName(): string;
  60603. /**
  60604. * Creates an effect layer from parsed effect layer data
  60605. * @param parsedEffectLayer defines effect layer data
  60606. * @param scene defines the current scene
  60607. * @param rootUrl defines the root URL containing the effect layer information
  60608. * @returns a parsed effect Layer
  60609. */
  60610. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60611. }
  60612. }
  60613. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60614. import { Scene } from "babylonjs/scene";
  60615. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60616. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60617. import { AbstractScene } from "babylonjs/abstractScene";
  60618. module "babylonjs/abstractScene" {
  60619. interface AbstractScene {
  60620. /**
  60621. * The list of effect layers (highlights/glow) added to the scene
  60622. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60623. * @see https://doc.babylonjs.com/how_to/glow_layer
  60624. */
  60625. effectLayers: Array<EffectLayer>;
  60626. /**
  60627. * Removes the given effect layer from this scene.
  60628. * @param toRemove defines the effect layer to remove
  60629. * @returns the index of the removed effect layer
  60630. */
  60631. removeEffectLayer(toRemove: EffectLayer): number;
  60632. /**
  60633. * Adds the given effect layer to this scene
  60634. * @param newEffectLayer defines the effect layer to add
  60635. */
  60636. addEffectLayer(newEffectLayer: EffectLayer): void;
  60637. }
  60638. }
  60639. /**
  60640. * Defines the layer scene component responsible to manage any effect layers
  60641. * in a given scene.
  60642. */
  60643. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60644. /**
  60645. * The component name helpfull to identify the component in the list of scene components.
  60646. */
  60647. readonly name: string;
  60648. /**
  60649. * The scene the component belongs to.
  60650. */
  60651. scene: Scene;
  60652. private _engine;
  60653. private _renderEffects;
  60654. private _needStencil;
  60655. private _previousStencilState;
  60656. /**
  60657. * Creates a new instance of the component for the given scene
  60658. * @param scene Defines the scene to register the component in
  60659. */
  60660. constructor(scene: Scene);
  60661. /**
  60662. * Registers the component in a given scene
  60663. */
  60664. register(): void;
  60665. /**
  60666. * Rebuilds the elements related to this component in case of
  60667. * context lost for instance.
  60668. */
  60669. rebuild(): void;
  60670. /**
  60671. * Serializes the component data to the specified json object
  60672. * @param serializationObject The object to serialize to
  60673. */
  60674. serialize(serializationObject: any): void;
  60675. /**
  60676. * Adds all the elements from the container to the scene
  60677. * @param container the container holding the elements
  60678. */
  60679. addFromContainer(container: AbstractScene): void;
  60680. /**
  60681. * Removes all the elements in the container from the scene
  60682. * @param container contains the elements to remove
  60683. * @param dispose if the removed element should be disposed (default: false)
  60684. */
  60685. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60686. /**
  60687. * Disposes the component and the associated ressources.
  60688. */
  60689. dispose(): void;
  60690. private _isReadyForMesh;
  60691. private _renderMainTexture;
  60692. private _setStencil;
  60693. private _setStencilBack;
  60694. private _draw;
  60695. private _drawCamera;
  60696. private _drawRenderingGroup;
  60697. }
  60698. }
  60699. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60700. /** @hidden */
  60701. export var glowMapMergePixelShader: {
  60702. name: string;
  60703. shader: string;
  60704. };
  60705. }
  60706. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60707. /** @hidden */
  60708. export var glowMapMergeVertexShader: {
  60709. name: string;
  60710. shader: string;
  60711. };
  60712. }
  60713. declare module "babylonjs/Layers/glowLayer" {
  60714. import { Nullable } from "babylonjs/types";
  60715. import { Camera } from "babylonjs/Cameras/camera";
  60716. import { Scene } from "babylonjs/scene";
  60717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60719. import { Mesh } from "babylonjs/Meshes/mesh";
  60720. import { Texture } from "babylonjs/Materials/Textures/texture";
  60721. import { Effect } from "babylonjs/Materials/effect";
  60722. import { Material } from "babylonjs/Materials/material";
  60723. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60724. import { Color4 } from "babylonjs/Maths/math.color";
  60725. import "babylonjs/Shaders/glowMapMerge.fragment";
  60726. import "babylonjs/Shaders/glowMapMerge.vertex";
  60727. import "babylonjs/Layers/effectLayerSceneComponent";
  60728. module "babylonjs/abstractScene" {
  60729. interface AbstractScene {
  60730. /**
  60731. * Return a the first highlight layer of the scene with a given name.
  60732. * @param name The name of the highlight layer to look for.
  60733. * @return The highlight layer if found otherwise null.
  60734. */
  60735. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60736. }
  60737. }
  60738. /**
  60739. * Glow layer options. This helps customizing the behaviour
  60740. * of the glow layer.
  60741. */
  60742. export interface IGlowLayerOptions {
  60743. /**
  60744. * Multiplication factor apply to the canvas size to compute the render target size
  60745. * used to generated the glowing objects (the smaller the faster).
  60746. */
  60747. mainTextureRatio: number;
  60748. /**
  60749. * Enforces a fixed size texture to ensure resize independant blur.
  60750. */
  60751. mainTextureFixedSize?: number;
  60752. /**
  60753. * How big is the kernel of the blur texture.
  60754. */
  60755. blurKernelSize: number;
  60756. /**
  60757. * The camera attached to the layer.
  60758. */
  60759. camera: Nullable<Camera>;
  60760. /**
  60761. * Enable MSAA by chosing the number of samples.
  60762. */
  60763. mainTextureSamples?: number;
  60764. /**
  60765. * The rendering group to draw the layer in.
  60766. */
  60767. renderingGroupId: number;
  60768. }
  60769. /**
  60770. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60771. *
  60772. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60773. *
  60774. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60775. */
  60776. export class GlowLayer extends EffectLayer {
  60777. /**
  60778. * Effect Name of the layer.
  60779. */
  60780. static readonly EffectName: string;
  60781. /**
  60782. * The default blur kernel size used for the glow.
  60783. */
  60784. static DefaultBlurKernelSize: number;
  60785. /**
  60786. * The default texture size ratio used for the glow.
  60787. */
  60788. static DefaultTextureRatio: number;
  60789. /**
  60790. * Sets the kernel size of the blur.
  60791. */
  60792. set blurKernelSize(value: number);
  60793. /**
  60794. * Gets the kernel size of the blur.
  60795. */
  60796. get blurKernelSize(): number;
  60797. /**
  60798. * Sets the glow intensity.
  60799. */
  60800. set intensity(value: number);
  60801. /**
  60802. * Gets the glow intensity.
  60803. */
  60804. get intensity(): number;
  60805. private _options;
  60806. private _intensity;
  60807. private _horizontalBlurPostprocess1;
  60808. private _verticalBlurPostprocess1;
  60809. private _horizontalBlurPostprocess2;
  60810. private _verticalBlurPostprocess2;
  60811. private _blurTexture1;
  60812. private _blurTexture2;
  60813. private _postProcesses1;
  60814. private _postProcesses2;
  60815. private _includedOnlyMeshes;
  60816. private _excludedMeshes;
  60817. private _meshesUsingTheirOwnMaterials;
  60818. /**
  60819. * Callback used to let the user override the color selection on a per mesh basis
  60820. */
  60821. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60822. /**
  60823. * Callback used to let the user override the texture selection on a per mesh basis
  60824. */
  60825. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60826. /**
  60827. * Instantiates a new glow Layer and references it to the scene.
  60828. * @param name The name of the layer
  60829. * @param scene The scene to use the layer in
  60830. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60831. */
  60832. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60833. /**
  60834. * Get the effect name of the layer.
  60835. * @return The effect name
  60836. */
  60837. getEffectName(): string;
  60838. /**
  60839. * Create the merge effect. This is the shader use to blit the information back
  60840. * to the main canvas at the end of the scene rendering.
  60841. */
  60842. protected _createMergeEffect(): Effect;
  60843. /**
  60844. * Creates the render target textures and post processes used in the glow layer.
  60845. */
  60846. protected _createTextureAndPostProcesses(): void;
  60847. /**
  60848. * Checks for the readiness of the element composing the layer.
  60849. * @param subMesh the mesh to check for
  60850. * @param useInstances specify wether or not to use instances to render the mesh
  60851. * @param emissiveTexture the associated emissive texture used to generate the glow
  60852. * @return true if ready otherwise, false
  60853. */
  60854. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60855. /**
  60856. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60857. */
  60858. needStencil(): boolean;
  60859. /**
  60860. * Returns true if the mesh can be rendered, otherwise false.
  60861. * @param mesh The mesh to render
  60862. * @param material The material used on the mesh
  60863. * @returns true if it can be rendered otherwise false
  60864. */
  60865. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60866. /**
  60867. * Implementation specific of rendering the generating effect on the main canvas.
  60868. * @param effect The effect used to render through
  60869. */
  60870. protected _internalRender(effect: Effect): void;
  60871. /**
  60872. * Sets the required values for both the emissive texture and and the main color.
  60873. */
  60874. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60875. /**
  60876. * Returns true if the mesh should render, otherwise false.
  60877. * @param mesh The mesh to render
  60878. * @returns true if it should render otherwise false
  60879. */
  60880. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60881. /**
  60882. * Adds specific effects defines.
  60883. * @param defines The defines to add specifics to.
  60884. */
  60885. protected _addCustomEffectDefines(defines: string[]): void;
  60886. /**
  60887. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60888. * @param mesh The mesh to exclude from the glow layer
  60889. */
  60890. addExcludedMesh(mesh: Mesh): void;
  60891. /**
  60892. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60893. * @param mesh The mesh to remove
  60894. */
  60895. removeExcludedMesh(mesh: Mesh): void;
  60896. /**
  60897. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60898. * @param mesh The mesh to include in the glow layer
  60899. */
  60900. addIncludedOnlyMesh(mesh: Mesh): void;
  60901. /**
  60902. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60903. * @param mesh The mesh to remove
  60904. */
  60905. removeIncludedOnlyMesh(mesh: Mesh): void;
  60906. /**
  60907. * Determine if a given mesh will be used in the glow layer
  60908. * @param mesh The mesh to test
  60909. * @returns true if the mesh will be highlighted by the current glow layer
  60910. */
  60911. hasMesh(mesh: AbstractMesh): boolean;
  60912. /**
  60913. * Defines whether the current material of the mesh should be use to render the effect.
  60914. * @param mesh defines the current mesh to render
  60915. */
  60916. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60917. /**
  60918. * Add a mesh to be rendered through its own material and not with emissive only.
  60919. * @param mesh The mesh for which we need to use its material
  60920. */
  60921. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60922. /**
  60923. * Remove a mesh from being rendered through its own material and not with emissive only.
  60924. * @param mesh The mesh for which we need to not use its material
  60925. */
  60926. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60927. /**
  60928. * Free any resources and references associated to a mesh.
  60929. * Internal use
  60930. * @param mesh The mesh to free.
  60931. * @hidden
  60932. */
  60933. _disposeMesh(mesh: Mesh): void;
  60934. /**
  60935. * Gets the class name of the effect layer
  60936. * @returns the string with the class name of the effect layer
  60937. */
  60938. getClassName(): string;
  60939. /**
  60940. * Serializes this glow layer
  60941. * @returns a serialized glow layer object
  60942. */
  60943. serialize(): any;
  60944. /**
  60945. * Creates a Glow Layer from parsed glow layer data
  60946. * @param parsedGlowLayer defines glow layer data
  60947. * @param scene defines the current scene
  60948. * @param rootUrl defines the root URL containing the glow layer information
  60949. * @returns a parsed Glow Layer
  60950. */
  60951. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60952. }
  60953. }
  60954. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60955. /** @hidden */
  60956. export var glowBlurPostProcessPixelShader: {
  60957. name: string;
  60958. shader: string;
  60959. };
  60960. }
  60961. declare module "babylonjs/Layers/highlightLayer" {
  60962. import { Observable } from "babylonjs/Misc/observable";
  60963. import { Nullable } from "babylonjs/types";
  60964. import { Camera } from "babylonjs/Cameras/camera";
  60965. import { Scene } from "babylonjs/scene";
  60966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60968. import { Mesh } from "babylonjs/Meshes/mesh";
  60969. import { Effect } from "babylonjs/Materials/effect";
  60970. import { Material } from "babylonjs/Materials/material";
  60971. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60972. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60973. import "babylonjs/Shaders/glowMapMerge.fragment";
  60974. import "babylonjs/Shaders/glowMapMerge.vertex";
  60975. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60976. module "babylonjs/abstractScene" {
  60977. interface AbstractScene {
  60978. /**
  60979. * Return a the first highlight layer of the scene with a given name.
  60980. * @param name The name of the highlight layer to look for.
  60981. * @return The highlight layer if found otherwise null.
  60982. */
  60983. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60984. }
  60985. }
  60986. /**
  60987. * Highlight layer options. This helps customizing the behaviour
  60988. * of the highlight layer.
  60989. */
  60990. export interface IHighlightLayerOptions {
  60991. /**
  60992. * Multiplication factor apply to the canvas size to compute the render target size
  60993. * used to generated the glowing objects (the smaller the faster).
  60994. */
  60995. mainTextureRatio: number;
  60996. /**
  60997. * Enforces a fixed size texture to ensure resize independant blur.
  60998. */
  60999. mainTextureFixedSize?: number;
  61000. /**
  61001. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61002. * of the picture to blur (the smaller the faster).
  61003. */
  61004. blurTextureSizeRatio: number;
  61005. /**
  61006. * How big in texel of the blur texture is the vertical blur.
  61007. */
  61008. blurVerticalSize: number;
  61009. /**
  61010. * How big in texel of the blur texture is the horizontal blur.
  61011. */
  61012. blurHorizontalSize: number;
  61013. /**
  61014. * Alpha blending mode used to apply the blur. Default is combine.
  61015. */
  61016. alphaBlendingMode: number;
  61017. /**
  61018. * The camera attached to the layer.
  61019. */
  61020. camera: Nullable<Camera>;
  61021. /**
  61022. * Should we display highlight as a solid stroke?
  61023. */
  61024. isStroke?: boolean;
  61025. /**
  61026. * The rendering group to draw the layer in.
  61027. */
  61028. renderingGroupId: number;
  61029. }
  61030. /**
  61031. * The highlight layer Helps adding a glow effect around a mesh.
  61032. *
  61033. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61034. * glowy meshes to your scene.
  61035. *
  61036. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61037. */
  61038. export class HighlightLayer extends EffectLayer {
  61039. name: string;
  61040. /**
  61041. * Effect Name of the highlight layer.
  61042. */
  61043. static readonly EffectName: string;
  61044. /**
  61045. * The neutral color used during the preparation of the glow effect.
  61046. * This is black by default as the blend operation is a blend operation.
  61047. */
  61048. static NeutralColor: Color4;
  61049. /**
  61050. * Stencil value used for glowing meshes.
  61051. */
  61052. static GlowingMeshStencilReference: number;
  61053. /**
  61054. * Stencil value used for the other meshes in the scene.
  61055. */
  61056. static NormalMeshStencilReference: number;
  61057. /**
  61058. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61059. */
  61060. innerGlow: boolean;
  61061. /**
  61062. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61063. */
  61064. outerGlow: boolean;
  61065. /**
  61066. * Specifies the horizontal size of the blur.
  61067. */
  61068. set blurHorizontalSize(value: number);
  61069. /**
  61070. * Specifies the vertical size of the blur.
  61071. */
  61072. set blurVerticalSize(value: number);
  61073. /**
  61074. * Gets the horizontal size of the blur.
  61075. */
  61076. get blurHorizontalSize(): number;
  61077. /**
  61078. * Gets the vertical size of the blur.
  61079. */
  61080. get blurVerticalSize(): number;
  61081. /**
  61082. * An event triggered when the highlight layer is being blurred.
  61083. */
  61084. onBeforeBlurObservable: Observable<HighlightLayer>;
  61085. /**
  61086. * An event triggered when the highlight layer has been blurred.
  61087. */
  61088. onAfterBlurObservable: Observable<HighlightLayer>;
  61089. private _instanceGlowingMeshStencilReference;
  61090. private _options;
  61091. private _downSamplePostprocess;
  61092. private _horizontalBlurPostprocess;
  61093. private _verticalBlurPostprocess;
  61094. private _blurTexture;
  61095. private _meshes;
  61096. private _excludedMeshes;
  61097. /**
  61098. * Instantiates a new highlight Layer and references it to the scene..
  61099. * @param name The name of the layer
  61100. * @param scene The scene to use the layer in
  61101. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61102. */
  61103. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61104. /**
  61105. * Get the effect name of the layer.
  61106. * @return The effect name
  61107. */
  61108. getEffectName(): string;
  61109. /**
  61110. * Create the merge effect. This is the shader use to blit the information back
  61111. * to the main canvas at the end of the scene rendering.
  61112. */
  61113. protected _createMergeEffect(): Effect;
  61114. /**
  61115. * Creates the render target textures and post processes used in the highlight layer.
  61116. */
  61117. protected _createTextureAndPostProcesses(): void;
  61118. /**
  61119. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61120. */
  61121. needStencil(): boolean;
  61122. /**
  61123. * Checks for the readiness of the element composing the layer.
  61124. * @param subMesh the mesh to check for
  61125. * @param useInstances specify wether or not to use instances to render the mesh
  61126. * @param emissiveTexture the associated emissive texture used to generate the glow
  61127. * @return true if ready otherwise, false
  61128. */
  61129. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61130. /**
  61131. * Implementation specific of rendering the generating effect on the main canvas.
  61132. * @param effect The effect used to render through
  61133. */
  61134. protected _internalRender(effect: Effect): void;
  61135. /**
  61136. * Returns true if the layer contains information to display, otherwise false.
  61137. */
  61138. shouldRender(): boolean;
  61139. /**
  61140. * Returns true if the mesh should render, otherwise false.
  61141. * @param mesh The mesh to render
  61142. * @returns true if it should render otherwise false
  61143. */
  61144. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61145. /**
  61146. * Returns true if the mesh can be rendered, otherwise false.
  61147. * @param mesh The mesh to render
  61148. * @param material The material used on the mesh
  61149. * @returns true if it can be rendered otherwise false
  61150. */
  61151. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61152. /**
  61153. * Adds specific effects defines.
  61154. * @param defines The defines to add specifics to.
  61155. */
  61156. protected _addCustomEffectDefines(defines: string[]): void;
  61157. /**
  61158. * Sets the required values for both the emissive texture and and the main color.
  61159. */
  61160. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61161. /**
  61162. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61163. * @param mesh The mesh to exclude from the highlight layer
  61164. */
  61165. addExcludedMesh(mesh: Mesh): void;
  61166. /**
  61167. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61168. * @param mesh The mesh to highlight
  61169. */
  61170. removeExcludedMesh(mesh: Mesh): void;
  61171. /**
  61172. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61173. * @param mesh mesh to test
  61174. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61175. */
  61176. hasMesh(mesh: AbstractMesh): boolean;
  61177. /**
  61178. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61179. * @param mesh The mesh to highlight
  61180. * @param color The color of the highlight
  61181. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61182. */
  61183. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61184. /**
  61185. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61186. * @param mesh The mesh to highlight
  61187. */
  61188. removeMesh(mesh: Mesh): void;
  61189. /**
  61190. * Remove all the meshes currently referenced in the highlight layer
  61191. */
  61192. removeAllMeshes(): void;
  61193. /**
  61194. * Force the stencil to the normal expected value for none glowing parts
  61195. */
  61196. private _defaultStencilReference;
  61197. /**
  61198. * Free any resources and references associated to a mesh.
  61199. * Internal use
  61200. * @param mesh The mesh to free.
  61201. * @hidden
  61202. */
  61203. _disposeMesh(mesh: Mesh): void;
  61204. /**
  61205. * Dispose the highlight layer and free resources.
  61206. */
  61207. dispose(): void;
  61208. /**
  61209. * Gets the class name of the effect layer
  61210. * @returns the string with the class name of the effect layer
  61211. */
  61212. getClassName(): string;
  61213. /**
  61214. * Serializes this Highlight layer
  61215. * @returns a serialized Highlight layer object
  61216. */
  61217. serialize(): any;
  61218. /**
  61219. * Creates a Highlight layer from parsed Highlight layer data
  61220. * @param parsedHightlightLayer defines the Highlight layer data
  61221. * @param scene defines the current scene
  61222. * @param rootUrl defines the root URL containing the Highlight layer information
  61223. * @returns a parsed Highlight layer
  61224. */
  61225. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61226. }
  61227. }
  61228. declare module "babylonjs/Layers/layerSceneComponent" {
  61229. import { Scene } from "babylonjs/scene";
  61230. import { ISceneComponent } from "babylonjs/sceneComponent";
  61231. import { Layer } from "babylonjs/Layers/layer";
  61232. import { AbstractScene } from "babylonjs/abstractScene";
  61233. module "babylonjs/abstractScene" {
  61234. interface AbstractScene {
  61235. /**
  61236. * The list of layers (background and foreground) of the scene
  61237. */
  61238. layers: Array<Layer>;
  61239. }
  61240. }
  61241. /**
  61242. * Defines the layer scene component responsible to manage any layers
  61243. * in a given scene.
  61244. */
  61245. export class LayerSceneComponent implements ISceneComponent {
  61246. /**
  61247. * The component name helpfull to identify the component in the list of scene components.
  61248. */
  61249. readonly name: string;
  61250. /**
  61251. * The scene the component belongs to.
  61252. */
  61253. scene: Scene;
  61254. private _engine;
  61255. /**
  61256. * Creates a new instance of the component for the given scene
  61257. * @param scene Defines the scene to register the component in
  61258. */
  61259. constructor(scene: Scene);
  61260. /**
  61261. * Registers the component in a given scene
  61262. */
  61263. register(): void;
  61264. /**
  61265. * Rebuilds the elements related to this component in case of
  61266. * context lost for instance.
  61267. */
  61268. rebuild(): void;
  61269. /**
  61270. * Disposes the component and the associated ressources.
  61271. */
  61272. dispose(): void;
  61273. private _draw;
  61274. private _drawCameraPredicate;
  61275. private _drawCameraBackground;
  61276. private _drawCameraForeground;
  61277. private _drawRenderTargetPredicate;
  61278. private _drawRenderTargetBackground;
  61279. private _drawRenderTargetForeground;
  61280. /**
  61281. * Adds all the elements from the container to the scene
  61282. * @param container the container holding the elements
  61283. */
  61284. addFromContainer(container: AbstractScene): void;
  61285. /**
  61286. * Removes all the elements in the container from the scene
  61287. * @param container contains the elements to remove
  61288. * @param dispose if the removed element should be disposed (default: false)
  61289. */
  61290. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61291. }
  61292. }
  61293. declare module "babylonjs/Shaders/layer.fragment" {
  61294. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61295. /** @hidden */
  61296. export var layerPixelShader: {
  61297. name: string;
  61298. shader: string;
  61299. };
  61300. }
  61301. declare module "babylonjs/Shaders/layer.vertex" {
  61302. /** @hidden */
  61303. export var layerVertexShader: {
  61304. name: string;
  61305. shader: string;
  61306. };
  61307. }
  61308. declare module "babylonjs/Layers/layer" {
  61309. import { Observable } from "babylonjs/Misc/observable";
  61310. import { Nullable } from "babylonjs/types";
  61311. import { Scene } from "babylonjs/scene";
  61312. import { Vector2 } from "babylonjs/Maths/math.vector";
  61313. import { Color4 } from "babylonjs/Maths/math.color";
  61314. import { Texture } from "babylonjs/Materials/Textures/texture";
  61315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61316. import "babylonjs/Shaders/layer.fragment";
  61317. import "babylonjs/Shaders/layer.vertex";
  61318. /**
  61319. * This represents a full screen 2d layer.
  61320. * This can be useful to display a picture in the background of your scene for instance.
  61321. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61322. */
  61323. export class Layer {
  61324. /**
  61325. * Define the name of the layer.
  61326. */
  61327. name: string;
  61328. /**
  61329. * Define the texture the layer should display.
  61330. */
  61331. texture: Nullable<Texture>;
  61332. /**
  61333. * Is the layer in background or foreground.
  61334. */
  61335. isBackground: boolean;
  61336. /**
  61337. * Define the color of the layer (instead of texture).
  61338. */
  61339. color: Color4;
  61340. /**
  61341. * Define the scale of the layer in order to zoom in out of the texture.
  61342. */
  61343. scale: Vector2;
  61344. /**
  61345. * Define an offset for the layer in order to shift the texture.
  61346. */
  61347. offset: Vector2;
  61348. /**
  61349. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61350. */
  61351. alphaBlendingMode: number;
  61352. /**
  61353. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61354. * Alpha test will not mix with the background color in case of transparency.
  61355. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61356. */
  61357. alphaTest: boolean;
  61358. /**
  61359. * Define a mask to restrict the layer to only some of the scene cameras.
  61360. */
  61361. layerMask: number;
  61362. /**
  61363. * Define the list of render target the layer is visible into.
  61364. */
  61365. renderTargetTextures: RenderTargetTexture[];
  61366. /**
  61367. * Define if the layer is only used in renderTarget or if it also
  61368. * renders in the main frame buffer of the canvas.
  61369. */
  61370. renderOnlyInRenderTargetTextures: boolean;
  61371. private _scene;
  61372. private _vertexBuffers;
  61373. private _indexBuffer;
  61374. private _effect;
  61375. private _previousDefines;
  61376. /**
  61377. * An event triggered when the layer is disposed.
  61378. */
  61379. onDisposeObservable: Observable<Layer>;
  61380. private _onDisposeObserver;
  61381. /**
  61382. * Back compatibility with callback before the onDisposeObservable existed.
  61383. * The set callback will be triggered when the layer has been disposed.
  61384. */
  61385. set onDispose(callback: () => void);
  61386. /**
  61387. * An event triggered before rendering the scene
  61388. */
  61389. onBeforeRenderObservable: Observable<Layer>;
  61390. private _onBeforeRenderObserver;
  61391. /**
  61392. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61393. * The set callback will be triggered just before rendering the layer.
  61394. */
  61395. set onBeforeRender(callback: () => void);
  61396. /**
  61397. * An event triggered after rendering the scene
  61398. */
  61399. onAfterRenderObservable: Observable<Layer>;
  61400. private _onAfterRenderObserver;
  61401. /**
  61402. * Back compatibility with callback before the onAfterRenderObservable existed.
  61403. * The set callback will be triggered just after rendering the layer.
  61404. */
  61405. set onAfterRender(callback: () => void);
  61406. /**
  61407. * Instantiates a new layer.
  61408. * This represents a full screen 2d layer.
  61409. * This can be useful to display a picture in the background of your scene for instance.
  61410. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61411. * @param name Define the name of the layer in the scene
  61412. * @param imgUrl Define the url of the texture to display in the layer
  61413. * @param scene Define the scene the layer belongs to
  61414. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61415. * @param color Defines a color for the layer
  61416. */
  61417. constructor(
  61418. /**
  61419. * Define the name of the layer.
  61420. */
  61421. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61422. private _createIndexBuffer;
  61423. /** @hidden */
  61424. _rebuild(): void;
  61425. /**
  61426. * Renders the layer in the scene.
  61427. */
  61428. render(): void;
  61429. /**
  61430. * Disposes and releases the associated ressources.
  61431. */
  61432. dispose(): void;
  61433. }
  61434. }
  61435. declare module "babylonjs/Layers/index" {
  61436. export * from "babylonjs/Layers/effectLayer";
  61437. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61438. export * from "babylonjs/Layers/glowLayer";
  61439. export * from "babylonjs/Layers/highlightLayer";
  61440. export * from "babylonjs/Layers/layer";
  61441. export * from "babylonjs/Layers/layerSceneComponent";
  61442. }
  61443. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61444. /** @hidden */
  61445. export var lensFlarePixelShader: {
  61446. name: string;
  61447. shader: string;
  61448. };
  61449. }
  61450. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61451. /** @hidden */
  61452. export var lensFlareVertexShader: {
  61453. name: string;
  61454. shader: string;
  61455. };
  61456. }
  61457. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61458. import { Scene } from "babylonjs/scene";
  61459. import { Vector3 } from "babylonjs/Maths/math.vector";
  61460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61461. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61462. import "babylonjs/Shaders/lensFlare.fragment";
  61463. import "babylonjs/Shaders/lensFlare.vertex";
  61464. import { Viewport } from "babylonjs/Maths/math.viewport";
  61465. /**
  61466. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61467. * It is usually composed of several `lensFlare`.
  61468. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61469. */
  61470. export class LensFlareSystem {
  61471. /**
  61472. * Define the name of the lens flare system
  61473. */
  61474. name: string;
  61475. /**
  61476. * List of lens flares used in this system.
  61477. */
  61478. lensFlares: LensFlare[];
  61479. /**
  61480. * Define a limit from the border the lens flare can be visible.
  61481. */
  61482. borderLimit: number;
  61483. /**
  61484. * Define a viewport border we do not want to see the lens flare in.
  61485. */
  61486. viewportBorder: number;
  61487. /**
  61488. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61489. */
  61490. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61491. /**
  61492. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61493. */
  61494. layerMask: number;
  61495. /**
  61496. * Define the id of the lens flare system in the scene.
  61497. * (equal to name by default)
  61498. */
  61499. id: string;
  61500. private _scene;
  61501. private _emitter;
  61502. private _vertexBuffers;
  61503. private _indexBuffer;
  61504. private _effect;
  61505. private _positionX;
  61506. private _positionY;
  61507. private _isEnabled;
  61508. /** @hidden */
  61509. static _SceneComponentInitialization: (scene: Scene) => void;
  61510. /**
  61511. * Instantiates a lens flare system.
  61512. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61513. * It is usually composed of several `lensFlare`.
  61514. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61515. * @param name Define the name of the lens flare system in the scene
  61516. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61517. * @param scene Define the scene the lens flare system belongs to
  61518. */
  61519. constructor(
  61520. /**
  61521. * Define the name of the lens flare system
  61522. */
  61523. name: string, emitter: any, scene: Scene);
  61524. /**
  61525. * Define if the lens flare system is enabled.
  61526. */
  61527. get isEnabled(): boolean;
  61528. set isEnabled(value: boolean);
  61529. /**
  61530. * Get the scene the effects belongs to.
  61531. * @returns the scene holding the lens flare system
  61532. */
  61533. getScene(): Scene;
  61534. /**
  61535. * Get the emitter of the lens flare system.
  61536. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61537. * @returns the emitter of the lens flare system
  61538. */
  61539. getEmitter(): any;
  61540. /**
  61541. * Set the emitter of the lens flare system.
  61542. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61543. * @param newEmitter Define the new emitter of the system
  61544. */
  61545. setEmitter(newEmitter: any): void;
  61546. /**
  61547. * Get the lens flare system emitter position.
  61548. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61549. * @returns the position
  61550. */
  61551. getEmitterPosition(): Vector3;
  61552. /**
  61553. * @hidden
  61554. */
  61555. computeEffectivePosition(globalViewport: Viewport): boolean;
  61556. /** @hidden */
  61557. _isVisible(): boolean;
  61558. /**
  61559. * @hidden
  61560. */
  61561. render(): boolean;
  61562. /**
  61563. * Dispose and release the lens flare with its associated resources.
  61564. */
  61565. dispose(): void;
  61566. /**
  61567. * Parse a lens flare system from a JSON repressentation
  61568. * @param parsedLensFlareSystem Define the JSON to parse
  61569. * @param scene Define the scene the parsed system should be instantiated in
  61570. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61571. * @returns the parsed system
  61572. */
  61573. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61574. /**
  61575. * Serialize the current Lens Flare System into a JSON representation.
  61576. * @returns the serialized JSON
  61577. */
  61578. serialize(): any;
  61579. }
  61580. }
  61581. declare module "babylonjs/LensFlares/lensFlare" {
  61582. import { Nullable } from "babylonjs/types";
  61583. import { Color3 } from "babylonjs/Maths/math.color";
  61584. import { Texture } from "babylonjs/Materials/Textures/texture";
  61585. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61586. /**
  61587. * This represents one of the lens effect in a `lensFlareSystem`.
  61588. * It controls one of the indiviual texture used in the effect.
  61589. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61590. */
  61591. export class LensFlare {
  61592. /**
  61593. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61594. */
  61595. size: number;
  61596. /**
  61597. * 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.
  61598. */
  61599. position: number;
  61600. /**
  61601. * Define the lens color.
  61602. */
  61603. color: Color3;
  61604. /**
  61605. * Define the lens texture.
  61606. */
  61607. texture: Nullable<Texture>;
  61608. /**
  61609. * Define the alpha mode to render this particular lens.
  61610. */
  61611. alphaMode: number;
  61612. private _system;
  61613. /**
  61614. * Creates a new Lens Flare.
  61615. * This represents one of the lens effect in a `lensFlareSystem`.
  61616. * It controls one of the indiviual texture used in the effect.
  61617. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61618. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61619. * @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.
  61620. * @param color Define the lens color
  61621. * @param imgUrl Define the lens texture url
  61622. * @param system Define the `lensFlareSystem` this flare is part of
  61623. * @returns The newly created Lens Flare
  61624. */
  61625. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61626. /**
  61627. * Instantiates a new Lens Flare.
  61628. * This represents one of the lens effect in a `lensFlareSystem`.
  61629. * It controls one of the indiviual texture used in the effect.
  61630. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61631. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61632. * @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.
  61633. * @param color Define the lens color
  61634. * @param imgUrl Define the lens texture url
  61635. * @param system Define the `lensFlareSystem` this flare is part of
  61636. */
  61637. constructor(
  61638. /**
  61639. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61640. */
  61641. size: number,
  61642. /**
  61643. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  61644. */
  61645. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61646. /**
  61647. * Dispose and release the lens flare with its associated resources.
  61648. */
  61649. dispose(): void;
  61650. }
  61651. }
  61652. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61653. import { Nullable } from "babylonjs/types";
  61654. import { Scene } from "babylonjs/scene";
  61655. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61656. import { AbstractScene } from "babylonjs/abstractScene";
  61657. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61658. module "babylonjs/abstractScene" {
  61659. interface AbstractScene {
  61660. /**
  61661. * The list of lens flare system added to the scene
  61662. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61663. */
  61664. lensFlareSystems: Array<LensFlareSystem>;
  61665. /**
  61666. * Removes the given lens flare system from this scene.
  61667. * @param toRemove The lens flare system to remove
  61668. * @returns The index of the removed lens flare system
  61669. */
  61670. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61671. /**
  61672. * Adds the given lens flare system to this scene
  61673. * @param newLensFlareSystem The lens flare system to add
  61674. */
  61675. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61676. /**
  61677. * Gets a lens flare system using its name
  61678. * @param name defines the name to look for
  61679. * @returns the lens flare system or null if not found
  61680. */
  61681. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61682. /**
  61683. * Gets a lens flare system using its id
  61684. * @param id defines the id to look for
  61685. * @returns the lens flare system or null if not found
  61686. */
  61687. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61688. }
  61689. }
  61690. /**
  61691. * Defines the lens flare scene component responsible to manage any lens flares
  61692. * in a given scene.
  61693. */
  61694. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61695. /**
  61696. * The component name helpfull to identify the component in the list of scene components.
  61697. */
  61698. readonly name: string;
  61699. /**
  61700. * The scene the component belongs to.
  61701. */
  61702. scene: Scene;
  61703. /**
  61704. * Creates a new instance of the component for the given scene
  61705. * @param scene Defines the scene to register the component in
  61706. */
  61707. constructor(scene: Scene);
  61708. /**
  61709. * Registers the component in a given scene
  61710. */
  61711. register(): void;
  61712. /**
  61713. * Rebuilds the elements related to this component in case of
  61714. * context lost for instance.
  61715. */
  61716. rebuild(): void;
  61717. /**
  61718. * Adds all the elements from the container to the scene
  61719. * @param container the container holding the elements
  61720. */
  61721. addFromContainer(container: AbstractScene): void;
  61722. /**
  61723. * Removes all the elements in the container from the scene
  61724. * @param container contains the elements to remove
  61725. * @param dispose if the removed element should be disposed (default: false)
  61726. */
  61727. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61728. /**
  61729. * Serializes the component data to the specified json object
  61730. * @param serializationObject The object to serialize to
  61731. */
  61732. serialize(serializationObject: any): void;
  61733. /**
  61734. * Disposes the component and the associated ressources.
  61735. */
  61736. dispose(): void;
  61737. private _draw;
  61738. }
  61739. }
  61740. declare module "babylonjs/LensFlares/index" {
  61741. export * from "babylonjs/LensFlares/lensFlare";
  61742. export * from "babylonjs/LensFlares/lensFlareSystem";
  61743. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61744. }
  61745. declare module "babylonjs/Shaders/depth.fragment" {
  61746. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61747. /** @hidden */
  61748. export var depthPixelShader: {
  61749. name: string;
  61750. shader: string;
  61751. };
  61752. }
  61753. declare module "babylonjs/Shaders/depth.vertex" {
  61754. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61755. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61756. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61757. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61758. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61759. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61760. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61761. /** @hidden */
  61762. export var depthVertexShader: {
  61763. name: string;
  61764. shader: string;
  61765. };
  61766. }
  61767. declare module "babylonjs/Rendering/depthRenderer" {
  61768. import { Nullable } from "babylonjs/types";
  61769. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61770. import { Scene } from "babylonjs/scene";
  61771. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61772. import { Camera } from "babylonjs/Cameras/camera";
  61773. import "babylonjs/Shaders/depth.fragment";
  61774. import "babylonjs/Shaders/depth.vertex";
  61775. /**
  61776. * This represents a depth renderer in Babylon.
  61777. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61778. */
  61779. export class DepthRenderer {
  61780. private _scene;
  61781. private _depthMap;
  61782. private _effect;
  61783. private readonly _storeNonLinearDepth;
  61784. private readonly _clearColor;
  61785. /** Get if the depth renderer is using packed depth or not */
  61786. readonly isPacked: boolean;
  61787. private _cachedDefines;
  61788. private _camera;
  61789. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61790. enabled: boolean;
  61791. /**
  61792. * Specifiess that the depth renderer will only be used within
  61793. * the camera it is created for.
  61794. * This can help forcing its rendering during the camera processing.
  61795. */
  61796. useOnlyInActiveCamera: boolean;
  61797. /** @hidden */
  61798. static _SceneComponentInitialization: (scene: Scene) => void;
  61799. /**
  61800. * Instantiates a depth renderer
  61801. * @param scene The scene the renderer belongs to
  61802. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61803. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61804. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61805. */
  61806. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61807. /**
  61808. * Creates the depth rendering effect and checks if the effect is ready.
  61809. * @param subMesh The submesh to be used to render the depth map of
  61810. * @param useInstances If multiple world instances should be used
  61811. * @returns if the depth renderer is ready to render the depth map
  61812. */
  61813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61814. /**
  61815. * Gets the texture which the depth map will be written to.
  61816. * @returns The depth map texture
  61817. */
  61818. getDepthMap(): RenderTargetTexture;
  61819. /**
  61820. * Disposes of the depth renderer.
  61821. */
  61822. dispose(): void;
  61823. }
  61824. }
  61825. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61826. /** @hidden */
  61827. export var minmaxReduxPixelShader: {
  61828. name: string;
  61829. shader: string;
  61830. };
  61831. }
  61832. declare module "babylonjs/Misc/minMaxReducer" {
  61833. import { Nullable } from "babylonjs/types";
  61834. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61835. import { Camera } from "babylonjs/Cameras/camera";
  61836. import { Observer } from "babylonjs/Misc/observable";
  61837. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61838. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61839. import { Observable } from "babylonjs/Misc/observable";
  61840. import "babylonjs/Shaders/minmaxRedux.fragment";
  61841. /**
  61842. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61843. * and maximum values from all values of the texture.
  61844. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61845. * The source values are read from the red channel of the texture.
  61846. */
  61847. export class MinMaxReducer {
  61848. /**
  61849. * Observable triggered when the computation has been performed
  61850. */
  61851. onAfterReductionPerformed: Observable<{
  61852. min: number;
  61853. max: number;
  61854. }>;
  61855. protected _camera: Camera;
  61856. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61857. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61858. protected _postProcessManager: PostProcessManager;
  61859. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61860. protected _forceFullscreenViewport: boolean;
  61861. /**
  61862. * Creates a min/max reducer
  61863. * @param camera The camera to use for the post processes
  61864. */
  61865. constructor(camera: Camera);
  61866. /**
  61867. * Gets the texture used to read the values from.
  61868. */
  61869. get sourceTexture(): Nullable<RenderTargetTexture>;
  61870. /**
  61871. * Sets the source texture to read the values from.
  61872. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61873. * because in such textures '1' value must not be taken into account to compute the maximum
  61874. * as this value is used to clear the texture.
  61875. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61876. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61877. * @param depthRedux Indicates if the texture is a depth texture or not
  61878. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61879. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61880. */
  61881. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61882. /**
  61883. * Defines the refresh rate of the computation.
  61884. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61885. */
  61886. get refreshRate(): number;
  61887. set refreshRate(value: number);
  61888. protected _activated: boolean;
  61889. /**
  61890. * Gets the activation status of the reducer
  61891. */
  61892. get activated(): boolean;
  61893. /**
  61894. * Activates the reduction computation.
  61895. * When activated, the observers registered in onAfterReductionPerformed are
  61896. * called after the compuation is performed
  61897. */
  61898. activate(): void;
  61899. /**
  61900. * Deactivates the reduction computation.
  61901. */
  61902. deactivate(): void;
  61903. /**
  61904. * Disposes the min/max reducer
  61905. * @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.
  61906. */
  61907. dispose(disposeAll?: boolean): void;
  61908. }
  61909. }
  61910. declare module "babylonjs/Misc/depthReducer" {
  61911. import { Nullable } from "babylonjs/types";
  61912. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61913. import { Camera } from "babylonjs/Cameras/camera";
  61914. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61915. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61916. /**
  61917. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61918. */
  61919. export class DepthReducer extends MinMaxReducer {
  61920. private _depthRenderer;
  61921. private _depthRendererId;
  61922. /**
  61923. * Gets the depth renderer used for the computation.
  61924. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61925. */
  61926. get depthRenderer(): Nullable<DepthRenderer>;
  61927. /**
  61928. * Creates a depth reducer
  61929. * @param camera The camera used to render the depth texture
  61930. */
  61931. constructor(camera: Camera);
  61932. /**
  61933. * Sets the depth renderer to use to generate the depth map
  61934. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61935. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61936. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61937. */
  61938. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61939. /** @hidden */
  61940. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61941. /**
  61942. * Activates the reduction computation.
  61943. * When activated, the observers registered in onAfterReductionPerformed are
  61944. * called after the compuation is performed
  61945. */
  61946. activate(): void;
  61947. /**
  61948. * Deactivates the reduction computation.
  61949. */
  61950. deactivate(): void;
  61951. /**
  61952. * Disposes the depth reducer
  61953. * @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.
  61954. */
  61955. dispose(disposeAll?: boolean): void;
  61956. }
  61957. }
  61958. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61959. import { Nullable } from "babylonjs/types";
  61960. import { Scene } from "babylonjs/scene";
  61961. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61962. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61964. import { Effect } from "babylonjs/Materials/effect";
  61965. import "babylonjs/Shaders/shadowMap.fragment";
  61966. import "babylonjs/Shaders/shadowMap.vertex";
  61967. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61968. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61969. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61970. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61971. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61972. /**
  61973. * A CSM implementation allowing casting shadows on large scenes.
  61974. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61975. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61976. */
  61977. export class CascadedShadowGenerator extends ShadowGenerator {
  61978. private static readonly frustumCornersNDCSpace;
  61979. /**
  61980. * Name of the CSM class
  61981. */
  61982. static CLASSNAME: string;
  61983. /**
  61984. * Defines the default number of cascades used by the CSM.
  61985. */
  61986. static readonly DEFAULT_CASCADES_COUNT: number;
  61987. /**
  61988. * Defines the minimum number of cascades used by the CSM.
  61989. */
  61990. static readonly MIN_CASCADES_COUNT: number;
  61991. /**
  61992. * Defines the maximum number of cascades used by the CSM.
  61993. */
  61994. static readonly MAX_CASCADES_COUNT: number;
  61995. protected _validateFilter(filter: number): number;
  61996. /**
  61997. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61998. */
  61999. penumbraDarkness: number;
  62000. private _numCascades;
  62001. /**
  62002. * Gets or set the number of cascades used by the CSM.
  62003. */
  62004. get numCascades(): number;
  62005. set numCascades(value: number);
  62006. /**
  62007. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62008. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62009. */
  62010. stabilizeCascades: boolean;
  62011. private _freezeShadowCastersBoundingInfo;
  62012. private _freezeShadowCastersBoundingInfoObservable;
  62013. /**
  62014. * Enables or disables the shadow casters bounding info computation.
  62015. * If your shadow casters don't move, you can disable this feature.
  62016. * If it is enabled, the bounding box computation is done every frame.
  62017. */
  62018. get freezeShadowCastersBoundingInfo(): boolean;
  62019. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62020. private _scbiMin;
  62021. private _scbiMax;
  62022. protected _computeShadowCastersBoundingInfo(): void;
  62023. protected _shadowCastersBoundingInfo: BoundingInfo;
  62024. /**
  62025. * Gets or sets the shadow casters bounding info.
  62026. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62027. * so that the system won't overwrite the bounds you provide
  62028. */
  62029. get shadowCastersBoundingInfo(): BoundingInfo;
  62030. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62031. protected _breaksAreDirty: boolean;
  62032. protected _minDistance: number;
  62033. protected _maxDistance: number;
  62034. /**
  62035. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62036. *
  62037. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62038. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62039. * @param min minimal distance for the breaks (default to 0.)
  62040. * @param max maximal distance for the breaks (default to 1.)
  62041. */
  62042. setMinMaxDistance(min: number, max: number): void;
  62043. /** Gets the minimal distance used in the cascade break computation */
  62044. get minDistance(): number;
  62045. /** Gets the maximal distance used in the cascade break computation */
  62046. get maxDistance(): number;
  62047. /**
  62048. * Gets the class name of that object
  62049. * @returns "CascadedShadowGenerator"
  62050. */
  62051. getClassName(): string;
  62052. private _cascadeMinExtents;
  62053. private _cascadeMaxExtents;
  62054. /**
  62055. * Gets a cascade minimum extents
  62056. * @param cascadeIndex index of the cascade
  62057. * @returns the minimum cascade extents
  62058. */
  62059. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62060. /**
  62061. * Gets a cascade maximum extents
  62062. * @param cascadeIndex index of the cascade
  62063. * @returns the maximum cascade extents
  62064. */
  62065. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62066. private _cascades;
  62067. private _currentLayer;
  62068. private _viewSpaceFrustumsZ;
  62069. private _viewMatrices;
  62070. private _projectionMatrices;
  62071. private _transformMatrices;
  62072. private _transformMatricesAsArray;
  62073. private _frustumLengths;
  62074. private _lightSizeUVCorrection;
  62075. private _depthCorrection;
  62076. private _frustumCornersWorldSpace;
  62077. private _frustumCenter;
  62078. private _shadowCameraPos;
  62079. private _shadowMaxZ;
  62080. /**
  62081. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62082. * It defaults to camera.maxZ
  62083. */
  62084. get shadowMaxZ(): number;
  62085. /**
  62086. * Sets the shadow max z distance.
  62087. */
  62088. set shadowMaxZ(value: number);
  62089. protected _debug: boolean;
  62090. /**
  62091. * Gets or sets the debug flag.
  62092. * When enabled, the cascades are materialized by different colors on the screen.
  62093. */
  62094. get debug(): boolean;
  62095. set debug(dbg: boolean);
  62096. private _depthClamp;
  62097. /**
  62098. * Gets or sets the depth clamping value.
  62099. *
  62100. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62101. * to account for the shadow casters far away.
  62102. *
  62103. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62104. */
  62105. get depthClamp(): boolean;
  62106. set depthClamp(value: boolean);
  62107. private _cascadeBlendPercentage;
  62108. /**
  62109. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62110. * It defaults to 0.1 (10% blending).
  62111. */
  62112. get cascadeBlendPercentage(): number;
  62113. set cascadeBlendPercentage(value: number);
  62114. private _lambda;
  62115. /**
  62116. * Gets or set the lambda parameter.
  62117. * This parameter is used to split the camera frustum and create the cascades.
  62118. * 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.
  62119. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62120. */
  62121. get lambda(): number;
  62122. set lambda(value: number);
  62123. /**
  62124. * Gets the view matrix corresponding to a given cascade
  62125. * @param cascadeNum cascade to retrieve the view matrix from
  62126. * @returns the cascade view matrix
  62127. */
  62128. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62129. /**
  62130. * Gets the projection matrix corresponding to a given cascade
  62131. * @param cascadeNum cascade to retrieve the projection matrix from
  62132. * @returns the cascade projection matrix
  62133. */
  62134. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62135. /**
  62136. * Gets the transformation matrix corresponding to a given cascade
  62137. * @param cascadeNum cascade to retrieve the transformation matrix from
  62138. * @returns the cascade transformation matrix
  62139. */
  62140. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62141. private _depthRenderer;
  62142. /**
  62143. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62144. *
  62145. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62146. *
  62147. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62148. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62149. * @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
  62150. */
  62151. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62152. private _depthReducer;
  62153. private _autoCalcDepthBounds;
  62154. /**
  62155. * Gets or sets the autoCalcDepthBounds property.
  62156. *
  62157. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62158. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62159. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62160. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62161. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62162. */
  62163. get autoCalcDepthBounds(): boolean;
  62164. set autoCalcDepthBounds(value: boolean);
  62165. /**
  62166. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62167. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62168. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62169. * for setting the refresh rate on the renderer yourself!
  62170. */
  62171. get autoCalcDepthBoundsRefreshRate(): number;
  62172. set autoCalcDepthBoundsRefreshRate(value: number);
  62173. /**
  62174. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62175. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62176. * you change the camera near/far planes!
  62177. */
  62178. splitFrustum(): void;
  62179. private _splitFrustum;
  62180. private _computeMatrices;
  62181. private _computeFrustumInWorldSpace;
  62182. private _computeCascadeFrustum;
  62183. /**
  62184. * Support test.
  62185. */
  62186. static get IsSupported(): boolean;
  62187. /** @hidden */
  62188. static _SceneComponentInitialization: (scene: Scene) => void;
  62189. /**
  62190. * Creates a Cascaded Shadow Generator object.
  62191. * A ShadowGenerator is the required tool to use the shadows.
  62192. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62193. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62194. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62195. * @param light The directional light object generating the shadows.
  62196. * @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.
  62197. */
  62198. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62199. protected _initializeGenerator(): void;
  62200. protected _createTargetRenderTexture(): void;
  62201. protected _initializeShadowMap(): void;
  62202. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62203. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62204. /**
  62205. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62206. * @param defines Defines of the material we want to update
  62207. * @param lightIndex Index of the light in the enabled light list of the material
  62208. */
  62209. prepareDefines(defines: any, lightIndex: number): void;
  62210. /**
  62211. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62212. * defined in the generator but impacting the effect).
  62213. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62214. * @param effect The effect we are binfing the information for
  62215. */
  62216. bindShadowLight(lightIndex: string, effect: Effect): void;
  62217. /**
  62218. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62219. * (eq to view projection * shadow projection matrices)
  62220. * @returns The transform matrix used to create the shadow map
  62221. */
  62222. getTransformMatrix(): Matrix;
  62223. /**
  62224. * Disposes the ShadowGenerator.
  62225. * Returns nothing.
  62226. */
  62227. dispose(): void;
  62228. /**
  62229. * Serializes the shadow generator setup to a json object.
  62230. * @returns The serialized JSON object
  62231. */
  62232. serialize(): any;
  62233. /**
  62234. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62235. * @param parsedShadowGenerator The JSON object to parse
  62236. * @param scene The scene to create the shadow map for
  62237. * @returns The parsed shadow generator
  62238. */
  62239. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62240. }
  62241. }
  62242. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62243. import { Scene } from "babylonjs/scene";
  62244. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62245. import { AbstractScene } from "babylonjs/abstractScene";
  62246. /**
  62247. * Defines the shadow generator component responsible to manage any shadow generators
  62248. * in a given scene.
  62249. */
  62250. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62251. /**
  62252. * The component name helpfull to identify the component in the list of scene components.
  62253. */
  62254. readonly name: string;
  62255. /**
  62256. * The scene the component belongs to.
  62257. */
  62258. scene: Scene;
  62259. /**
  62260. * Creates a new instance of the component for the given scene
  62261. * @param scene Defines the scene to register the component in
  62262. */
  62263. constructor(scene: Scene);
  62264. /**
  62265. * Registers the component in a given scene
  62266. */
  62267. register(): void;
  62268. /**
  62269. * Rebuilds the elements related to this component in case of
  62270. * context lost for instance.
  62271. */
  62272. rebuild(): void;
  62273. /**
  62274. * Serializes the component data to the specified json object
  62275. * @param serializationObject The object to serialize to
  62276. */
  62277. serialize(serializationObject: any): void;
  62278. /**
  62279. * Adds all the elements from the container to the scene
  62280. * @param container the container holding the elements
  62281. */
  62282. addFromContainer(container: AbstractScene): void;
  62283. /**
  62284. * Removes all the elements in the container from the scene
  62285. * @param container contains the elements to remove
  62286. * @param dispose if the removed element should be disposed (default: false)
  62287. */
  62288. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62289. /**
  62290. * Rebuilds the elements related to this component in case of
  62291. * context lost for instance.
  62292. */
  62293. dispose(): void;
  62294. private _gatherRenderTargets;
  62295. }
  62296. }
  62297. declare module "babylonjs/Lights/Shadows/index" {
  62298. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62299. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62300. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62301. }
  62302. declare module "babylonjs/Lights/pointLight" {
  62303. import { Scene } from "babylonjs/scene";
  62304. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62306. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62307. import { Effect } from "babylonjs/Materials/effect";
  62308. /**
  62309. * A point light is a light defined by an unique point in world space.
  62310. * The light is emitted in every direction from this point.
  62311. * A good example of a point light is a standard light bulb.
  62312. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62313. */
  62314. export class PointLight extends ShadowLight {
  62315. private _shadowAngle;
  62316. /**
  62317. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62318. * This specifies what angle the shadow will use to be created.
  62319. *
  62320. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62321. */
  62322. get shadowAngle(): number;
  62323. /**
  62324. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62325. * This specifies what angle the shadow will use to be created.
  62326. *
  62327. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62328. */
  62329. set shadowAngle(value: number);
  62330. /**
  62331. * Gets the direction if it has been set.
  62332. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62333. */
  62334. get direction(): Vector3;
  62335. /**
  62336. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62337. */
  62338. set direction(value: Vector3);
  62339. /**
  62340. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62341. * A PointLight emits the light in every direction.
  62342. * It can cast shadows.
  62343. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62344. * ```javascript
  62345. * var pointLight = new PointLight("pl", camera.position, scene);
  62346. * ```
  62347. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62348. * @param name The light friendly name
  62349. * @param position The position of the point light in the scene
  62350. * @param scene The scene the lights belongs to
  62351. */
  62352. constructor(name: string, position: Vector3, scene: Scene);
  62353. /**
  62354. * Returns the string "PointLight"
  62355. * @returns the class name
  62356. */
  62357. getClassName(): string;
  62358. /**
  62359. * Returns the integer 0.
  62360. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62361. */
  62362. getTypeID(): number;
  62363. /**
  62364. * Specifies wether or not the shadowmap should be a cube texture.
  62365. * @returns true if the shadowmap needs to be a cube texture.
  62366. */
  62367. needCube(): boolean;
  62368. /**
  62369. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62370. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62371. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62372. */
  62373. getShadowDirection(faceIndex?: number): Vector3;
  62374. /**
  62375. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62376. * - fov = PI / 2
  62377. * - aspect ratio : 1.0
  62378. * - z-near and far equal to the active camera minZ and maxZ.
  62379. * Returns the PointLight.
  62380. */
  62381. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62382. protected _buildUniformLayout(): void;
  62383. /**
  62384. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62385. * @param effect The effect to update
  62386. * @param lightIndex The index of the light in the effect to update
  62387. * @returns The point light
  62388. */
  62389. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62390. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62391. /**
  62392. * Prepares the list of defines specific to the light type.
  62393. * @param defines the list of defines
  62394. * @param lightIndex defines the index of the light for the effect
  62395. */
  62396. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62397. }
  62398. }
  62399. declare module "babylonjs/Lights/index" {
  62400. export * from "babylonjs/Lights/light";
  62401. export * from "babylonjs/Lights/shadowLight";
  62402. export * from "babylonjs/Lights/Shadows/index";
  62403. export * from "babylonjs/Lights/directionalLight";
  62404. export * from "babylonjs/Lights/hemisphericLight";
  62405. export * from "babylonjs/Lights/pointLight";
  62406. export * from "babylonjs/Lights/spotLight";
  62407. }
  62408. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62409. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62410. /**
  62411. * Header information of HDR texture files.
  62412. */
  62413. export interface HDRInfo {
  62414. /**
  62415. * The height of the texture in pixels.
  62416. */
  62417. height: number;
  62418. /**
  62419. * The width of the texture in pixels.
  62420. */
  62421. width: number;
  62422. /**
  62423. * The index of the beginning of the data in the binary file.
  62424. */
  62425. dataPosition: number;
  62426. }
  62427. /**
  62428. * This groups tools to convert HDR texture to native colors array.
  62429. */
  62430. export class HDRTools {
  62431. private static Ldexp;
  62432. private static Rgbe2float;
  62433. private static readStringLine;
  62434. /**
  62435. * Reads header information from an RGBE texture stored in a native array.
  62436. * More information on this format are available here:
  62437. * https://en.wikipedia.org/wiki/RGBE_image_format
  62438. *
  62439. * @param uint8array The binary file stored in native array.
  62440. * @return The header information.
  62441. */
  62442. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62443. /**
  62444. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62445. * This RGBE texture needs to store the information as a panorama.
  62446. *
  62447. * More information on this format are available here:
  62448. * https://en.wikipedia.org/wiki/RGBE_image_format
  62449. *
  62450. * @param buffer The binary file stored in an array buffer.
  62451. * @param size The expected size of the extracted cubemap.
  62452. * @return The Cube Map information.
  62453. */
  62454. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62455. /**
  62456. * Returns the pixels data extracted from an RGBE texture.
  62457. * This pixels will be stored left to right up to down in the R G B order in one array.
  62458. *
  62459. * More information on this format are available here:
  62460. * https://en.wikipedia.org/wiki/RGBE_image_format
  62461. *
  62462. * @param uint8array The binary file stored in an array buffer.
  62463. * @param hdrInfo The header information of the file.
  62464. * @return The pixels data in RGB right to left up to down order.
  62465. */
  62466. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62467. private static RGBE_ReadPixels_RLE;
  62468. private static RGBE_ReadPixels_NOT_RLE;
  62469. }
  62470. }
  62471. declare module "babylonjs/Materials/effectRenderer" {
  62472. import { Nullable } from "babylonjs/types";
  62473. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62474. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62475. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62476. import { Viewport } from "babylonjs/Maths/math.viewport";
  62477. import { Observable } from "babylonjs/Misc/observable";
  62478. import { Effect } from "babylonjs/Materials/effect";
  62479. import "babylonjs/Shaders/postprocess.vertex";
  62480. /**
  62481. * Effect Render Options
  62482. */
  62483. export interface IEffectRendererOptions {
  62484. /**
  62485. * Defines the vertices positions.
  62486. */
  62487. positions?: number[];
  62488. /**
  62489. * Defines the indices.
  62490. */
  62491. indices?: number[];
  62492. }
  62493. /**
  62494. * Helper class to render one or more effects.
  62495. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62496. */
  62497. export class EffectRenderer {
  62498. private engine;
  62499. private static _DefaultOptions;
  62500. private _vertexBuffers;
  62501. private _indexBuffer;
  62502. private _fullscreenViewport;
  62503. /**
  62504. * Creates an effect renderer
  62505. * @param engine the engine to use for rendering
  62506. * @param options defines the options of the effect renderer
  62507. */
  62508. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62509. /**
  62510. * Sets the current viewport in normalized coordinates 0-1
  62511. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62512. */
  62513. setViewport(viewport?: Viewport): void;
  62514. /**
  62515. * Binds the embedded attributes buffer to the effect.
  62516. * @param effect Defines the effect to bind the attributes for
  62517. */
  62518. bindBuffers(effect: Effect): void;
  62519. /**
  62520. * Sets the current effect wrapper to use during draw.
  62521. * The effect needs to be ready before calling this api.
  62522. * This also sets the default full screen position attribute.
  62523. * @param effectWrapper Defines the effect to draw with
  62524. */
  62525. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62526. /**
  62527. * Restores engine states
  62528. */
  62529. restoreStates(): void;
  62530. /**
  62531. * Draws a full screen quad.
  62532. */
  62533. draw(): void;
  62534. private isRenderTargetTexture;
  62535. /**
  62536. * renders one or more effects to a specified texture
  62537. * @param effectWrapper the effect to renderer
  62538. * @param outputTexture texture to draw to, if null it will render to the screen.
  62539. */
  62540. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62541. /**
  62542. * Disposes of the effect renderer
  62543. */
  62544. dispose(): void;
  62545. }
  62546. /**
  62547. * Options to create an EffectWrapper
  62548. */
  62549. interface EffectWrapperCreationOptions {
  62550. /**
  62551. * Engine to use to create the effect
  62552. */
  62553. engine: ThinEngine;
  62554. /**
  62555. * Fragment shader for the effect
  62556. */
  62557. fragmentShader: string;
  62558. /**
  62559. * Use the shader store instead of direct source code
  62560. */
  62561. useShaderStore?: boolean;
  62562. /**
  62563. * Vertex shader for the effect
  62564. */
  62565. vertexShader?: string;
  62566. /**
  62567. * Attributes to use in the shader
  62568. */
  62569. attributeNames?: Array<string>;
  62570. /**
  62571. * Uniforms to use in the shader
  62572. */
  62573. uniformNames?: Array<string>;
  62574. /**
  62575. * Texture sampler names to use in the shader
  62576. */
  62577. samplerNames?: Array<string>;
  62578. /**
  62579. * Defines to use in the shader
  62580. */
  62581. defines?: Array<string>;
  62582. /**
  62583. * Callback when effect is compiled
  62584. */
  62585. onCompiled?: Nullable<(effect: Effect) => void>;
  62586. /**
  62587. * The friendly name of the effect displayed in Spector.
  62588. */
  62589. name?: string;
  62590. }
  62591. /**
  62592. * Wraps an effect to be used for rendering
  62593. */
  62594. export class EffectWrapper {
  62595. /**
  62596. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62597. */
  62598. onApplyObservable: Observable<{}>;
  62599. /**
  62600. * The underlying effect
  62601. */
  62602. effect: Effect;
  62603. /**
  62604. * Creates an effect to be renderer
  62605. * @param creationOptions options to create the effect
  62606. */
  62607. constructor(creationOptions: EffectWrapperCreationOptions);
  62608. /**
  62609. * Disposes of the effect wrapper
  62610. */
  62611. dispose(): void;
  62612. }
  62613. }
  62614. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62615. /** @hidden */
  62616. export var hdrFilteringVertexShader: {
  62617. name: string;
  62618. shader: string;
  62619. };
  62620. }
  62621. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62622. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62623. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62624. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62625. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62626. /** @hidden */
  62627. export var hdrFilteringPixelShader: {
  62628. name: string;
  62629. shader: string;
  62630. };
  62631. }
  62632. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62634. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62635. import { Nullable } from "babylonjs/types";
  62636. import "babylonjs/Shaders/hdrFiltering.vertex";
  62637. import "babylonjs/Shaders/hdrFiltering.fragment";
  62638. /**
  62639. * Options for texture filtering
  62640. */
  62641. interface IHDRFilteringOptions {
  62642. /**
  62643. * Scales pixel intensity for the input HDR map.
  62644. */
  62645. hdrScale?: number;
  62646. /**
  62647. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62648. */
  62649. quality?: number;
  62650. }
  62651. /**
  62652. * Filters HDR maps to get correct renderings of PBR reflections
  62653. */
  62654. export class HDRFiltering {
  62655. private _engine;
  62656. private _effectRenderer;
  62657. private _effectWrapper;
  62658. private _lodGenerationOffset;
  62659. private _lodGenerationScale;
  62660. /**
  62661. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62662. * you care about baking speed.
  62663. */
  62664. quality: number;
  62665. /**
  62666. * Scales pixel intensity for the input HDR map.
  62667. */
  62668. hdrScale: number;
  62669. /**
  62670. * Instantiates HDR filter for reflection maps
  62671. *
  62672. * @param engine Thin engine
  62673. * @param options Options
  62674. */
  62675. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62676. private _createRenderTarget;
  62677. private _prefilterInternal;
  62678. private _createEffect;
  62679. /**
  62680. * Get a value indicating if the filter is ready to be used
  62681. * @param texture Texture to filter
  62682. * @returns true if the filter is ready
  62683. */
  62684. isReady(texture: BaseTexture): boolean;
  62685. /**
  62686. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62687. * Prefiltering will be invoked at the end of next rendering pass.
  62688. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62689. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62690. * @param texture Texture to filter
  62691. * @param onFinished Callback when filtering is done
  62692. * @return Promise called when prefiltering is done
  62693. */
  62694. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62695. }
  62696. }
  62697. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62698. import { Nullable } from "babylonjs/types";
  62699. import { Scene } from "babylonjs/scene";
  62700. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62701. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62702. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62703. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62704. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62705. /**
  62706. * This represents a texture coming from an HDR input.
  62707. *
  62708. * The only supported format is currently panorama picture stored in RGBE format.
  62709. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62710. */
  62711. export class HDRCubeTexture extends BaseTexture {
  62712. private static _facesMapping;
  62713. private _generateHarmonics;
  62714. private _noMipmap;
  62715. private _prefilterOnLoad;
  62716. private _textureMatrix;
  62717. private _size;
  62718. private _onLoad;
  62719. private _onError;
  62720. /**
  62721. * The texture URL.
  62722. */
  62723. url: string;
  62724. /**
  62725. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62726. */
  62727. coordinatesMode: number;
  62728. protected _isBlocking: boolean;
  62729. /**
  62730. * Sets wether or not the texture is blocking during loading.
  62731. */
  62732. set isBlocking(value: boolean);
  62733. /**
  62734. * Gets wether or not the texture is blocking during loading.
  62735. */
  62736. get isBlocking(): boolean;
  62737. protected _rotationY: number;
  62738. /**
  62739. * Sets texture matrix rotation angle around Y axis in radians.
  62740. */
  62741. set rotationY(value: number);
  62742. /**
  62743. * Gets texture matrix rotation angle around Y axis radians.
  62744. */
  62745. get rotationY(): number;
  62746. /**
  62747. * Gets or sets the center of the bounding box associated with the cube texture
  62748. * It must define where the camera used to render the texture was set
  62749. */
  62750. boundingBoxPosition: Vector3;
  62751. private _boundingBoxSize;
  62752. /**
  62753. * Gets or sets the size of the bounding box associated with the cube texture
  62754. * When defined, the cubemap will switch to local mode
  62755. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62756. * @example https://www.babylonjs-playground.com/#RNASML
  62757. */
  62758. set boundingBoxSize(value: Vector3);
  62759. get boundingBoxSize(): Vector3;
  62760. /**
  62761. * Instantiates an HDRTexture from the following parameters.
  62762. *
  62763. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62764. * @param sceneOrEngine The scene or engine the texture will be used in
  62765. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62766. * @param noMipmap Forces to not generate the mipmap if true
  62767. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62768. * @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)
  62769. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62770. */
  62771. 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>);
  62772. /**
  62773. * Get the current class name of the texture useful for serialization or dynamic coding.
  62774. * @returns "HDRCubeTexture"
  62775. */
  62776. getClassName(): string;
  62777. /**
  62778. * Occurs when the file is raw .hdr file.
  62779. */
  62780. private loadTexture;
  62781. clone(): HDRCubeTexture;
  62782. delayLoad(): void;
  62783. /**
  62784. * Get the texture reflection matrix used to rotate/transform the reflection.
  62785. * @returns the reflection matrix
  62786. */
  62787. getReflectionTextureMatrix(): Matrix;
  62788. /**
  62789. * Set the texture reflection matrix used to rotate/transform the reflection.
  62790. * @param value Define the reflection matrix to set
  62791. */
  62792. setReflectionTextureMatrix(value: Matrix): void;
  62793. /**
  62794. * Parses a JSON representation of an HDR Texture in order to create the texture
  62795. * @param parsedTexture Define the JSON representation
  62796. * @param scene Define the scene the texture should be created in
  62797. * @param rootUrl Define the root url in case we need to load relative dependencies
  62798. * @returns the newly created texture after parsing
  62799. */
  62800. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62801. serialize(): any;
  62802. }
  62803. }
  62804. declare module "babylonjs/Physics/physicsEngine" {
  62805. import { Nullable } from "babylonjs/types";
  62806. import { Vector3 } from "babylonjs/Maths/math.vector";
  62807. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62808. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62809. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62810. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62811. /**
  62812. * Class used to control physics engine
  62813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62814. */
  62815. export class PhysicsEngine implements IPhysicsEngine {
  62816. private _physicsPlugin;
  62817. /**
  62818. * Global value used to control the smallest number supported by the simulation
  62819. */
  62820. static Epsilon: number;
  62821. private _impostors;
  62822. private _joints;
  62823. private _subTimeStep;
  62824. /**
  62825. * Gets the gravity vector used by the simulation
  62826. */
  62827. gravity: Vector3;
  62828. /**
  62829. * Factory used to create the default physics plugin.
  62830. * @returns The default physics plugin
  62831. */
  62832. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62833. /**
  62834. * Creates a new Physics Engine
  62835. * @param gravity defines the gravity vector used by the simulation
  62836. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62837. */
  62838. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62839. /**
  62840. * Sets the gravity vector used by the simulation
  62841. * @param gravity defines the gravity vector to use
  62842. */
  62843. setGravity(gravity: Vector3): void;
  62844. /**
  62845. * Set the time step of the physics engine.
  62846. * Default is 1/60.
  62847. * To slow it down, enter 1/600 for example.
  62848. * To speed it up, 1/30
  62849. * @param newTimeStep defines the new timestep to apply to this world.
  62850. */
  62851. setTimeStep(newTimeStep?: number): void;
  62852. /**
  62853. * Get the time step of the physics engine.
  62854. * @returns the current time step
  62855. */
  62856. getTimeStep(): number;
  62857. /**
  62858. * Set the sub time step of the physics engine.
  62859. * Default is 0 meaning there is no sub steps
  62860. * To increase physics resolution precision, set a small value (like 1 ms)
  62861. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62862. */
  62863. setSubTimeStep(subTimeStep?: number): void;
  62864. /**
  62865. * Get the sub time step of the physics engine.
  62866. * @returns the current sub time step
  62867. */
  62868. getSubTimeStep(): number;
  62869. /**
  62870. * Release all resources
  62871. */
  62872. dispose(): void;
  62873. /**
  62874. * Gets the name of the current physics plugin
  62875. * @returns the name of the plugin
  62876. */
  62877. getPhysicsPluginName(): string;
  62878. /**
  62879. * Adding a new impostor for the impostor tracking.
  62880. * This will be done by the impostor itself.
  62881. * @param impostor the impostor to add
  62882. */
  62883. addImpostor(impostor: PhysicsImpostor): void;
  62884. /**
  62885. * Remove an impostor from the engine.
  62886. * This impostor and its mesh will not longer be updated by the physics engine.
  62887. * @param impostor the impostor to remove
  62888. */
  62889. removeImpostor(impostor: PhysicsImpostor): void;
  62890. /**
  62891. * Add a joint to the physics engine
  62892. * @param mainImpostor defines the main impostor to which the joint is added.
  62893. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62894. * @param joint defines the joint that will connect both impostors.
  62895. */
  62896. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62897. /**
  62898. * Removes a joint from the simulation
  62899. * @param mainImpostor defines the impostor used with the joint
  62900. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62901. * @param joint defines the joint to remove
  62902. */
  62903. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62904. /**
  62905. * Called by the scene. No need to call it.
  62906. * @param delta defines the timespam between frames
  62907. */
  62908. _step(delta: number): void;
  62909. /**
  62910. * Gets the current plugin used to run the simulation
  62911. * @returns current plugin
  62912. */
  62913. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62914. /**
  62915. * Gets the list of physic impostors
  62916. * @returns an array of PhysicsImpostor
  62917. */
  62918. getImpostors(): Array<PhysicsImpostor>;
  62919. /**
  62920. * Gets the impostor for a physics enabled object
  62921. * @param object defines the object impersonated by the impostor
  62922. * @returns the PhysicsImpostor or null if not found
  62923. */
  62924. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62925. /**
  62926. * Gets the impostor for a physics body object
  62927. * @param body defines physics body used by the impostor
  62928. * @returns the PhysicsImpostor or null if not found
  62929. */
  62930. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62931. /**
  62932. * Does a raycast in the physics world
  62933. * @param from when should the ray start?
  62934. * @param to when should the ray end?
  62935. * @returns PhysicsRaycastResult
  62936. */
  62937. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62938. }
  62939. }
  62940. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62941. import { Nullable } from "babylonjs/types";
  62942. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62944. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62945. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62946. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62947. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62948. /** @hidden */
  62949. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62950. private _useDeltaForWorldStep;
  62951. world: any;
  62952. name: string;
  62953. private _physicsMaterials;
  62954. private _fixedTimeStep;
  62955. private _cannonRaycastResult;
  62956. private _raycastResult;
  62957. private _physicsBodysToRemoveAfterStep;
  62958. private _firstFrame;
  62959. BJSCANNON: any;
  62960. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62961. setGravity(gravity: Vector3): void;
  62962. setTimeStep(timeStep: number): void;
  62963. getTimeStep(): number;
  62964. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62965. private _removeMarkedPhysicsBodiesFromWorld;
  62966. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62967. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62968. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62969. private _processChildMeshes;
  62970. removePhysicsBody(impostor: PhysicsImpostor): void;
  62971. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62972. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62973. private _addMaterial;
  62974. private _checkWithEpsilon;
  62975. private _createShape;
  62976. private _createHeightmap;
  62977. private _minus90X;
  62978. private _plus90X;
  62979. private _tmpPosition;
  62980. private _tmpDeltaPosition;
  62981. private _tmpUnityRotation;
  62982. private _updatePhysicsBodyTransformation;
  62983. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62984. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62985. isSupported(): boolean;
  62986. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62987. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62988. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62989. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62990. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62991. getBodyMass(impostor: PhysicsImpostor): number;
  62992. getBodyFriction(impostor: PhysicsImpostor): number;
  62993. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62994. getBodyRestitution(impostor: PhysicsImpostor): number;
  62995. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62996. sleepBody(impostor: PhysicsImpostor): void;
  62997. wakeUpBody(impostor: PhysicsImpostor): void;
  62998. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62999. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63000. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63001. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63002. getRadius(impostor: PhysicsImpostor): number;
  63003. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63004. dispose(): void;
  63005. private _extendNamespace;
  63006. /**
  63007. * Does a raycast in the physics world
  63008. * @param from when should the ray start?
  63009. * @param to when should the ray end?
  63010. * @returns PhysicsRaycastResult
  63011. */
  63012. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63013. }
  63014. }
  63015. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63016. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63017. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63018. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63020. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63021. import { Nullable } from "babylonjs/types";
  63022. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63023. /** @hidden */
  63024. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63025. private _useDeltaForWorldStep;
  63026. world: any;
  63027. name: string;
  63028. BJSOIMO: any;
  63029. private _raycastResult;
  63030. private _fixedTimeStep;
  63031. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63032. setGravity(gravity: Vector3): void;
  63033. setTimeStep(timeStep: number): void;
  63034. getTimeStep(): number;
  63035. private _tmpImpostorsArray;
  63036. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63037. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63038. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63039. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63040. private _tmpPositionVector;
  63041. removePhysicsBody(impostor: PhysicsImpostor): void;
  63042. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63043. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63044. isSupported(): boolean;
  63045. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63046. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63047. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63048. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63049. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63050. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63051. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63052. getBodyMass(impostor: PhysicsImpostor): number;
  63053. getBodyFriction(impostor: PhysicsImpostor): number;
  63054. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63055. getBodyRestitution(impostor: PhysicsImpostor): number;
  63056. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63057. sleepBody(impostor: PhysicsImpostor): void;
  63058. wakeUpBody(impostor: PhysicsImpostor): void;
  63059. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63060. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63061. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63062. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63063. getRadius(impostor: PhysicsImpostor): number;
  63064. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63065. dispose(): void;
  63066. /**
  63067. * Does a raycast in the physics world
  63068. * @param from when should the ray start?
  63069. * @param to when should the ray end?
  63070. * @returns PhysicsRaycastResult
  63071. */
  63072. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63073. }
  63074. }
  63075. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63076. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63077. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63079. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63080. import { Nullable } from "babylonjs/types";
  63081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63082. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63083. /**
  63084. * AmmoJS Physics plugin
  63085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63086. * @see https://github.com/kripken/ammo.js/
  63087. */
  63088. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63089. private _useDeltaForWorldStep;
  63090. /**
  63091. * Reference to the Ammo library
  63092. */
  63093. bjsAMMO: any;
  63094. /**
  63095. * Created ammoJS world which physics bodies are added to
  63096. */
  63097. world: any;
  63098. /**
  63099. * Name of the plugin
  63100. */
  63101. name: string;
  63102. private _timeStep;
  63103. private _fixedTimeStep;
  63104. private _maxSteps;
  63105. private _tmpQuaternion;
  63106. private _tmpAmmoTransform;
  63107. private _tmpAmmoQuaternion;
  63108. private _tmpAmmoConcreteContactResultCallback;
  63109. private _collisionConfiguration;
  63110. private _dispatcher;
  63111. private _overlappingPairCache;
  63112. private _solver;
  63113. private _softBodySolver;
  63114. private _tmpAmmoVectorA;
  63115. private _tmpAmmoVectorB;
  63116. private _tmpAmmoVectorC;
  63117. private _tmpAmmoVectorD;
  63118. private _tmpContactCallbackResult;
  63119. private _tmpAmmoVectorRCA;
  63120. private _tmpAmmoVectorRCB;
  63121. private _raycastResult;
  63122. private static readonly DISABLE_COLLISION_FLAG;
  63123. private static readonly KINEMATIC_FLAG;
  63124. private static readonly DISABLE_DEACTIVATION_FLAG;
  63125. /**
  63126. * Initializes the ammoJS plugin
  63127. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63128. * @param ammoInjection can be used to inject your own ammo reference
  63129. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63130. */
  63131. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63132. /**
  63133. * Sets the gravity of the physics world (m/(s^2))
  63134. * @param gravity Gravity to set
  63135. */
  63136. setGravity(gravity: Vector3): void;
  63137. /**
  63138. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63139. * @param timeStep timestep to use in seconds
  63140. */
  63141. setTimeStep(timeStep: number): void;
  63142. /**
  63143. * 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)
  63144. * @param fixedTimeStep fixedTimeStep to use in seconds
  63145. */
  63146. setFixedTimeStep(fixedTimeStep: number): void;
  63147. /**
  63148. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63149. * @param maxSteps the maximum number of steps by the physics engine per frame
  63150. */
  63151. setMaxSteps(maxSteps: number): void;
  63152. /**
  63153. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63154. * @returns the current timestep in seconds
  63155. */
  63156. getTimeStep(): number;
  63157. /**
  63158. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63159. */
  63160. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63161. private _isImpostorInContact;
  63162. private _isImpostorPairInContact;
  63163. private _stepSimulation;
  63164. /**
  63165. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63166. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63167. * After the step the babylon meshes are set to the position of the physics imposters
  63168. * @param delta amount of time to step forward
  63169. * @param impostors array of imposters to update before/after the step
  63170. */
  63171. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63172. /**
  63173. * Update babylon mesh to match physics world object
  63174. * @param impostor imposter to match
  63175. */
  63176. private _afterSoftStep;
  63177. /**
  63178. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63179. * @param impostor imposter to match
  63180. */
  63181. private _ropeStep;
  63182. /**
  63183. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63184. * @param impostor imposter to match
  63185. */
  63186. private _softbodyOrClothStep;
  63187. private _tmpMatrix;
  63188. /**
  63189. * Applies an impulse on the imposter
  63190. * @param impostor imposter to apply impulse to
  63191. * @param force amount of force to be applied to the imposter
  63192. * @param contactPoint the location to apply the impulse on the imposter
  63193. */
  63194. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63195. /**
  63196. * Applies a force on the imposter
  63197. * @param impostor imposter to apply force
  63198. * @param force amount of force to be applied to the imposter
  63199. * @param contactPoint the location to apply the force on the imposter
  63200. */
  63201. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63202. /**
  63203. * Creates a physics body using the plugin
  63204. * @param impostor the imposter to create the physics body on
  63205. */
  63206. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63207. /**
  63208. * Removes the physics body from the imposter and disposes of the body's memory
  63209. * @param impostor imposter to remove the physics body from
  63210. */
  63211. removePhysicsBody(impostor: PhysicsImpostor): void;
  63212. /**
  63213. * Generates a joint
  63214. * @param impostorJoint the imposter joint to create the joint with
  63215. */
  63216. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63217. /**
  63218. * Removes a joint
  63219. * @param impostorJoint the imposter joint to remove the joint from
  63220. */
  63221. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63222. private _addMeshVerts;
  63223. /**
  63224. * Initialise the soft body vertices to match its object's (mesh) vertices
  63225. * Softbody vertices (nodes) are in world space and to match this
  63226. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63227. * @param impostor to create the softbody for
  63228. */
  63229. private _softVertexData;
  63230. /**
  63231. * Create an impostor's soft body
  63232. * @param impostor to create the softbody for
  63233. */
  63234. private _createSoftbody;
  63235. /**
  63236. * Create cloth for an impostor
  63237. * @param impostor to create the softbody for
  63238. */
  63239. private _createCloth;
  63240. /**
  63241. * Create rope for an impostor
  63242. * @param impostor to create the softbody for
  63243. */
  63244. private _createRope;
  63245. /**
  63246. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63247. * @param impostor to create the custom physics shape for
  63248. */
  63249. private _createCustom;
  63250. private _addHullVerts;
  63251. private _createShape;
  63252. /**
  63253. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63254. * @param impostor imposter containing the physics body and babylon object
  63255. */
  63256. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63257. /**
  63258. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63259. * @param impostor imposter containing the physics body and babylon object
  63260. * @param newPosition new position
  63261. * @param newRotation new rotation
  63262. */
  63263. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63264. /**
  63265. * If this plugin is supported
  63266. * @returns true if its supported
  63267. */
  63268. isSupported(): boolean;
  63269. /**
  63270. * Sets the linear velocity of the physics body
  63271. * @param impostor imposter to set the velocity on
  63272. * @param velocity velocity to set
  63273. */
  63274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63275. /**
  63276. * Sets the angular velocity of the physics body
  63277. * @param impostor imposter to set the velocity on
  63278. * @param velocity velocity to set
  63279. */
  63280. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63281. /**
  63282. * gets the linear velocity
  63283. * @param impostor imposter to get linear velocity from
  63284. * @returns linear velocity
  63285. */
  63286. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63287. /**
  63288. * gets the angular velocity
  63289. * @param impostor imposter to get angular velocity from
  63290. * @returns angular velocity
  63291. */
  63292. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63293. /**
  63294. * Sets the mass of physics body
  63295. * @param impostor imposter to set the mass on
  63296. * @param mass mass to set
  63297. */
  63298. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63299. /**
  63300. * Gets the mass of the physics body
  63301. * @param impostor imposter to get the mass from
  63302. * @returns mass
  63303. */
  63304. getBodyMass(impostor: PhysicsImpostor): number;
  63305. /**
  63306. * Gets friction of the impostor
  63307. * @param impostor impostor to get friction from
  63308. * @returns friction value
  63309. */
  63310. getBodyFriction(impostor: PhysicsImpostor): number;
  63311. /**
  63312. * Sets friction of the impostor
  63313. * @param impostor impostor to set friction on
  63314. * @param friction friction value
  63315. */
  63316. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63317. /**
  63318. * Gets restitution of the impostor
  63319. * @param impostor impostor to get restitution from
  63320. * @returns restitution value
  63321. */
  63322. getBodyRestitution(impostor: PhysicsImpostor): number;
  63323. /**
  63324. * Sets resitution of the impostor
  63325. * @param impostor impostor to set resitution on
  63326. * @param restitution resitution value
  63327. */
  63328. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63329. /**
  63330. * Gets pressure inside the impostor
  63331. * @param impostor impostor to get pressure from
  63332. * @returns pressure value
  63333. */
  63334. getBodyPressure(impostor: PhysicsImpostor): number;
  63335. /**
  63336. * Sets pressure inside a soft body impostor
  63337. * Cloth and rope must remain 0 pressure
  63338. * @param impostor impostor to set pressure on
  63339. * @param pressure pressure value
  63340. */
  63341. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63342. /**
  63343. * Gets stiffness of the impostor
  63344. * @param impostor impostor to get stiffness from
  63345. * @returns pressure value
  63346. */
  63347. getBodyStiffness(impostor: PhysicsImpostor): number;
  63348. /**
  63349. * Sets stiffness of the impostor
  63350. * @param impostor impostor to set stiffness on
  63351. * @param stiffness stiffness value from 0 to 1
  63352. */
  63353. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63354. /**
  63355. * Gets velocityIterations of the impostor
  63356. * @param impostor impostor to get velocity iterations from
  63357. * @returns velocityIterations value
  63358. */
  63359. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63360. /**
  63361. * Sets velocityIterations of the impostor
  63362. * @param impostor impostor to set velocity iterations on
  63363. * @param velocityIterations velocityIterations value
  63364. */
  63365. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63366. /**
  63367. * Gets positionIterations of the impostor
  63368. * @param impostor impostor to get position iterations from
  63369. * @returns positionIterations value
  63370. */
  63371. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63372. /**
  63373. * Sets positionIterations of the impostor
  63374. * @param impostor impostor to set position on
  63375. * @param positionIterations positionIterations value
  63376. */
  63377. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63378. /**
  63379. * Append an anchor to a cloth object
  63380. * @param impostor is the cloth impostor to add anchor to
  63381. * @param otherImpostor is the rigid impostor to anchor to
  63382. * @param width ratio across width from 0 to 1
  63383. * @param height ratio up height from 0 to 1
  63384. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63385. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63386. */
  63387. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63388. /**
  63389. * Append an hook to a rope object
  63390. * @param impostor is the rope impostor to add hook to
  63391. * @param otherImpostor is the rigid impostor to hook to
  63392. * @param length ratio along the rope from 0 to 1
  63393. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63394. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63395. */
  63396. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63397. /**
  63398. * Sleeps the physics body and stops it from being active
  63399. * @param impostor impostor to sleep
  63400. */
  63401. sleepBody(impostor: PhysicsImpostor): void;
  63402. /**
  63403. * Activates the physics body
  63404. * @param impostor impostor to activate
  63405. */
  63406. wakeUpBody(impostor: PhysicsImpostor): void;
  63407. /**
  63408. * Updates the distance parameters of the joint
  63409. * @param joint joint to update
  63410. * @param maxDistance maximum distance of the joint
  63411. * @param minDistance minimum distance of the joint
  63412. */
  63413. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63414. /**
  63415. * Sets a motor on the joint
  63416. * @param joint joint to set motor on
  63417. * @param speed speed of the motor
  63418. * @param maxForce maximum force of the motor
  63419. * @param motorIndex index of the motor
  63420. */
  63421. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63422. /**
  63423. * Sets the motors limit
  63424. * @param joint joint to set limit on
  63425. * @param upperLimit upper limit
  63426. * @param lowerLimit lower limit
  63427. */
  63428. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63429. /**
  63430. * Syncs the position and rotation of a mesh with the impostor
  63431. * @param mesh mesh to sync
  63432. * @param impostor impostor to update the mesh with
  63433. */
  63434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63435. /**
  63436. * Gets the radius of the impostor
  63437. * @param impostor impostor to get radius from
  63438. * @returns the radius
  63439. */
  63440. getRadius(impostor: PhysicsImpostor): number;
  63441. /**
  63442. * Gets the box size of the impostor
  63443. * @param impostor impostor to get box size from
  63444. * @param result the resulting box size
  63445. */
  63446. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63447. /**
  63448. * Disposes of the impostor
  63449. */
  63450. dispose(): void;
  63451. /**
  63452. * Does a raycast in the physics world
  63453. * @param from when should the ray start?
  63454. * @param to when should the ray end?
  63455. * @returns PhysicsRaycastResult
  63456. */
  63457. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63458. }
  63459. }
  63460. declare module "babylonjs/Probes/reflectionProbe" {
  63461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63462. import { Vector3 } from "babylonjs/Maths/math.vector";
  63463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63464. import { Nullable } from "babylonjs/types";
  63465. import { Scene } from "babylonjs/scene";
  63466. module "babylonjs/abstractScene" {
  63467. interface AbstractScene {
  63468. /**
  63469. * The list of reflection probes added to the scene
  63470. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63471. */
  63472. reflectionProbes: Array<ReflectionProbe>;
  63473. /**
  63474. * Removes the given reflection probe from this scene.
  63475. * @param toRemove The reflection probe to remove
  63476. * @returns The index of the removed reflection probe
  63477. */
  63478. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63479. /**
  63480. * Adds the given reflection probe to this scene.
  63481. * @param newReflectionProbe The reflection probe to add
  63482. */
  63483. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63484. }
  63485. }
  63486. /**
  63487. * Class used to generate realtime reflection / refraction cube textures
  63488. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63489. */
  63490. export class ReflectionProbe {
  63491. /** defines the name of the probe */
  63492. name: string;
  63493. private _scene;
  63494. private _renderTargetTexture;
  63495. private _projectionMatrix;
  63496. private _viewMatrix;
  63497. private _target;
  63498. private _add;
  63499. private _attachedMesh;
  63500. private _invertYAxis;
  63501. /** Gets or sets probe position (center of the cube map) */
  63502. position: Vector3;
  63503. /**
  63504. * Creates a new reflection probe
  63505. * @param name defines the name of the probe
  63506. * @param size defines the texture resolution (for each face)
  63507. * @param scene defines the hosting scene
  63508. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63509. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63510. */
  63511. constructor(
  63512. /** defines the name of the probe */
  63513. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63514. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63515. get samples(): number;
  63516. set samples(value: number);
  63517. /** Gets or sets the refresh rate to use (on every frame by default) */
  63518. get refreshRate(): number;
  63519. set refreshRate(value: number);
  63520. /**
  63521. * Gets the hosting scene
  63522. * @returns a Scene
  63523. */
  63524. getScene(): Scene;
  63525. /** Gets the internal CubeTexture used to render to */
  63526. get cubeTexture(): RenderTargetTexture;
  63527. /** Gets the list of meshes to render */
  63528. get renderList(): Nullable<AbstractMesh[]>;
  63529. /**
  63530. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63531. * @param mesh defines the mesh to attach to
  63532. */
  63533. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63534. /**
  63535. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63536. * @param renderingGroupId The rendering group id corresponding to its index
  63537. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63538. */
  63539. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63540. /**
  63541. * Clean all associated resources
  63542. */
  63543. dispose(): void;
  63544. /**
  63545. * Converts the reflection probe information to a readable string for debug purpose.
  63546. * @param fullDetails Supports for multiple levels of logging within scene loading
  63547. * @returns the human readable reflection probe info
  63548. */
  63549. toString(fullDetails?: boolean): string;
  63550. /**
  63551. * Get the class name of the relfection probe.
  63552. * @returns "ReflectionProbe"
  63553. */
  63554. getClassName(): string;
  63555. /**
  63556. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63557. * @returns The JSON representation of the texture
  63558. */
  63559. serialize(): any;
  63560. /**
  63561. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63562. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63563. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63564. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63565. * @returns The parsed reflection probe if successful
  63566. */
  63567. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63568. }
  63569. }
  63570. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63571. /** @hidden */
  63572. export var _BabylonLoaderRegistered: boolean;
  63573. /**
  63574. * Helps setting up some configuration for the babylon file loader.
  63575. */
  63576. export class BabylonFileLoaderConfiguration {
  63577. /**
  63578. * The loader does not allow injecting custom physix engine into the plugins.
  63579. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63580. * So you could set this variable to your engine import to make it work.
  63581. */
  63582. static LoaderInjectedPhysicsEngine: any;
  63583. }
  63584. }
  63585. declare module "babylonjs/Loading/Plugins/index" {
  63586. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63587. }
  63588. declare module "babylonjs/Loading/index" {
  63589. export * from "babylonjs/Loading/loadingScreen";
  63590. export * from "babylonjs/Loading/Plugins/index";
  63591. export * from "babylonjs/Loading/sceneLoader";
  63592. export * from "babylonjs/Loading/sceneLoaderFlags";
  63593. }
  63594. declare module "babylonjs/Materials/Background/index" {
  63595. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63596. }
  63597. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63598. import { Scene } from "babylonjs/scene";
  63599. import { Color3 } from "babylonjs/Maths/math.color";
  63600. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63601. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63602. /**
  63603. * The Physically based simple base material of BJS.
  63604. *
  63605. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63606. * It is used as the base class for both the specGloss and metalRough conventions.
  63607. */
  63608. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63609. /**
  63610. * Number of Simultaneous lights allowed on the material.
  63611. */
  63612. maxSimultaneousLights: number;
  63613. /**
  63614. * If sets to true, disables all the lights affecting the material.
  63615. */
  63616. disableLighting: boolean;
  63617. /**
  63618. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63619. */
  63620. environmentTexture: BaseTexture;
  63621. /**
  63622. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63623. */
  63624. invertNormalMapX: boolean;
  63625. /**
  63626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63627. */
  63628. invertNormalMapY: boolean;
  63629. /**
  63630. * Normal map used in the model.
  63631. */
  63632. normalTexture: BaseTexture;
  63633. /**
  63634. * Emissivie color used to self-illuminate the model.
  63635. */
  63636. emissiveColor: Color3;
  63637. /**
  63638. * Emissivie texture used to self-illuminate the model.
  63639. */
  63640. emissiveTexture: BaseTexture;
  63641. /**
  63642. * Occlusion Channel Strenght.
  63643. */
  63644. occlusionStrength: number;
  63645. /**
  63646. * Occlusion Texture of the material (adding extra occlusion effects).
  63647. */
  63648. occlusionTexture: BaseTexture;
  63649. /**
  63650. * Defines the alpha limits in alpha test mode.
  63651. */
  63652. alphaCutOff: number;
  63653. /**
  63654. * Gets the current double sided mode.
  63655. */
  63656. get doubleSided(): boolean;
  63657. /**
  63658. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63659. */
  63660. set doubleSided(value: boolean);
  63661. /**
  63662. * Stores the pre-calculated light information of a mesh in a texture.
  63663. */
  63664. lightmapTexture: BaseTexture;
  63665. /**
  63666. * If true, the light map contains occlusion information instead of lighting info.
  63667. */
  63668. useLightmapAsShadowmap: boolean;
  63669. /**
  63670. * Instantiates a new PBRMaterial instance.
  63671. *
  63672. * @param name The material name
  63673. * @param scene The scene the material will be use in.
  63674. */
  63675. constructor(name: string, scene: Scene);
  63676. getClassName(): string;
  63677. }
  63678. }
  63679. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63680. import { Scene } from "babylonjs/scene";
  63681. import { Color3 } from "babylonjs/Maths/math.color";
  63682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63683. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63684. /**
  63685. * The PBR material of BJS following the metal roughness convention.
  63686. *
  63687. * This fits to the PBR convention in the GLTF definition:
  63688. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63689. */
  63690. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63691. /**
  63692. * The base color has two different interpretations depending on the value of metalness.
  63693. * When the material is a metal, the base color is the specific measured reflectance value
  63694. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63695. * of the material.
  63696. */
  63697. baseColor: Color3;
  63698. /**
  63699. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63700. * well as opacity information in the alpha channel.
  63701. */
  63702. baseTexture: BaseTexture;
  63703. /**
  63704. * Specifies the metallic scalar value of the material.
  63705. * Can also be used to scale the metalness values of the metallic texture.
  63706. */
  63707. metallic: number;
  63708. /**
  63709. * Specifies the roughness scalar value of the material.
  63710. * Can also be used to scale the roughness values of the metallic texture.
  63711. */
  63712. roughness: number;
  63713. /**
  63714. * Texture containing both the metallic value in the B channel and the
  63715. * roughness value in the G channel to keep better precision.
  63716. */
  63717. metallicRoughnessTexture: BaseTexture;
  63718. /**
  63719. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63720. *
  63721. * @param name The material name
  63722. * @param scene The scene the material will be use in.
  63723. */
  63724. constructor(name: string, scene: Scene);
  63725. /**
  63726. * Return the currrent class name of the material.
  63727. */
  63728. getClassName(): string;
  63729. /**
  63730. * Makes a duplicate of the current material.
  63731. * @param name - name to use for the new material.
  63732. */
  63733. clone(name: string): PBRMetallicRoughnessMaterial;
  63734. /**
  63735. * Serialize the material to a parsable JSON object.
  63736. */
  63737. serialize(): any;
  63738. /**
  63739. * Parses a JSON object correponding to the serialize function.
  63740. */
  63741. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63742. }
  63743. }
  63744. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63745. import { Scene } from "babylonjs/scene";
  63746. import { Color3 } from "babylonjs/Maths/math.color";
  63747. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63748. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63749. /**
  63750. * The PBR material of BJS following the specular glossiness convention.
  63751. *
  63752. * This fits to the PBR convention in the GLTF definition:
  63753. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63754. */
  63755. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63756. /**
  63757. * Specifies the diffuse color of the material.
  63758. */
  63759. diffuseColor: Color3;
  63760. /**
  63761. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63762. * channel.
  63763. */
  63764. diffuseTexture: BaseTexture;
  63765. /**
  63766. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63767. */
  63768. specularColor: Color3;
  63769. /**
  63770. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63771. */
  63772. glossiness: number;
  63773. /**
  63774. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63775. */
  63776. specularGlossinessTexture: BaseTexture;
  63777. /**
  63778. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63779. *
  63780. * @param name The material name
  63781. * @param scene The scene the material will be use in.
  63782. */
  63783. constructor(name: string, scene: Scene);
  63784. /**
  63785. * Return the currrent class name of the material.
  63786. */
  63787. getClassName(): string;
  63788. /**
  63789. * Makes a duplicate of the current material.
  63790. * @param name - name to use for the new material.
  63791. */
  63792. clone(name: string): PBRSpecularGlossinessMaterial;
  63793. /**
  63794. * Serialize the material to a parsable JSON object.
  63795. */
  63796. serialize(): any;
  63797. /**
  63798. * Parses a JSON object correponding to the serialize function.
  63799. */
  63800. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63801. }
  63802. }
  63803. declare module "babylonjs/Materials/PBR/index" {
  63804. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63805. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63806. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63807. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63808. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63809. }
  63810. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63811. import { Nullable } from "babylonjs/types";
  63812. import { Scene } from "babylonjs/scene";
  63813. import { Matrix } from "babylonjs/Maths/math.vector";
  63814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63815. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63816. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63817. /**
  63818. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63819. * It can help converting any input color in a desired output one. This can then be used to create effects
  63820. * from sepia, black and white to sixties or futuristic rendering...
  63821. *
  63822. * The only supported format is currently 3dl.
  63823. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63824. */
  63825. export class ColorGradingTexture extends BaseTexture {
  63826. /**
  63827. * The texture URL.
  63828. */
  63829. url: string;
  63830. /**
  63831. * Empty line regex stored for GC.
  63832. */
  63833. private static _noneEmptyLineRegex;
  63834. private _textureMatrix;
  63835. private _onLoad;
  63836. /**
  63837. * Instantiates a ColorGradingTexture from the following parameters.
  63838. *
  63839. * @param url The location of the color gradind data (currently only supporting 3dl)
  63840. * @param sceneOrEngine The scene or engine the texture will be used in
  63841. * @param onLoad defines a callback triggered when the texture has been loaded
  63842. */
  63843. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63844. /**
  63845. * Fires the onload event from the constructor if requested.
  63846. */
  63847. private _triggerOnLoad;
  63848. /**
  63849. * Returns the texture matrix used in most of the material.
  63850. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63851. */
  63852. getTextureMatrix(): Matrix;
  63853. /**
  63854. * Occurs when the file being loaded is a .3dl LUT file.
  63855. */
  63856. private load3dlTexture;
  63857. /**
  63858. * Starts the loading process of the texture.
  63859. */
  63860. private loadTexture;
  63861. /**
  63862. * Clones the color gradind texture.
  63863. */
  63864. clone(): ColorGradingTexture;
  63865. /**
  63866. * Called during delayed load for textures.
  63867. */
  63868. delayLoad(): void;
  63869. /**
  63870. * Parses a color grading texture serialized by Babylon.
  63871. * @param parsedTexture The texture information being parsedTexture
  63872. * @param scene The scene to load the texture in
  63873. * @param rootUrl The root url of the data assets to load
  63874. * @return A color gradind texture
  63875. */
  63876. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63877. /**
  63878. * Serializes the LUT texture to json format.
  63879. */
  63880. serialize(): any;
  63881. }
  63882. }
  63883. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63885. import { Scene } from "babylonjs/scene";
  63886. import { Nullable } from "babylonjs/types";
  63887. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63888. /**
  63889. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63890. */
  63891. export class EquiRectangularCubeTexture extends BaseTexture {
  63892. /** The six faces of the cube. */
  63893. private static _FacesMapping;
  63894. private _noMipmap;
  63895. private _onLoad;
  63896. private _onError;
  63897. /** The size of the cubemap. */
  63898. private _size;
  63899. /** The buffer of the image. */
  63900. private _buffer;
  63901. /** The width of the input image. */
  63902. private _width;
  63903. /** The height of the input image. */
  63904. private _height;
  63905. /** The URL to the image. */
  63906. url: string;
  63907. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63908. coordinatesMode: number;
  63909. /**
  63910. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63911. * @param url The location of the image
  63912. * @param scene The scene the texture will be used in
  63913. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63914. * @param noMipmap Forces to not generate the mipmap if true
  63915. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63916. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63917. * @param onLoad — defines a callback called when texture is loaded
  63918. * @param onError — defines a callback called if there is an error
  63919. */
  63920. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63921. /**
  63922. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63923. */
  63924. private loadImage;
  63925. /**
  63926. * Convert the image buffer into a cubemap and create a CubeTexture.
  63927. */
  63928. private loadTexture;
  63929. /**
  63930. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63931. * @param buffer The ArrayBuffer that should be converted.
  63932. * @returns The buffer as Float32Array.
  63933. */
  63934. private getFloat32ArrayFromArrayBuffer;
  63935. /**
  63936. * Get the current class name of the texture useful for serialization or dynamic coding.
  63937. * @returns "EquiRectangularCubeTexture"
  63938. */
  63939. getClassName(): string;
  63940. /**
  63941. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63942. * @returns A clone of the current EquiRectangularCubeTexture.
  63943. */
  63944. clone(): EquiRectangularCubeTexture;
  63945. }
  63946. }
  63947. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63948. import { Nullable } from "babylonjs/types";
  63949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63950. import { Matrix } from "babylonjs/Maths/math.vector";
  63951. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63952. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63953. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63954. import { Scene } from "babylonjs/scene";
  63955. /**
  63956. * Defines the options related to the creation of an HtmlElementTexture
  63957. */
  63958. export interface IHtmlElementTextureOptions {
  63959. /**
  63960. * Defines wether mip maps should be created or not.
  63961. */
  63962. generateMipMaps?: boolean;
  63963. /**
  63964. * Defines the sampling mode of the texture.
  63965. */
  63966. samplingMode?: number;
  63967. /**
  63968. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63969. */
  63970. engine: Nullable<ThinEngine>;
  63971. /**
  63972. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63973. */
  63974. scene: Nullable<Scene>;
  63975. }
  63976. /**
  63977. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63978. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63979. * is automatically managed.
  63980. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63981. * in your application.
  63982. *
  63983. * As the update is not automatic, you need to call them manually.
  63984. */
  63985. export class HtmlElementTexture extends BaseTexture {
  63986. /**
  63987. * The texture URL.
  63988. */
  63989. element: HTMLVideoElement | HTMLCanvasElement;
  63990. private static readonly DefaultOptions;
  63991. private _textureMatrix;
  63992. private _isVideo;
  63993. private _generateMipMaps;
  63994. private _samplingMode;
  63995. /**
  63996. * Instantiates a HtmlElementTexture from the following parameters.
  63997. *
  63998. * @param name Defines the name of the texture
  63999. * @param element Defines the video or canvas the texture is filled with
  64000. * @param options Defines the other none mandatory texture creation options
  64001. */
  64002. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64003. private _createInternalTexture;
  64004. /**
  64005. * Returns the texture matrix used in most of the material.
  64006. */
  64007. getTextureMatrix(): Matrix;
  64008. /**
  64009. * Updates the content of the texture.
  64010. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64011. */
  64012. update(invertY?: Nullable<boolean>): void;
  64013. }
  64014. }
  64015. declare module "babylonjs/Misc/tga" {
  64016. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64017. /**
  64018. * Based on jsTGALoader - Javascript loader for TGA file
  64019. * By Vincent Thibault
  64020. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64021. */
  64022. export class TGATools {
  64023. private static _TYPE_INDEXED;
  64024. private static _TYPE_RGB;
  64025. private static _TYPE_GREY;
  64026. private static _TYPE_RLE_INDEXED;
  64027. private static _TYPE_RLE_RGB;
  64028. private static _TYPE_RLE_GREY;
  64029. private static _ORIGIN_MASK;
  64030. private static _ORIGIN_SHIFT;
  64031. private static _ORIGIN_BL;
  64032. private static _ORIGIN_BR;
  64033. private static _ORIGIN_UL;
  64034. private static _ORIGIN_UR;
  64035. /**
  64036. * Gets the header of a TGA file
  64037. * @param data defines the TGA data
  64038. * @returns the header
  64039. */
  64040. static GetTGAHeader(data: Uint8Array): any;
  64041. /**
  64042. * Uploads TGA content to a Babylon Texture
  64043. * @hidden
  64044. */
  64045. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64046. /** @hidden */
  64047. 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;
  64048. /** @hidden */
  64049. 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;
  64050. /** @hidden */
  64051. 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;
  64052. /** @hidden */
  64053. 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;
  64054. /** @hidden */
  64055. 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;
  64056. /** @hidden */
  64057. 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;
  64058. }
  64059. }
  64060. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64061. import { Nullable } from "babylonjs/types";
  64062. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64063. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64064. /**
  64065. * Implementation of the TGA Texture Loader.
  64066. * @hidden
  64067. */
  64068. export class _TGATextureLoader implements IInternalTextureLoader {
  64069. /**
  64070. * Defines wether the loader supports cascade loading the different faces.
  64071. */
  64072. readonly supportCascades: boolean;
  64073. /**
  64074. * This returns if the loader support the current file information.
  64075. * @param extension defines the file extension of the file being loaded
  64076. * @returns true if the loader can load the specified file
  64077. */
  64078. canLoad(extension: string): boolean;
  64079. /**
  64080. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64081. * @param data contains the texture data
  64082. * @param texture defines the BabylonJS internal texture
  64083. * @param createPolynomials will be true if polynomials have been requested
  64084. * @param onLoad defines the callback to trigger once the texture is ready
  64085. * @param onError defines the callback to trigger in case of error
  64086. */
  64087. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64088. /**
  64089. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64090. * @param data contains the texture data
  64091. * @param texture defines the BabylonJS internal texture
  64092. * @param callback defines the method to call once ready to upload
  64093. */
  64094. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64095. }
  64096. }
  64097. declare module "babylonjs/Misc/basis" {
  64098. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64099. /**
  64100. * Info about the .basis files
  64101. */
  64102. class BasisFileInfo {
  64103. /**
  64104. * If the file has alpha
  64105. */
  64106. hasAlpha: boolean;
  64107. /**
  64108. * Info about each image of the basis file
  64109. */
  64110. images: Array<{
  64111. levels: Array<{
  64112. width: number;
  64113. height: number;
  64114. transcodedPixels: ArrayBufferView;
  64115. }>;
  64116. }>;
  64117. }
  64118. /**
  64119. * Result of transcoding a basis file
  64120. */
  64121. class TranscodeResult {
  64122. /**
  64123. * Info about the .basis file
  64124. */
  64125. fileInfo: BasisFileInfo;
  64126. /**
  64127. * Format to use when loading the file
  64128. */
  64129. format: number;
  64130. }
  64131. /**
  64132. * Configuration options for the Basis transcoder
  64133. */
  64134. export class BasisTranscodeConfiguration {
  64135. /**
  64136. * Supported compression formats used to determine the supported output format of the transcoder
  64137. */
  64138. supportedCompressionFormats?: {
  64139. /**
  64140. * etc1 compression format
  64141. */
  64142. etc1?: boolean;
  64143. /**
  64144. * s3tc compression format
  64145. */
  64146. s3tc?: boolean;
  64147. /**
  64148. * pvrtc compression format
  64149. */
  64150. pvrtc?: boolean;
  64151. /**
  64152. * etc2 compression format
  64153. */
  64154. etc2?: boolean;
  64155. };
  64156. /**
  64157. * If mipmap levels should be loaded for transcoded images (Default: true)
  64158. */
  64159. loadMipmapLevels?: boolean;
  64160. /**
  64161. * Index of a single image to load (Default: all images)
  64162. */
  64163. loadSingleImage?: number;
  64164. }
  64165. /**
  64166. * Used to load .Basis files
  64167. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64168. */
  64169. export class BasisTools {
  64170. private static _IgnoreSupportedFormats;
  64171. /**
  64172. * URL to use when loading the basis transcoder
  64173. */
  64174. static JSModuleURL: string;
  64175. /**
  64176. * URL to use when loading the wasm module for the transcoder
  64177. */
  64178. static WasmModuleURL: string;
  64179. /**
  64180. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64181. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64182. * @returns internal format corresponding to the Basis format
  64183. */
  64184. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64185. private static _WorkerPromise;
  64186. private static _Worker;
  64187. private static _actionId;
  64188. private static _CreateWorkerAsync;
  64189. /**
  64190. * Transcodes a loaded image file to compressed pixel data
  64191. * @param data image data to transcode
  64192. * @param config configuration options for the transcoding
  64193. * @returns a promise resulting in the transcoded image
  64194. */
  64195. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64196. /**
  64197. * Loads a texture from the transcode result
  64198. * @param texture texture load to
  64199. * @param transcodeResult the result of transcoding the basis file to load from
  64200. */
  64201. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64202. }
  64203. }
  64204. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64205. import { Nullable } from "babylonjs/types";
  64206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64207. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64208. /**
  64209. * Loader for .basis file format
  64210. */
  64211. export class _BasisTextureLoader implements IInternalTextureLoader {
  64212. /**
  64213. * Defines whether the loader supports cascade loading the different faces.
  64214. */
  64215. readonly supportCascades: boolean;
  64216. /**
  64217. * This returns if the loader support the current file information.
  64218. * @param extension defines the file extension of the file being loaded
  64219. * @returns true if the loader can load the specified file
  64220. */
  64221. canLoad(extension: string): boolean;
  64222. /**
  64223. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64224. * @param data contains the texture data
  64225. * @param texture defines the BabylonJS internal texture
  64226. * @param createPolynomials will be true if polynomials have been requested
  64227. * @param onLoad defines the callback to trigger once the texture is ready
  64228. * @param onError defines the callback to trigger in case of error
  64229. */
  64230. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64231. /**
  64232. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64233. * @param data contains the texture data
  64234. * @param texture defines the BabylonJS internal texture
  64235. * @param callback defines the method to call once ready to upload
  64236. */
  64237. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64238. }
  64239. }
  64240. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64241. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64242. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64243. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64244. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64245. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64246. }
  64247. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64248. import { Vector2 } from "babylonjs/Maths/math.vector";
  64249. /**
  64250. * Defines the basic options interface of a TexturePacker Frame
  64251. */
  64252. export interface ITexturePackerFrame {
  64253. /**
  64254. * The frame ID
  64255. */
  64256. id: number;
  64257. /**
  64258. * The frames Scale
  64259. */
  64260. scale: Vector2;
  64261. /**
  64262. * The Frames offset
  64263. */
  64264. offset: Vector2;
  64265. }
  64266. /**
  64267. * This is a support class for frame Data on texture packer sets.
  64268. */
  64269. export class TexturePackerFrame implements ITexturePackerFrame {
  64270. /**
  64271. * The frame ID
  64272. */
  64273. id: number;
  64274. /**
  64275. * The frames Scale
  64276. */
  64277. scale: Vector2;
  64278. /**
  64279. * The Frames offset
  64280. */
  64281. offset: Vector2;
  64282. /**
  64283. * Initializes a texture package frame.
  64284. * @param id The numerical frame identifier
  64285. * @param scale Scalar Vector2 for UV frame
  64286. * @param offset Vector2 for the frame position in UV units.
  64287. * @returns TexturePackerFrame
  64288. */
  64289. constructor(id: number, scale: Vector2, offset: Vector2);
  64290. }
  64291. }
  64292. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64294. import { Scene } from "babylonjs/scene";
  64295. import { Nullable } from "babylonjs/types";
  64296. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64297. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64298. /**
  64299. * Defines the basic options interface of a TexturePacker
  64300. */
  64301. export interface ITexturePackerOptions {
  64302. /**
  64303. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64304. */
  64305. map?: string[];
  64306. /**
  64307. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64308. */
  64309. uvsIn?: string;
  64310. /**
  64311. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64312. */
  64313. uvsOut?: string;
  64314. /**
  64315. * number representing the layout style. Defaults to LAYOUT_STRIP
  64316. */
  64317. layout?: number;
  64318. /**
  64319. * number of columns if using custom column count layout(2). This defaults to 4.
  64320. */
  64321. colnum?: number;
  64322. /**
  64323. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64324. */
  64325. updateInputMeshes?: boolean;
  64326. /**
  64327. * boolean flag to dispose all the source textures. Defaults to true.
  64328. */
  64329. disposeSources?: boolean;
  64330. /**
  64331. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64332. */
  64333. fillBlanks?: boolean;
  64334. /**
  64335. * string value representing the context fill style color. Defaults to 'black'.
  64336. */
  64337. customFillColor?: string;
  64338. /**
  64339. * Width and Height Value of each Frame in the TexturePacker Sets
  64340. */
  64341. frameSize?: number;
  64342. /**
  64343. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64344. */
  64345. paddingRatio?: number;
  64346. /**
  64347. * Number that declares the fill method for the padding gutter.
  64348. */
  64349. paddingMode?: number;
  64350. /**
  64351. * If in SUBUV_COLOR padding mode what color to use.
  64352. */
  64353. paddingColor?: Color3 | Color4;
  64354. }
  64355. /**
  64356. * Defines the basic interface of a TexturePacker JSON File
  64357. */
  64358. export interface ITexturePackerJSON {
  64359. /**
  64360. * The frame ID
  64361. */
  64362. name: string;
  64363. /**
  64364. * The base64 channel data
  64365. */
  64366. sets: any;
  64367. /**
  64368. * The options of the Packer
  64369. */
  64370. options: ITexturePackerOptions;
  64371. /**
  64372. * The frame data of the Packer
  64373. */
  64374. frames: Array<number>;
  64375. }
  64376. /**
  64377. * This is a support class that generates a series of packed texture sets.
  64378. * @see https://doc.babylonjs.com/babylon101/materials
  64379. */
  64380. export class TexturePacker {
  64381. /** Packer Layout Constant 0 */
  64382. static readonly LAYOUT_STRIP: number;
  64383. /** Packer Layout Constant 1 */
  64384. static readonly LAYOUT_POWER2: number;
  64385. /** Packer Layout Constant 2 */
  64386. static readonly LAYOUT_COLNUM: number;
  64387. /** Packer Layout Constant 0 */
  64388. static readonly SUBUV_WRAP: number;
  64389. /** Packer Layout Constant 1 */
  64390. static readonly SUBUV_EXTEND: number;
  64391. /** Packer Layout Constant 2 */
  64392. static readonly SUBUV_COLOR: number;
  64393. /** The Name of the Texture Package */
  64394. name: string;
  64395. /** The scene scope of the TexturePacker */
  64396. scene: Scene;
  64397. /** The Meshes to target */
  64398. meshes: AbstractMesh[];
  64399. /** Arguments passed with the Constructor */
  64400. options: ITexturePackerOptions;
  64401. /** The promise that is started upon initialization */
  64402. promise: Nullable<Promise<TexturePacker | string>>;
  64403. /** The Container object for the channel sets that are generated */
  64404. sets: object;
  64405. /** The Container array for the frames that are generated */
  64406. frames: TexturePackerFrame[];
  64407. /** The expected number of textures the system is parsing. */
  64408. private _expecting;
  64409. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64410. private _paddingValue;
  64411. /**
  64412. * Initializes a texture package series from an array of meshes or a single mesh.
  64413. * @param name The name of the package
  64414. * @param meshes The target meshes to compose the package from
  64415. * @param options The arguments that texture packer should follow while building.
  64416. * @param scene The scene which the textures are scoped to.
  64417. * @returns TexturePacker
  64418. */
  64419. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64420. /**
  64421. * Starts the package process
  64422. * @param resolve The promises resolution function
  64423. * @returns TexturePacker
  64424. */
  64425. private _createFrames;
  64426. /**
  64427. * Calculates the Size of the Channel Sets
  64428. * @returns Vector2
  64429. */
  64430. private _calculateSize;
  64431. /**
  64432. * Calculates the UV data for the frames.
  64433. * @param baseSize the base frameSize
  64434. * @param padding the base frame padding
  64435. * @param dtSize size of the Dynamic Texture for that channel
  64436. * @param dtUnits is 1/dtSize
  64437. * @param update flag to update the input meshes
  64438. */
  64439. private _calculateMeshUVFrames;
  64440. /**
  64441. * Calculates the frames Offset.
  64442. * @param index of the frame
  64443. * @returns Vector2
  64444. */
  64445. private _getFrameOffset;
  64446. /**
  64447. * Updates a Mesh to the frame data
  64448. * @param mesh that is the target
  64449. * @param frameID or the frame index
  64450. */
  64451. private _updateMeshUV;
  64452. /**
  64453. * Updates a Meshes materials to use the texture packer channels
  64454. * @param m is the mesh to target
  64455. * @param force all channels on the packer to be set.
  64456. */
  64457. private _updateTextureReferences;
  64458. /**
  64459. * Public method to set a Mesh to a frame
  64460. * @param m that is the target
  64461. * @param frameID or the frame index
  64462. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64463. */
  64464. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64465. /**
  64466. * Starts the async promise to compile the texture packer.
  64467. * @returns Promise<void>
  64468. */
  64469. processAsync(): Promise<void>;
  64470. /**
  64471. * Disposes all textures associated with this packer
  64472. */
  64473. dispose(): void;
  64474. /**
  64475. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64476. * @param imageType is the image type to use.
  64477. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64478. */
  64479. download(imageType?: string, quality?: number): void;
  64480. /**
  64481. * Public method to load a texturePacker JSON file.
  64482. * @param data of the JSON file in string format.
  64483. */
  64484. updateFromJSON(data: string): void;
  64485. }
  64486. }
  64487. declare module "babylonjs/Materials/Textures/Packer/index" {
  64488. export * from "babylonjs/Materials/Textures/Packer/packer";
  64489. export * from "babylonjs/Materials/Textures/Packer/frame";
  64490. }
  64491. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64492. import { Scene } from "babylonjs/scene";
  64493. import { Texture } from "babylonjs/Materials/Textures/texture";
  64494. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64495. /**
  64496. * 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.
  64497. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64498. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64499. */
  64500. export class CustomProceduralTexture extends ProceduralTexture {
  64501. private _animate;
  64502. private _time;
  64503. private _config;
  64504. private _texturePath;
  64505. /**
  64506. * Instantiates a new Custom Procedural Texture.
  64507. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  64508. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64509. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64510. * @param name Define the name of the texture
  64511. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64512. * @param size Define the size of the texture to create
  64513. * @param scene Define the scene the texture belongs to
  64514. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64515. * @param generateMipMaps Define if the texture should creates mip maps or not
  64516. */
  64517. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64518. private _loadJson;
  64519. /**
  64520. * Is the texture ready to be used ? (rendered at least once)
  64521. * @returns true if ready, otherwise, false.
  64522. */
  64523. isReady(): boolean;
  64524. /**
  64525. * Render the texture to its associated render target.
  64526. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64527. */
  64528. render(useCameraPostProcess?: boolean): void;
  64529. /**
  64530. * Update the list of dependant textures samplers in the shader.
  64531. */
  64532. updateTextures(): void;
  64533. /**
  64534. * Update the uniform values of the procedural texture in the shader.
  64535. */
  64536. updateShaderUniforms(): void;
  64537. /**
  64538. * Define if the texture animates or not.
  64539. */
  64540. get animate(): boolean;
  64541. set animate(value: boolean);
  64542. }
  64543. }
  64544. declare module "babylonjs/Shaders/noise.fragment" {
  64545. /** @hidden */
  64546. export var noisePixelShader: {
  64547. name: string;
  64548. shader: string;
  64549. };
  64550. }
  64551. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64552. import { Nullable } from "babylonjs/types";
  64553. import { Scene } from "babylonjs/scene";
  64554. import { Texture } from "babylonjs/Materials/Textures/texture";
  64555. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64556. import "babylonjs/Shaders/noise.fragment";
  64557. /**
  64558. * Class used to generate noise procedural textures
  64559. */
  64560. export class NoiseProceduralTexture extends ProceduralTexture {
  64561. private _time;
  64562. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64563. brightness: number;
  64564. /** Defines the number of octaves to process */
  64565. octaves: number;
  64566. /** Defines the level of persistence (0.8 by default) */
  64567. persistence: number;
  64568. /** Gets or sets animation speed factor (default is 1) */
  64569. animationSpeedFactor: number;
  64570. /**
  64571. * Creates a new NoiseProceduralTexture
  64572. * @param name defines the name fo the texture
  64573. * @param size defines the size of the texture (default is 256)
  64574. * @param scene defines the hosting scene
  64575. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64576. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64577. */
  64578. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64579. private _updateShaderUniforms;
  64580. protected _getDefines(): string;
  64581. /** Generate the current state of the procedural texture */
  64582. render(useCameraPostProcess?: boolean): void;
  64583. /**
  64584. * Serializes this noise procedural texture
  64585. * @returns a serialized noise procedural texture object
  64586. */
  64587. serialize(): any;
  64588. /**
  64589. * Clone the texture.
  64590. * @returns the cloned texture
  64591. */
  64592. clone(): NoiseProceduralTexture;
  64593. /**
  64594. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64595. * @param parsedTexture defines parsed texture data
  64596. * @param scene defines the current scene
  64597. * @param rootUrl defines the root URL containing noise procedural texture information
  64598. * @returns a parsed NoiseProceduralTexture
  64599. */
  64600. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64601. }
  64602. }
  64603. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64604. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64605. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64606. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64607. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64608. }
  64609. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64610. import { Nullable } from "babylonjs/types";
  64611. import { Scene } from "babylonjs/scene";
  64612. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64613. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64614. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64615. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64616. /**
  64617. * Raw cube texture where the raw buffers are passed in
  64618. */
  64619. export class RawCubeTexture extends CubeTexture {
  64620. /**
  64621. * Creates a cube texture where the raw buffers are passed in.
  64622. * @param scene defines the scene the texture is attached to
  64623. * @param data defines the array of data to use to create each face
  64624. * @param size defines the size of the textures
  64625. * @param format defines the format of the data
  64626. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64627. * @param generateMipMaps defines if the engine should generate the mip levels
  64628. * @param invertY defines if data must be stored with Y axis inverted
  64629. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64630. * @param compression defines the compression used (null by default)
  64631. */
  64632. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64633. /**
  64634. * Updates the raw cube texture.
  64635. * @param data defines the data to store
  64636. * @param format defines the data format
  64637. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64638. * @param invertY defines if data must be stored with Y axis inverted
  64639. * @param compression defines the compression used (null by default)
  64640. * @param level defines which level of the texture to update
  64641. */
  64642. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64643. /**
  64644. * Updates a raw cube texture with RGBD encoded data.
  64645. * @param data defines the array of data [mipmap][face] to use to create each face
  64646. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64649. * @returns a promsie that resolves when the operation is complete
  64650. */
  64651. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64652. /**
  64653. * Clones the raw cube texture.
  64654. * @return a new cube texture
  64655. */
  64656. clone(): CubeTexture;
  64657. /** @hidden */
  64658. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64659. }
  64660. }
  64661. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64662. import { Scene } from "babylonjs/scene";
  64663. import { Texture } from "babylonjs/Materials/Textures/texture";
  64664. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64665. /**
  64666. * Class used to store 2D array textures containing user data
  64667. */
  64668. export class RawTexture2DArray extends Texture {
  64669. /** Gets or sets the texture format to use */
  64670. format: number;
  64671. /**
  64672. * Create a new RawTexture2DArray
  64673. * @param data defines the data of the texture
  64674. * @param width defines the width of the texture
  64675. * @param height defines the height of the texture
  64676. * @param depth defines the number of layers of the texture
  64677. * @param format defines the texture format to use
  64678. * @param scene defines the hosting scene
  64679. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64680. * @param invertY defines if texture must be stored with Y axis inverted
  64681. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64682. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64683. */
  64684. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64685. /** Gets or sets the texture format to use */
  64686. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64687. /**
  64688. * Update the texture with new data
  64689. * @param data defines the data to store in the texture
  64690. */
  64691. update(data: ArrayBufferView): void;
  64692. }
  64693. }
  64694. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64695. import { Scene } from "babylonjs/scene";
  64696. import { Texture } from "babylonjs/Materials/Textures/texture";
  64697. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64698. /**
  64699. * Class used to store 3D textures containing user data
  64700. */
  64701. export class RawTexture3D extends Texture {
  64702. /** Gets or sets the texture format to use */
  64703. format: number;
  64704. /**
  64705. * Create a new RawTexture3D
  64706. * @param data defines the data of the texture
  64707. * @param width defines the width of the texture
  64708. * @param height defines the height of the texture
  64709. * @param depth defines the depth of the texture
  64710. * @param format defines the texture format to use
  64711. * @param scene defines the hosting scene
  64712. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64713. * @param invertY defines if texture must be stored with Y axis inverted
  64714. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64715. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64716. */
  64717. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64718. /** Gets or sets the texture format to use */
  64719. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64720. /**
  64721. * Update the texture with new data
  64722. * @param data defines the data to store in the texture
  64723. */
  64724. update(data: ArrayBufferView): void;
  64725. }
  64726. }
  64727. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64728. import { Scene } from "babylonjs/scene";
  64729. import { Plane } from "babylonjs/Maths/math.plane";
  64730. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64731. /**
  64732. * Creates a refraction texture used by refraction channel of the standard material.
  64733. * It is like a mirror but to see through a material.
  64734. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64735. */
  64736. export class RefractionTexture extends RenderTargetTexture {
  64737. /**
  64738. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64739. * 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.
  64740. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64741. */
  64742. refractionPlane: Plane;
  64743. /**
  64744. * Define how deep under the surface we should see.
  64745. */
  64746. depth: number;
  64747. /**
  64748. * Creates a refraction texture used by refraction channel of the standard material.
  64749. * It is like a mirror but to see through a material.
  64750. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64751. * @param name Define the texture name
  64752. * @param size Define the size of the underlying texture
  64753. * @param scene Define the scene the refraction belongs to
  64754. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64755. */
  64756. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64757. /**
  64758. * Clone the refraction texture.
  64759. * @returns the cloned texture
  64760. */
  64761. clone(): RefractionTexture;
  64762. /**
  64763. * Serialize the texture to a JSON representation you could use in Parse later on
  64764. * @returns the serialized JSON representation
  64765. */
  64766. serialize(): any;
  64767. }
  64768. }
  64769. declare module "babylonjs/Materials/Textures/index" {
  64770. export * from "babylonjs/Materials/Textures/baseTexture";
  64771. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64772. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64773. export * from "babylonjs/Materials/Textures/cubeTexture";
  64774. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64775. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64776. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64777. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64778. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64779. export * from "babylonjs/Materials/Textures/internalTexture";
  64780. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64781. export * from "babylonjs/Materials/Textures/Loaders/index";
  64782. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64783. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64784. export * from "babylonjs/Materials/Textures/Packer/index";
  64785. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64786. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64787. export * from "babylonjs/Materials/Textures/rawTexture";
  64788. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64789. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64790. export * from "babylonjs/Materials/Textures/refractionTexture";
  64791. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64792. export * from "babylonjs/Materials/Textures/texture";
  64793. export * from "babylonjs/Materials/Textures/videoTexture";
  64794. }
  64795. declare module "babylonjs/Materials/Node/Enums/index" {
  64796. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64797. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64798. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64799. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64800. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64801. }
  64802. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64803. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64804. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64806. import { Mesh } from "babylonjs/Meshes/mesh";
  64807. import { Effect } from "babylonjs/Materials/effect";
  64808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64809. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64810. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64811. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64812. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64813. /**
  64814. * Block used to add support for vertex skinning (bones)
  64815. */
  64816. export class BonesBlock extends NodeMaterialBlock {
  64817. /**
  64818. * Creates a new BonesBlock
  64819. * @param name defines the block name
  64820. */
  64821. constructor(name: string);
  64822. /**
  64823. * Initialize the block and prepare the context for build
  64824. * @param state defines the state that will be used for the build
  64825. */
  64826. initialize(state: NodeMaterialBuildState): void;
  64827. /**
  64828. * Gets the current class name
  64829. * @returns the class name
  64830. */
  64831. getClassName(): string;
  64832. /**
  64833. * Gets the matrix indices input component
  64834. */
  64835. get matricesIndices(): NodeMaterialConnectionPoint;
  64836. /**
  64837. * Gets the matrix weights input component
  64838. */
  64839. get matricesWeights(): NodeMaterialConnectionPoint;
  64840. /**
  64841. * Gets the extra matrix indices input component
  64842. */
  64843. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64844. /**
  64845. * Gets the extra matrix weights input component
  64846. */
  64847. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64848. /**
  64849. * Gets the world input component
  64850. */
  64851. get world(): NodeMaterialConnectionPoint;
  64852. /**
  64853. * Gets the output component
  64854. */
  64855. get output(): NodeMaterialConnectionPoint;
  64856. autoConfigure(material: NodeMaterial): void;
  64857. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64858. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64859. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64860. protected _buildBlock(state: NodeMaterialBuildState): this;
  64861. }
  64862. }
  64863. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64868. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64869. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64870. /**
  64871. * Block used to add support for instances
  64872. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64873. */
  64874. export class InstancesBlock extends NodeMaterialBlock {
  64875. /**
  64876. * Creates a new InstancesBlock
  64877. * @param name defines the block name
  64878. */
  64879. constructor(name: string);
  64880. /**
  64881. * Gets the current class name
  64882. * @returns the class name
  64883. */
  64884. getClassName(): string;
  64885. /**
  64886. * Gets the first world row input component
  64887. */
  64888. get world0(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the second world row input component
  64891. */
  64892. get world1(): NodeMaterialConnectionPoint;
  64893. /**
  64894. * Gets the third world row input component
  64895. */
  64896. get world2(): NodeMaterialConnectionPoint;
  64897. /**
  64898. * Gets the forth world row input component
  64899. */
  64900. get world3(): NodeMaterialConnectionPoint;
  64901. /**
  64902. * Gets the world input component
  64903. */
  64904. get world(): NodeMaterialConnectionPoint;
  64905. /**
  64906. * Gets the output component
  64907. */
  64908. get output(): NodeMaterialConnectionPoint;
  64909. /**
  64910. * Gets the isntanceID component
  64911. */
  64912. get instanceID(): NodeMaterialConnectionPoint;
  64913. autoConfigure(material: NodeMaterial): void;
  64914. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64915. protected _buildBlock(state: NodeMaterialBuildState): this;
  64916. }
  64917. }
  64918. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64923. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64924. import { Effect } from "babylonjs/Materials/effect";
  64925. import { Mesh } from "babylonjs/Meshes/mesh";
  64926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64927. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64928. /**
  64929. * Block used to add morph targets support to vertex shader
  64930. */
  64931. export class MorphTargetsBlock extends NodeMaterialBlock {
  64932. private _repeatableContentAnchor;
  64933. /**
  64934. * Create a new MorphTargetsBlock
  64935. * @param name defines the block name
  64936. */
  64937. constructor(name: string);
  64938. /**
  64939. * Gets the current class name
  64940. * @returns the class name
  64941. */
  64942. getClassName(): string;
  64943. /**
  64944. * Gets the position input component
  64945. */
  64946. get position(): NodeMaterialConnectionPoint;
  64947. /**
  64948. * Gets the normal input component
  64949. */
  64950. get normal(): NodeMaterialConnectionPoint;
  64951. /**
  64952. * Gets the tangent input component
  64953. */
  64954. get tangent(): NodeMaterialConnectionPoint;
  64955. /**
  64956. * Gets the tangent input component
  64957. */
  64958. get uv(): NodeMaterialConnectionPoint;
  64959. /**
  64960. * Gets the position output component
  64961. */
  64962. get positionOutput(): NodeMaterialConnectionPoint;
  64963. /**
  64964. * Gets the normal output component
  64965. */
  64966. get normalOutput(): NodeMaterialConnectionPoint;
  64967. /**
  64968. * Gets the tangent output component
  64969. */
  64970. get tangentOutput(): NodeMaterialConnectionPoint;
  64971. /**
  64972. * Gets the tangent output component
  64973. */
  64974. get uvOutput(): NodeMaterialConnectionPoint;
  64975. initialize(state: NodeMaterialBuildState): void;
  64976. autoConfigure(material: NodeMaterial): void;
  64977. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64979. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64980. protected _buildBlock(state: NodeMaterialBuildState): this;
  64981. }
  64982. }
  64983. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64987. import { Nullable } from "babylonjs/types";
  64988. import { Scene } from "babylonjs/scene";
  64989. import { Effect } from "babylonjs/Materials/effect";
  64990. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64991. import { Mesh } from "babylonjs/Meshes/mesh";
  64992. import { Light } from "babylonjs/Lights/light";
  64993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64994. /**
  64995. * Block used to get data information from a light
  64996. */
  64997. export class LightInformationBlock extends NodeMaterialBlock {
  64998. private _lightDataUniformName;
  64999. private _lightColorUniformName;
  65000. private _lightTypeDefineName;
  65001. /**
  65002. * Gets or sets the light associated with this block
  65003. */
  65004. light: Nullable<Light>;
  65005. /**
  65006. * Creates a new LightInformationBlock
  65007. * @param name defines the block name
  65008. */
  65009. constructor(name: string);
  65010. /**
  65011. * Gets the current class name
  65012. * @returns the class name
  65013. */
  65014. getClassName(): string;
  65015. /**
  65016. * Gets the world position input component
  65017. */
  65018. get worldPosition(): NodeMaterialConnectionPoint;
  65019. /**
  65020. * Gets the direction output component
  65021. */
  65022. get direction(): NodeMaterialConnectionPoint;
  65023. /**
  65024. * Gets the direction output component
  65025. */
  65026. get color(): NodeMaterialConnectionPoint;
  65027. /**
  65028. * Gets the direction output component
  65029. */
  65030. get intensity(): NodeMaterialConnectionPoint;
  65031. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65033. protected _buildBlock(state: NodeMaterialBuildState): this;
  65034. serialize(): any;
  65035. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65036. }
  65037. }
  65038. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65039. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65040. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65041. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65042. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65043. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65044. }
  65045. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65050. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65051. import { Effect } from "babylonjs/Materials/effect";
  65052. import { Mesh } from "babylonjs/Meshes/mesh";
  65053. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65054. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65055. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65056. /**
  65057. * Block used to add image processing support to fragment shader
  65058. */
  65059. export class ImageProcessingBlock extends NodeMaterialBlock {
  65060. /**
  65061. * Create a new ImageProcessingBlock
  65062. * @param name defines the block name
  65063. */
  65064. constructor(name: string);
  65065. /**
  65066. * Gets the current class name
  65067. * @returns the class name
  65068. */
  65069. getClassName(): string;
  65070. /**
  65071. * Gets the color input component
  65072. */
  65073. get color(): NodeMaterialConnectionPoint;
  65074. /**
  65075. * Gets the output component
  65076. */
  65077. get output(): NodeMaterialConnectionPoint;
  65078. /**
  65079. * Initialize the block and prepare the context for build
  65080. * @param state defines the state that will be used for the build
  65081. */
  65082. initialize(state: NodeMaterialBuildState): void;
  65083. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65084. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65086. protected _buildBlock(state: NodeMaterialBuildState): this;
  65087. }
  65088. }
  65089. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65093. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65095. import { Effect } from "babylonjs/Materials/effect";
  65096. import { Mesh } from "babylonjs/Meshes/mesh";
  65097. import { Scene } from "babylonjs/scene";
  65098. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65099. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65100. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65101. /**
  65102. * Block used to pertub normals based on a normal map
  65103. */
  65104. export class PerturbNormalBlock extends NodeMaterialBlock {
  65105. private _tangentSpaceParameterName;
  65106. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65107. invertX: boolean;
  65108. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65109. invertY: boolean;
  65110. /**
  65111. * Create a new PerturbNormalBlock
  65112. * @param name defines the block name
  65113. */
  65114. constructor(name: string);
  65115. /**
  65116. * Gets the current class name
  65117. * @returns the class name
  65118. */
  65119. getClassName(): string;
  65120. /**
  65121. * Gets the world position input component
  65122. */
  65123. get worldPosition(): NodeMaterialConnectionPoint;
  65124. /**
  65125. * Gets the world normal input component
  65126. */
  65127. get worldNormal(): NodeMaterialConnectionPoint;
  65128. /**
  65129. * Gets the world tangent input component
  65130. */
  65131. get worldTangent(): NodeMaterialConnectionPoint;
  65132. /**
  65133. * Gets the uv input component
  65134. */
  65135. get uv(): NodeMaterialConnectionPoint;
  65136. /**
  65137. * Gets the normal map color input component
  65138. */
  65139. get normalMapColor(): NodeMaterialConnectionPoint;
  65140. /**
  65141. * Gets the strength input component
  65142. */
  65143. get strength(): NodeMaterialConnectionPoint;
  65144. /**
  65145. * Gets the output component
  65146. */
  65147. get output(): NodeMaterialConnectionPoint;
  65148. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65149. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65150. autoConfigure(material: NodeMaterial): void;
  65151. protected _buildBlock(state: NodeMaterialBuildState): this;
  65152. protected _dumpPropertiesCode(): string;
  65153. serialize(): any;
  65154. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65155. }
  65156. }
  65157. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65161. /**
  65162. * Block used to discard a pixel if a value is smaller than a cutoff
  65163. */
  65164. export class DiscardBlock extends NodeMaterialBlock {
  65165. /**
  65166. * Create a new DiscardBlock
  65167. * @param name defines the block name
  65168. */
  65169. constructor(name: string);
  65170. /**
  65171. * Gets the current class name
  65172. * @returns the class name
  65173. */
  65174. getClassName(): string;
  65175. /**
  65176. * Gets the color input component
  65177. */
  65178. get value(): NodeMaterialConnectionPoint;
  65179. /**
  65180. * Gets the cutoff input component
  65181. */
  65182. get cutoff(): NodeMaterialConnectionPoint;
  65183. protected _buildBlock(state: NodeMaterialBuildState): this;
  65184. }
  65185. }
  65186. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65188. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65189. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65190. /**
  65191. * Block used to test if the fragment shader is front facing
  65192. */
  65193. export class FrontFacingBlock extends NodeMaterialBlock {
  65194. /**
  65195. * Creates a new FrontFacingBlock
  65196. * @param name defines the block name
  65197. */
  65198. constructor(name: string);
  65199. /**
  65200. * Gets the current class name
  65201. * @returns the class name
  65202. */
  65203. getClassName(): string;
  65204. /**
  65205. * Gets the output component
  65206. */
  65207. get output(): NodeMaterialConnectionPoint;
  65208. protected _buildBlock(state: NodeMaterialBuildState): this;
  65209. }
  65210. }
  65211. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65212. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65213. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65214. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65215. /**
  65216. * Block used to get the derivative value on x and y of a given input
  65217. */
  65218. export class DerivativeBlock extends NodeMaterialBlock {
  65219. /**
  65220. * Create a new DerivativeBlock
  65221. * @param name defines the block name
  65222. */
  65223. constructor(name: string);
  65224. /**
  65225. * Gets the current class name
  65226. * @returns the class name
  65227. */
  65228. getClassName(): string;
  65229. /**
  65230. * Gets the input component
  65231. */
  65232. get input(): NodeMaterialConnectionPoint;
  65233. /**
  65234. * Gets the derivative output on x
  65235. */
  65236. get dx(): NodeMaterialConnectionPoint;
  65237. /**
  65238. * Gets the derivative output on y
  65239. */
  65240. get dy(): NodeMaterialConnectionPoint;
  65241. protected _buildBlock(state: NodeMaterialBuildState): this;
  65242. }
  65243. }
  65244. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65248. /**
  65249. * Block used to make gl_FragCoord available
  65250. */
  65251. export class FragCoordBlock extends NodeMaterialBlock {
  65252. /**
  65253. * Creates a new FragCoordBlock
  65254. * @param name defines the block name
  65255. */
  65256. constructor(name: string);
  65257. /**
  65258. * Gets the current class name
  65259. * @returns the class name
  65260. */
  65261. getClassName(): string;
  65262. /**
  65263. * Gets the xy component
  65264. */
  65265. get xy(): NodeMaterialConnectionPoint;
  65266. /**
  65267. * Gets the xyz component
  65268. */
  65269. get xyz(): NodeMaterialConnectionPoint;
  65270. /**
  65271. * Gets the xyzw component
  65272. */
  65273. get xyzw(): NodeMaterialConnectionPoint;
  65274. /**
  65275. * Gets the x component
  65276. */
  65277. get x(): NodeMaterialConnectionPoint;
  65278. /**
  65279. * Gets the y component
  65280. */
  65281. get y(): NodeMaterialConnectionPoint;
  65282. /**
  65283. * Gets the z component
  65284. */
  65285. get z(): NodeMaterialConnectionPoint;
  65286. /**
  65287. * Gets the w component
  65288. */
  65289. get output(): NodeMaterialConnectionPoint;
  65290. protected writeOutputs(state: NodeMaterialBuildState): string;
  65291. protected _buildBlock(state: NodeMaterialBuildState): this;
  65292. }
  65293. }
  65294. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65298. import { Effect } from "babylonjs/Materials/effect";
  65299. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65300. import { Mesh } from "babylonjs/Meshes/mesh";
  65301. /**
  65302. * Block used to get the screen sizes
  65303. */
  65304. export class ScreenSizeBlock extends NodeMaterialBlock {
  65305. private _varName;
  65306. private _scene;
  65307. /**
  65308. * Creates a new ScreenSizeBlock
  65309. * @param name defines the block name
  65310. */
  65311. constructor(name: string);
  65312. /**
  65313. * Gets the current class name
  65314. * @returns the class name
  65315. */
  65316. getClassName(): string;
  65317. /**
  65318. * Gets the xy component
  65319. */
  65320. get xy(): NodeMaterialConnectionPoint;
  65321. /**
  65322. * Gets the x component
  65323. */
  65324. get x(): NodeMaterialConnectionPoint;
  65325. /**
  65326. * Gets the y component
  65327. */
  65328. get y(): NodeMaterialConnectionPoint;
  65329. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65330. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65331. protected _buildBlock(state: NodeMaterialBuildState): this;
  65332. }
  65333. }
  65334. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65335. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65336. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65337. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65338. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65339. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65340. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65341. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65342. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65343. }
  65344. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65347. import { Mesh } from "babylonjs/Meshes/mesh";
  65348. import { Effect } from "babylonjs/Materials/effect";
  65349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65351. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65352. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65353. /**
  65354. * Block used to add support for scene fog
  65355. */
  65356. export class FogBlock extends NodeMaterialBlock {
  65357. private _fogDistanceName;
  65358. private _fogParameters;
  65359. /**
  65360. * Create a new FogBlock
  65361. * @param name defines the block name
  65362. */
  65363. constructor(name: string);
  65364. /**
  65365. * Gets the current class name
  65366. * @returns the class name
  65367. */
  65368. getClassName(): string;
  65369. /**
  65370. * Gets the world position input component
  65371. */
  65372. get worldPosition(): NodeMaterialConnectionPoint;
  65373. /**
  65374. * Gets the view input component
  65375. */
  65376. get view(): NodeMaterialConnectionPoint;
  65377. /**
  65378. * Gets the color input component
  65379. */
  65380. get input(): NodeMaterialConnectionPoint;
  65381. /**
  65382. * Gets the fog color input component
  65383. */
  65384. get fogColor(): NodeMaterialConnectionPoint;
  65385. /**
  65386. * Gets the output component
  65387. */
  65388. get output(): NodeMaterialConnectionPoint;
  65389. autoConfigure(material: NodeMaterial): void;
  65390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65391. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65392. protected _buildBlock(state: NodeMaterialBuildState): this;
  65393. }
  65394. }
  65395. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65398. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65400. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65401. import { Effect } from "babylonjs/Materials/effect";
  65402. import { Mesh } from "babylonjs/Meshes/mesh";
  65403. import { Light } from "babylonjs/Lights/light";
  65404. import { Nullable } from "babylonjs/types";
  65405. import { Scene } from "babylonjs/scene";
  65406. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65407. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65408. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65409. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65410. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65411. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65412. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65413. /**
  65414. * Block used to add light in the fragment shader
  65415. */
  65416. export class LightBlock extends NodeMaterialBlock {
  65417. private _lightId;
  65418. /**
  65419. * Gets or sets the light associated with this block
  65420. */
  65421. light: Nullable<Light>;
  65422. /**
  65423. * Create a new LightBlock
  65424. * @param name defines the block name
  65425. */
  65426. constructor(name: string);
  65427. /**
  65428. * Gets the current class name
  65429. * @returns the class name
  65430. */
  65431. getClassName(): string;
  65432. /**
  65433. * Gets the world position input component
  65434. */
  65435. get worldPosition(): NodeMaterialConnectionPoint;
  65436. /**
  65437. * Gets the world normal input component
  65438. */
  65439. get worldNormal(): NodeMaterialConnectionPoint;
  65440. /**
  65441. * Gets the camera (or eye) position component
  65442. */
  65443. get cameraPosition(): NodeMaterialConnectionPoint;
  65444. /**
  65445. * Gets the glossiness component
  65446. */
  65447. get glossiness(): NodeMaterialConnectionPoint;
  65448. /**
  65449. * Gets the glossinness power component
  65450. */
  65451. get glossPower(): NodeMaterialConnectionPoint;
  65452. /**
  65453. * Gets the diffuse color component
  65454. */
  65455. get diffuseColor(): NodeMaterialConnectionPoint;
  65456. /**
  65457. * Gets the specular color component
  65458. */
  65459. get specularColor(): NodeMaterialConnectionPoint;
  65460. /**
  65461. * Gets the diffuse output component
  65462. */
  65463. get diffuseOutput(): NodeMaterialConnectionPoint;
  65464. /**
  65465. * Gets the specular output component
  65466. */
  65467. get specularOutput(): NodeMaterialConnectionPoint;
  65468. /**
  65469. * Gets the shadow output component
  65470. */
  65471. get shadow(): NodeMaterialConnectionPoint;
  65472. autoConfigure(material: NodeMaterial): void;
  65473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65474. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65476. private _injectVertexCode;
  65477. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65478. serialize(): any;
  65479. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65480. }
  65481. }
  65482. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65485. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65486. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65487. /**
  65488. * Block used to read a reflection texture from a sampler
  65489. */
  65490. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65491. /**
  65492. * Create a new ReflectionTextureBlock
  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 world position input component
  65503. */
  65504. get position(): NodeMaterialConnectionPoint;
  65505. /**
  65506. * Gets the world position input component
  65507. */
  65508. get worldPosition(): NodeMaterialConnectionPoint;
  65509. /**
  65510. * Gets the world normal input component
  65511. */
  65512. get worldNormal(): NodeMaterialConnectionPoint;
  65513. /**
  65514. * Gets the world input component
  65515. */
  65516. get world(): NodeMaterialConnectionPoint;
  65517. /**
  65518. * Gets the camera (or eye) position component
  65519. */
  65520. get cameraPosition(): NodeMaterialConnectionPoint;
  65521. /**
  65522. * Gets the view input component
  65523. */
  65524. get view(): NodeMaterialConnectionPoint;
  65525. /**
  65526. * Gets the rgb output component
  65527. */
  65528. get rgb(): NodeMaterialConnectionPoint;
  65529. /**
  65530. * Gets the rgba output component
  65531. */
  65532. get rgba(): NodeMaterialConnectionPoint;
  65533. /**
  65534. * Gets the r output component
  65535. */
  65536. get r(): NodeMaterialConnectionPoint;
  65537. /**
  65538. * Gets the g output component
  65539. */
  65540. get g(): NodeMaterialConnectionPoint;
  65541. /**
  65542. * Gets the b output component
  65543. */
  65544. get b(): NodeMaterialConnectionPoint;
  65545. /**
  65546. * Gets the a output component
  65547. */
  65548. get a(): NodeMaterialConnectionPoint;
  65549. autoConfigure(material: NodeMaterial): void;
  65550. protected _buildBlock(state: NodeMaterialBuildState): this;
  65551. }
  65552. }
  65553. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65554. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65555. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65556. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65557. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65558. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65559. }
  65560. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65561. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65562. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65563. }
  65564. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65568. /**
  65569. * Block used to add 2 vectors
  65570. */
  65571. export class AddBlock extends NodeMaterialBlock {
  65572. /**
  65573. * Creates a new AddBlock
  65574. * @param name defines the block name
  65575. */
  65576. constructor(name: string);
  65577. /**
  65578. * Gets the current class name
  65579. * @returns the class name
  65580. */
  65581. getClassName(): string;
  65582. /**
  65583. * Gets the left operand input component
  65584. */
  65585. get left(): NodeMaterialConnectionPoint;
  65586. /**
  65587. * Gets the right operand input component
  65588. */
  65589. get right(): NodeMaterialConnectionPoint;
  65590. /**
  65591. * Gets the output component
  65592. */
  65593. get output(): NodeMaterialConnectionPoint;
  65594. protected _buildBlock(state: NodeMaterialBuildState): this;
  65595. }
  65596. }
  65597. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65601. /**
  65602. * Block used to scale a vector by a float
  65603. */
  65604. export class ScaleBlock extends NodeMaterialBlock {
  65605. /**
  65606. * Creates a new ScaleBlock
  65607. * @param name defines the block name
  65608. */
  65609. constructor(name: string);
  65610. /**
  65611. * Gets the current class name
  65612. * @returns the class name
  65613. */
  65614. getClassName(): string;
  65615. /**
  65616. * Gets the input component
  65617. */
  65618. get input(): NodeMaterialConnectionPoint;
  65619. /**
  65620. * Gets the factor input component
  65621. */
  65622. get factor(): NodeMaterialConnectionPoint;
  65623. /**
  65624. * Gets the output component
  65625. */
  65626. get output(): NodeMaterialConnectionPoint;
  65627. protected _buildBlock(state: NodeMaterialBuildState): this;
  65628. }
  65629. }
  65630. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65634. import { Scene } from "babylonjs/scene";
  65635. /**
  65636. * Block used to clamp a float
  65637. */
  65638. export class ClampBlock extends NodeMaterialBlock {
  65639. /** Gets or sets the minimum range */
  65640. minimum: number;
  65641. /** Gets or sets the maximum range */
  65642. maximum: number;
  65643. /**
  65644. * Creates a new ClampBlock
  65645. * @param name defines the block name
  65646. */
  65647. constructor(name: string);
  65648. /**
  65649. * Gets the current class name
  65650. * @returns the class name
  65651. */
  65652. getClassName(): string;
  65653. /**
  65654. * Gets the value input component
  65655. */
  65656. get value(): NodeMaterialConnectionPoint;
  65657. /**
  65658. * Gets the output component
  65659. */
  65660. get output(): NodeMaterialConnectionPoint;
  65661. protected _buildBlock(state: NodeMaterialBuildState): this;
  65662. protected _dumpPropertiesCode(): string;
  65663. serialize(): any;
  65664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65665. }
  65666. }
  65667. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65671. /**
  65672. * Block used to apply a cross product between 2 vectors
  65673. */
  65674. export class CrossBlock extends NodeMaterialBlock {
  65675. /**
  65676. * Creates a new CrossBlock
  65677. * @param name defines the block name
  65678. */
  65679. constructor(name: string);
  65680. /**
  65681. * Gets the current class name
  65682. * @returns the class name
  65683. */
  65684. getClassName(): string;
  65685. /**
  65686. * Gets the left operand input component
  65687. */
  65688. get left(): NodeMaterialConnectionPoint;
  65689. /**
  65690. * Gets the right operand input component
  65691. */
  65692. get right(): NodeMaterialConnectionPoint;
  65693. /**
  65694. * Gets the output component
  65695. */
  65696. get output(): NodeMaterialConnectionPoint;
  65697. protected _buildBlock(state: NodeMaterialBuildState): this;
  65698. }
  65699. }
  65700. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65704. /**
  65705. * Block used to apply a dot product between 2 vectors
  65706. */
  65707. export class DotBlock extends NodeMaterialBlock {
  65708. /**
  65709. * Creates a new DotBlock
  65710. * @param name defines the block name
  65711. */
  65712. constructor(name: string);
  65713. /**
  65714. * Gets the current class name
  65715. * @returns the class name
  65716. */
  65717. getClassName(): string;
  65718. /**
  65719. * Gets the left operand input component
  65720. */
  65721. get left(): NodeMaterialConnectionPoint;
  65722. /**
  65723. * Gets the right operand input component
  65724. */
  65725. get right(): NodeMaterialConnectionPoint;
  65726. /**
  65727. * Gets the output component
  65728. */
  65729. get output(): NodeMaterialConnectionPoint;
  65730. protected _buildBlock(state: NodeMaterialBuildState): this;
  65731. }
  65732. }
  65733. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65737. /**
  65738. * Block used to normalize a vector
  65739. */
  65740. export class NormalizeBlock extends NodeMaterialBlock {
  65741. /**
  65742. * Creates a new NormalizeBlock
  65743. * @param name defines the block name
  65744. */
  65745. constructor(name: string);
  65746. /**
  65747. * Gets the current class name
  65748. * @returns the class name
  65749. */
  65750. getClassName(): string;
  65751. /**
  65752. * Gets the input component
  65753. */
  65754. get input(): NodeMaterialConnectionPoint;
  65755. /**
  65756. * Gets the output component
  65757. */
  65758. get output(): NodeMaterialConnectionPoint;
  65759. protected _buildBlock(state: NodeMaterialBuildState): this;
  65760. }
  65761. }
  65762. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65766. import { Scene } from "babylonjs/scene";
  65767. /**
  65768. * Operations supported by the Trigonometry block
  65769. */
  65770. export enum TrigonometryBlockOperations {
  65771. /** Cos */
  65772. Cos = 0,
  65773. /** Sin */
  65774. Sin = 1,
  65775. /** Abs */
  65776. Abs = 2,
  65777. /** Exp */
  65778. Exp = 3,
  65779. /** Exp2 */
  65780. Exp2 = 4,
  65781. /** Round */
  65782. Round = 5,
  65783. /** Floor */
  65784. Floor = 6,
  65785. /** Ceiling */
  65786. Ceiling = 7,
  65787. /** Square root */
  65788. Sqrt = 8,
  65789. /** Log */
  65790. Log = 9,
  65791. /** Tangent */
  65792. Tan = 10,
  65793. /** Arc tangent */
  65794. ArcTan = 11,
  65795. /** Arc cosinus */
  65796. ArcCos = 12,
  65797. /** Arc sinus */
  65798. ArcSin = 13,
  65799. /** Fraction */
  65800. Fract = 14,
  65801. /** Sign */
  65802. Sign = 15,
  65803. /** To radians (from degrees) */
  65804. Radians = 16,
  65805. /** To degrees (from radians) */
  65806. Degrees = 17
  65807. }
  65808. /**
  65809. * Block used to apply trigonometry operation to floats
  65810. */
  65811. export class TrigonometryBlock extends NodeMaterialBlock {
  65812. /**
  65813. * Gets or sets the operation applied by the block
  65814. */
  65815. operation: TrigonometryBlockOperations;
  65816. /**
  65817. * Creates a new TrigonometryBlock
  65818. * @param name defines the block name
  65819. */
  65820. constructor(name: string);
  65821. /**
  65822. * Gets the current class name
  65823. * @returns the class name
  65824. */
  65825. getClassName(): string;
  65826. /**
  65827. * Gets the input component
  65828. */
  65829. get input(): NodeMaterialConnectionPoint;
  65830. /**
  65831. * Gets the output component
  65832. */
  65833. get output(): NodeMaterialConnectionPoint;
  65834. protected _buildBlock(state: NodeMaterialBuildState): this;
  65835. serialize(): any;
  65836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65837. protected _dumpPropertiesCode(): string;
  65838. }
  65839. }
  65840. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65844. /**
  65845. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65846. */
  65847. export class ColorMergerBlock extends NodeMaterialBlock {
  65848. /**
  65849. * Create a new ColorMergerBlock
  65850. * @param name defines the block name
  65851. */
  65852. constructor(name: string);
  65853. /**
  65854. * Gets the current class name
  65855. * @returns the class name
  65856. */
  65857. getClassName(): string;
  65858. /**
  65859. * Gets the rgb component (input)
  65860. */
  65861. get rgbIn(): NodeMaterialConnectionPoint;
  65862. /**
  65863. * Gets the r component (input)
  65864. */
  65865. get r(): NodeMaterialConnectionPoint;
  65866. /**
  65867. * Gets the g component (input)
  65868. */
  65869. get g(): NodeMaterialConnectionPoint;
  65870. /**
  65871. * Gets the b component (input)
  65872. */
  65873. get b(): NodeMaterialConnectionPoint;
  65874. /**
  65875. * Gets the a component (input)
  65876. */
  65877. get a(): NodeMaterialConnectionPoint;
  65878. /**
  65879. * Gets the rgba component (output)
  65880. */
  65881. get rgba(): NodeMaterialConnectionPoint;
  65882. /**
  65883. * Gets the rgb component (output)
  65884. */
  65885. get rgbOut(): NodeMaterialConnectionPoint;
  65886. /**
  65887. * Gets the rgb component (output)
  65888. * @deprecated Please use rgbOut instead.
  65889. */
  65890. get rgb(): NodeMaterialConnectionPoint;
  65891. protected _buildBlock(state: NodeMaterialBuildState): this;
  65892. }
  65893. }
  65894. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65895. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65896. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65897. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65898. /**
  65899. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65900. */
  65901. export class VectorSplitterBlock extends NodeMaterialBlock {
  65902. /**
  65903. * Create a new VectorSplitterBlock
  65904. * @param name defines the block name
  65905. */
  65906. constructor(name: string);
  65907. /**
  65908. * Gets the current class name
  65909. * @returns the class name
  65910. */
  65911. getClassName(): string;
  65912. /**
  65913. * Gets the xyzw component (input)
  65914. */
  65915. get xyzw(): NodeMaterialConnectionPoint;
  65916. /**
  65917. * Gets the xyz component (input)
  65918. */
  65919. get xyzIn(): NodeMaterialConnectionPoint;
  65920. /**
  65921. * Gets the xy component (input)
  65922. */
  65923. get xyIn(): NodeMaterialConnectionPoint;
  65924. /**
  65925. * Gets the xyz component (output)
  65926. */
  65927. get xyzOut(): NodeMaterialConnectionPoint;
  65928. /**
  65929. * Gets the xy component (output)
  65930. */
  65931. get xyOut(): NodeMaterialConnectionPoint;
  65932. /**
  65933. * Gets the x component (output)
  65934. */
  65935. get x(): NodeMaterialConnectionPoint;
  65936. /**
  65937. * Gets the y component (output)
  65938. */
  65939. get y(): NodeMaterialConnectionPoint;
  65940. /**
  65941. * Gets the z component (output)
  65942. */
  65943. get z(): NodeMaterialConnectionPoint;
  65944. /**
  65945. * Gets the w component (output)
  65946. */
  65947. get w(): NodeMaterialConnectionPoint;
  65948. protected _inputRename(name: string): string;
  65949. protected _outputRename(name: string): string;
  65950. protected _buildBlock(state: NodeMaterialBuildState): this;
  65951. }
  65952. }
  65953. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65957. /**
  65958. * Block used to lerp between 2 values
  65959. */
  65960. export class LerpBlock extends NodeMaterialBlock {
  65961. /**
  65962. * Creates a new LerpBlock
  65963. * @param name defines the block name
  65964. */
  65965. constructor(name: string);
  65966. /**
  65967. * Gets the current class name
  65968. * @returns the class name
  65969. */
  65970. getClassName(): string;
  65971. /**
  65972. * Gets the left operand input component
  65973. */
  65974. get left(): NodeMaterialConnectionPoint;
  65975. /**
  65976. * Gets the right operand input component
  65977. */
  65978. get right(): NodeMaterialConnectionPoint;
  65979. /**
  65980. * Gets the gradient operand input component
  65981. */
  65982. get gradient(): NodeMaterialConnectionPoint;
  65983. /**
  65984. * Gets the output component
  65985. */
  65986. get output(): NodeMaterialConnectionPoint;
  65987. protected _buildBlock(state: NodeMaterialBuildState): this;
  65988. }
  65989. }
  65990. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65994. /**
  65995. * Block used to divide 2 vectors
  65996. */
  65997. export class DivideBlock extends NodeMaterialBlock {
  65998. /**
  65999. * Creates a new DivideBlock
  66000. * @param name defines the block name
  66001. */
  66002. constructor(name: string);
  66003. /**
  66004. * Gets the current class name
  66005. * @returns the class name
  66006. */
  66007. getClassName(): string;
  66008. /**
  66009. * Gets the left operand input component
  66010. */
  66011. get left(): NodeMaterialConnectionPoint;
  66012. /**
  66013. * Gets the right operand input component
  66014. */
  66015. get right(): NodeMaterialConnectionPoint;
  66016. /**
  66017. * Gets the output component
  66018. */
  66019. get output(): NodeMaterialConnectionPoint;
  66020. protected _buildBlock(state: NodeMaterialBuildState): this;
  66021. }
  66022. }
  66023. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66027. /**
  66028. * Block used to subtract 2 vectors
  66029. */
  66030. export class SubtractBlock extends NodeMaterialBlock {
  66031. /**
  66032. * Creates a new SubtractBlock
  66033. * @param name defines the block name
  66034. */
  66035. constructor(name: string);
  66036. /**
  66037. * Gets the current class name
  66038. * @returns the class name
  66039. */
  66040. getClassName(): string;
  66041. /**
  66042. * Gets the left operand input component
  66043. */
  66044. get left(): NodeMaterialConnectionPoint;
  66045. /**
  66046. * Gets the right operand input component
  66047. */
  66048. get right(): NodeMaterialConnectionPoint;
  66049. /**
  66050. * Gets the output component
  66051. */
  66052. get output(): NodeMaterialConnectionPoint;
  66053. protected _buildBlock(state: NodeMaterialBuildState): this;
  66054. }
  66055. }
  66056. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66060. /**
  66061. * Block used to step a value
  66062. */
  66063. export class StepBlock extends NodeMaterialBlock {
  66064. /**
  66065. * Creates a new StepBlock
  66066. * @param name defines the block name
  66067. */
  66068. constructor(name: string);
  66069. /**
  66070. * Gets the current class name
  66071. * @returns the class name
  66072. */
  66073. getClassName(): string;
  66074. /**
  66075. * Gets the value operand input component
  66076. */
  66077. get value(): NodeMaterialConnectionPoint;
  66078. /**
  66079. * Gets the edge operand input component
  66080. */
  66081. get edge(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the output component
  66084. */
  66085. get output(): NodeMaterialConnectionPoint;
  66086. protected _buildBlock(state: NodeMaterialBuildState): this;
  66087. }
  66088. }
  66089. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66093. /**
  66094. * Block used to get the opposite (1 - x) of a value
  66095. */
  66096. export class OneMinusBlock extends NodeMaterialBlock {
  66097. /**
  66098. * Creates a new OneMinusBlock
  66099. * @param name defines the block name
  66100. */
  66101. constructor(name: string);
  66102. /**
  66103. * Gets the current class name
  66104. * @returns the class name
  66105. */
  66106. getClassName(): string;
  66107. /**
  66108. * Gets the input component
  66109. */
  66110. get input(): NodeMaterialConnectionPoint;
  66111. /**
  66112. * Gets the output component
  66113. */
  66114. get output(): NodeMaterialConnectionPoint;
  66115. protected _buildBlock(state: NodeMaterialBuildState): this;
  66116. }
  66117. }
  66118. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66122. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66123. /**
  66124. * Block used to get the view direction
  66125. */
  66126. export class ViewDirectionBlock extends NodeMaterialBlock {
  66127. /**
  66128. * Creates a new ViewDirectionBlock
  66129. * @param name defines the block name
  66130. */
  66131. constructor(name: string);
  66132. /**
  66133. * Gets the current class name
  66134. * @returns the class name
  66135. */
  66136. getClassName(): string;
  66137. /**
  66138. * Gets the world position component
  66139. */
  66140. get worldPosition(): NodeMaterialConnectionPoint;
  66141. /**
  66142. * Gets the camera position component
  66143. */
  66144. get cameraPosition(): NodeMaterialConnectionPoint;
  66145. /**
  66146. * Gets the output component
  66147. */
  66148. get output(): NodeMaterialConnectionPoint;
  66149. autoConfigure(material: NodeMaterial): void;
  66150. protected _buildBlock(state: NodeMaterialBuildState): this;
  66151. }
  66152. }
  66153. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66157. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66158. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66159. /**
  66160. * Block used to compute fresnel value
  66161. */
  66162. export class FresnelBlock extends NodeMaterialBlock {
  66163. /**
  66164. * Create a new FresnelBlock
  66165. * @param name defines the block name
  66166. */
  66167. constructor(name: string);
  66168. /**
  66169. * Gets the current class name
  66170. * @returns the class name
  66171. */
  66172. getClassName(): string;
  66173. /**
  66174. * Gets the world normal input component
  66175. */
  66176. get worldNormal(): NodeMaterialConnectionPoint;
  66177. /**
  66178. * Gets the view direction input component
  66179. */
  66180. get viewDirection(): NodeMaterialConnectionPoint;
  66181. /**
  66182. * Gets the bias input component
  66183. */
  66184. get bias(): NodeMaterialConnectionPoint;
  66185. /**
  66186. * Gets the camera (or eye) position component
  66187. */
  66188. get power(): NodeMaterialConnectionPoint;
  66189. /**
  66190. * Gets the fresnel output component
  66191. */
  66192. get fresnel(): NodeMaterialConnectionPoint;
  66193. autoConfigure(material: NodeMaterial): void;
  66194. protected _buildBlock(state: NodeMaterialBuildState): this;
  66195. }
  66196. }
  66197. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66201. /**
  66202. * Block used to get the max of 2 values
  66203. */
  66204. export class MaxBlock extends NodeMaterialBlock {
  66205. /**
  66206. * Creates a new MaxBlock
  66207. * @param name defines the block name
  66208. */
  66209. constructor(name: string);
  66210. /**
  66211. * Gets the current class name
  66212. * @returns the class name
  66213. */
  66214. getClassName(): string;
  66215. /**
  66216. * Gets the left operand input component
  66217. */
  66218. get left(): NodeMaterialConnectionPoint;
  66219. /**
  66220. * Gets the right operand input component
  66221. */
  66222. get right(): NodeMaterialConnectionPoint;
  66223. /**
  66224. * Gets the output component
  66225. */
  66226. get output(): NodeMaterialConnectionPoint;
  66227. protected _buildBlock(state: NodeMaterialBuildState): this;
  66228. }
  66229. }
  66230. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66234. /**
  66235. * Block used to get the min of 2 values
  66236. */
  66237. export class MinBlock extends NodeMaterialBlock {
  66238. /**
  66239. * Creates a new MinBlock
  66240. * @param name defines the block name
  66241. */
  66242. constructor(name: string);
  66243. /**
  66244. * Gets the current class name
  66245. * @returns the class name
  66246. */
  66247. getClassName(): string;
  66248. /**
  66249. * Gets the left operand input component
  66250. */
  66251. get left(): NodeMaterialConnectionPoint;
  66252. /**
  66253. * Gets the right operand input component
  66254. */
  66255. get right(): NodeMaterialConnectionPoint;
  66256. /**
  66257. * Gets the output component
  66258. */
  66259. get output(): NodeMaterialConnectionPoint;
  66260. protected _buildBlock(state: NodeMaterialBuildState): this;
  66261. }
  66262. }
  66263. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66267. /**
  66268. * Block used to get the distance between 2 values
  66269. */
  66270. export class DistanceBlock extends NodeMaterialBlock {
  66271. /**
  66272. * Creates a new DistanceBlock
  66273. * @param name defines the block name
  66274. */
  66275. constructor(name: string);
  66276. /**
  66277. * Gets the current class name
  66278. * @returns the class name
  66279. */
  66280. getClassName(): string;
  66281. /**
  66282. * Gets the left operand input component
  66283. */
  66284. get left(): NodeMaterialConnectionPoint;
  66285. /**
  66286. * Gets the right operand input component
  66287. */
  66288. get right(): NodeMaterialConnectionPoint;
  66289. /**
  66290. * Gets the output component
  66291. */
  66292. get output(): NodeMaterialConnectionPoint;
  66293. protected _buildBlock(state: NodeMaterialBuildState): this;
  66294. }
  66295. }
  66296. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66300. /**
  66301. * Block used to get the length of a vector
  66302. */
  66303. export class LengthBlock extends NodeMaterialBlock {
  66304. /**
  66305. * Creates a new LengthBlock
  66306. * @param name defines the block name
  66307. */
  66308. constructor(name: string);
  66309. /**
  66310. * Gets the current class name
  66311. * @returns the class name
  66312. */
  66313. getClassName(): string;
  66314. /**
  66315. * Gets the value input component
  66316. */
  66317. get value(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the output component
  66320. */
  66321. get output(): NodeMaterialConnectionPoint;
  66322. protected _buildBlock(state: NodeMaterialBuildState): this;
  66323. }
  66324. }
  66325. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66329. /**
  66330. * Block used to get negative version of a value (i.e. x * -1)
  66331. */
  66332. export class NegateBlock extends NodeMaterialBlock {
  66333. /**
  66334. * Creates a new NegateBlock
  66335. * @param name defines the block name
  66336. */
  66337. constructor(name: string);
  66338. /**
  66339. * Gets the current class name
  66340. * @returns the class name
  66341. */
  66342. getClassName(): string;
  66343. /**
  66344. * Gets the value input component
  66345. */
  66346. get value(): NodeMaterialConnectionPoint;
  66347. /**
  66348. * Gets the output component
  66349. */
  66350. get output(): NodeMaterialConnectionPoint;
  66351. protected _buildBlock(state: NodeMaterialBuildState): this;
  66352. }
  66353. }
  66354. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66358. /**
  66359. * Block used to get the value of the first parameter raised to the power of the second
  66360. */
  66361. export class PowBlock extends NodeMaterialBlock {
  66362. /**
  66363. * Creates a new PowBlock
  66364. * @param name defines the block name
  66365. */
  66366. constructor(name: string);
  66367. /**
  66368. * Gets the current class name
  66369. * @returns the class name
  66370. */
  66371. getClassName(): string;
  66372. /**
  66373. * Gets the value operand input component
  66374. */
  66375. get value(): NodeMaterialConnectionPoint;
  66376. /**
  66377. * Gets the power operand input component
  66378. */
  66379. get power(): NodeMaterialConnectionPoint;
  66380. /**
  66381. * Gets the output component
  66382. */
  66383. get output(): NodeMaterialConnectionPoint;
  66384. protected _buildBlock(state: NodeMaterialBuildState): this;
  66385. }
  66386. }
  66387. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66391. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66392. /**
  66393. * Block used to get a random number
  66394. */
  66395. export class RandomNumberBlock extends NodeMaterialBlock {
  66396. /**
  66397. * Creates a new RandomNumberBlock
  66398. * @param name defines the block name
  66399. */
  66400. constructor(name: string);
  66401. /**
  66402. * Gets the current class name
  66403. * @returns the class name
  66404. */
  66405. getClassName(): string;
  66406. /**
  66407. * Gets the seed input component
  66408. */
  66409. get seed(): NodeMaterialConnectionPoint;
  66410. /**
  66411. * Gets the output component
  66412. */
  66413. get output(): NodeMaterialConnectionPoint;
  66414. protected _buildBlock(state: NodeMaterialBuildState): this;
  66415. }
  66416. }
  66417. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66421. /**
  66422. * Block used to compute arc tangent of 2 values
  66423. */
  66424. export class ArcTan2Block extends NodeMaterialBlock {
  66425. /**
  66426. * Creates a new ArcTan2Block
  66427. * @param name defines the block name
  66428. */
  66429. constructor(name: string);
  66430. /**
  66431. * Gets the current class name
  66432. * @returns the class name
  66433. */
  66434. getClassName(): string;
  66435. /**
  66436. * Gets the x operand input component
  66437. */
  66438. get x(): NodeMaterialConnectionPoint;
  66439. /**
  66440. * Gets the y operand input component
  66441. */
  66442. get y(): NodeMaterialConnectionPoint;
  66443. /**
  66444. * Gets the output component
  66445. */
  66446. get output(): NodeMaterialConnectionPoint;
  66447. protected _buildBlock(state: NodeMaterialBuildState): this;
  66448. }
  66449. }
  66450. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66454. /**
  66455. * Block used to smooth step a value
  66456. */
  66457. export class SmoothStepBlock extends NodeMaterialBlock {
  66458. /**
  66459. * Creates a new SmoothStepBlock
  66460. * @param name defines the block name
  66461. */
  66462. constructor(name: string);
  66463. /**
  66464. * Gets the current class name
  66465. * @returns the class name
  66466. */
  66467. getClassName(): string;
  66468. /**
  66469. * Gets the value operand input component
  66470. */
  66471. get value(): NodeMaterialConnectionPoint;
  66472. /**
  66473. * Gets the first edge operand input component
  66474. */
  66475. get edge0(): NodeMaterialConnectionPoint;
  66476. /**
  66477. * Gets the second edge operand input component
  66478. */
  66479. get edge1(): NodeMaterialConnectionPoint;
  66480. /**
  66481. * Gets the output component
  66482. */
  66483. get output(): NodeMaterialConnectionPoint;
  66484. protected _buildBlock(state: NodeMaterialBuildState): this;
  66485. }
  66486. }
  66487. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66491. /**
  66492. * Block used to get the reciprocal (1 / x) of a value
  66493. */
  66494. export class ReciprocalBlock extends NodeMaterialBlock {
  66495. /**
  66496. * Creates a new ReciprocalBlock
  66497. * @param name defines the block name
  66498. */
  66499. constructor(name: string);
  66500. /**
  66501. * Gets the current class name
  66502. * @returns the class name
  66503. */
  66504. getClassName(): string;
  66505. /**
  66506. * Gets the input component
  66507. */
  66508. get input(): NodeMaterialConnectionPoint;
  66509. /**
  66510. * Gets the output component
  66511. */
  66512. get output(): NodeMaterialConnectionPoint;
  66513. protected _buildBlock(state: NodeMaterialBuildState): this;
  66514. }
  66515. }
  66516. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66520. /**
  66521. * Block used to replace a color by another one
  66522. */
  66523. export class ReplaceColorBlock extends NodeMaterialBlock {
  66524. /**
  66525. * Creates a new ReplaceColorBlock
  66526. * @param name defines the block name
  66527. */
  66528. constructor(name: string);
  66529. /**
  66530. * Gets the current class name
  66531. * @returns the class name
  66532. */
  66533. getClassName(): string;
  66534. /**
  66535. * Gets the value input component
  66536. */
  66537. get value(): NodeMaterialConnectionPoint;
  66538. /**
  66539. * Gets the reference input component
  66540. */
  66541. get reference(): NodeMaterialConnectionPoint;
  66542. /**
  66543. * Gets the distance input component
  66544. */
  66545. get distance(): NodeMaterialConnectionPoint;
  66546. /**
  66547. * Gets the replacement input component
  66548. */
  66549. get replacement(): NodeMaterialConnectionPoint;
  66550. /**
  66551. * Gets the output component
  66552. */
  66553. get output(): NodeMaterialConnectionPoint;
  66554. protected _buildBlock(state: NodeMaterialBuildState): this;
  66555. }
  66556. }
  66557. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  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. /**
  66562. * Block used to posterize a value
  66563. * @see https://en.wikipedia.org/wiki/Posterization
  66564. */
  66565. export class PosterizeBlock extends NodeMaterialBlock {
  66566. /**
  66567. * Creates a new PosterizeBlock
  66568. * @param name defines the block name
  66569. */
  66570. constructor(name: string);
  66571. /**
  66572. * Gets the current class name
  66573. * @returns the class name
  66574. */
  66575. getClassName(): string;
  66576. /**
  66577. * Gets the value input component
  66578. */
  66579. get value(): NodeMaterialConnectionPoint;
  66580. /**
  66581. * Gets the steps input component
  66582. */
  66583. get steps(): NodeMaterialConnectionPoint;
  66584. /**
  66585. * Gets the output component
  66586. */
  66587. get output(): NodeMaterialConnectionPoint;
  66588. protected _buildBlock(state: NodeMaterialBuildState): this;
  66589. }
  66590. }
  66591. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66595. import { Scene } from "babylonjs/scene";
  66596. /**
  66597. * Operations supported by the Wave block
  66598. */
  66599. export enum WaveBlockKind {
  66600. /** SawTooth */
  66601. SawTooth = 0,
  66602. /** Square */
  66603. Square = 1,
  66604. /** Triangle */
  66605. Triangle = 2
  66606. }
  66607. /**
  66608. * Block used to apply wave operation to floats
  66609. */
  66610. export class WaveBlock extends NodeMaterialBlock {
  66611. /**
  66612. * Gets or sets the kibnd of wave to be applied by the block
  66613. */
  66614. kind: WaveBlockKind;
  66615. /**
  66616. * Creates a new WaveBlock
  66617. * @param name defines the block name
  66618. */
  66619. constructor(name: string);
  66620. /**
  66621. * Gets the current class name
  66622. * @returns the class name
  66623. */
  66624. getClassName(): string;
  66625. /**
  66626. * Gets the input component
  66627. */
  66628. get input(): NodeMaterialConnectionPoint;
  66629. /**
  66630. * Gets the output component
  66631. */
  66632. get output(): NodeMaterialConnectionPoint;
  66633. protected _buildBlock(state: NodeMaterialBuildState): this;
  66634. serialize(): any;
  66635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66636. }
  66637. }
  66638. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66642. import { Color3 } from "babylonjs/Maths/math.color";
  66643. import { Scene } from "babylonjs/scene";
  66644. /**
  66645. * Class used to store a color step for the GradientBlock
  66646. */
  66647. export class GradientBlockColorStep {
  66648. /**
  66649. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66650. */
  66651. step: number;
  66652. /**
  66653. * Gets or sets the color associated with this step
  66654. */
  66655. color: Color3;
  66656. /**
  66657. * Creates a new GradientBlockColorStep
  66658. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66659. * @param color defines the color associated with this step
  66660. */
  66661. constructor(
  66662. /**
  66663. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66664. */
  66665. step: number,
  66666. /**
  66667. * Gets or sets the color associated with this step
  66668. */
  66669. color: Color3);
  66670. }
  66671. /**
  66672. * Block used to return a color from a gradient based on an input value between 0 and 1
  66673. */
  66674. export class GradientBlock extends NodeMaterialBlock {
  66675. /**
  66676. * Gets or sets the list of color steps
  66677. */
  66678. colorSteps: GradientBlockColorStep[];
  66679. /**
  66680. * Creates a new GradientBlock
  66681. * @param name defines the block name
  66682. */
  66683. constructor(name: string);
  66684. /**
  66685. * Gets the current class name
  66686. * @returns the class name
  66687. */
  66688. getClassName(): string;
  66689. /**
  66690. * Gets the gradient input component
  66691. */
  66692. get gradient(): NodeMaterialConnectionPoint;
  66693. /**
  66694. * Gets the output component
  66695. */
  66696. get output(): NodeMaterialConnectionPoint;
  66697. private _writeColorConstant;
  66698. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66699. serialize(): any;
  66700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66701. protected _dumpPropertiesCode(): string;
  66702. }
  66703. }
  66704. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66708. /**
  66709. * Block used to normalize lerp between 2 values
  66710. */
  66711. export class NLerpBlock extends NodeMaterialBlock {
  66712. /**
  66713. * Creates a new NLerpBlock
  66714. * @param name defines the block name
  66715. */
  66716. constructor(name: string);
  66717. /**
  66718. * Gets the current class name
  66719. * @returns the class name
  66720. */
  66721. getClassName(): string;
  66722. /**
  66723. * Gets the left operand input component
  66724. */
  66725. get left(): NodeMaterialConnectionPoint;
  66726. /**
  66727. * Gets the right operand input component
  66728. */
  66729. get right(): NodeMaterialConnectionPoint;
  66730. /**
  66731. * Gets the gradient operand input component
  66732. */
  66733. get gradient(): NodeMaterialConnectionPoint;
  66734. /**
  66735. * Gets the output component
  66736. */
  66737. get output(): NodeMaterialConnectionPoint;
  66738. protected _buildBlock(state: NodeMaterialBuildState): this;
  66739. }
  66740. }
  66741. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66745. import { Scene } from "babylonjs/scene";
  66746. /**
  66747. * block used to Generate a Worley Noise 3D Noise Pattern
  66748. */
  66749. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66750. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66751. manhattanDistance: boolean;
  66752. /**
  66753. * Creates a new WorleyNoise3DBlock
  66754. * @param name defines the block name
  66755. */
  66756. constructor(name: string);
  66757. /**
  66758. * Gets the current class name
  66759. * @returns the class name
  66760. */
  66761. getClassName(): string;
  66762. /**
  66763. * Gets the seed input component
  66764. */
  66765. get seed(): NodeMaterialConnectionPoint;
  66766. /**
  66767. * Gets the jitter input component
  66768. */
  66769. get jitter(): NodeMaterialConnectionPoint;
  66770. /**
  66771. * Gets the output component
  66772. */
  66773. get output(): NodeMaterialConnectionPoint;
  66774. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66775. /**
  66776. * Exposes the properties to the UI?
  66777. */
  66778. protected _dumpPropertiesCode(): string;
  66779. /**
  66780. * Exposes the properties to the Seralize?
  66781. */
  66782. serialize(): any;
  66783. /**
  66784. * Exposes the properties to the deseralize?
  66785. */
  66786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66787. }
  66788. }
  66789. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66793. /**
  66794. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66795. */
  66796. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66797. /**
  66798. * Creates a new SimplexPerlin3DBlock
  66799. * @param name defines the block name
  66800. */
  66801. constructor(name: string);
  66802. /**
  66803. * Gets the current class name
  66804. * @returns the class name
  66805. */
  66806. getClassName(): string;
  66807. /**
  66808. * Gets the seed operand input component
  66809. */
  66810. get seed(): NodeMaterialConnectionPoint;
  66811. /**
  66812. * Gets the output component
  66813. */
  66814. get output(): NodeMaterialConnectionPoint;
  66815. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66816. }
  66817. }
  66818. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66822. /**
  66823. * Block used to blend normals
  66824. */
  66825. export class NormalBlendBlock extends NodeMaterialBlock {
  66826. /**
  66827. * Creates a new NormalBlendBlock
  66828. * @param name defines the block name
  66829. */
  66830. constructor(name: string);
  66831. /**
  66832. * Gets the current class name
  66833. * @returns the class name
  66834. */
  66835. getClassName(): string;
  66836. /**
  66837. * Gets the first input component
  66838. */
  66839. get normalMap0(): NodeMaterialConnectionPoint;
  66840. /**
  66841. * Gets the second input component
  66842. */
  66843. get normalMap1(): NodeMaterialConnectionPoint;
  66844. /**
  66845. * Gets the output component
  66846. */
  66847. get output(): NodeMaterialConnectionPoint;
  66848. protected _buildBlock(state: NodeMaterialBuildState): this;
  66849. }
  66850. }
  66851. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66855. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66856. /**
  66857. * Block used to rotate a 2d vector by a given angle
  66858. */
  66859. export class Rotate2dBlock extends NodeMaterialBlock {
  66860. /**
  66861. * Creates a new Rotate2dBlock
  66862. * @param name defines the block name
  66863. */
  66864. constructor(name: string);
  66865. /**
  66866. * Gets the current class name
  66867. * @returns the class name
  66868. */
  66869. getClassName(): string;
  66870. /**
  66871. * Gets the input vector
  66872. */
  66873. get input(): NodeMaterialConnectionPoint;
  66874. /**
  66875. * Gets the input angle
  66876. */
  66877. get angle(): NodeMaterialConnectionPoint;
  66878. /**
  66879. * Gets the output component
  66880. */
  66881. get output(): NodeMaterialConnectionPoint;
  66882. autoConfigure(material: NodeMaterial): void;
  66883. protected _buildBlock(state: NodeMaterialBuildState): this;
  66884. }
  66885. }
  66886. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66890. /**
  66891. * Block used to get the reflected vector from a direction and a normal
  66892. */
  66893. export class ReflectBlock extends NodeMaterialBlock {
  66894. /**
  66895. * Creates a new ReflectBlock
  66896. * @param name defines the block name
  66897. */
  66898. constructor(name: string);
  66899. /**
  66900. * Gets the current class name
  66901. * @returns the class name
  66902. */
  66903. getClassName(): string;
  66904. /**
  66905. * Gets the incident component
  66906. */
  66907. get incident(): NodeMaterialConnectionPoint;
  66908. /**
  66909. * Gets the normal component
  66910. */
  66911. get normal(): NodeMaterialConnectionPoint;
  66912. /**
  66913. * Gets the output component
  66914. */
  66915. get output(): NodeMaterialConnectionPoint;
  66916. protected _buildBlock(state: NodeMaterialBuildState): this;
  66917. }
  66918. }
  66919. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66923. /**
  66924. * Block used to get the refracted vector from a direction and a normal
  66925. */
  66926. export class RefractBlock extends NodeMaterialBlock {
  66927. /**
  66928. * Creates a new RefractBlock
  66929. * @param name defines the block name
  66930. */
  66931. constructor(name: string);
  66932. /**
  66933. * Gets the current class name
  66934. * @returns the class name
  66935. */
  66936. getClassName(): string;
  66937. /**
  66938. * Gets the incident component
  66939. */
  66940. get incident(): NodeMaterialConnectionPoint;
  66941. /**
  66942. * Gets the normal component
  66943. */
  66944. get normal(): NodeMaterialConnectionPoint;
  66945. /**
  66946. * Gets the index of refraction component
  66947. */
  66948. get ior(): NodeMaterialConnectionPoint;
  66949. /**
  66950. * Gets the output component
  66951. */
  66952. get output(): NodeMaterialConnectionPoint;
  66953. protected _buildBlock(state: NodeMaterialBuildState): this;
  66954. }
  66955. }
  66956. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66960. /**
  66961. * Block used to desaturate a color
  66962. */
  66963. export class DesaturateBlock extends NodeMaterialBlock {
  66964. /**
  66965. * Creates a new DesaturateBlock
  66966. * @param name defines the block name
  66967. */
  66968. constructor(name: string);
  66969. /**
  66970. * Gets the current class name
  66971. * @returns the class name
  66972. */
  66973. getClassName(): string;
  66974. /**
  66975. * Gets the color operand input component
  66976. */
  66977. get color(): NodeMaterialConnectionPoint;
  66978. /**
  66979. * Gets the level operand input component
  66980. */
  66981. get level(): NodeMaterialConnectionPoint;
  66982. /**
  66983. * Gets the output component
  66984. */
  66985. get output(): NodeMaterialConnectionPoint;
  66986. protected _buildBlock(state: NodeMaterialBuildState): this;
  66987. }
  66988. }
  66989. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66993. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66994. import { Nullable } from "babylonjs/types";
  66995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66996. import { Scene } from "babylonjs/scene";
  66997. /**
  66998. * Block used to implement the ambient occlusion module of the PBR material
  66999. */
  67000. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67001. /**
  67002. * Create a new AmbientOcclusionBlock
  67003. * @param name defines the block name
  67004. */
  67005. constructor(name: string);
  67006. /**
  67007. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67008. */
  67009. useAmbientInGrayScale: boolean;
  67010. /**
  67011. * Initialize the block and prepare the context for build
  67012. * @param state defines the state that will be used for the build
  67013. */
  67014. initialize(state: NodeMaterialBuildState): void;
  67015. /**
  67016. * Gets the current class name
  67017. * @returns the class name
  67018. */
  67019. getClassName(): string;
  67020. /**
  67021. * Gets the texture input component
  67022. */
  67023. get texture(): NodeMaterialConnectionPoint;
  67024. /**
  67025. * Gets the texture intensity component
  67026. */
  67027. get intensity(): NodeMaterialConnectionPoint;
  67028. /**
  67029. * Gets the direct light intensity input component
  67030. */
  67031. get directLightIntensity(): NodeMaterialConnectionPoint;
  67032. /**
  67033. * Gets the ambient occlusion object output component
  67034. */
  67035. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67036. /**
  67037. * Gets the main code of the block (fragment side)
  67038. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67039. * @returns the shader code
  67040. */
  67041. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67043. protected _buildBlock(state: NodeMaterialBuildState): this;
  67044. protected _dumpPropertiesCode(): string;
  67045. serialize(): any;
  67046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67047. }
  67048. }
  67049. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67052. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67053. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67055. import { Nullable } from "babylonjs/types";
  67056. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67057. import { Mesh } from "babylonjs/Meshes/mesh";
  67058. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67059. import { Effect } from "babylonjs/Materials/effect";
  67060. import { Scene } from "babylonjs/scene";
  67061. /**
  67062. * Block used to implement the reflection module of the PBR material
  67063. */
  67064. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67065. /** @hidden */
  67066. _defineLODReflectionAlpha: string;
  67067. /** @hidden */
  67068. _defineLinearSpecularReflection: string;
  67069. private _vEnvironmentIrradianceName;
  67070. /** @hidden */
  67071. _vReflectionMicrosurfaceInfosName: string;
  67072. /** @hidden */
  67073. _vReflectionInfosName: string;
  67074. /** @hidden */
  67075. _vReflectionFilteringInfoName: string;
  67076. private _scene;
  67077. /**
  67078. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67079. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67080. * It's less burden on the user side in the editor part.
  67081. */
  67082. /** @hidden */
  67083. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67084. /** @hidden */
  67085. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67086. /** @hidden */
  67087. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67088. /**
  67089. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67090. * diffuse part of the IBL.
  67091. */
  67092. useSphericalHarmonics: boolean;
  67093. /**
  67094. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67095. */
  67096. forceIrradianceInFragment: boolean;
  67097. /**
  67098. * Create a new ReflectionBlock
  67099. * @param name defines the block name
  67100. */
  67101. constructor(name: string);
  67102. /**
  67103. * Gets the current class name
  67104. * @returns the class name
  67105. */
  67106. getClassName(): string;
  67107. /**
  67108. * Gets the position input component
  67109. */
  67110. get position(): NodeMaterialConnectionPoint;
  67111. /**
  67112. * Gets the world position input component
  67113. */
  67114. get worldPosition(): NodeMaterialConnectionPoint;
  67115. /**
  67116. * Gets the world normal input component
  67117. */
  67118. get worldNormal(): NodeMaterialConnectionPoint;
  67119. /**
  67120. * Gets the world input component
  67121. */
  67122. get world(): NodeMaterialConnectionPoint;
  67123. /**
  67124. * Gets the camera (or eye) position component
  67125. */
  67126. get cameraPosition(): NodeMaterialConnectionPoint;
  67127. /**
  67128. * Gets the view input component
  67129. */
  67130. get view(): NodeMaterialConnectionPoint;
  67131. /**
  67132. * Gets the color input component
  67133. */
  67134. get color(): NodeMaterialConnectionPoint;
  67135. /**
  67136. * Gets the reflection object output component
  67137. */
  67138. get reflection(): NodeMaterialConnectionPoint;
  67139. /**
  67140. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67141. */
  67142. get hasTexture(): boolean;
  67143. /**
  67144. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67145. */
  67146. get reflectionColor(): string;
  67147. protected _getTexture(): Nullable<BaseTexture>;
  67148. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67149. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67150. /**
  67151. * Gets the code to inject in the vertex shader
  67152. * @param state current state of the node material building
  67153. * @returns the shader code
  67154. */
  67155. handleVertexSide(state: NodeMaterialBuildState): string;
  67156. /**
  67157. * Gets the main code of the block (fragment side)
  67158. * @param state current state of the node material building
  67159. * @param normalVarName name of the existing variable corresponding to the normal
  67160. * @returns the shader code
  67161. */
  67162. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67163. protected _buildBlock(state: NodeMaterialBuildState): this;
  67164. protected _dumpPropertiesCode(): string;
  67165. serialize(): any;
  67166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67167. }
  67168. }
  67169. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67173. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67175. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67176. import { Scene } from "babylonjs/scene";
  67177. import { Nullable } from "babylonjs/types";
  67178. /**
  67179. * Block used to implement the sheen module of the PBR material
  67180. */
  67181. export class SheenBlock extends NodeMaterialBlock {
  67182. /**
  67183. * Create a new SheenBlock
  67184. * @param name defines the block name
  67185. */
  67186. constructor(name: string);
  67187. /**
  67188. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67189. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67190. * making it easier to setup and tweak the effect
  67191. */
  67192. albedoScaling: boolean;
  67193. /**
  67194. * Defines if the sheen is linked to the sheen color.
  67195. */
  67196. linkSheenWithAlbedo: boolean;
  67197. /**
  67198. * Initialize the block and prepare the context for build
  67199. * @param state defines the state that will be used for the build
  67200. */
  67201. initialize(state: NodeMaterialBuildState): void;
  67202. /**
  67203. * Gets the current class name
  67204. * @returns the class name
  67205. */
  67206. getClassName(): string;
  67207. /**
  67208. * Gets the intensity input component
  67209. */
  67210. get intensity(): NodeMaterialConnectionPoint;
  67211. /**
  67212. * Gets the color input component
  67213. */
  67214. get color(): NodeMaterialConnectionPoint;
  67215. /**
  67216. * Gets the roughness input component
  67217. */
  67218. get roughness(): NodeMaterialConnectionPoint;
  67219. /**
  67220. * Gets the sheen object output component
  67221. */
  67222. get sheen(): NodeMaterialConnectionPoint;
  67223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67224. /**
  67225. * Gets the main code of the block (fragment side)
  67226. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67227. * @returns the shader code
  67228. */
  67229. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67230. protected _buildBlock(state: NodeMaterialBuildState): this;
  67231. protected _dumpPropertiesCode(): string;
  67232. serialize(): any;
  67233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67234. }
  67235. }
  67236. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67237. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67242. import { Scene } from "babylonjs/scene";
  67243. import { Nullable } from "babylonjs/types";
  67244. import { Mesh } from "babylonjs/Meshes/mesh";
  67245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67246. import { Effect } from "babylonjs/Materials/effect";
  67247. /**
  67248. * Block used to implement the reflectivity module of the PBR material
  67249. */
  67250. export class ReflectivityBlock extends NodeMaterialBlock {
  67251. private _metallicReflectanceColor;
  67252. private _metallicF0Factor;
  67253. /** @hidden */
  67254. _vMetallicReflectanceFactorsName: string;
  67255. /**
  67256. * The property below is set by the main PBR block prior to calling methods of this class.
  67257. */
  67258. /** @hidden */
  67259. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67260. /**
  67261. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67262. */
  67263. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67264. /**
  67265. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67266. */
  67267. useMetallnessFromMetallicTextureBlue: boolean;
  67268. /**
  67269. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67270. */
  67271. useRoughnessFromMetallicTextureAlpha: boolean;
  67272. /**
  67273. * Specifies if the metallic texture contains the roughness information in its green channel.
  67274. */
  67275. useRoughnessFromMetallicTextureGreen: boolean;
  67276. /**
  67277. * Create a new ReflectivityBlock
  67278. * @param name defines the block name
  67279. */
  67280. constructor(name: string);
  67281. /**
  67282. * Initialize the block and prepare the context for build
  67283. * @param state defines the state that will be used for the build
  67284. */
  67285. initialize(state: NodeMaterialBuildState): void;
  67286. /**
  67287. * Gets the current class name
  67288. * @returns the class name
  67289. */
  67290. getClassName(): string;
  67291. /**
  67292. * Gets the metallic input component
  67293. */
  67294. get metallic(): NodeMaterialConnectionPoint;
  67295. /**
  67296. * Gets the roughness input component
  67297. */
  67298. get roughness(): NodeMaterialConnectionPoint;
  67299. /**
  67300. * Gets the texture input component
  67301. */
  67302. get texture(): NodeMaterialConnectionPoint;
  67303. /**
  67304. * Gets the reflectivity object output component
  67305. */
  67306. get reflectivity(): NodeMaterialConnectionPoint;
  67307. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67308. /**
  67309. * Gets the main code of the block (fragment side)
  67310. * @param state current state of the node material building
  67311. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67312. * @returns the shader code
  67313. */
  67314. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67316. protected _buildBlock(state: NodeMaterialBuildState): this;
  67317. protected _dumpPropertiesCode(): string;
  67318. serialize(): any;
  67319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67320. }
  67321. }
  67322. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67323. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67328. /**
  67329. * Block used to implement the anisotropy module of the PBR material
  67330. */
  67331. export class AnisotropyBlock extends NodeMaterialBlock {
  67332. /**
  67333. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67334. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67335. * It's less burden on the user side in the editor part.
  67336. */
  67337. /** @hidden */
  67338. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67339. /** @hidden */
  67340. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67341. /**
  67342. * Create a new AnisotropyBlock
  67343. * @param name defines the block name
  67344. */
  67345. constructor(name: string);
  67346. /**
  67347. * Initialize the block and prepare the context for build
  67348. * @param state defines the state that will be used for the build
  67349. */
  67350. initialize(state: NodeMaterialBuildState): void;
  67351. /**
  67352. * Gets the current class name
  67353. * @returns the class name
  67354. */
  67355. getClassName(): string;
  67356. /**
  67357. * Gets the intensity input component
  67358. */
  67359. get intensity(): NodeMaterialConnectionPoint;
  67360. /**
  67361. * Gets the direction input component
  67362. */
  67363. get direction(): NodeMaterialConnectionPoint;
  67364. /**
  67365. * Gets the texture input component
  67366. */
  67367. get texture(): NodeMaterialConnectionPoint;
  67368. /**
  67369. * Gets the uv input component
  67370. */
  67371. get uv(): NodeMaterialConnectionPoint;
  67372. /**
  67373. * Gets the worldTangent input component
  67374. */
  67375. get worldTangent(): NodeMaterialConnectionPoint;
  67376. /**
  67377. * Gets the anisotropy object output component
  67378. */
  67379. get anisotropy(): NodeMaterialConnectionPoint;
  67380. private _generateTBNSpace;
  67381. /**
  67382. * Gets the main code of the block (fragment side)
  67383. * @param state current state of the node material building
  67384. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67385. * @returns the shader code
  67386. */
  67387. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67389. protected _buildBlock(state: NodeMaterialBuildState): this;
  67390. }
  67391. }
  67392. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67396. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67398. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67399. import { Nullable } from "babylonjs/types";
  67400. import { Mesh } from "babylonjs/Meshes/mesh";
  67401. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67402. import { Effect } from "babylonjs/Materials/effect";
  67403. /**
  67404. * Block used to implement the clear coat module of the PBR material
  67405. */
  67406. export class ClearCoatBlock extends NodeMaterialBlock {
  67407. private _scene;
  67408. /**
  67409. * Create a new ClearCoatBlock
  67410. * @param name defines the block name
  67411. */
  67412. constructor(name: string);
  67413. /**
  67414. * Initialize the block and prepare the context for build
  67415. * @param state defines the state that will be used for the build
  67416. */
  67417. initialize(state: NodeMaterialBuildState): void;
  67418. /**
  67419. * Gets the current class name
  67420. * @returns the class name
  67421. */
  67422. getClassName(): string;
  67423. /**
  67424. * Gets the intensity input component
  67425. */
  67426. get intensity(): NodeMaterialConnectionPoint;
  67427. /**
  67428. * Gets the roughness input component
  67429. */
  67430. get roughness(): NodeMaterialConnectionPoint;
  67431. /**
  67432. * Gets the ior input component
  67433. */
  67434. get ior(): NodeMaterialConnectionPoint;
  67435. /**
  67436. * Gets the texture input component
  67437. */
  67438. get texture(): NodeMaterialConnectionPoint;
  67439. /**
  67440. * Gets the bump texture input component
  67441. */
  67442. get bumpTexture(): NodeMaterialConnectionPoint;
  67443. /**
  67444. * Gets the uv input component
  67445. */
  67446. get uv(): NodeMaterialConnectionPoint;
  67447. /**
  67448. * Gets the tint color input component
  67449. */
  67450. get tintColor(): NodeMaterialConnectionPoint;
  67451. /**
  67452. * Gets the tint "at distance" input component
  67453. */
  67454. get tintAtDistance(): NodeMaterialConnectionPoint;
  67455. /**
  67456. * Gets the tint thickness input component
  67457. */
  67458. get tintThickness(): NodeMaterialConnectionPoint;
  67459. /**
  67460. * Gets the world tangent input component
  67461. */
  67462. get worldTangent(): NodeMaterialConnectionPoint;
  67463. /**
  67464. * Gets the clear coat object output component
  67465. */
  67466. get clearcoat(): NodeMaterialConnectionPoint;
  67467. autoConfigure(material: NodeMaterial): void;
  67468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67469. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67470. private _generateTBNSpace;
  67471. /**
  67472. * Gets the main code of the block (fragment side)
  67473. * @param state current state of the node material building
  67474. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67475. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67476. * @param worldPosVarName name of the variable holding the world position
  67477. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67478. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67479. * @param worldNormalVarName name of the variable holding the world normal
  67480. * @returns the shader code
  67481. */
  67482. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67483. protected _buildBlock(state: NodeMaterialBuildState): this;
  67484. }
  67485. }
  67486. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67489. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67490. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67492. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67493. import { Nullable } from "babylonjs/types";
  67494. /**
  67495. * Block used to implement the sub surface module of the PBR material
  67496. */
  67497. export class SubSurfaceBlock extends NodeMaterialBlock {
  67498. /**
  67499. * Create a new SubSurfaceBlock
  67500. * @param name defines the block name
  67501. */
  67502. constructor(name: string);
  67503. /**
  67504. * Stores the intensity of the different subsurface effects in the thickness texture.
  67505. * * the green channel is the translucency intensity.
  67506. * * the blue channel is the scattering intensity.
  67507. * * the alpha channel is the refraction intensity.
  67508. */
  67509. useMaskFromThicknessTexture: boolean;
  67510. /**
  67511. * Initialize the block and prepare the context for build
  67512. * @param state defines the state that will be used for the build
  67513. */
  67514. initialize(state: NodeMaterialBuildState): void;
  67515. /**
  67516. * Gets the current class name
  67517. * @returns the class name
  67518. */
  67519. getClassName(): string;
  67520. /**
  67521. * Gets the min thickness input component
  67522. */
  67523. get minThickness(): NodeMaterialConnectionPoint;
  67524. /**
  67525. * Gets the max thickness input component
  67526. */
  67527. get maxThickness(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the thickness texture component
  67530. */
  67531. get thicknessTexture(): NodeMaterialConnectionPoint;
  67532. /**
  67533. * Gets the tint color input component
  67534. */
  67535. get tintColor(): NodeMaterialConnectionPoint;
  67536. /**
  67537. * Gets the translucency intensity input component
  67538. */
  67539. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67540. /**
  67541. * Gets the translucency diffusion distance input component
  67542. */
  67543. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67544. /**
  67545. * Gets the refraction object parameters
  67546. */
  67547. get refraction(): NodeMaterialConnectionPoint;
  67548. /**
  67549. * Gets the sub surface object output component
  67550. */
  67551. get subsurface(): NodeMaterialConnectionPoint;
  67552. autoConfigure(material: NodeMaterial): void;
  67553. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67554. /**
  67555. * Gets the main code of the block (fragment side)
  67556. * @param state current state of the node material building
  67557. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67558. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67559. * @param worldPosVarName name of the variable holding the world position
  67560. * @returns the shader code
  67561. */
  67562. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67563. protected _buildBlock(state: NodeMaterialBuildState): this;
  67564. }
  67565. }
  67566. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67570. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67571. import { Light } from "babylonjs/Lights/light";
  67572. import { Nullable } from "babylonjs/types";
  67573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67574. import { Effect } from "babylonjs/Materials/effect";
  67575. import { Mesh } from "babylonjs/Meshes/mesh";
  67576. import { Scene } from "babylonjs/scene";
  67577. /**
  67578. * Block used to implement the PBR metallic/roughness model
  67579. */
  67580. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67581. /**
  67582. * Gets or sets the light associated with this block
  67583. */
  67584. light: Nullable<Light>;
  67585. private _lightId;
  67586. private _scene;
  67587. private _environmentBRDFTexture;
  67588. private _environmentBrdfSamplerName;
  67589. private _vNormalWName;
  67590. private _invertNormalName;
  67591. /**
  67592. * Create a new ReflectionBlock
  67593. * @param name defines the block name
  67594. */
  67595. constructor(name: string);
  67596. /**
  67597. * Intensity of the direct lights e.g. the four lights available in your scene.
  67598. * This impacts both the direct diffuse and specular highlights.
  67599. */
  67600. directIntensity: number;
  67601. /**
  67602. * Intensity of the environment e.g. how much the environment will light the object
  67603. * either through harmonics for rough material or through the refelction for shiny ones.
  67604. */
  67605. environmentIntensity: number;
  67606. /**
  67607. * This is a special control allowing the reduction of the specular highlights coming from the
  67608. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67609. */
  67610. specularIntensity: number;
  67611. /**
  67612. * Defines the falloff type used in this material.
  67613. * It by default is Physical.
  67614. */
  67615. lightFalloff: number;
  67616. /**
  67617. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67618. */
  67619. useAlphaFromAlbedoTexture: boolean;
  67620. /**
  67621. * Specifies that alpha test should be used
  67622. */
  67623. useAlphaTest: boolean;
  67624. /**
  67625. * Defines the alpha limits in alpha test mode.
  67626. */
  67627. alphaTestCutoff: number;
  67628. /**
  67629. * Specifies that alpha blending should be used
  67630. */
  67631. useAlphaBlending: boolean;
  67632. /**
  67633. * Defines if the alpha value should be determined via the rgb values.
  67634. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67635. */
  67636. opacityRGB: boolean;
  67637. /**
  67638. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67639. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67640. */
  67641. useRadianceOverAlpha: boolean;
  67642. /**
  67643. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67644. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67645. */
  67646. useSpecularOverAlpha: boolean;
  67647. /**
  67648. * Enables specular anti aliasing in the PBR shader.
  67649. * It will both interacts on the Geometry for analytical and IBL lighting.
  67650. * It also prefilter the roughness map based on the bump values.
  67651. */
  67652. enableSpecularAntiAliasing: boolean;
  67653. /**
  67654. * Enables realtime filtering on the texture.
  67655. */
  67656. realTimeFiltering: boolean;
  67657. /**
  67658. * Quality switch for realtime filtering
  67659. */
  67660. realTimeFilteringQuality: number;
  67661. /**
  67662. * Defines if the material uses energy conservation.
  67663. */
  67664. useEnergyConservation: boolean;
  67665. /**
  67666. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67667. * too much the area relying on ambient texture to define their ambient occlusion.
  67668. */
  67669. useRadianceOcclusion: boolean;
  67670. /**
  67671. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67672. * makes the reflect vector face the model (under horizon).
  67673. */
  67674. useHorizonOcclusion: boolean;
  67675. /**
  67676. * If set to true, no lighting calculations will be applied.
  67677. */
  67678. unlit: boolean;
  67679. /**
  67680. * Force normal to face away from face.
  67681. */
  67682. forceNormalForward: boolean;
  67683. /**
  67684. * Defines the material debug mode.
  67685. * It helps seeing only some components of the material while troubleshooting.
  67686. */
  67687. debugMode: number;
  67688. /**
  67689. * Specify from where on screen the debug mode should start.
  67690. * The value goes from -1 (full screen) to 1 (not visible)
  67691. * It helps with side by side comparison against the final render
  67692. * This defaults to 0
  67693. */
  67694. debugLimit: number;
  67695. /**
  67696. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67697. * You can use the factor to better multiply the final value.
  67698. */
  67699. debugFactor: number;
  67700. /**
  67701. * Initialize the block and prepare the context for build
  67702. * @param state defines the state that will be used for the build
  67703. */
  67704. initialize(state: NodeMaterialBuildState): void;
  67705. /**
  67706. * Gets the current class name
  67707. * @returns the class name
  67708. */
  67709. getClassName(): string;
  67710. /**
  67711. * Gets the world position input component
  67712. */
  67713. get worldPosition(): NodeMaterialConnectionPoint;
  67714. /**
  67715. * Gets the world normal input component
  67716. */
  67717. get worldNormal(): NodeMaterialConnectionPoint;
  67718. /**
  67719. * Gets the perturbed normal input component
  67720. */
  67721. get perturbedNormal(): NodeMaterialConnectionPoint;
  67722. /**
  67723. * Gets the camera position input component
  67724. */
  67725. get cameraPosition(): NodeMaterialConnectionPoint;
  67726. /**
  67727. * Gets the base color input component
  67728. */
  67729. get baseColor(): NodeMaterialConnectionPoint;
  67730. /**
  67731. * Gets the opacity texture input component
  67732. */
  67733. get opacityTexture(): NodeMaterialConnectionPoint;
  67734. /**
  67735. * Gets the ambient color input component
  67736. */
  67737. get ambientColor(): NodeMaterialConnectionPoint;
  67738. /**
  67739. * Gets the reflectivity object parameters
  67740. */
  67741. get reflectivity(): NodeMaterialConnectionPoint;
  67742. /**
  67743. * Gets the ambient occlusion object parameters
  67744. */
  67745. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67746. /**
  67747. * Gets the reflection object parameters
  67748. */
  67749. get reflection(): NodeMaterialConnectionPoint;
  67750. /**
  67751. * Gets the sheen object parameters
  67752. */
  67753. get sheen(): NodeMaterialConnectionPoint;
  67754. /**
  67755. * Gets the clear coat object parameters
  67756. */
  67757. get clearcoat(): NodeMaterialConnectionPoint;
  67758. /**
  67759. * Gets the sub surface object parameters
  67760. */
  67761. get subsurface(): NodeMaterialConnectionPoint;
  67762. /**
  67763. * Gets the anisotropy object parameters
  67764. */
  67765. get anisotropy(): NodeMaterialConnectionPoint;
  67766. /**
  67767. * Gets the ambient output component
  67768. */
  67769. get ambient(): NodeMaterialConnectionPoint;
  67770. /**
  67771. * Gets the diffuse output component
  67772. */
  67773. get diffuse(): NodeMaterialConnectionPoint;
  67774. /**
  67775. * Gets the specular output component
  67776. */
  67777. get specular(): NodeMaterialConnectionPoint;
  67778. /**
  67779. * Gets the sheen output component
  67780. */
  67781. get sheenDir(): NodeMaterialConnectionPoint;
  67782. /**
  67783. * Gets the clear coat output component
  67784. */
  67785. get clearcoatDir(): NodeMaterialConnectionPoint;
  67786. /**
  67787. * Gets the indirect diffuse output component
  67788. */
  67789. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67790. /**
  67791. * Gets the indirect specular output component
  67792. */
  67793. get specularIndirect(): NodeMaterialConnectionPoint;
  67794. /**
  67795. * Gets the indirect sheen output component
  67796. */
  67797. get sheenIndirect(): NodeMaterialConnectionPoint;
  67798. /**
  67799. * Gets the indirect clear coat output component
  67800. */
  67801. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67802. /**
  67803. * Gets the refraction output component
  67804. */
  67805. get refraction(): NodeMaterialConnectionPoint;
  67806. /**
  67807. * Gets the global lighting output component
  67808. */
  67809. get lighting(): NodeMaterialConnectionPoint;
  67810. /**
  67811. * Gets the shadow output component
  67812. */
  67813. get shadow(): NodeMaterialConnectionPoint;
  67814. /**
  67815. * Gets the alpha output component
  67816. */
  67817. get alpha(): NodeMaterialConnectionPoint;
  67818. autoConfigure(material: NodeMaterial): void;
  67819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67820. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67822. private _injectVertexCode;
  67823. /**
  67824. * Gets the code corresponding to the albedo/opacity module
  67825. * @returns the shader code
  67826. */
  67827. getAlbedoOpacityCode(): string;
  67828. protected _buildBlock(state: NodeMaterialBuildState): this;
  67829. protected _dumpPropertiesCode(): string;
  67830. serialize(): any;
  67831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67832. }
  67833. }
  67834. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67835. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67836. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67837. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67838. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67839. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67840. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67841. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67842. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67843. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67844. }
  67845. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67846. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67847. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67848. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67849. }
  67850. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67854. /**
  67855. * Block used to compute value of one parameter modulo another
  67856. */
  67857. export class ModBlock extends NodeMaterialBlock {
  67858. /**
  67859. * Creates a new ModBlock
  67860. * @param name defines the block name
  67861. */
  67862. constructor(name: string);
  67863. /**
  67864. * Gets the current class name
  67865. * @returns the class name
  67866. */
  67867. getClassName(): string;
  67868. /**
  67869. * Gets the left operand input component
  67870. */
  67871. get left(): NodeMaterialConnectionPoint;
  67872. /**
  67873. * Gets the right operand input component
  67874. */
  67875. get right(): NodeMaterialConnectionPoint;
  67876. /**
  67877. * Gets the output component
  67878. */
  67879. get output(): NodeMaterialConnectionPoint;
  67880. protected _buildBlock(state: NodeMaterialBuildState): this;
  67881. }
  67882. }
  67883. declare module "babylonjs/Materials/Node/Blocks/index" {
  67884. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67885. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67886. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67887. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67888. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67889. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67890. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67891. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67892. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67893. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67894. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67895. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67896. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67897. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67898. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67899. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67900. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67901. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67902. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67903. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67904. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67905. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67906. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67907. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67908. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67909. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67910. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67911. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67912. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67913. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67914. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67915. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67916. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67917. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67918. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67919. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67920. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67921. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67922. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67923. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67924. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67925. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67926. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67927. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67928. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67929. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67930. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67931. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67932. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67933. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67934. }
  67935. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67936. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67937. }
  67938. declare module "babylonjs/Materials/Node/index" {
  67939. export * from "babylonjs/Materials/Node/Enums/index";
  67940. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67941. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67942. export * from "babylonjs/Materials/Node/nodeMaterial";
  67943. export * from "babylonjs/Materials/Node/Blocks/index";
  67944. export * from "babylonjs/Materials/Node/Optimizers/index";
  67945. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67946. }
  67947. declare module "babylonjs/Materials/index" {
  67948. export * from "babylonjs/Materials/Background/index";
  67949. export * from "babylonjs/Materials/colorCurves";
  67950. export * from "babylonjs/Materials/iEffectFallbacks";
  67951. export * from "babylonjs/Materials/effectFallbacks";
  67952. export * from "babylonjs/Materials/effect";
  67953. export * from "babylonjs/Materials/fresnelParameters";
  67954. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67955. export * from "babylonjs/Materials/material";
  67956. export * from "babylonjs/Materials/materialDefines";
  67957. export * from "babylonjs/Materials/materialHelper";
  67958. export * from "babylonjs/Materials/multiMaterial";
  67959. export * from "babylonjs/Materials/PBR/index";
  67960. export * from "babylonjs/Materials/pushMaterial";
  67961. export * from "babylonjs/Materials/shaderMaterial";
  67962. export * from "babylonjs/Materials/standardMaterial";
  67963. export * from "babylonjs/Materials/Textures/index";
  67964. export * from "babylonjs/Materials/uniformBuffer";
  67965. export * from "babylonjs/Materials/materialFlags";
  67966. export * from "babylonjs/Materials/Node/index";
  67967. export * from "babylonjs/Materials/effectRenderer";
  67968. export * from "babylonjs/Materials/shadowDepthWrapper";
  67969. }
  67970. declare module "babylonjs/Maths/index" {
  67971. export * from "babylonjs/Maths/math.scalar";
  67972. export * from "babylonjs/Maths/math";
  67973. export * from "babylonjs/Maths/sphericalPolynomial";
  67974. }
  67975. declare module "babylonjs/Misc/workerPool" {
  67976. import { IDisposable } from "babylonjs/scene";
  67977. /**
  67978. * Helper class to push actions to a pool of workers.
  67979. */
  67980. export class WorkerPool implements IDisposable {
  67981. private _workerInfos;
  67982. private _pendingActions;
  67983. /**
  67984. * Constructor
  67985. * @param workers Array of workers to use for actions
  67986. */
  67987. constructor(workers: Array<Worker>);
  67988. /**
  67989. * Terminates all workers and clears any pending actions.
  67990. */
  67991. dispose(): void;
  67992. /**
  67993. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67994. * pended until a worker has completed its action.
  67995. * @param action The action to perform. Call onComplete when the action is complete.
  67996. */
  67997. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67998. private _execute;
  67999. }
  68000. }
  68001. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68002. import { IDisposable } from "babylonjs/scene";
  68003. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68004. /**
  68005. * Configuration for Draco compression
  68006. */
  68007. export interface IDracoCompressionConfiguration {
  68008. /**
  68009. * Configuration for the decoder.
  68010. */
  68011. decoder: {
  68012. /**
  68013. * The url to the WebAssembly module.
  68014. */
  68015. wasmUrl?: string;
  68016. /**
  68017. * The url to the WebAssembly binary.
  68018. */
  68019. wasmBinaryUrl?: string;
  68020. /**
  68021. * The url to the fallback JavaScript module.
  68022. */
  68023. fallbackUrl?: string;
  68024. };
  68025. }
  68026. /**
  68027. * Draco compression (https://google.github.io/draco/)
  68028. *
  68029. * This class wraps the Draco module.
  68030. *
  68031. * **Encoder**
  68032. *
  68033. * The encoder is not currently implemented.
  68034. *
  68035. * **Decoder**
  68036. *
  68037. * 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.
  68038. *
  68039. * To update the configuration, use the following code:
  68040. * ```javascript
  68041. * DracoCompression.Configuration = {
  68042. * decoder: {
  68043. * wasmUrl: "<url to the WebAssembly library>",
  68044. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68045. * fallbackUrl: "<url to the fallback JavaScript library>",
  68046. * }
  68047. * };
  68048. * ```
  68049. *
  68050. * 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.
  68051. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68052. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68053. *
  68054. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68055. * ```javascript
  68056. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68057. * ```
  68058. *
  68059. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68060. */
  68061. export class DracoCompression implements IDisposable {
  68062. private _workerPoolPromise?;
  68063. private _decoderModulePromise?;
  68064. /**
  68065. * The configuration. Defaults to the following urls:
  68066. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68067. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68068. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68069. */
  68070. static Configuration: IDracoCompressionConfiguration;
  68071. /**
  68072. * Returns true if the decoder configuration is available.
  68073. */
  68074. static get DecoderAvailable(): boolean;
  68075. /**
  68076. * Default number of workers to create when creating the draco compression object.
  68077. */
  68078. static DefaultNumWorkers: number;
  68079. private static GetDefaultNumWorkers;
  68080. private static _Default;
  68081. /**
  68082. * Default instance for the draco compression object.
  68083. */
  68084. static get Default(): DracoCompression;
  68085. /**
  68086. * Constructor
  68087. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68088. */
  68089. constructor(numWorkers?: number);
  68090. /**
  68091. * Stop all async operations and release resources.
  68092. */
  68093. dispose(): void;
  68094. /**
  68095. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68096. * @returns a promise that resolves when ready
  68097. */
  68098. whenReadyAsync(): Promise<void>;
  68099. /**
  68100. * Decode Draco compressed mesh data to vertex data.
  68101. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68102. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68103. * @returns A promise that resolves with the decoded vertex data
  68104. */
  68105. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68106. [kind: string]: number;
  68107. }): Promise<VertexData>;
  68108. }
  68109. }
  68110. declare module "babylonjs/Meshes/Compression/index" {
  68111. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68112. }
  68113. declare module "babylonjs/Meshes/csg" {
  68114. import { Nullable } from "babylonjs/types";
  68115. import { Scene } from "babylonjs/scene";
  68116. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68117. import { Mesh } from "babylonjs/Meshes/mesh";
  68118. import { Material } from "babylonjs/Materials/material";
  68119. /**
  68120. * Class for building Constructive Solid Geometry
  68121. */
  68122. export class CSG {
  68123. private polygons;
  68124. /**
  68125. * The world matrix
  68126. */
  68127. matrix: Matrix;
  68128. /**
  68129. * Stores the position
  68130. */
  68131. position: Vector3;
  68132. /**
  68133. * Stores the rotation
  68134. */
  68135. rotation: Vector3;
  68136. /**
  68137. * Stores the rotation quaternion
  68138. */
  68139. rotationQuaternion: Nullable<Quaternion>;
  68140. /**
  68141. * Stores the scaling vector
  68142. */
  68143. scaling: Vector3;
  68144. /**
  68145. * Convert the Mesh to CSG
  68146. * @param mesh The Mesh to convert to CSG
  68147. * @returns A new CSG from the Mesh
  68148. */
  68149. static FromMesh(mesh: Mesh): CSG;
  68150. /**
  68151. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68152. * @param polygons Polygons used to construct a CSG solid
  68153. */
  68154. private static FromPolygons;
  68155. /**
  68156. * Clones, or makes a deep copy, of the CSG
  68157. * @returns A new CSG
  68158. */
  68159. clone(): CSG;
  68160. /**
  68161. * Unions this CSG with another CSG
  68162. * @param csg The CSG to union against this CSG
  68163. * @returns The unioned CSG
  68164. */
  68165. union(csg: CSG): CSG;
  68166. /**
  68167. * Unions this CSG with another CSG in place
  68168. * @param csg The CSG to union against this CSG
  68169. */
  68170. unionInPlace(csg: CSG): void;
  68171. /**
  68172. * Subtracts this CSG with another CSG
  68173. * @param csg The CSG to subtract against this CSG
  68174. * @returns A new CSG
  68175. */
  68176. subtract(csg: CSG): CSG;
  68177. /**
  68178. * Subtracts this CSG with another CSG in place
  68179. * @param csg The CSG to subtact against this CSG
  68180. */
  68181. subtractInPlace(csg: CSG): void;
  68182. /**
  68183. * Intersect this CSG with another CSG
  68184. * @param csg The CSG to intersect against this CSG
  68185. * @returns A new CSG
  68186. */
  68187. intersect(csg: CSG): CSG;
  68188. /**
  68189. * Intersects this CSG with another CSG in place
  68190. * @param csg The CSG to intersect against this CSG
  68191. */
  68192. intersectInPlace(csg: CSG): void;
  68193. /**
  68194. * Return a new CSG solid with solid and empty space switched. This solid is
  68195. * not modified.
  68196. * @returns A new CSG solid with solid and empty space switched
  68197. */
  68198. inverse(): CSG;
  68199. /**
  68200. * Inverses the CSG in place
  68201. */
  68202. inverseInPlace(): void;
  68203. /**
  68204. * This is used to keep meshes transformations so they can be restored
  68205. * when we build back a Babylon Mesh
  68206. * NB : All CSG operations are performed in world coordinates
  68207. * @param csg The CSG to copy the transform attributes from
  68208. * @returns This CSG
  68209. */
  68210. copyTransformAttributes(csg: CSG): CSG;
  68211. /**
  68212. * Build Raw mesh from CSG
  68213. * Coordinates here are in world space
  68214. * @param name The name of the mesh geometry
  68215. * @param scene The Scene
  68216. * @param keepSubMeshes Specifies if the submeshes should be kept
  68217. * @returns A new Mesh
  68218. */
  68219. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68220. /**
  68221. * Build Mesh from CSG taking material and transforms into account
  68222. * @param name The name of the Mesh
  68223. * @param material The material of the Mesh
  68224. * @param scene The Scene
  68225. * @param keepSubMeshes Specifies if submeshes should be kept
  68226. * @returns The new Mesh
  68227. */
  68228. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68229. }
  68230. }
  68231. declare module "babylonjs/Meshes/trailMesh" {
  68232. import { Mesh } from "babylonjs/Meshes/mesh";
  68233. import { Scene } from "babylonjs/scene";
  68234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68235. /**
  68236. * Class used to create a trail following a mesh
  68237. */
  68238. export class TrailMesh extends Mesh {
  68239. private _generator;
  68240. private _autoStart;
  68241. private _running;
  68242. private _diameter;
  68243. private _length;
  68244. private _sectionPolygonPointsCount;
  68245. private _sectionVectors;
  68246. private _sectionNormalVectors;
  68247. private _beforeRenderObserver;
  68248. /**
  68249. * @constructor
  68250. * @param name The value used by scene.getMeshByName() to do a lookup.
  68251. * @param generator The mesh or transform node to generate a trail.
  68252. * @param scene The scene to add this mesh to.
  68253. * @param diameter Diameter of trailing mesh. Default is 1.
  68254. * @param length Length of trailing mesh. Default is 60.
  68255. * @param autoStart Automatically start trailing mesh. Default true.
  68256. */
  68257. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68258. /**
  68259. * "TrailMesh"
  68260. * @returns "TrailMesh"
  68261. */
  68262. getClassName(): string;
  68263. private _createMesh;
  68264. /**
  68265. * Start trailing mesh.
  68266. */
  68267. start(): void;
  68268. /**
  68269. * Stop trailing mesh.
  68270. */
  68271. stop(): void;
  68272. /**
  68273. * Update trailing mesh geometry.
  68274. */
  68275. update(): void;
  68276. /**
  68277. * Returns a new TrailMesh object.
  68278. * @param name is a string, the name given to the new mesh
  68279. * @param newGenerator use new generator object for cloned trail mesh
  68280. * @returns a new mesh
  68281. */
  68282. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68283. /**
  68284. * Serializes this trail mesh
  68285. * @param serializationObject object to write serialization to
  68286. */
  68287. serialize(serializationObject: any): void;
  68288. /**
  68289. * Parses a serialized trail mesh
  68290. * @param parsedMesh the serialized mesh
  68291. * @param scene the scene to create the trail mesh in
  68292. * @returns the created trail mesh
  68293. */
  68294. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68295. }
  68296. }
  68297. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68298. import { Nullable } from "babylonjs/types";
  68299. import { Scene } from "babylonjs/scene";
  68300. import { Vector4 } from "babylonjs/Maths/math.vector";
  68301. import { Color4 } from "babylonjs/Maths/math.color";
  68302. import { Mesh } from "babylonjs/Meshes/mesh";
  68303. /**
  68304. * Class containing static functions to help procedurally build meshes
  68305. */
  68306. export class TiledBoxBuilder {
  68307. /**
  68308. * Creates a box mesh
  68309. * 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)
  68310. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68314. * @param name defines the name of the mesh
  68315. * @param options defines the options used to create the mesh
  68316. * @param scene defines the hosting scene
  68317. * @returns the box mesh
  68318. */
  68319. static CreateTiledBox(name: string, options: {
  68320. pattern?: number;
  68321. width?: number;
  68322. height?: number;
  68323. depth?: number;
  68324. tileSize?: number;
  68325. tileWidth?: number;
  68326. tileHeight?: number;
  68327. alignHorizontal?: number;
  68328. alignVertical?: number;
  68329. faceUV?: Vector4[];
  68330. faceColors?: Color4[];
  68331. sideOrientation?: number;
  68332. updatable?: boolean;
  68333. }, scene?: Nullable<Scene>): Mesh;
  68334. }
  68335. }
  68336. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68337. import { Vector4 } from "babylonjs/Maths/math.vector";
  68338. import { Mesh } from "babylonjs/Meshes/mesh";
  68339. /**
  68340. * Class containing static functions to help procedurally build meshes
  68341. */
  68342. export class TorusKnotBuilder {
  68343. /**
  68344. * Creates a torus knot mesh
  68345. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68346. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68347. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68348. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68352. * @param name defines the name of the mesh
  68353. * @param options defines the options used to create the mesh
  68354. * @param scene defines the hosting scene
  68355. * @returns the torus knot mesh
  68356. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68357. */
  68358. static CreateTorusKnot(name: string, options: {
  68359. radius?: number;
  68360. tube?: number;
  68361. radialSegments?: number;
  68362. tubularSegments?: number;
  68363. p?: number;
  68364. q?: number;
  68365. updatable?: boolean;
  68366. sideOrientation?: number;
  68367. frontUVs?: Vector4;
  68368. backUVs?: Vector4;
  68369. }, scene: any): Mesh;
  68370. }
  68371. }
  68372. declare module "babylonjs/Meshes/polygonMesh" {
  68373. import { Scene } from "babylonjs/scene";
  68374. import { Vector2 } from "babylonjs/Maths/math.vector";
  68375. import { Mesh } from "babylonjs/Meshes/mesh";
  68376. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68377. import { Path2 } from "babylonjs/Maths/math.path";
  68378. /**
  68379. * Polygon
  68380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68381. */
  68382. export class Polygon {
  68383. /**
  68384. * Creates a rectangle
  68385. * @param xmin bottom X coord
  68386. * @param ymin bottom Y coord
  68387. * @param xmax top X coord
  68388. * @param ymax top Y coord
  68389. * @returns points that make the resulting rectation
  68390. */
  68391. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68392. /**
  68393. * Creates a circle
  68394. * @param radius radius of circle
  68395. * @param cx scale in x
  68396. * @param cy scale in y
  68397. * @param numberOfSides number of sides that make up the circle
  68398. * @returns points that make the resulting circle
  68399. */
  68400. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68401. /**
  68402. * Creates a polygon from input string
  68403. * @param input Input polygon data
  68404. * @returns the parsed points
  68405. */
  68406. static Parse(input: string): Vector2[];
  68407. /**
  68408. * Starts building a polygon from x and y coordinates
  68409. * @param x x coordinate
  68410. * @param y y coordinate
  68411. * @returns the started path2
  68412. */
  68413. static StartingAt(x: number, y: number): Path2;
  68414. }
  68415. /**
  68416. * Builds a polygon
  68417. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68418. */
  68419. export class PolygonMeshBuilder {
  68420. private _points;
  68421. private _outlinepoints;
  68422. private _holes;
  68423. private _name;
  68424. private _scene;
  68425. private _epoints;
  68426. private _eholes;
  68427. private _addToepoint;
  68428. /**
  68429. * Babylon reference to the earcut plugin.
  68430. */
  68431. bjsEarcut: any;
  68432. /**
  68433. * Creates a PolygonMeshBuilder
  68434. * @param name name of the builder
  68435. * @param contours Path of the polygon
  68436. * @param scene scene to add to when creating the mesh
  68437. * @param earcutInjection can be used to inject your own earcut reference
  68438. */
  68439. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68440. /**
  68441. * Adds a whole within the polygon
  68442. * @param hole Array of points defining the hole
  68443. * @returns this
  68444. */
  68445. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68446. /**
  68447. * Creates the polygon
  68448. * @param updatable If the mesh should be updatable
  68449. * @param depth The depth of the mesh created
  68450. * @returns the created mesh
  68451. */
  68452. build(updatable?: boolean, depth?: number): Mesh;
  68453. /**
  68454. * Creates the polygon
  68455. * @param depth The depth of the mesh created
  68456. * @returns the created VertexData
  68457. */
  68458. buildVertexData(depth?: number): VertexData;
  68459. /**
  68460. * Adds a side to the polygon
  68461. * @param positions points that make the polygon
  68462. * @param normals normals of the polygon
  68463. * @param uvs uvs of the polygon
  68464. * @param indices indices of the polygon
  68465. * @param bounds bounds of the polygon
  68466. * @param points points of the polygon
  68467. * @param depth depth of the polygon
  68468. * @param flip flip of the polygon
  68469. */
  68470. private addSide;
  68471. }
  68472. }
  68473. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68474. import { Scene } from "babylonjs/scene";
  68475. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68476. import { Color4 } from "babylonjs/Maths/math.color";
  68477. import { Mesh } from "babylonjs/Meshes/mesh";
  68478. import { Nullable } from "babylonjs/types";
  68479. /**
  68480. * Class containing static functions to help procedurally build meshes
  68481. */
  68482. export class PolygonBuilder {
  68483. /**
  68484. * Creates a polygon mesh
  68485. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68486. * * 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
  68487. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68490. * * Remember you can only change the shape positions, not their number when updating a polygon
  68491. * @param name defines the name of the mesh
  68492. * @param options defines the options used to create the mesh
  68493. * @param scene defines the hosting scene
  68494. * @param earcutInjection can be used to inject your own earcut reference
  68495. * @returns the polygon mesh
  68496. */
  68497. static CreatePolygon(name: string, options: {
  68498. shape: Vector3[];
  68499. holes?: Vector3[][];
  68500. depth?: number;
  68501. faceUV?: Vector4[];
  68502. faceColors?: Color4[];
  68503. updatable?: boolean;
  68504. sideOrientation?: number;
  68505. frontUVs?: Vector4;
  68506. backUVs?: Vector4;
  68507. wrap?: boolean;
  68508. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68509. /**
  68510. * Creates an extruded polygon mesh, with depth in the Y direction.
  68511. * * 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)
  68512. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68513. * @param name defines the name of the mesh
  68514. * @param options defines the options used to create the mesh
  68515. * @param scene defines the hosting scene
  68516. * @param earcutInjection can be used to inject your own earcut reference
  68517. * @returns the polygon mesh
  68518. */
  68519. static ExtrudePolygon(name: string, options: {
  68520. shape: Vector3[];
  68521. holes?: Vector3[][];
  68522. depth?: number;
  68523. faceUV?: Vector4[];
  68524. faceColors?: Color4[];
  68525. updatable?: boolean;
  68526. sideOrientation?: number;
  68527. frontUVs?: Vector4;
  68528. backUVs?: Vector4;
  68529. wrap?: boolean;
  68530. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68531. }
  68532. }
  68533. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68534. import { Scene } from "babylonjs/scene";
  68535. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68536. import { Mesh } from "babylonjs/Meshes/mesh";
  68537. import { Nullable } from "babylonjs/types";
  68538. /**
  68539. * Class containing static functions to help procedurally build meshes
  68540. */
  68541. export class LatheBuilder {
  68542. /**
  68543. * Creates lathe mesh.
  68544. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68545. * * 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
  68546. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68547. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68548. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68549. * * 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
  68550. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68551. * * 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
  68552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68556. * @param name defines the name of the mesh
  68557. * @param options defines the options used to create the mesh
  68558. * @param scene defines the hosting scene
  68559. * @returns the lathe mesh
  68560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68561. */
  68562. static CreateLathe(name: string, options: {
  68563. shape: Vector3[];
  68564. radius?: number;
  68565. tessellation?: number;
  68566. clip?: number;
  68567. arc?: number;
  68568. closed?: boolean;
  68569. updatable?: boolean;
  68570. sideOrientation?: number;
  68571. frontUVs?: Vector4;
  68572. backUVs?: Vector4;
  68573. cap?: number;
  68574. invertUV?: boolean;
  68575. }, scene?: Nullable<Scene>): Mesh;
  68576. }
  68577. }
  68578. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68579. import { Nullable } from "babylonjs/types";
  68580. import { Scene } from "babylonjs/scene";
  68581. import { Vector4 } from "babylonjs/Maths/math.vector";
  68582. import { Mesh } from "babylonjs/Meshes/mesh";
  68583. /**
  68584. * Class containing static functions to help procedurally build meshes
  68585. */
  68586. export class TiledPlaneBuilder {
  68587. /**
  68588. * Creates a tiled plane mesh
  68589. * * The parameter `pattern` will, depending on value, do nothing or
  68590. * * * flip (reflect about central vertical) alternate tiles across and up
  68591. * * * flip every tile on alternate rows
  68592. * * * rotate (180 degs) alternate tiles across and up
  68593. * * * rotate every tile on alternate rows
  68594. * * * flip and rotate alternate tiles across and up
  68595. * * * flip and rotate every tile on alternate rows
  68596. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68597. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68600. * * 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)
  68601. * * 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)
  68602. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68603. * @param name defines the name of the mesh
  68604. * @param options defines the options used to create the mesh
  68605. * @param scene defines the hosting scene
  68606. * @returns the box mesh
  68607. */
  68608. static CreateTiledPlane(name: string, options: {
  68609. pattern?: number;
  68610. tileSize?: number;
  68611. tileWidth?: number;
  68612. tileHeight?: number;
  68613. size?: number;
  68614. width?: number;
  68615. height?: number;
  68616. alignHorizontal?: number;
  68617. alignVertical?: number;
  68618. sideOrientation?: number;
  68619. frontUVs?: Vector4;
  68620. backUVs?: Vector4;
  68621. updatable?: boolean;
  68622. }, scene?: Nullable<Scene>): Mesh;
  68623. }
  68624. }
  68625. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68626. import { Nullable } from "babylonjs/types";
  68627. import { Scene } from "babylonjs/scene";
  68628. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68629. import { Mesh } from "babylonjs/Meshes/mesh";
  68630. /**
  68631. * Class containing static functions to help procedurally build meshes
  68632. */
  68633. export class TubeBuilder {
  68634. /**
  68635. * Creates a tube mesh.
  68636. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68637. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68638. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68639. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68640. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68641. * * 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)
  68642. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68643. * * 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
  68644. * * 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
  68645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68647. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68649. * @param name defines the name of the mesh
  68650. * @param options defines the options used to create the mesh
  68651. * @param scene defines the hosting scene
  68652. * @returns the tube mesh
  68653. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68654. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68655. */
  68656. static CreateTube(name: string, options: {
  68657. path: Vector3[];
  68658. radius?: number;
  68659. tessellation?: number;
  68660. radiusFunction?: {
  68661. (i: number, distance: number): number;
  68662. };
  68663. cap?: number;
  68664. arc?: number;
  68665. updatable?: boolean;
  68666. sideOrientation?: number;
  68667. frontUVs?: Vector4;
  68668. backUVs?: Vector4;
  68669. instance?: Mesh;
  68670. invertUV?: boolean;
  68671. }, scene?: Nullable<Scene>): Mesh;
  68672. }
  68673. }
  68674. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68675. import { Scene } from "babylonjs/scene";
  68676. import { Vector4 } from "babylonjs/Maths/math.vector";
  68677. import { Mesh } from "babylonjs/Meshes/mesh";
  68678. import { Nullable } from "babylonjs/types";
  68679. /**
  68680. * Class containing static functions to help procedurally build meshes
  68681. */
  68682. export class IcoSphereBuilder {
  68683. /**
  68684. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68685. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68686. * * 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`)
  68687. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68688. * * 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
  68689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68692. * @param name defines the name of the mesh
  68693. * @param options defines the options used to create the mesh
  68694. * @param scene defines the hosting scene
  68695. * @returns the icosahedron mesh
  68696. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68697. */
  68698. static CreateIcoSphere(name: string, options: {
  68699. radius?: number;
  68700. radiusX?: number;
  68701. radiusY?: number;
  68702. radiusZ?: number;
  68703. flat?: boolean;
  68704. subdivisions?: number;
  68705. sideOrientation?: number;
  68706. frontUVs?: Vector4;
  68707. backUVs?: Vector4;
  68708. updatable?: boolean;
  68709. }, scene?: Nullable<Scene>): Mesh;
  68710. }
  68711. }
  68712. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68713. import { Vector3 } from "babylonjs/Maths/math.vector";
  68714. import { Mesh } from "babylonjs/Meshes/mesh";
  68715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68716. /**
  68717. * Class containing static functions to help procedurally build meshes
  68718. */
  68719. export class DecalBuilder {
  68720. /**
  68721. * Creates a decal mesh.
  68722. * 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
  68723. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68724. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68725. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68726. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68727. * @param name defines the name of the mesh
  68728. * @param sourceMesh defines the mesh where the decal must be applied
  68729. * @param options defines the options used to create the mesh
  68730. * @param scene defines the hosting scene
  68731. * @returns the decal mesh
  68732. * @see https://doc.babylonjs.com/how_to/decals
  68733. */
  68734. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68735. position?: Vector3;
  68736. normal?: Vector3;
  68737. size?: Vector3;
  68738. angle?: number;
  68739. }): Mesh;
  68740. }
  68741. }
  68742. declare module "babylonjs/Meshes/meshBuilder" {
  68743. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68744. import { Nullable } from "babylonjs/types";
  68745. import { Scene } from "babylonjs/scene";
  68746. import { Mesh } from "babylonjs/Meshes/mesh";
  68747. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68748. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68750. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68751. import { Plane } from "babylonjs/Maths/math.plane";
  68752. /**
  68753. * Class containing static functions to help procedurally build meshes
  68754. */
  68755. export class MeshBuilder {
  68756. /**
  68757. * Creates a box mesh
  68758. * * The parameter `size` sets the size (float) of each box side (default 1)
  68759. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68760. * * 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)
  68761. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68765. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68766. * @param name defines the name of the mesh
  68767. * @param options defines the options used to create the mesh
  68768. * @param scene defines the hosting scene
  68769. * @returns the box mesh
  68770. */
  68771. static CreateBox(name: string, options: {
  68772. size?: number;
  68773. width?: number;
  68774. height?: number;
  68775. depth?: number;
  68776. faceUV?: Vector4[];
  68777. faceColors?: Color4[];
  68778. sideOrientation?: number;
  68779. frontUVs?: Vector4;
  68780. backUVs?: Vector4;
  68781. wrap?: boolean;
  68782. topBaseAt?: number;
  68783. bottomBaseAt?: number;
  68784. updatable?: boolean;
  68785. }, scene?: Nullable<Scene>): Mesh;
  68786. /**
  68787. * Creates a tiled box mesh
  68788. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68790. * @param name defines the name of the mesh
  68791. * @param options defines the options used to create the mesh
  68792. * @param scene defines the hosting scene
  68793. * @returns the tiled box mesh
  68794. */
  68795. static CreateTiledBox(name: string, options: {
  68796. pattern?: number;
  68797. size?: number;
  68798. width?: number;
  68799. height?: number;
  68800. depth: number;
  68801. tileSize?: number;
  68802. tileWidth?: number;
  68803. tileHeight?: number;
  68804. faceUV?: Vector4[];
  68805. faceColors?: Color4[];
  68806. alignHorizontal?: number;
  68807. alignVertical?: number;
  68808. sideOrientation?: number;
  68809. updatable?: boolean;
  68810. }, scene?: Nullable<Scene>): Mesh;
  68811. /**
  68812. * Creates a sphere mesh
  68813. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68814. * * 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`)
  68815. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68816. * * 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
  68817. * * 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)
  68818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68821. * @param name defines the name of the mesh
  68822. * @param options defines the options used to create the mesh
  68823. * @param scene defines the hosting scene
  68824. * @returns the sphere mesh
  68825. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68826. */
  68827. static CreateSphere(name: string, options: {
  68828. segments?: number;
  68829. diameter?: number;
  68830. diameterX?: number;
  68831. diameterY?: number;
  68832. diameterZ?: number;
  68833. arc?: number;
  68834. slice?: number;
  68835. sideOrientation?: number;
  68836. frontUVs?: Vector4;
  68837. backUVs?: Vector4;
  68838. updatable?: boolean;
  68839. }, scene?: Nullable<Scene>): Mesh;
  68840. /**
  68841. * Creates a plane polygonal mesh. By default, this is a disc
  68842. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68843. * * 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
  68844. * * 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
  68845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68848. * @param name defines the name of the mesh
  68849. * @param options defines the options used to create the mesh
  68850. * @param scene defines the hosting scene
  68851. * @returns the plane polygonal mesh
  68852. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68853. */
  68854. static CreateDisc(name: string, options: {
  68855. radius?: number;
  68856. tessellation?: number;
  68857. arc?: number;
  68858. updatable?: boolean;
  68859. sideOrientation?: number;
  68860. frontUVs?: Vector4;
  68861. backUVs?: Vector4;
  68862. }, scene?: Nullable<Scene>): Mesh;
  68863. /**
  68864. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68865. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68866. * * 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`)
  68867. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68868. * * 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
  68869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68872. * @param name defines the name of the mesh
  68873. * @param options defines the options used to create the mesh
  68874. * @param scene defines the hosting scene
  68875. * @returns the icosahedron mesh
  68876. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68877. */
  68878. static CreateIcoSphere(name: string, options: {
  68879. radius?: number;
  68880. radiusX?: number;
  68881. radiusY?: number;
  68882. radiusZ?: number;
  68883. flat?: boolean;
  68884. subdivisions?: number;
  68885. sideOrientation?: number;
  68886. frontUVs?: Vector4;
  68887. backUVs?: Vector4;
  68888. updatable?: boolean;
  68889. }, scene?: Nullable<Scene>): Mesh;
  68890. /**
  68891. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68892. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68893. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68894. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68895. * * 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
  68896. * * 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
  68897. * * 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
  68898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68901. * * 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
  68902. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68903. * * 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
  68904. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68906. * @param name defines the name of the mesh
  68907. * @param options defines the options used to create the mesh
  68908. * @param scene defines the hosting scene
  68909. * @returns the ribbon mesh
  68910. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68912. */
  68913. static CreateRibbon(name: string, options: {
  68914. pathArray: Vector3[][];
  68915. closeArray?: boolean;
  68916. closePath?: boolean;
  68917. offset?: number;
  68918. updatable?: boolean;
  68919. sideOrientation?: number;
  68920. frontUVs?: Vector4;
  68921. backUVs?: Vector4;
  68922. instance?: Mesh;
  68923. invertUV?: boolean;
  68924. uvs?: Vector2[];
  68925. colors?: Color4[];
  68926. }, scene?: Nullable<Scene>): Mesh;
  68927. /**
  68928. * Creates a cylinder or a cone mesh
  68929. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68930. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68931. * * 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.
  68932. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68933. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68934. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68935. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68936. * * 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).
  68937. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68938. * * 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).
  68939. * * 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
  68940. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68941. * * 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
  68942. * * 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.
  68943. * * If `enclose` is false, a ring surface is one element.
  68944. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68945. * * 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
  68946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68949. * @param name defines the name of the mesh
  68950. * @param options defines the options used to create the mesh
  68951. * @param scene defines the hosting scene
  68952. * @returns the cylinder mesh
  68953. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68954. */
  68955. static CreateCylinder(name: string, options: {
  68956. height?: number;
  68957. diameterTop?: number;
  68958. diameterBottom?: number;
  68959. diameter?: number;
  68960. tessellation?: number;
  68961. subdivisions?: number;
  68962. arc?: number;
  68963. faceColors?: Color4[];
  68964. faceUV?: Vector4[];
  68965. updatable?: boolean;
  68966. hasRings?: boolean;
  68967. enclose?: boolean;
  68968. cap?: number;
  68969. sideOrientation?: number;
  68970. frontUVs?: Vector4;
  68971. backUVs?: Vector4;
  68972. }, scene?: Nullable<Scene>): Mesh;
  68973. /**
  68974. * Creates a torus mesh
  68975. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68976. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68977. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68981. * @param name defines the name of the mesh
  68982. * @param options defines the options used to create the mesh
  68983. * @param scene defines the hosting scene
  68984. * @returns the torus mesh
  68985. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68986. */
  68987. static CreateTorus(name: string, options: {
  68988. diameter?: number;
  68989. thickness?: number;
  68990. tessellation?: number;
  68991. updatable?: boolean;
  68992. sideOrientation?: number;
  68993. frontUVs?: Vector4;
  68994. backUVs?: Vector4;
  68995. }, scene?: Nullable<Scene>): Mesh;
  68996. /**
  68997. * Creates a torus knot mesh
  68998. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68999. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69000. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69001. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69005. * @param name defines the name of the mesh
  69006. * @param options defines the options used to create the mesh
  69007. * @param scene defines the hosting scene
  69008. * @returns the torus knot mesh
  69009. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69010. */
  69011. static CreateTorusKnot(name: string, options: {
  69012. radius?: number;
  69013. tube?: number;
  69014. radialSegments?: number;
  69015. tubularSegments?: number;
  69016. p?: number;
  69017. q?: number;
  69018. updatable?: boolean;
  69019. sideOrientation?: number;
  69020. frontUVs?: Vector4;
  69021. backUVs?: Vector4;
  69022. }, scene?: Nullable<Scene>): Mesh;
  69023. /**
  69024. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69025. * * 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
  69026. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69027. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69028. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69029. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69030. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69031. * * 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
  69032. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69035. * @param name defines the name of the new line system
  69036. * @param options defines the options used to create the line system
  69037. * @param scene defines the hosting scene
  69038. * @returns a new line system mesh
  69039. */
  69040. static CreateLineSystem(name: string, options: {
  69041. lines: Vector3[][];
  69042. updatable?: boolean;
  69043. instance?: Nullable<LinesMesh>;
  69044. colors?: Nullable<Color4[][]>;
  69045. useVertexAlpha?: boolean;
  69046. }, scene: Nullable<Scene>): LinesMesh;
  69047. /**
  69048. * Creates a line mesh
  69049. * 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
  69050. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69051. * * The parameter `points` is an array successive Vector3
  69052. * * 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
  69053. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69054. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69055. * * When updating an instance, remember that only point positions can change, not the number of points
  69056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69058. * @param name defines the name of the new line system
  69059. * @param options defines the options used to create the line system
  69060. * @param scene defines the hosting scene
  69061. * @returns a new line mesh
  69062. */
  69063. static CreateLines(name: string, options: {
  69064. points: Vector3[];
  69065. updatable?: boolean;
  69066. instance?: Nullable<LinesMesh>;
  69067. colors?: Color4[];
  69068. useVertexAlpha?: boolean;
  69069. }, scene?: Nullable<Scene>): LinesMesh;
  69070. /**
  69071. * Creates a dashed line mesh
  69072. * * 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
  69073. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69074. * * The parameter `points` is an array successive Vector3
  69075. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69076. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69077. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69078. * * 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
  69079. * * When updating an instance, remember that only point positions can change, not the number of points
  69080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69081. * @param name defines the name of the mesh
  69082. * @param options defines the options used to create the mesh
  69083. * @param scene defines the hosting scene
  69084. * @returns the dashed line mesh
  69085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69086. */
  69087. static CreateDashedLines(name: string, options: {
  69088. points: Vector3[];
  69089. dashSize?: number;
  69090. gapSize?: number;
  69091. dashNb?: number;
  69092. updatable?: boolean;
  69093. instance?: LinesMesh;
  69094. }, scene?: Nullable<Scene>): LinesMesh;
  69095. /**
  69096. * 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.
  69097. * * 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.
  69098. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69099. * * 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.
  69100. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69101. * * 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
  69102. * * 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
  69103. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69106. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69108. * @param name defines the name of the mesh
  69109. * @param options defines the options used to create the mesh
  69110. * @param scene defines the hosting scene
  69111. * @returns the extruded shape mesh
  69112. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69114. */
  69115. static ExtrudeShape(name: string, options: {
  69116. shape: Vector3[];
  69117. path: Vector3[];
  69118. scale?: number;
  69119. rotation?: number;
  69120. cap?: number;
  69121. updatable?: boolean;
  69122. sideOrientation?: number;
  69123. frontUVs?: Vector4;
  69124. backUVs?: Vector4;
  69125. instance?: Mesh;
  69126. invertUV?: boolean;
  69127. }, scene?: Nullable<Scene>): Mesh;
  69128. /**
  69129. * Creates an custom extruded shape mesh.
  69130. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69131. * * 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.
  69132. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69133. * * 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
  69134. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69135. * * 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
  69136. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69137. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69138. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69139. * * 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
  69140. * * 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
  69141. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69146. * @param name defines the name of the mesh
  69147. * @param options defines the options used to create the mesh
  69148. * @param scene defines the hosting scene
  69149. * @returns the custom extruded shape mesh
  69150. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69151. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69153. */
  69154. static ExtrudeShapeCustom(name: string, options: {
  69155. shape: Vector3[];
  69156. path: Vector3[];
  69157. scaleFunction?: any;
  69158. rotationFunction?: any;
  69159. ribbonCloseArray?: boolean;
  69160. ribbonClosePath?: boolean;
  69161. cap?: number;
  69162. updatable?: boolean;
  69163. sideOrientation?: number;
  69164. frontUVs?: Vector4;
  69165. backUVs?: Vector4;
  69166. instance?: Mesh;
  69167. invertUV?: boolean;
  69168. }, scene?: Nullable<Scene>): Mesh;
  69169. /**
  69170. * Creates lathe mesh.
  69171. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69172. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  69173. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69174. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69175. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69176. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  69177. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69178. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  69179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69181. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69183. * @param name defines the name of the mesh
  69184. * @param options defines the options used to create the mesh
  69185. * @param scene defines the hosting scene
  69186. * @returns the lathe mesh
  69187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69188. */
  69189. static CreateLathe(name: string, options: {
  69190. shape: Vector3[];
  69191. radius?: number;
  69192. tessellation?: number;
  69193. clip?: number;
  69194. arc?: number;
  69195. closed?: boolean;
  69196. updatable?: boolean;
  69197. sideOrientation?: number;
  69198. frontUVs?: Vector4;
  69199. backUVs?: Vector4;
  69200. cap?: number;
  69201. invertUV?: boolean;
  69202. }, scene?: Nullable<Scene>): Mesh;
  69203. /**
  69204. * Creates a tiled plane mesh
  69205. * * You can set a limited pattern arrangement with the tiles
  69206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69209. * @param name defines the name of the mesh
  69210. * @param options defines the options used to create the mesh
  69211. * @param scene defines the hosting scene
  69212. * @returns the plane mesh
  69213. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69214. */
  69215. static CreateTiledPlane(name: string, options: {
  69216. pattern?: number;
  69217. tileSize?: number;
  69218. tileWidth?: number;
  69219. tileHeight?: number;
  69220. size?: number;
  69221. width?: number;
  69222. height?: number;
  69223. alignHorizontal?: number;
  69224. alignVertical?: number;
  69225. sideOrientation?: number;
  69226. frontUVs?: Vector4;
  69227. backUVs?: Vector4;
  69228. updatable?: boolean;
  69229. }, scene?: Nullable<Scene>): Mesh;
  69230. /**
  69231. * Creates a plane mesh
  69232. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69233. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69234. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69238. * @param name defines the name of the mesh
  69239. * @param options defines the options used to create the mesh
  69240. * @param scene defines the hosting scene
  69241. * @returns the plane mesh
  69242. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69243. */
  69244. static CreatePlane(name: string, options: {
  69245. size?: number;
  69246. width?: number;
  69247. height?: number;
  69248. sideOrientation?: number;
  69249. frontUVs?: Vector4;
  69250. backUVs?: Vector4;
  69251. updatable?: boolean;
  69252. sourcePlane?: Plane;
  69253. }, scene?: Nullable<Scene>): Mesh;
  69254. /**
  69255. * Creates a ground mesh
  69256. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69257. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69259. * @param name defines the name of the mesh
  69260. * @param options defines the options used to create the mesh
  69261. * @param scene defines the hosting scene
  69262. * @returns the ground mesh
  69263. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69264. */
  69265. static CreateGround(name: string, options: {
  69266. width?: number;
  69267. height?: number;
  69268. subdivisions?: number;
  69269. subdivisionsX?: number;
  69270. subdivisionsY?: number;
  69271. updatable?: boolean;
  69272. }, scene?: Nullable<Scene>): Mesh;
  69273. /**
  69274. * Creates a tiled ground mesh
  69275. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69276. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69277. * * 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
  69278. * * 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
  69279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69280. * @param name defines the name of the mesh
  69281. * @param options defines the options used to create the mesh
  69282. * @param scene defines the hosting scene
  69283. * @returns the tiled ground mesh
  69284. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69285. */
  69286. static CreateTiledGround(name: string, options: {
  69287. xmin: number;
  69288. zmin: number;
  69289. xmax: number;
  69290. zmax: number;
  69291. subdivisions?: {
  69292. w: number;
  69293. h: number;
  69294. };
  69295. precision?: {
  69296. w: number;
  69297. h: number;
  69298. };
  69299. updatable?: boolean;
  69300. }, scene?: Nullable<Scene>): Mesh;
  69301. /**
  69302. * Creates a ground mesh from a height map
  69303. * * The parameter `url` sets the URL of the height map image resource.
  69304. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69305. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69306. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69307. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69308. * * 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.
  69309. * * 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).
  69310. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69312. * @param name defines the name of the mesh
  69313. * @param url defines the url to the height map
  69314. * @param options defines the options used to create the mesh
  69315. * @param scene defines the hosting scene
  69316. * @returns the ground mesh
  69317. * @see https://doc.babylonjs.com/babylon101/height_map
  69318. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69319. */
  69320. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69321. width?: number;
  69322. height?: number;
  69323. subdivisions?: number;
  69324. minHeight?: number;
  69325. maxHeight?: number;
  69326. colorFilter?: Color3;
  69327. alphaFilter?: number;
  69328. updatable?: boolean;
  69329. onReady?: (mesh: GroundMesh) => void;
  69330. }, scene?: Nullable<Scene>): GroundMesh;
  69331. /**
  69332. * Creates a polygon mesh
  69333. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69334. * * 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
  69335. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69338. * * Remember you can only change the shape positions, not their number when updating a polygon
  69339. * @param name defines the name of the mesh
  69340. * @param options defines the options used to create the mesh
  69341. * @param scene defines the hosting scene
  69342. * @param earcutInjection can be used to inject your own earcut reference
  69343. * @returns the polygon mesh
  69344. */
  69345. static CreatePolygon(name: string, options: {
  69346. shape: Vector3[];
  69347. holes?: Vector3[][];
  69348. depth?: number;
  69349. faceUV?: Vector4[];
  69350. faceColors?: Color4[];
  69351. updatable?: boolean;
  69352. sideOrientation?: number;
  69353. frontUVs?: Vector4;
  69354. backUVs?: Vector4;
  69355. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69356. /**
  69357. * Creates an extruded polygon mesh, with depth in the Y direction.
  69358. * * 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)
  69359. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69360. * @param name defines the name of the mesh
  69361. * @param options defines the options used to create the mesh
  69362. * @param scene defines the hosting scene
  69363. * @param earcutInjection can be used to inject your own earcut reference
  69364. * @returns the polygon mesh
  69365. */
  69366. static ExtrudePolygon(name: string, options: {
  69367. shape: Vector3[];
  69368. holes?: Vector3[][];
  69369. depth?: number;
  69370. faceUV?: Vector4[];
  69371. faceColors?: Color4[];
  69372. updatable?: boolean;
  69373. sideOrientation?: number;
  69374. frontUVs?: Vector4;
  69375. backUVs?: Vector4;
  69376. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69377. /**
  69378. * Creates a tube mesh.
  69379. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69380. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69381. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69382. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69383. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69384. * * 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)
  69385. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69386. * * 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
  69387. * * 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
  69388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69390. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69392. * @param name defines the name of the mesh
  69393. * @param options defines the options used to create the mesh
  69394. * @param scene defines the hosting scene
  69395. * @returns the tube mesh
  69396. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69397. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69398. */
  69399. static CreateTube(name: string, options: {
  69400. path: Vector3[];
  69401. radius?: number;
  69402. tessellation?: number;
  69403. radiusFunction?: {
  69404. (i: number, distance: number): number;
  69405. };
  69406. cap?: number;
  69407. arc?: number;
  69408. updatable?: boolean;
  69409. sideOrientation?: number;
  69410. frontUVs?: Vector4;
  69411. backUVs?: Vector4;
  69412. instance?: Mesh;
  69413. invertUV?: boolean;
  69414. }, scene?: Nullable<Scene>): Mesh;
  69415. /**
  69416. * Creates a polyhedron mesh
  69417. * * 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
  69418. * * The parameter `size` (positive float, default 1) sets the polygon size
  69419. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69420. * * 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`
  69421. * * 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
  69422. * * 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)`)
  69423. * * 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
  69424. * * 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
  69425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69428. * @param name defines the name of the mesh
  69429. * @param options defines the options used to create the mesh
  69430. * @param scene defines the hosting scene
  69431. * @returns the polyhedron mesh
  69432. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69433. */
  69434. static CreatePolyhedron(name: string, options: {
  69435. type?: number;
  69436. size?: number;
  69437. sizeX?: number;
  69438. sizeY?: number;
  69439. sizeZ?: number;
  69440. custom?: any;
  69441. faceUV?: Vector4[];
  69442. faceColors?: Color4[];
  69443. flat?: boolean;
  69444. updatable?: boolean;
  69445. sideOrientation?: number;
  69446. frontUVs?: Vector4;
  69447. backUVs?: Vector4;
  69448. }, scene?: Nullable<Scene>): Mesh;
  69449. /**
  69450. * Creates a decal mesh.
  69451. * 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
  69452. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69453. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69454. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69455. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69456. * @param name defines the name of the mesh
  69457. * @param sourceMesh defines the mesh where the decal must be applied
  69458. * @param options defines the options used to create the mesh
  69459. * @param scene defines the hosting scene
  69460. * @returns the decal mesh
  69461. * @see https://doc.babylonjs.com/how_to/decals
  69462. */
  69463. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69464. position?: Vector3;
  69465. normal?: Vector3;
  69466. size?: Vector3;
  69467. angle?: number;
  69468. }): Mesh;
  69469. }
  69470. }
  69471. declare module "babylonjs/Meshes/meshSimplification" {
  69472. import { Mesh } from "babylonjs/Meshes/mesh";
  69473. /**
  69474. * A simplifier interface for future simplification implementations
  69475. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69476. */
  69477. export interface ISimplifier {
  69478. /**
  69479. * Simplification of a given mesh according to the given settings.
  69480. * Since this requires computation, it is assumed that the function runs async.
  69481. * @param settings The settings of the simplification, including quality and distance
  69482. * @param successCallback A callback that will be called after the mesh was simplified.
  69483. * @param errorCallback in case of an error, this callback will be called. optional.
  69484. */
  69485. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69486. }
  69487. /**
  69488. * Expected simplification settings.
  69489. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69490. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69491. */
  69492. export interface ISimplificationSettings {
  69493. /**
  69494. * Gets or sets the expected quality
  69495. */
  69496. quality: number;
  69497. /**
  69498. * Gets or sets the distance when this optimized version should be used
  69499. */
  69500. distance: number;
  69501. /**
  69502. * Gets an already optimized mesh
  69503. */
  69504. optimizeMesh?: boolean;
  69505. }
  69506. /**
  69507. * Class used to specify simplification options
  69508. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69509. */
  69510. export class SimplificationSettings implements ISimplificationSettings {
  69511. /** expected quality */
  69512. quality: number;
  69513. /** distance when this optimized version should be used */
  69514. distance: number;
  69515. /** already optimized mesh */
  69516. optimizeMesh?: boolean | undefined;
  69517. /**
  69518. * Creates a SimplificationSettings
  69519. * @param quality expected quality
  69520. * @param distance distance when this optimized version should be used
  69521. * @param optimizeMesh already optimized mesh
  69522. */
  69523. constructor(
  69524. /** expected quality */
  69525. quality: number,
  69526. /** distance when this optimized version should be used */
  69527. distance: number,
  69528. /** already optimized mesh */
  69529. optimizeMesh?: boolean | undefined);
  69530. }
  69531. /**
  69532. * Interface used to define a simplification task
  69533. */
  69534. export interface ISimplificationTask {
  69535. /**
  69536. * Array of settings
  69537. */
  69538. settings: Array<ISimplificationSettings>;
  69539. /**
  69540. * Simplification type
  69541. */
  69542. simplificationType: SimplificationType;
  69543. /**
  69544. * Mesh to simplify
  69545. */
  69546. mesh: Mesh;
  69547. /**
  69548. * Callback called on success
  69549. */
  69550. successCallback?: () => void;
  69551. /**
  69552. * Defines if parallel processing can be used
  69553. */
  69554. parallelProcessing: boolean;
  69555. }
  69556. /**
  69557. * Queue used to order the simplification tasks
  69558. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69559. */
  69560. export class SimplificationQueue {
  69561. private _simplificationArray;
  69562. /**
  69563. * Gets a boolean indicating that the process is still running
  69564. */
  69565. running: boolean;
  69566. /**
  69567. * Creates a new queue
  69568. */
  69569. constructor();
  69570. /**
  69571. * Adds a new simplification task
  69572. * @param task defines a task to add
  69573. */
  69574. addTask(task: ISimplificationTask): void;
  69575. /**
  69576. * Execute next task
  69577. */
  69578. executeNext(): void;
  69579. /**
  69580. * Execute a simplification task
  69581. * @param task defines the task to run
  69582. */
  69583. runSimplification(task: ISimplificationTask): void;
  69584. private getSimplifier;
  69585. }
  69586. /**
  69587. * The implemented types of simplification
  69588. * At the moment only Quadratic Error Decimation is implemented
  69589. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69590. */
  69591. export enum SimplificationType {
  69592. /** Quadratic error decimation */
  69593. QUADRATIC = 0
  69594. }
  69595. /**
  69596. * An implementation of the Quadratic Error simplification algorithm.
  69597. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69598. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69599. * @author RaananW
  69600. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69601. */
  69602. export class QuadraticErrorSimplification implements ISimplifier {
  69603. private _mesh;
  69604. private triangles;
  69605. private vertices;
  69606. private references;
  69607. private _reconstructedMesh;
  69608. /** Gets or sets the number pf sync interations */
  69609. syncIterations: number;
  69610. /** Gets or sets the aggressiveness of the simplifier */
  69611. aggressiveness: number;
  69612. /** Gets or sets the number of allowed iterations for decimation */
  69613. decimationIterations: number;
  69614. /** Gets or sets the espilon to use for bounding box computation */
  69615. boundingBoxEpsilon: number;
  69616. /**
  69617. * Creates a new QuadraticErrorSimplification
  69618. * @param _mesh defines the target mesh
  69619. */
  69620. constructor(_mesh: Mesh);
  69621. /**
  69622. * Simplification of a given mesh according to the given settings.
  69623. * Since this requires computation, it is assumed that the function runs async.
  69624. * @param settings The settings of the simplification, including quality and distance
  69625. * @param successCallback A callback that will be called after the mesh was simplified.
  69626. */
  69627. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69628. private runDecimation;
  69629. private initWithMesh;
  69630. private init;
  69631. private reconstructMesh;
  69632. private initDecimatedMesh;
  69633. private isFlipped;
  69634. private updateTriangles;
  69635. private identifyBorder;
  69636. private updateMesh;
  69637. private vertexError;
  69638. private calculateError;
  69639. }
  69640. }
  69641. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69642. import { Scene } from "babylonjs/scene";
  69643. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69644. import { ISceneComponent } from "babylonjs/sceneComponent";
  69645. module "babylonjs/scene" {
  69646. interface Scene {
  69647. /** @hidden (Backing field) */
  69648. _simplificationQueue: SimplificationQueue;
  69649. /**
  69650. * Gets or sets the simplification queue attached to the scene
  69651. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69652. */
  69653. simplificationQueue: SimplificationQueue;
  69654. }
  69655. }
  69656. module "babylonjs/Meshes/mesh" {
  69657. interface Mesh {
  69658. /**
  69659. * Simplify the mesh according to the given array of settings.
  69660. * Function will return immediately and will simplify async
  69661. * @param settings a collection of simplification settings
  69662. * @param parallelProcessing should all levels calculate parallel or one after the other
  69663. * @param simplificationType the type of simplification to run
  69664. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69665. * @returns the current mesh
  69666. */
  69667. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69668. }
  69669. }
  69670. /**
  69671. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69672. * created in a scene
  69673. */
  69674. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69675. /**
  69676. * The component name helpfull to identify the component in the list of scene components.
  69677. */
  69678. readonly name: string;
  69679. /**
  69680. * The scene the component belongs to.
  69681. */
  69682. scene: Scene;
  69683. /**
  69684. * Creates a new instance of the component for the given scene
  69685. * @param scene Defines the scene to register the component in
  69686. */
  69687. constructor(scene: Scene);
  69688. /**
  69689. * Registers the component in a given scene
  69690. */
  69691. register(): void;
  69692. /**
  69693. * Rebuilds the elements related to this component in case of
  69694. * context lost for instance.
  69695. */
  69696. rebuild(): void;
  69697. /**
  69698. * Disposes the component and the associated ressources
  69699. */
  69700. dispose(): void;
  69701. private _beforeCameraUpdate;
  69702. }
  69703. }
  69704. declare module "babylonjs/Meshes/Builders/index" {
  69705. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69706. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69707. export * from "babylonjs/Meshes/Builders/discBuilder";
  69708. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69709. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69710. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69711. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69712. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69713. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69714. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69715. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69716. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69717. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69718. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69719. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69720. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69721. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69722. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69723. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69724. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69725. }
  69726. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69727. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69728. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69729. import { Matrix } from "babylonjs/Maths/math.vector";
  69730. module "babylonjs/Meshes/mesh" {
  69731. interface Mesh {
  69732. /**
  69733. * Creates a new thin instance
  69734. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69735. * @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
  69736. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69737. */
  69738. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69739. /**
  69740. * Adds the transformation (matrix) of the current mesh as a thin instance
  69741. * @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
  69742. * @returns the thin instance index number
  69743. */
  69744. thinInstanceAddSelf(refresh: boolean): number;
  69745. /**
  69746. * Registers a custom attribute to be used with thin instances
  69747. * @param kind name of the attribute
  69748. * @param stride size in floats of the attribute
  69749. */
  69750. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69751. /**
  69752. * Sets the matrix of a thin instance
  69753. * @param index index of the thin instance
  69754. * @param matrix matrix to set
  69755. * @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
  69756. */
  69757. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69758. /**
  69759. * Sets the value of a custom attribute for a thin instance
  69760. * @param kind name of the attribute
  69761. * @param index index of the thin instance
  69762. * @param value value to set
  69763. * @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
  69764. */
  69765. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69766. /**
  69767. * 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.
  69768. */
  69769. thinInstanceCount: number;
  69770. /**
  69771. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69772. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69773. * @param buffer buffer to set
  69774. * @param stride size in floats of each value of the buffer
  69775. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69776. */
  69777. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69778. /**
  69779. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69780. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69781. */
  69782. thinInstanceBufferUpdated(kind: string): void;
  69783. /**
  69784. * Refreshes the bounding info, taking into account all the thin instances defined
  69785. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69786. */
  69787. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69788. /** @hidden */
  69789. _thinInstanceInitializeUserStorage(): void;
  69790. /** @hidden */
  69791. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69792. /** @hidden */
  69793. _userThinInstanceBuffersStorage: {
  69794. data: {
  69795. [key: string]: Float32Array;
  69796. };
  69797. sizes: {
  69798. [key: string]: number;
  69799. };
  69800. vertexBuffers: {
  69801. [key: string]: Nullable<VertexBuffer>;
  69802. };
  69803. strides: {
  69804. [key: string]: number;
  69805. };
  69806. };
  69807. }
  69808. }
  69809. }
  69810. declare module "babylonjs/Meshes/index" {
  69811. export * from "babylonjs/Meshes/abstractMesh";
  69812. export * from "babylonjs/Meshes/buffer";
  69813. export * from "babylonjs/Meshes/Compression/index";
  69814. export * from "babylonjs/Meshes/csg";
  69815. export * from "babylonjs/Meshes/geometry";
  69816. export * from "babylonjs/Meshes/groundMesh";
  69817. export * from "babylonjs/Meshes/trailMesh";
  69818. export * from "babylonjs/Meshes/instancedMesh";
  69819. export * from "babylonjs/Meshes/linesMesh";
  69820. export * from "babylonjs/Meshes/mesh";
  69821. export * from "babylonjs/Meshes/mesh.vertexData";
  69822. export * from "babylonjs/Meshes/meshBuilder";
  69823. export * from "babylonjs/Meshes/meshSimplification";
  69824. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69825. export * from "babylonjs/Meshes/polygonMesh";
  69826. export * from "babylonjs/Meshes/subMesh";
  69827. export * from "babylonjs/Meshes/meshLODLevel";
  69828. export * from "babylonjs/Meshes/transformNode";
  69829. export * from "babylonjs/Meshes/Builders/index";
  69830. export * from "babylonjs/Meshes/dataBuffer";
  69831. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69832. import "babylonjs/Meshes/thinInstanceMesh";
  69833. export * from "babylonjs/Meshes/thinInstanceMesh";
  69834. }
  69835. declare module "babylonjs/Morph/index" {
  69836. export * from "babylonjs/Morph/morphTarget";
  69837. export * from "babylonjs/Morph/morphTargetManager";
  69838. }
  69839. declare module "babylonjs/Navigation/INavigationEngine" {
  69840. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69841. import { Vector3 } from "babylonjs/Maths/math";
  69842. import { Mesh } from "babylonjs/Meshes/mesh";
  69843. import { Scene } from "babylonjs/scene";
  69844. /**
  69845. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69846. */
  69847. export interface INavigationEnginePlugin {
  69848. /**
  69849. * plugin name
  69850. */
  69851. name: string;
  69852. /**
  69853. * Creates a navigation mesh
  69854. * @param meshes array of all the geometry used to compute the navigatio mesh
  69855. * @param parameters bunch of parameters used to filter geometry
  69856. */
  69857. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69858. /**
  69859. * Create a navigation mesh debug mesh
  69860. * @param scene is where the mesh will be added
  69861. * @returns debug display mesh
  69862. */
  69863. createDebugNavMesh(scene: Scene): Mesh;
  69864. /**
  69865. * Get a navigation mesh constrained position, closest to the parameter position
  69866. * @param position world position
  69867. * @returns the closest point to position constrained by the navigation mesh
  69868. */
  69869. getClosestPoint(position: Vector3): Vector3;
  69870. /**
  69871. * Get a navigation mesh constrained position, closest to the parameter position
  69872. * @param position world position
  69873. * @param result output the closest point to position constrained by the navigation mesh
  69874. */
  69875. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69876. /**
  69877. * Get a navigation mesh constrained position, within a particular radius
  69878. * @param position world position
  69879. * @param maxRadius the maximum distance to the constrained world position
  69880. * @returns the closest point to position constrained by the navigation mesh
  69881. */
  69882. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69883. /**
  69884. * Get a navigation mesh constrained position, within a particular radius
  69885. * @param position world position
  69886. * @param maxRadius the maximum distance to the constrained world position
  69887. * @param result output the closest point to position constrained by the navigation mesh
  69888. */
  69889. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69890. /**
  69891. * Compute the final position from a segment made of destination-position
  69892. * @param position world position
  69893. * @param destination world position
  69894. * @returns the resulting point along the navmesh
  69895. */
  69896. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69897. /**
  69898. * Compute the final position from a segment made of destination-position
  69899. * @param position world position
  69900. * @param destination world position
  69901. * @param result output the resulting point along the navmesh
  69902. */
  69903. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69904. /**
  69905. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69906. * @param start world position
  69907. * @param end world position
  69908. * @returns array containing world position composing the path
  69909. */
  69910. computePath(start: Vector3, end: Vector3): Vector3[];
  69911. /**
  69912. * If this plugin is supported
  69913. * @returns true if plugin is supported
  69914. */
  69915. isSupported(): boolean;
  69916. /**
  69917. * Create a new Crowd so you can add agents
  69918. * @param maxAgents the maximum agent count in the crowd
  69919. * @param maxAgentRadius the maximum radius an agent can have
  69920. * @param scene to attach the crowd to
  69921. * @returns the crowd you can add agents to
  69922. */
  69923. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69924. /**
  69925. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69926. * The queries will try to find a solution within those bounds
  69927. * default is (1,1,1)
  69928. * @param extent x,y,z value that define the extent around the queries point of reference
  69929. */
  69930. setDefaultQueryExtent(extent: Vector3): void;
  69931. /**
  69932. * Get the Bounding box extent specified by setDefaultQueryExtent
  69933. * @returns the box extent values
  69934. */
  69935. getDefaultQueryExtent(): Vector3;
  69936. /**
  69937. * build the navmesh from a previously saved state using getNavmeshData
  69938. * @param data the Uint8Array returned by getNavmeshData
  69939. */
  69940. buildFromNavmeshData(data: Uint8Array): void;
  69941. /**
  69942. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69943. * @returns data the Uint8Array that can be saved and reused
  69944. */
  69945. getNavmeshData(): Uint8Array;
  69946. /**
  69947. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69948. * @param result output the box extent values
  69949. */
  69950. getDefaultQueryExtentToRef(result: Vector3): void;
  69951. /**
  69952. * Release all resources
  69953. */
  69954. dispose(): void;
  69955. }
  69956. /**
  69957. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69958. */
  69959. export interface ICrowd {
  69960. /**
  69961. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69962. * You can attach anything to that node. The node position is updated in the scene update tick.
  69963. * @param pos world position that will be constrained by the navigation mesh
  69964. * @param parameters agent parameters
  69965. * @param transform hooked to the agent that will be update by the scene
  69966. * @returns agent index
  69967. */
  69968. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69969. /**
  69970. * Returns the agent position in world space
  69971. * @param index agent index returned by addAgent
  69972. * @returns world space position
  69973. */
  69974. getAgentPosition(index: number): Vector3;
  69975. /**
  69976. * Gets the agent position result in world space
  69977. * @param index agent index returned by addAgent
  69978. * @param result output world space position
  69979. */
  69980. getAgentPositionToRef(index: number, result: Vector3): void;
  69981. /**
  69982. * Gets the agent velocity in world space
  69983. * @param index agent index returned by addAgent
  69984. * @returns world space velocity
  69985. */
  69986. getAgentVelocity(index: number): Vector3;
  69987. /**
  69988. * Gets the agent velocity result in world space
  69989. * @param index agent index returned by addAgent
  69990. * @param result output world space velocity
  69991. */
  69992. getAgentVelocityToRef(index: number, result: Vector3): void;
  69993. /**
  69994. * remove a particular agent previously created
  69995. * @param index agent index returned by addAgent
  69996. */
  69997. removeAgent(index: number): void;
  69998. /**
  69999. * get the list of all agents attached to this crowd
  70000. * @returns list of agent indices
  70001. */
  70002. getAgents(): number[];
  70003. /**
  70004. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70005. * @param deltaTime in seconds
  70006. */
  70007. update(deltaTime: number): void;
  70008. /**
  70009. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70010. * @param index agent index returned by addAgent
  70011. * @param destination targeted world position
  70012. */
  70013. agentGoto(index: number, destination: Vector3): void;
  70014. /**
  70015. * Teleport the agent to a new position
  70016. * @param index agent index returned by addAgent
  70017. * @param destination targeted world position
  70018. */
  70019. agentTeleport(index: number, destination: Vector3): void;
  70020. /**
  70021. * Update agent parameters
  70022. * @param index agent index returned by addAgent
  70023. * @param parameters agent parameters
  70024. */
  70025. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70026. /**
  70027. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70028. * The queries will try to find a solution within those bounds
  70029. * default is (1,1,1)
  70030. * @param extent x,y,z value that define the extent around the queries point of reference
  70031. */
  70032. setDefaultQueryExtent(extent: Vector3): void;
  70033. /**
  70034. * Get the Bounding box extent specified by setDefaultQueryExtent
  70035. * @returns the box extent values
  70036. */
  70037. getDefaultQueryExtent(): Vector3;
  70038. /**
  70039. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70040. * @param result output the box extent values
  70041. */
  70042. getDefaultQueryExtentToRef(result: Vector3): void;
  70043. /**
  70044. * Release all resources
  70045. */
  70046. dispose(): void;
  70047. }
  70048. /**
  70049. * Configures an agent
  70050. */
  70051. export interface IAgentParameters {
  70052. /**
  70053. * Agent radius. [Limit: >= 0]
  70054. */
  70055. radius: number;
  70056. /**
  70057. * Agent height. [Limit: > 0]
  70058. */
  70059. height: number;
  70060. /**
  70061. * Maximum allowed acceleration. [Limit: >= 0]
  70062. */
  70063. maxAcceleration: number;
  70064. /**
  70065. * Maximum allowed speed. [Limit: >= 0]
  70066. */
  70067. maxSpeed: number;
  70068. /**
  70069. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70070. */
  70071. collisionQueryRange: number;
  70072. /**
  70073. * The path visibility optimization range. [Limit: > 0]
  70074. */
  70075. pathOptimizationRange: number;
  70076. /**
  70077. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70078. */
  70079. separationWeight: number;
  70080. }
  70081. /**
  70082. * Configures the navigation mesh creation
  70083. */
  70084. export interface INavMeshParameters {
  70085. /**
  70086. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70087. */
  70088. cs: number;
  70089. /**
  70090. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70091. */
  70092. ch: number;
  70093. /**
  70094. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70095. */
  70096. walkableSlopeAngle: number;
  70097. /**
  70098. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70099. * be considered walkable. [Limit: >= 3] [Units: vx]
  70100. */
  70101. walkableHeight: number;
  70102. /**
  70103. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70104. */
  70105. walkableClimb: number;
  70106. /**
  70107. * The distance to erode/shrink the walkable area of the heightfield away from
  70108. * obstructions. [Limit: >=0] [Units: vx]
  70109. */
  70110. walkableRadius: number;
  70111. /**
  70112. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70113. */
  70114. maxEdgeLen: number;
  70115. /**
  70116. * The maximum distance a simplfied contour's border edges should deviate
  70117. * the original raw contour. [Limit: >=0] [Units: vx]
  70118. */
  70119. maxSimplificationError: number;
  70120. /**
  70121. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70122. */
  70123. minRegionArea: number;
  70124. /**
  70125. * Any regions with a span count smaller than this value will, if possible,
  70126. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70127. */
  70128. mergeRegionArea: number;
  70129. /**
  70130. * The maximum number of vertices allowed for polygons generated during the
  70131. * contour to polygon conversion process. [Limit: >= 3]
  70132. */
  70133. maxVertsPerPoly: number;
  70134. /**
  70135. * Sets the sampling distance to use when generating the detail mesh.
  70136. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70137. */
  70138. detailSampleDist: number;
  70139. /**
  70140. * The maximum distance the detail mesh surface should deviate from heightfield
  70141. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70142. */
  70143. detailSampleMaxError: number;
  70144. }
  70145. }
  70146. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70147. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70148. import { Mesh } from "babylonjs/Meshes/mesh";
  70149. import { Scene } from "babylonjs/scene";
  70150. import { Vector3 } from "babylonjs/Maths/math";
  70151. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70152. /**
  70153. * RecastJS navigation plugin
  70154. */
  70155. export class RecastJSPlugin implements INavigationEnginePlugin {
  70156. /**
  70157. * Reference to the Recast library
  70158. */
  70159. bjsRECAST: any;
  70160. /**
  70161. * plugin name
  70162. */
  70163. name: string;
  70164. /**
  70165. * the first navmesh created. We might extend this to support multiple navmeshes
  70166. */
  70167. navMesh: any;
  70168. /**
  70169. * Initializes the recastJS plugin
  70170. * @param recastInjection can be used to inject your own recast reference
  70171. */
  70172. constructor(recastInjection?: any);
  70173. /**
  70174. * Creates a navigation mesh
  70175. * @param meshes array of all the geometry used to compute the navigatio mesh
  70176. * @param parameters bunch of parameters used to filter geometry
  70177. */
  70178. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70179. /**
  70180. * Create a navigation mesh debug mesh
  70181. * @param scene is where the mesh will be added
  70182. * @returns debug display mesh
  70183. */
  70184. createDebugNavMesh(scene: Scene): Mesh;
  70185. /**
  70186. * Get a navigation mesh constrained position, closest to the parameter position
  70187. * @param position world position
  70188. * @returns the closest point to position constrained by the navigation mesh
  70189. */
  70190. getClosestPoint(position: Vector3): Vector3;
  70191. /**
  70192. * Get a navigation mesh constrained position, closest to the parameter position
  70193. * @param position world position
  70194. * @param result output the closest point to position constrained by the navigation mesh
  70195. */
  70196. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70197. /**
  70198. * Get a navigation mesh constrained position, within a particular radius
  70199. * @param position world position
  70200. * @param maxRadius the maximum distance to the constrained world position
  70201. * @returns the closest point to position constrained by the navigation mesh
  70202. */
  70203. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70204. /**
  70205. * Get a navigation mesh constrained position, within a particular radius
  70206. * @param position world position
  70207. * @param maxRadius the maximum distance to the constrained world position
  70208. * @param result output the closest point to position constrained by the navigation mesh
  70209. */
  70210. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70211. /**
  70212. * Compute the final position from a segment made of destination-position
  70213. * @param position world position
  70214. * @param destination world position
  70215. * @returns the resulting point along the navmesh
  70216. */
  70217. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70218. /**
  70219. * Compute the final position from a segment made of destination-position
  70220. * @param position world position
  70221. * @param destination world position
  70222. * @param result output the resulting point along the navmesh
  70223. */
  70224. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70225. /**
  70226. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70227. * @param start world position
  70228. * @param end world position
  70229. * @returns array containing world position composing the path
  70230. */
  70231. computePath(start: Vector3, end: Vector3): Vector3[];
  70232. /**
  70233. * Create a new Crowd so you can add agents
  70234. * @param maxAgents the maximum agent count in the crowd
  70235. * @param maxAgentRadius the maximum radius an agent can have
  70236. * @param scene to attach the crowd to
  70237. * @returns the crowd you can add agents to
  70238. */
  70239. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70240. /**
  70241. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70242. * The queries will try to find a solution within those bounds
  70243. * default is (1,1,1)
  70244. * @param extent x,y,z value that define the extent around the queries point of reference
  70245. */
  70246. setDefaultQueryExtent(extent: Vector3): void;
  70247. /**
  70248. * Get the Bounding box extent specified by setDefaultQueryExtent
  70249. * @returns the box extent values
  70250. */
  70251. getDefaultQueryExtent(): Vector3;
  70252. /**
  70253. * build the navmesh from a previously saved state using getNavmeshData
  70254. * @param data the Uint8Array returned by getNavmeshData
  70255. */
  70256. buildFromNavmeshData(data: Uint8Array): void;
  70257. /**
  70258. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70259. * @returns data the Uint8Array that can be saved and reused
  70260. */
  70261. getNavmeshData(): Uint8Array;
  70262. /**
  70263. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70264. * @param result output the box extent values
  70265. */
  70266. getDefaultQueryExtentToRef(result: Vector3): void;
  70267. /**
  70268. * Disposes
  70269. */
  70270. dispose(): void;
  70271. /**
  70272. * If this plugin is supported
  70273. * @returns true if plugin is supported
  70274. */
  70275. isSupported(): boolean;
  70276. }
  70277. /**
  70278. * Recast detour crowd implementation
  70279. */
  70280. export class RecastJSCrowd implements ICrowd {
  70281. /**
  70282. * Recast/detour plugin
  70283. */
  70284. bjsRECASTPlugin: RecastJSPlugin;
  70285. /**
  70286. * Link to the detour crowd
  70287. */
  70288. recastCrowd: any;
  70289. /**
  70290. * One transform per agent
  70291. */
  70292. transforms: TransformNode[];
  70293. /**
  70294. * All agents created
  70295. */
  70296. agents: number[];
  70297. /**
  70298. * Link to the scene is kept to unregister the crowd from the scene
  70299. */
  70300. private _scene;
  70301. /**
  70302. * Observer for crowd updates
  70303. */
  70304. private _onBeforeAnimationsObserver;
  70305. /**
  70306. * Constructor
  70307. * @param plugin recastJS plugin
  70308. * @param maxAgents the maximum agent count in the crowd
  70309. * @param maxAgentRadius the maximum radius an agent can have
  70310. * @param scene to attach the crowd to
  70311. * @returns the crowd you can add agents to
  70312. */
  70313. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70314. /**
  70315. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70316. * You can attach anything to that node. The node position is updated in the scene update tick.
  70317. * @param pos world position that will be constrained by the navigation mesh
  70318. * @param parameters agent parameters
  70319. * @param transform hooked to the agent that will be update by the scene
  70320. * @returns agent index
  70321. */
  70322. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70323. /**
  70324. * Returns the agent position in world space
  70325. * @param index agent index returned by addAgent
  70326. * @returns world space position
  70327. */
  70328. getAgentPosition(index: number): Vector3;
  70329. /**
  70330. * Returns the agent position result in world space
  70331. * @param index agent index returned by addAgent
  70332. * @param result output world space position
  70333. */
  70334. getAgentPositionToRef(index: number, result: Vector3): void;
  70335. /**
  70336. * Returns the agent velocity in world space
  70337. * @param index agent index returned by addAgent
  70338. * @returns world space velocity
  70339. */
  70340. getAgentVelocity(index: number): Vector3;
  70341. /**
  70342. * Returns the agent velocity result in world space
  70343. * @param index agent index returned by addAgent
  70344. * @param result output world space velocity
  70345. */
  70346. getAgentVelocityToRef(index: number, result: Vector3): void;
  70347. /**
  70348. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70349. * @param index agent index returned by addAgent
  70350. * @param destination targeted world position
  70351. */
  70352. agentGoto(index: number, destination: Vector3): void;
  70353. /**
  70354. * Teleport the agent to a new position
  70355. * @param index agent index returned by addAgent
  70356. * @param destination targeted world position
  70357. */
  70358. agentTeleport(index: number, destination: Vector3): void;
  70359. /**
  70360. * Update agent parameters
  70361. * @param index agent index returned by addAgent
  70362. * @param parameters agent parameters
  70363. */
  70364. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70365. /**
  70366. * remove a particular agent previously created
  70367. * @param index agent index returned by addAgent
  70368. */
  70369. removeAgent(index: number): void;
  70370. /**
  70371. * get the list of all agents attached to this crowd
  70372. * @returns list of agent indices
  70373. */
  70374. getAgents(): number[];
  70375. /**
  70376. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70377. * @param deltaTime in seconds
  70378. */
  70379. update(deltaTime: number): void;
  70380. /**
  70381. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70382. * The queries will try to find a solution within those bounds
  70383. * default is (1,1,1)
  70384. * @param extent x,y,z value that define the extent around the queries point of reference
  70385. */
  70386. setDefaultQueryExtent(extent: Vector3): void;
  70387. /**
  70388. * Get the Bounding box extent specified by setDefaultQueryExtent
  70389. * @returns the box extent values
  70390. */
  70391. getDefaultQueryExtent(): Vector3;
  70392. /**
  70393. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70394. * @param result output the box extent values
  70395. */
  70396. getDefaultQueryExtentToRef(result: Vector3): void;
  70397. /**
  70398. * Release all resources
  70399. */
  70400. dispose(): void;
  70401. }
  70402. }
  70403. declare module "babylonjs/Navigation/Plugins/index" {
  70404. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70405. }
  70406. declare module "babylonjs/Navigation/index" {
  70407. export * from "babylonjs/Navigation/INavigationEngine";
  70408. export * from "babylonjs/Navigation/Plugins/index";
  70409. }
  70410. declare module "babylonjs/Offline/database" {
  70411. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70412. /**
  70413. * Class used to enable access to IndexedDB
  70414. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70415. */
  70416. export class Database implements IOfflineProvider {
  70417. private _callbackManifestChecked;
  70418. private _currentSceneUrl;
  70419. private _db;
  70420. private _enableSceneOffline;
  70421. private _enableTexturesOffline;
  70422. private _manifestVersionFound;
  70423. private _mustUpdateRessources;
  70424. private _hasReachedQuota;
  70425. private _isSupported;
  70426. private _idbFactory;
  70427. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70428. private static IsUASupportingBlobStorage;
  70429. /**
  70430. * Gets a boolean indicating if Database storate is enabled (off by default)
  70431. */
  70432. static IDBStorageEnabled: boolean;
  70433. /**
  70434. * Gets a boolean indicating if scene must be saved in the database
  70435. */
  70436. get enableSceneOffline(): boolean;
  70437. /**
  70438. * Gets a boolean indicating if textures must be saved in the database
  70439. */
  70440. get enableTexturesOffline(): boolean;
  70441. /**
  70442. * Creates a new Database
  70443. * @param urlToScene defines the url to load the scene
  70444. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70445. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70446. */
  70447. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70448. private static _ParseURL;
  70449. private static _ReturnFullUrlLocation;
  70450. private _checkManifestFile;
  70451. /**
  70452. * Open the database and make it available
  70453. * @param successCallback defines the callback to call on success
  70454. * @param errorCallback defines the callback to call on error
  70455. */
  70456. open(successCallback: () => void, errorCallback: () => void): void;
  70457. /**
  70458. * Loads an image from the database
  70459. * @param url defines the url to load from
  70460. * @param image defines the target DOM image
  70461. */
  70462. loadImage(url: string, image: HTMLImageElement): void;
  70463. private _loadImageFromDBAsync;
  70464. private _saveImageIntoDBAsync;
  70465. private _checkVersionFromDB;
  70466. private _loadVersionFromDBAsync;
  70467. private _saveVersionIntoDBAsync;
  70468. /**
  70469. * Loads a file from database
  70470. * @param url defines the URL to load from
  70471. * @param sceneLoaded defines a callback to call on success
  70472. * @param progressCallBack defines a callback to call when progress changed
  70473. * @param errorCallback defines a callback to call on error
  70474. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70475. */
  70476. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70477. private _loadFileAsync;
  70478. private _saveFileAsync;
  70479. /**
  70480. * Validates if xhr data is correct
  70481. * @param xhr defines the request to validate
  70482. * @param dataType defines the expected data type
  70483. * @returns true if data is correct
  70484. */
  70485. private static _ValidateXHRData;
  70486. }
  70487. }
  70488. declare module "babylonjs/Offline/index" {
  70489. export * from "babylonjs/Offline/database";
  70490. export * from "babylonjs/Offline/IOfflineProvider";
  70491. }
  70492. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70493. /** @hidden */
  70494. export var gpuUpdateParticlesPixelShader: {
  70495. name: string;
  70496. shader: string;
  70497. };
  70498. }
  70499. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70500. /** @hidden */
  70501. export var gpuUpdateParticlesVertexShader: {
  70502. name: string;
  70503. shader: string;
  70504. };
  70505. }
  70506. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70507. /** @hidden */
  70508. export var clipPlaneFragmentDeclaration2: {
  70509. name: string;
  70510. shader: string;
  70511. };
  70512. }
  70513. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70514. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70515. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70516. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70517. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70518. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70519. /** @hidden */
  70520. export var gpuRenderParticlesPixelShader: {
  70521. name: string;
  70522. shader: string;
  70523. };
  70524. }
  70525. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70526. /** @hidden */
  70527. export var clipPlaneVertexDeclaration2: {
  70528. name: string;
  70529. shader: string;
  70530. };
  70531. }
  70532. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70533. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70535. /** @hidden */
  70536. export var gpuRenderParticlesVertexShader: {
  70537. name: string;
  70538. shader: string;
  70539. };
  70540. }
  70541. declare module "babylonjs/Particles/gpuParticleSystem" {
  70542. import { Nullable } from "babylonjs/types";
  70543. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70544. import { Observable } from "babylonjs/Misc/observable";
  70545. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70546. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70547. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70548. import { Scene, IDisposable } from "babylonjs/scene";
  70549. import { Effect } from "babylonjs/Materials/effect";
  70550. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70551. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70552. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70553. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70554. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70555. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70556. /**
  70557. * This represents a GPU particle system in Babylon
  70558. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70559. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70560. */
  70561. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70562. /**
  70563. * The layer mask we are rendering the particles through.
  70564. */
  70565. layerMask: number;
  70566. private _capacity;
  70567. private _activeCount;
  70568. private _currentActiveCount;
  70569. private _accumulatedCount;
  70570. private _renderEffect;
  70571. private _updateEffect;
  70572. private _buffer0;
  70573. private _buffer1;
  70574. private _spriteBuffer;
  70575. private _updateVAO;
  70576. private _renderVAO;
  70577. private _targetIndex;
  70578. private _sourceBuffer;
  70579. private _targetBuffer;
  70580. private _engine;
  70581. private _currentRenderId;
  70582. private _started;
  70583. private _stopped;
  70584. private _timeDelta;
  70585. private _randomTexture;
  70586. private _randomTexture2;
  70587. private _attributesStrideSize;
  70588. private _updateEffectOptions;
  70589. private _randomTextureSize;
  70590. private _actualFrame;
  70591. private _customEffect;
  70592. private readonly _rawTextureWidth;
  70593. /**
  70594. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70595. */
  70596. static get IsSupported(): boolean;
  70597. /**
  70598. * An event triggered when the system is disposed.
  70599. */
  70600. onDisposeObservable: Observable<IParticleSystem>;
  70601. /**
  70602. * Gets the maximum number of particles active at the same time.
  70603. * @returns The max number of active particles.
  70604. */
  70605. getCapacity(): number;
  70606. /**
  70607. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70608. * to override the particles.
  70609. */
  70610. forceDepthWrite: boolean;
  70611. /**
  70612. * Gets or set the number of active particles
  70613. */
  70614. get activeParticleCount(): number;
  70615. set activeParticleCount(value: number);
  70616. private _preWarmDone;
  70617. /**
  70618. * Specifies if the particles are updated in emitter local space or world space.
  70619. */
  70620. isLocal: boolean;
  70621. /**
  70622. * Is this system ready to be used/rendered
  70623. * @return true if the system is ready
  70624. */
  70625. isReady(): boolean;
  70626. /**
  70627. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70628. * @returns True if it has been started, otherwise false.
  70629. */
  70630. isStarted(): boolean;
  70631. /**
  70632. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70633. * @returns True if it has been stopped, otherwise false.
  70634. */
  70635. isStopped(): boolean;
  70636. /**
  70637. * Gets a boolean indicating that the system is stopping
  70638. * @returns true if the system is currently stopping
  70639. */
  70640. isStopping(): boolean;
  70641. /**
  70642. * Gets the number of particles active at the same time.
  70643. * @returns The number of active particles.
  70644. */
  70645. getActiveCount(): number;
  70646. /**
  70647. * Starts the particle system and begins to emit
  70648. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70649. */
  70650. start(delay?: number): void;
  70651. /**
  70652. * Stops the particle system.
  70653. */
  70654. stop(): void;
  70655. /**
  70656. * Remove all active particles
  70657. */
  70658. reset(): void;
  70659. /**
  70660. * Returns the string "GPUParticleSystem"
  70661. * @returns a string containing the class name
  70662. */
  70663. getClassName(): string;
  70664. /**
  70665. * Gets the custom effect used to render the particles
  70666. * @param blendMode Blend mode for which the effect should be retrieved
  70667. * @returns The effect
  70668. */
  70669. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70670. /**
  70671. * Sets the custom effect used to render the particles
  70672. * @param effect The effect to set
  70673. * @param blendMode Blend mode for which the effect should be set
  70674. */
  70675. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70676. /** @hidden */
  70677. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70678. /**
  70679. * Observable that will be called just before the particles are drawn
  70680. */
  70681. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70682. /**
  70683. * Gets the name of the particle vertex shader
  70684. */
  70685. get vertexShaderName(): string;
  70686. private _colorGradientsTexture;
  70687. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70688. /**
  70689. * Adds a new color gradient
  70690. * @param gradient defines the gradient to use (between 0 and 1)
  70691. * @param color1 defines the color to affect to the specified gradient
  70692. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70693. * @returns the current particle system
  70694. */
  70695. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70696. private _refreshColorGradient;
  70697. /** Force the system to rebuild all gradients that need to be resync */
  70698. forceRefreshGradients(): void;
  70699. /**
  70700. * Remove a specific color gradient
  70701. * @param gradient defines the gradient to remove
  70702. * @returns the current particle system
  70703. */
  70704. removeColorGradient(gradient: number): GPUParticleSystem;
  70705. private _angularSpeedGradientsTexture;
  70706. private _sizeGradientsTexture;
  70707. private _velocityGradientsTexture;
  70708. private _limitVelocityGradientsTexture;
  70709. private _dragGradientsTexture;
  70710. private _addFactorGradient;
  70711. /**
  70712. * Adds a new size gradient
  70713. * @param gradient defines the gradient to use (between 0 and 1)
  70714. * @param factor defines the size factor to affect to the specified gradient
  70715. * @returns the current particle system
  70716. */
  70717. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70718. /**
  70719. * Remove a specific size gradient
  70720. * @param gradient defines the gradient to remove
  70721. * @returns the current particle system
  70722. */
  70723. removeSizeGradient(gradient: number): GPUParticleSystem;
  70724. private _refreshFactorGradient;
  70725. /**
  70726. * Adds a new angular speed gradient
  70727. * @param gradient defines the gradient to use (between 0 and 1)
  70728. * @param factor defines the angular speed to affect to the specified gradient
  70729. * @returns the current particle system
  70730. */
  70731. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70732. /**
  70733. * Remove a specific angular speed gradient
  70734. * @param gradient defines the gradient to remove
  70735. * @returns the current particle system
  70736. */
  70737. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70738. /**
  70739. * Adds a new velocity gradient
  70740. * @param gradient defines the gradient to use (between 0 and 1)
  70741. * @param factor defines the velocity to affect to the specified gradient
  70742. * @returns the current particle system
  70743. */
  70744. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70745. /**
  70746. * Remove a specific velocity gradient
  70747. * @param gradient defines the gradient to remove
  70748. * @returns the current particle system
  70749. */
  70750. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70751. /**
  70752. * Adds a new limit velocity gradient
  70753. * @param gradient defines the gradient to use (between 0 and 1)
  70754. * @param factor defines the limit velocity value to affect to the specified gradient
  70755. * @returns the current particle system
  70756. */
  70757. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70758. /**
  70759. * Remove a specific limit velocity gradient
  70760. * @param gradient defines the gradient to remove
  70761. * @returns the current particle system
  70762. */
  70763. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70764. /**
  70765. * Adds a new drag gradient
  70766. * @param gradient defines the gradient to use (between 0 and 1)
  70767. * @param factor defines the drag value to affect to the specified gradient
  70768. * @returns the current particle system
  70769. */
  70770. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70771. /**
  70772. * Remove a specific drag gradient
  70773. * @param gradient defines the gradient to remove
  70774. * @returns the current particle system
  70775. */
  70776. removeDragGradient(gradient: number): GPUParticleSystem;
  70777. /**
  70778. * Not supported by GPUParticleSystem
  70779. * @param gradient defines the gradient to use (between 0 and 1)
  70780. * @param factor defines the emit rate value 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. addEmitRateGradient(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. removeEmitRateGradient(gradient: number): IParticleSystem;
  70791. /**
  70792. * Not supported by GPUParticleSystem
  70793. * @param gradient defines the gradient to use (between 0 and 1)
  70794. * @param factor defines the start size value to affect to the specified gradient
  70795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70796. * @returns the current particle system
  70797. */
  70798. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70799. /**
  70800. * Not supported by GPUParticleSystem
  70801. * @param gradient defines the gradient to remove
  70802. * @returns the current particle system
  70803. */
  70804. removeStartSizeGradient(gradient: number): IParticleSystem;
  70805. /**
  70806. * Not supported by GPUParticleSystem
  70807. * @param gradient defines the gradient to use (between 0 and 1)
  70808. * @param min defines the color remap minimal range
  70809. * @param max defines the color remap maximal range
  70810. * @returns the current particle system
  70811. */
  70812. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70813. /**
  70814. * Not supported by GPUParticleSystem
  70815. * @param gradient defines the gradient to remove
  70816. * @returns the current particle system
  70817. */
  70818. removeColorRemapGradient(): IParticleSystem;
  70819. /**
  70820. * Not supported by GPUParticleSystem
  70821. * @param gradient defines the gradient to use (between 0 and 1)
  70822. * @param min defines the alpha remap minimal range
  70823. * @param max defines the alpha remap maximal range
  70824. * @returns the current particle system
  70825. */
  70826. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70827. /**
  70828. * Not supported by GPUParticleSystem
  70829. * @param gradient defines the gradient to remove
  70830. * @returns the current particle system
  70831. */
  70832. removeAlphaRemapGradient(): IParticleSystem;
  70833. /**
  70834. * Not supported by GPUParticleSystem
  70835. * @param gradient defines the gradient to use (between 0 and 1)
  70836. * @param color defines the color to affect to the specified gradient
  70837. * @returns the current particle system
  70838. */
  70839. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70840. /**
  70841. * Not supported by GPUParticleSystem
  70842. * @param gradient defines the gradient to remove
  70843. * @returns the current particle system
  70844. */
  70845. removeRampGradient(): IParticleSystem;
  70846. /**
  70847. * Not supported by GPUParticleSystem
  70848. * @returns the list of ramp gradients
  70849. */
  70850. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70851. /**
  70852. * Not supported by GPUParticleSystem
  70853. * Gets or sets a boolean indicating that ramp gradients must be used
  70854. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70855. */
  70856. get useRampGradients(): boolean;
  70857. set useRampGradients(value: boolean);
  70858. /**
  70859. * Not supported by GPUParticleSystem
  70860. * @param gradient defines the gradient to use (between 0 and 1)
  70861. * @param factor defines the life time factor to affect to the specified gradient
  70862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70863. * @returns the current particle system
  70864. */
  70865. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70866. /**
  70867. * Not supported by GPUParticleSystem
  70868. * @param gradient defines the gradient to remove
  70869. * @returns the current particle system
  70870. */
  70871. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70872. /**
  70873. * Instantiates a GPU particle system.
  70874. * 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.
  70875. * @param name The name of the particle system
  70876. * @param options The options used to create the system
  70877. * @param scene The scene the particle system belongs to
  70878. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70879. * @param customEffect a custom effect used to change the way particles are rendered by default
  70880. */
  70881. constructor(name: string, options: Partial<{
  70882. capacity: number;
  70883. randomTextureSize: number;
  70884. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70885. protected _reset(): void;
  70886. private _createUpdateVAO;
  70887. private _createRenderVAO;
  70888. private _initialize;
  70889. /** @hidden */
  70890. _recreateUpdateEffect(): void;
  70891. private _getEffect;
  70892. /**
  70893. * Fill the defines array according to the current settings of the particle system
  70894. * @param defines Array to be updated
  70895. * @param blendMode blend mode to take into account when updating the array
  70896. */
  70897. fillDefines(defines: Array<string>, blendMode?: number): void;
  70898. /**
  70899. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70900. * @param uniforms Uniforms array to fill
  70901. * @param attributes Attributes array to fill
  70902. * @param samplers Samplers array to fill
  70903. */
  70904. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70905. /** @hidden */
  70906. _recreateRenderEffect(): Effect;
  70907. /**
  70908. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70909. * @param preWarm defines if we are in the pre-warmimg phase
  70910. */
  70911. animate(preWarm?: boolean): void;
  70912. private _createFactorGradientTexture;
  70913. private _createSizeGradientTexture;
  70914. private _createAngularSpeedGradientTexture;
  70915. private _createVelocityGradientTexture;
  70916. private _createLimitVelocityGradientTexture;
  70917. private _createDragGradientTexture;
  70918. private _createColorGradientTexture;
  70919. /**
  70920. * Renders the particle system in its current state
  70921. * @param preWarm defines if the system should only update the particles but not render them
  70922. * @returns the current number of particles
  70923. */
  70924. render(preWarm?: boolean): number;
  70925. /**
  70926. * Rebuilds the particle system
  70927. */
  70928. rebuild(): void;
  70929. private _releaseBuffers;
  70930. private _releaseVAOs;
  70931. /**
  70932. * Disposes the particle system and free the associated resources
  70933. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70934. */
  70935. dispose(disposeTexture?: boolean): void;
  70936. /**
  70937. * Clones the particle system.
  70938. * @param name The name of the cloned object
  70939. * @param newEmitter The new emitter to use
  70940. * @returns the cloned particle system
  70941. */
  70942. clone(name: string, newEmitter: any): GPUParticleSystem;
  70943. /**
  70944. * Serializes the particle system to a JSON object
  70945. * @param serializeTexture defines if the texture must be serialized as well
  70946. * @returns the JSON object
  70947. */
  70948. serialize(serializeTexture?: boolean): any;
  70949. /**
  70950. * Parses a JSON object to create a GPU particle system.
  70951. * @param parsedParticleSystem The JSON object to parse
  70952. * @param scene The scene to create the particle system in
  70953. * @param rootUrl The root url to use to load external dependencies like texture
  70954. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70955. * @returns the parsed GPU particle system
  70956. */
  70957. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70958. }
  70959. }
  70960. declare module "babylonjs/Particles/particleSystemSet" {
  70961. import { Nullable } from "babylonjs/types";
  70962. import { Color3 } from "babylonjs/Maths/math.color";
  70963. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70965. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70966. import { Scene, IDisposable } from "babylonjs/scene";
  70967. /**
  70968. * Represents a set of particle systems working together to create a specific effect
  70969. */
  70970. export class ParticleSystemSet implements IDisposable {
  70971. /**
  70972. * Gets or sets base Assets URL
  70973. */
  70974. static BaseAssetsUrl: string;
  70975. private _emitterCreationOptions;
  70976. private _emitterNode;
  70977. /**
  70978. * Gets the particle system list
  70979. */
  70980. systems: IParticleSystem[];
  70981. /**
  70982. * Gets the emitter node used with this set
  70983. */
  70984. get emitterNode(): Nullable<TransformNode>;
  70985. /**
  70986. * Creates a new emitter mesh as a sphere
  70987. * @param options defines the options used to create the sphere
  70988. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70989. * @param scene defines the hosting scene
  70990. */
  70991. setEmitterAsSphere(options: {
  70992. diameter: number;
  70993. segments: number;
  70994. color: Color3;
  70995. }, renderingGroupId: number, scene: Scene): void;
  70996. /**
  70997. * Starts all particle systems of the set
  70998. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70999. */
  71000. start(emitter?: AbstractMesh): void;
  71001. /**
  71002. * Release all associated resources
  71003. */
  71004. dispose(): void;
  71005. /**
  71006. * Serialize the set into a JSON compatible object
  71007. * @param serializeTexture defines if the texture must be serialized as well
  71008. * @returns a JSON compatible representation of the set
  71009. */
  71010. serialize(serializeTexture?: boolean): any;
  71011. /**
  71012. * Parse a new ParticleSystemSet from a serialized source
  71013. * @param data defines a JSON compatible representation of the set
  71014. * @param scene defines the hosting scene
  71015. * @param gpu defines if we want GPU particles or CPU particles
  71016. * @returns a new ParticleSystemSet
  71017. */
  71018. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71019. }
  71020. }
  71021. declare module "babylonjs/Particles/particleHelper" {
  71022. import { Nullable } from "babylonjs/types";
  71023. import { Scene } from "babylonjs/scene";
  71024. import { Vector3 } from "babylonjs/Maths/math.vector";
  71025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71026. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71027. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71028. /**
  71029. * This class is made for on one-liner static method to help creating particle system set.
  71030. */
  71031. export class ParticleHelper {
  71032. /**
  71033. * Gets or sets base Assets URL
  71034. */
  71035. static BaseAssetsUrl: string;
  71036. /** Define the Url to load snippets */
  71037. static SnippetUrl: string;
  71038. /**
  71039. * Create a default particle system that you can tweak
  71040. * @param emitter defines the emitter to use
  71041. * @param capacity defines the system capacity (default is 500 particles)
  71042. * @param scene defines the hosting scene
  71043. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71044. * @returns the new Particle system
  71045. */
  71046. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71047. /**
  71048. * This is the main static method (one-liner) of this helper to create different particle systems
  71049. * @param type This string represents the type to the particle system to create
  71050. * @param scene The scene where the particle system should live
  71051. * @param gpu If the system will use gpu
  71052. * @returns the ParticleSystemSet created
  71053. */
  71054. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71055. /**
  71056. * Static function used to export a particle system to a ParticleSystemSet variable.
  71057. * Please note that the emitter shape is not exported
  71058. * @param systems defines the particle systems to export
  71059. * @returns the created particle system set
  71060. */
  71061. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71062. /**
  71063. * Creates a particle system from a snippet saved in a remote file
  71064. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71065. * @param url defines the url to load from
  71066. * @param scene defines the hosting scene
  71067. * @param gpu If the system will use gpu
  71068. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71069. * @returns a promise that will resolve to the new particle system
  71070. */
  71071. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71072. /**
  71073. * Creates a particle system from a snippet saved by the particle system editor
  71074. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71075. * @param scene defines the hosting scene
  71076. * @param gpu If the system will use gpu
  71077. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71078. * @returns a promise that will resolve to the new particle system
  71079. */
  71080. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71081. }
  71082. }
  71083. declare module "babylonjs/Particles/particleSystemComponent" {
  71084. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71085. import { Effect } from "babylonjs/Materials/effect";
  71086. import "babylonjs/Shaders/particles.vertex";
  71087. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71088. module "babylonjs/Engines/engine" {
  71089. interface Engine {
  71090. /**
  71091. * Create an effect to use with particle systems.
  71092. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71093. * the particle system for which you want to create a custom effect in the last parameter
  71094. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71095. * @param uniformsNames defines a list of attribute names
  71096. * @param samplers defines an array of string used to represent textures
  71097. * @param defines defines the string containing the defines to use to compile the shaders
  71098. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71099. * @param onCompiled defines a function to call when the effect creation is successful
  71100. * @param onError defines a function to call when the effect creation has failed
  71101. * @param particleSystem the particle system you want to create the effect for
  71102. * @returns the new Effect
  71103. */
  71104. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71105. }
  71106. }
  71107. module "babylonjs/Meshes/mesh" {
  71108. interface Mesh {
  71109. /**
  71110. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71111. * @returns an array of IParticleSystem
  71112. */
  71113. getEmittedParticleSystems(): IParticleSystem[];
  71114. /**
  71115. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71116. * @returns an array of IParticleSystem
  71117. */
  71118. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71119. }
  71120. }
  71121. }
  71122. declare module "babylonjs/Particles/pointsCloudSystem" {
  71123. import { Color4 } from "babylonjs/Maths/math";
  71124. import { Mesh } from "babylonjs/Meshes/mesh";
  71125. import { Scene, IDisposable } from "babylonjs/scene";
  71126. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71127. /** Defines the 4 color options */
  71128. export enum PointColor {
  71129. /** color value */
  71130. Color = 2,
  71131. /** uv value */
  71132. UV = 1,
  71133. /** random value */
  71134. Random = 0,
  71135. /** stated value */
  71136. Stated = 3
  71137. }
  71138. /**
  71139. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71140. * 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.
  71141. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71142. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71143. *
  71144. * Full documentation here : TO BE ENTERED
  71145. */
  71146. export class PointsCloudSystem implements IDisposable {
  71147. /**
  71148. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71149. * Example : var p = SPS.particles[i];
  71150. */
  71151. particles: CloudPoint[];
  71152. /**
  71153. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71154. */
  71155. nbParticles: number;
  71156. /**
  71157. * This a counter for your own usage. It's not set by any SPS functions.
  71158. */
  71159. counter: number;
  71160. /**
  71161. * The PCS name. This name is also given to the underlying mesh.
  71162. */
  71163. name: string;
  71164. /**
  71165. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71166. */
  71167. mesh: Mesh;
  71168. /**
  71169. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71170. * Please read :
  71171. */
  71172. vars: any;
  71173. /**
  71174. * @hidden
  71175. */
  71176. _size: number;
  71177. private _scene;
  71178. private _promises;
  71179. private _positions;
  71180. private _indices;
  71181. private _normals;
  71182. private _colors;
  71183. private _uvs;
  71184. private _indices32;
  71185. private _positions32;
  71186. private _colors32;
  71187. private _uvs32;
  71188. private _updatable;
  71189. private _isVisibilityBoxLocked;
  71190. private _alwaysVisible;
  71191. private _groups;
  71192. private _groupCounter;
  71193. private _computeParticleColor;
  71194. private _computeParticleTexture;
  71195. private _computeParticleRotation;
  71196. private _computeBoundingBox;
  71197. private _isReady;
  71198. /**
  71199. * Creates a PCS (Points Cloud System) object
  71200. * @param name (String) is the PCS name, this will be the underlying mesh name
  71201. * @param pointSize (number) is the size for each point
  71202. * @param scene (Scene) is the scene in which the PCS is added
  71203. * @param options defines the options of the PCS e.g.
  71204. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71205. */
  71206. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71207. updatable?: boolean;
  71208. });
  71209. /**
  71210. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71211. * If no points were added to the PCS, the returned mesh is just a single point.
  71212. * @returns a promise for the created mesh
  71213. */
  71214. buildMeshAsync(): Promise<Mesh>;
  71215. /**
  71216. * @hidden
  71217. */
  71218. private _buildMesh;
  71219. private _addParticle;
  71220. private _randomUnitVector;
  71221. private _getColorIndicesForCoord;
  71222. private _setPointsColorOrUV;
  71223. private _colorFromTexture;
  71224. private _calculateDensity;
  71225. /**
  71226. * Adds points to the PCS in random positions within a unit sphere
  71227. * @param nb (positive integer) the number of particles to be created from this model
  71228. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71229. * @returns the number of groups in the system
  71230. */
  71231. addPoints(nb: number, pointFunction?: any): number;
  71232. /**
  71233. * Adds points to the PCS from the surface of the model shape
  71234. * @param mesh is any Mesh object that will be used as a surface model for the points
  71235. * @param nb (positive integer) the number of particles to be created from this model
  71236. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71237. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71238. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71239. * @returns the number of groups in the system
  71240. */
  71241. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71242. /**
  71243. * Adds points to the PCS inside the model shape
  71244. * @param mesh is any Mesh object that will be used as a surface model for the points
  71245. * @param nb (positive integer) the number of particles to be created from this model
  71246. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71247. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71248. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71249. * @returns the number of groups in the system
  71250. */
  71251. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71252. /**
  71253. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71254. * This method calls `updateParticle()` for each particle of the SPS.
  71255. * For an animated SPS, it is usually called within the render loop.
  71256. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71257. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71258. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71259. * @returns the PCS.
  71260. */
  71261. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71262. /**
  71263. * Disposes the PCS.
  71264. */
  71265. dispose(): void;
  71266. /**
  71267. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71268. * doc :
  71269. * @returns the PCS.
  71270. */
  71271. refreshVisibleSize(): PointsCloudSystem;
  71272. /**
  71273. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71274. * @param size the size (float) of the visibility box
  71275. * note : this doesn't lock the PCS mesh bounding box.
  71276. * doc :
  71277. */
  71278. setVisibilityBox(size: number): void;
  71279. /**
  71280. * Gets whether the PCS is always visible or not
  71281. * doc :
  71282. */
  71283. get isAlwaysVisible(): boolean;
  71284. /**
  71285. * Sets the PCS as always visible or not
  71286. * doc :
  71287. */
  71288. set isAlwaysVisible(val: boolean);
  71289. /**
  71290. * Tells to `setParticles()` to compute the particle rotations or not
  71291. * Default value : false. The PCS is faster when it's set to false
  71292. * Note : particle rotations are only applied to parent particles
  71293. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71294. */
  71295. set computeParticleRotation(val: boolean);
  71296. /**
  71297. * Tells to `setParticles()` to compute the particle colors or not.
  71298. * Default value : true. The PCS is faster when it's set to false.
  71299. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71300. */
  71301. set computeParticleColor(val: boolean);
  71302. set computeParticleTexture(val: boolean);
  71303. /**
  71304. * Gets if `setParticles()` computes the particle colors or not.
  71305. * Default value : false. The PCS is faster when it's set to false.
  71306. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71307. */
  71308. get computeParticleColor(): boolean;
  71309. /**
  71310. * Gets if `setParticles()` computes the particle textures or not.
  71311. * Default value : false. The PCS is faster when it's set to false.
  71312. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71313. */
  71314. get computeParticleTexture(): boolean;
  71315. /**
  71316. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71317. */
  71318. set computeBoundingBox(val: boolean);
  71319. /**
  71320. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71321. */
  71322. get computeBoundingBox(): boolean;
  71323. /**
  71324. * This function does nothing. It may be overwritten to set all the particle first values.
  71325. * The PCS doesn't call this function, you may have to call it by your own.
  71326. * doc :
  71327. */
  71328. initParticles(): void;
  71329. /**
  71330. * This function does nothing. It may be overwritten to recycle a particle
  71331. * The PCS doesn't call this function, you can to call it
  71332. * doc :
  71333. * @param particle The particle to recycle
  71334. * @returns the recycled particle
  71335. */
  71336. recycleParticle(particle: CloudPoint): CloudPoint;
  71337. /**
  71338. * Updates a particle : this function should be overwritten by the user.
  71339. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71340. * doc :
  71341. * @example : just set a particle position or velocity and recycle conditions
  71342. * @param particle The particle to update
  71343. * @returns the updated particle
  71344. */
  71345. updateParticle(particle: CloudPoint): CloudPoint;
  71346. /**
  71347. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71348. * This does nothing and may be overwritten by the user.
  71349. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71350. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71351. * @param update the boolean update value actually passed to setParticles()
  71352. */
  71353. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71354. /**
  71355. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71356. * This will be passed three parameters.
  71357. * This does nothing and may be overwritten by the user.
  71358. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71359. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71360. * @param update the boolean update value actually passed to setParticles()
  71361. */
  71362. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71363. }
  71364. }
  71365. declare module "babylonjs/Particles/cloudPoint" {
  71366. import { Nullable } from "babylonjs/types";
  71367. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71368. import { Mesh } from "babylonjs/Meshes/mesh";
  71369. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71370. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71371. /**
  71372. * Represents one particle of a points cloud system.
  71373. */
  71374. export class CloudPoint {
  71375. /**
  71376. * particle global index
  71377. */
  71378. idx: number;
  71379. /**
  71380. * The color of the particle
  71381. */
  71382. color: Nullable<Color4>;
  71383. /**
  71384. * The world space position of the particle.
  71385. */
  71386. position: Vector3;
  71387. /**
  71388. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71389. */
  71390. rotation: Vector3;
  71391. /**
  71392. * The world space rotation quaternion of the particle.
  71393. */
  71394. rotationQuaternion: Nullable<Quaternion>;
  71395. /**
  71396. * The uv of the particle.
  71397. */
  71398. uv: Nullable<Vector2>;
  71399. /**
  71400. * The current speed of the particle.
  71401. */
  71402. velocity: Vector3;
  71403. /**
  71404. * The pivot point in the particle local space.
  71405. */
  71406. pivot: Vector3;
  71407. /**
  71408. * Must the particle be translated from its pivot point in its local space ?
  71409. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71410. * Default : false
  71411. */
  71412. translateFromPivot: boolean;
  71413. /**
  71414. * Index of this particle in the global "positions" array (Internal use)
  71415. * @hidden
  71416. */
  71417. _pos: number;
  71418. /**
  71419. * @hidden Index of this particle in the global "indices" array (Internal use)
  71420. */
  71421. _ind: number;
  71422. /**
  71423. * Group this particle belongs to
  71424. */
  71425. _group: PointsGroup;
  71426. /**
  71427. * Group id of this particle
  71428. */
  71429. groupId: number;
  71430. /**
  71431. * Index of the particle in its group id (Internal use)
  71432. */
  71433. idxInGroup: number;
  71434. /**
  71435. * @hidden Particle BoundingInfo object (Internal use)
  71436. */
  71437. _boundingInfo: BoundingInfo;
  71438. /**
  71439. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71440. */
  71441. _pcs: PointsCloudSystem;
  71442. /**
  71443. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71444. */
  71445. _stillInvisible: boolean;
  71446. /**
  71447. * @hidden Last computed particle rotation matrix
  71448. */
  71449. _rotationMatrix: number[];
  71450. /**
  71451. * Parent particle Id, if any.
  71452. * Default null.
  71453. */
  71454. parentId: Nullable<number>;
  71455. /**
  71456. * @hidden Internal global position in the PCS.
  71457. */
  71458. _globalPosition: Vector3;
  71459. /**
  71460. * Creates a Point Cloud object.
  71461. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71462. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71463. * @param group (PointsGroup) is the group the particle belongs to
  71464. * @param groupId (integer) is the group identifier in the PCS.
  71465. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71466. * @param pcs defines the PCS it is associated to
  71467. */
  71468. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71469. /**
  71470. * get point size
  71471. */
  71472. get size(): Vector3;
  71473. /**
  71474. * Set point size
  71475. */
  71476. set size(scale: Vector3);
  71477. /**
  71478. * Legacy support, changed quaternion to rotationQuaternion
  71479. */
  71480. get quaternion(): Nullable<Quaternion>;
  71481. /**
  71482. * Legacy support, changed quaternion to rotationQuaternion
  71483. */
  71484. set quaternion(q: Nullable<Quaternion>);
  71485. /**
  71486. * Returns a boolean. True if the particle intersects a mesh, else false
  71487. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71488. * @param target is the object (point or mesh) what the intersection is computed against
  71489. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71490. * @returns true if it intersects
  71491. */
  71492. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71493. /**
  71494. * get the rotation matrix of the particle
  71495. * @hidden
  71496. */
  71497. getRotationMatrix(m: Matrix): void;
  71498. }
  71499. /**
  71500. * Represents a group of points in a points cloud system
  71501. * * PCS internal tool, don't use it manually.
  71502. */
  71503. export class PointsGroup {
  71504. /**
  71505. * The group id
  71506. * @hidden
  71507. */
  71508. groupID: number;
  71509. /**
  71510. * image data for group (internal use)
  71511. * @hidden
  71512. */
  71513. _groupImageData: Nullable<ArrayBufferView>;
  71514. /**
  71515. * Image Width (internal use)
  71516. * @hidden
  71517. */
  71518. _groupImgWidth: number;
  71519. /**
  71520. * Image Height (internal use)
  71521. * @hidden
  71522. */
  71523. _groupImgHeight: number;
  71524. /**
  71525. * Custom position function (internal use)
  71526. * @hidden
  71527. */
  71528. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71529. /**
  71530. * density per facet for surface points
  71531. * @hidden
  71532. */
  71533. _groupDensity: number[];
  71534. /**
  71535. * Only when points are colored by texture carries pointer to texture list array
  71536. * @hidden
  71537. */
  71538. _textureNb: number;
  71539. /**
  71540. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71541. * PCS internal tool, don't use it manually.
  71542. * @hidden
  71543. */
  71544. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71545. }
  71546. }
  71547. declare module "babylonjs/Particles/index" {
  71548. export * from "babylonjs/Particles/baseParticleSystem";
  71549. export * from "babylonjs/Particles/EmitterTypes/index";
  71550. export * from "babylonjs/Particles/gpuParticleSystem";
  71551. export * from "babylonjs/Particles/IParticleSystem";
  71552. export * from "babylonjs/Particles/particle";
  71553. export * from "babylonjs/Particles/particleHelper";
  71554. export * from "babylonjs/Particles/particleSystem";
  71555. import "babylonjs/Particles/particleSystemComponent";
  71556. export * from "babylonjs/Particles/particleSystemComponent";
  71557. export * from "babylonjs/Particles/particleSystemSet";
  71558. export * from "babylonjs/Particles/solidParticle";
  71559. export * from "babylonjs/Particles/solidParticleSystem";
  71560. export * from "babylonjs/Particles/cloudPoint";
  71561. export * from "babylonjs/Particles/pointsCloudSystem";
  71562. export * from "babylonjs/Particles/subEmitter";
  71563. }
  71564. declare module "babylonjs/Physics/physicsEngineComponent" {
  71565. import { Nullable } from "babylonjs/types";
  71566. import { Observable, Observer } from "babylonjs/Misc/observable";
  71567. import { Vector3 } from "babylonjs/Maths/math.vector";
  71568. import { Mesh } from "babylonjs/Meshes/mesh";
  71569. import { ISceneComponent } from "babylonjs/sceneComponent";
  71570. import { Scene } from "babylonjs/scene";
  71571. import { Node } from "babylonjs/node";
  71572. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71573. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71574. module "babylonjs/scene" {
  71575. interface Scene {
  71576. /** @hidden (Backing field) */
  71577. _physicsEngine: Nullable<IPhysicsEngine>;
  71578. /** @hidden */
  71579. _physicsTimeAccumulator: number;
  71580. /**
  71581. * Gets the current physics engine
  71582. * @returns a IPhysicsEngine or null if none attached
  71583. */
  71584. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71585. /**
  71586. * Enables physics to the current scene
  71587. * @param gravity defines the scene's gravity for the physics engine
  71588. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71589. * @return a boolean indicating if the physics engine was initialized
  71590. */
  71591. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71592. /**
  71593. * Disables and disposes the physics engine associated with the scene
  71594. */
  71595. disablePhysicsEngine(): void;
  71596. /**
  71597. * Gets a boolean indicating if there is an active physics engine
  71598. * @returns a boolean indicating if there is an active physics engine
  71599. */
  71600. isPhysicsEnabled(): boolean;
  71601. /**
  71602. * Deletes a physics compound impostor
  71603. * @param compound defines the compound to delete
  71604. */
  71605. deleteCompoundImpostor(compound: any): void;
  71606. /**
  71607. * An event triggered when physic simulation is about to be run
  71608. */
  71609. onBeforePhysicsObservable: Observable<Scene>;
  71610. /**
  71611. * An event triggered when physic simulation has been done
  71612. */
  71613. onAfterPhysicsObservable: Observable<Scene>;
  71614. }
  71615. }
  71616. module "babylonjs/Meshes/abstractMesh" {
  71617. interface AbstractMesh {
  71618. /** @hidden */
  71619. _physicsImpostor: Nullable<PhysicsImpostor>;
  71620. /**
  71621. * Gets or sets impostor used for physic simulation
  71622. * @see https://doc.babylonjs.com/features/physics_engine
  71623. */
  71624. physicsImpostor: Nullable<PhysicsImpostor>;
  71625. /**
  71626. * Gets the current physics impostor
  71627. * @see https://doc.babylonjs.com/features/physics_engine
  71628. * @returns a physics impostor or null
  71629. */
  71630. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71631. /** Apply a physic impulse to the mesh
  71632. * @param force defines the force to apply
  71633. * @param contactPoint defines where to apply the force
  71634. * @returns the current mesh
  71635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71636. */
  71637. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71638. /**
  71639. * Creates a physic joint between two meshes
  71640. * @param otherMesh defines the other mesh to use
  71641. * @param pivot1 defines the pivot to use on this mesh
  71642. * @param pivot2 defines the pivot to use on the other mesh
  71643. * @param options defines additional options (can be plugin dependent)
  71644. * @returns the current mesh
  71645. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71646. */
  71647. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71648. /** @hidden */
  71649. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71650. }
  71651. }
  71652. /**
  71653. * Defines the physics engine scene component responsible to manage a physics engine
  71654. */
  71655. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71656. /**
  71657. * The component name helpful to identify the component in the list of scene components.
  71658. */
  71659. readonly name: string;
  71660. /**
  71661. * The scene the component belongs to.
  71662. */
  71663. scene: Scene;
  71664. /**
  71665. * Creates a new instance of the component for the given scene
  71666. * @param scene Defines the scene to register the component in
  71667. */
  71668. constructor(scene: Scene);
  71669. /**
  71670. * Registers the component in a given scene
  71671. */
  71672. register(): void;
  71673. /**
  71674. * Rebuilds the elements related to this component in case of
  71675. * context lost for instance.
  71676. */
  71677. rebuild(): void;
  71678. /**
  71679. * Disposes the component and the associated ressources
  71680. */
  71681. dispose(): void;
  71682. }
  71683. }
  71684. declare module "babylonjs/Physics/physicsHelper" {
  71685. import { Nullable } from "babylonjs/types";
  71686. import { Vector3 } from "babylonjs/Maths/math.vector";
  71687. import { Mesh } from "babylonjs/Meshes/mesh";
  71688. import { Scene } from "babylonjs/scene";
  71689. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71690. /**
  71691. * A helper for physics simulations
  71692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71693. */
  71694. export class PhysicsHelper {
  71695. private _scene;
  71696. private _physicsEngine;
  71697. /**
  71698. * Initializes the Physics helper
  71699. * @param scene Babylon.js scene
  71700. */
  71701. constructor(scene: Scene);
  71702. /**
  71703. * Applies a radial explosion impulse
  71704. * @param origin the origin of the explosion
  71705. * @param radiusOrEventOptions the radius or the options of radial explosion
  71706. * @param strength the explosion strength
  71707. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71708. * @returns A physics radial explosion event, or null
  71709. */
  71710. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71711. /**
  71712. * Applies a radial explosion force
  71713. * @param origin the origin of the explosion
  71714. * @param radiusOrEventOptions the radius or the options of radial explosion
  71715. * @param strength the explosion strength
  71716. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71717. * @returns A physics radial explosion event, or null
  71718. */
  71719. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71720. /**
  71721. * Creates a gravitational field
  71722. * @param origin the origin of the explosion
  71723. * @param radiusOrEventOptions the radius or the options of radial explosion
  71724. * @param strength the explosion strength
  71725. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71726. * @returns A physics gravitational field event, or null
  71727. */
  71728. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71729. /**
  71730. * Creates a physics updraft event
  71731. * @param origin the origin of the updraft
  71732. * @param radiusOrEventOptions the radius or the options of the updraft
  71733. * @param strength the strength of the updraft
  71734. * @param height the height of the updraft
  71735. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71736. * @returns A physics updraft event, or null
  71737. */
  71738. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71739. /**
  71740. * Creates a physics vortex event
  71741. * @param origin the of the vortex
  71742. * @param radiusOrEventOptions the radius or the options of the vortex
  71743. * @param strength the strength of the vortex
  71744. * @param height the height of the vortex
  71745. * @returns a Physics vortex event, or null
  71746. * A physics vortex event or null
  71747. */
  71748. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71749. }
  71750. /**
  71751. * Represents a physics radial explosion event
  71752. */
  71753. class PhysicsRadialExplosionEvent {
  71754. private _scene;
  71755. private _options;
  71756. private _sphere;
  71757. private _dataFetched;
  71758. /**
  71759. * Initializes a radial explosioin event
  71760. * @param _scene BabylonJS scene
  71761. * @param _options The options for the vortex event
  71762. */
  71763. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71764. /**
  71765. * Returns the data related to the radial explosion event (sphere).
  71766. * @returns The radial explosion event data
  71767. */
  71768. getData(): PhysicsRadialExplosionEventData;
  71769. /**
  71770. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71771. * @param impostor A physics imposter
  71772. * @param origin the origin of the explosion
  71773. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71774. */
  71775. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71776. /**
  71777. * Triggers affecterd impostors callbacks
  71778. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71779. */
  71780. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71781. /**
  71782. * Disposes the sphere.
  71783. * @param force Specifies if the sphere should be disposed by force
  71784. */
  71785. dispose(force?: boolean): void;
  71786. /*** Helpers ***/
  71787. private _prepareSphere;
  71788. private _intersectsWithSphere;
  71789. }
  71790. /**
  71791. * Represents a gravitational field event
  71792. */
  71793. class PhysicsGravitationalFieldEvent {
  71794. private _physicsHelper;
  71795. private _scene;
  71796. private _origin;
  71797. private _options;
  71798. private _tickCallback;
  71799. private _sphere;
  71800. private _dataFetched;
  71801. /**
  71802. * Initializes the physics gravitational field event
  71803. * @param _physicsHelper A physics helper
  71804. * @param _scene BabylonJS scene
  71805. * @param _origin The origin position of the gravitational field event
  71806. * @param _options The options for the vortex event
  71807. */
  71808. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71809. /**
  71810. * Returns the data related to the gravitational field event (sphere).
  71811. * @returns A gravitational field event
  71812. */
  71813. getData(): PhysicsGravitationalFieldEventData;
  71814. /**
  71815. * Enables the gravitational field.
  71816. */
  71817. enable(): void;
  71818. /**
  71819. * Disables the gravitational field.
  71820. */
  71821. disable(): void;
  71822. /**
  71823. * Disposes the sphere.
  71824. * @param force The force to dispose from the gravitational field event
  71825. */
  71826. dispose(force?: boolean): void;
  71827. private _tick;
  71828. }
  71829. /**
  71830. * Represents a physics updraft event
  71831. */
  71832. class PhysicsUpdraftEvent {
  71833. private _scene;
  71834. private _origin;
  71835. private _options;
  71836. private _physicsEngine;
  71837. private _originTop;
  71838. private _originDirection;
  71839. private _tickCallback;
  71840. private _cylinder;
  71841. private _cylinderPosition;
  71842. private _dataFetched;
  71843. /**
  71844. * Initializes the physics updraft event
  71845. * @param _scene BabylonJS scene
  71846. * @param _origin The origin position of the updraft
  71847. * @param _options The options for the updraft event
  71848. */
  71849. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71850. /**
  71851. * Returns the data related to the updraft event (cylinder).
  71852. * @returns A physics updraft event
  71853. */
  71854. getData(): PhysicsUpdraftEventData;
  71855. /**
  71856. * Enables the updraft.
  71857. */
  71858. enable(): void;
  71859. /**
  71860. * Disables the updraft.
  71861. */
  71862. disable(): void;
  71863. /**
  71864. * Disposes the cylinder.
  71865. * @param force Specifies if the updraft should be disposed by force
  71866. */
  71867. dispose(force?: boolean): void;
  71868. private getImpostorHitData;
  71869. private _tick;
  71870. /*** Helpers ***/
  71871. private _prepareCylinder;
  71872. private _intersectsWithCylinder;
  71873. }
  71874. /**
  71875. * Represents a physics vortex event
  71876. */
  71877. class PhysicsVortexEvent {
  71878. private _scene;
  71879. private _origin;
  71880. private _options;
  71881. private _physicsEngine;
  71882. private _originTop;
  71883. private _tickCallback;
  71884. private _cylinder;
  71885. private _cylinderPosition;
  71886. private _dataFetched;
  71887. /**
  71888. * Initializes the physics vortex event
  71889. * @param _scene The BabylonJS scene
  71890. * @param _origin The origin position of the vortex
  71891. * @param _options The options for the vortex event
  71892. */
  71893. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71894. /**
  71895. * Returns the data related to the vortex event (cylinder).
  71896. * @returns The physics vortex event data
  71897. */
  71898. getData(): PhysicsVortexEventData;
  71899. /**
  71900. * Enables the vortex.
  71901. */
  71902. enable(): void;
  71903. /**
  71904. * Disables the cortex.
  71905. */
  71906. disable(): void;
  71907. /**
  71908. * Disposes the sphere.
  71909. * @param force
  71910. */
  71911. dispose(force?: boolean): void;
  71912. private getImpostorHitData;
  71913. private _tick;
  71914. /*** Helpers ***/
  71915. private _prepareCylinder;
  71916. private _intersectsWithCylinder;
  71917. }
  71918. /**
  71919. * Options fot the radial explosion event
  71920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71921. */
  71922. export class PhysicsRadialExplosionEventOptions {
  71923. /**
  71924. * The radius of the sphere for the radial explosion.
  71925. */
  71926. radius: number;
  71927. /**
  71928. * The strenth of the explosion.
  71929. */
  71930. strength: number;
  71931. /**
  71932. * The strenght of the force in correspondence to the distance of the affected object
  71933. */
  71934. falloff: PhysicsRadialImpulseFalloff;
  71935. /**
  71936. * Sphere options for the radial explosion.
  71937. */
  71938. sphere: {
  71939. segments: number;
  71940. diameter: number;
  71941. };
  71942. /**
  71943. * Sphere options for the radial explosion.
  71944. */
  71945. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71946. }
  71947. /**
  71948. * Options fot the updraft event
  71949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71950. */
  71951. export class PhysicsUpdraftEventOptions {
  71952. /**
  71953. * The radius of the cylinder for the vortex
  71954. */
  71955. radius: number;
  71956. /**
  71957. * The strenth of the updraft.
  71958. */
  71959. strength: number;
  71960. /**
  71961. * The height of the cylinder for the updraft.
  71962. */
  71963. height: number;
  71964. /**
  71965. * The mode for the the updraft.
  71966. */
  71967. updraftMode: PhysicsUpdraftMode;
  71968. }
  71969. /**
  71970. * Options fot the vortex event
  71971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71972. */
  71973. export class PhysicsVortexEventOptions {
  71974. /**
  71975. * The radius of the cylinder for the vortex
  71976. */
  71977. radius: number;
  71978. /**
  71979. * The strenth of the vortex.
  71980. */
  71981. strength: number;
  71982. /**
  71983. * The height of the cylinder for the vortex.
  71984. */
  71985. height: number;
  71986. /**
  71987. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71988. */
  71989. centripetalForceThreshold: number;
  71990. /**
  71991. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71992. */
  71993. centripetalForceMultiplier: number;
  71994. /**
  71995. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71996. */
  71997. centrifugalForceMultiplier: number;
  71998. /**
  71999. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72000. */
  72001. updraftForceMultiplier: number;
  72002. }
  72003. /**
  72004. * The strenght of the force in correspondence to the distance of the affected object
  72005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72006. */
  72007. export enum PhysicsRadialImpulseFalloff {
  72008. /** Defines that impulse is constant in strength across it's whole radius */
  72009. Constant = 0,
  72010. /** Defines that impulse gets weaker if it's further from the origin */
  72011. Linear = 1
  72012. }
  72013. /**
  72014. * The strength of the force in correspondence to the distance of the affected object
  72015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72016. */
  72017. export enum PhysicsUpdraftMode {
  72018. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72019. Center = 0,
  72020. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72021. Perpendicular = 1
  72022. }
  72023. /**
  72024. * Interface for a physics hit data
  72025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72026. */
  72027. export interface PhysicsHitData {
  72028. /**
  72029. * The force applied at the contact point
  72030. */
  72031. force: Vector3;
  72032. /**
  72033. * The contact point
  72034. */
  72035. contactPoint: Vector3;
  72036. /**
  72037. * The distance from the origin to the contact point
  72038. */
  72039. distanceFromOrigin: number;
  72040. }
  72041. /**
  72042. * Interface for radial explosion event data
  72043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72044. */
  72045. export interface PhysicsRadialExplosionEventData {
  72046. /**
  72047. * A sphere used for the radial explosion event
  72048. */
  72049. sphere: Mesh;
  72050. }
  72051. /**
  72052. * Interface for gravitational field event data
  72053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72054. */
  72055. export interface PhysicsGravitationalFieldEventData {
  72056. /**
  72057. * A sphere mesh used for the gravitational field event
  72058. */
  72059. sphere: Mesh;
  72060. }
  72061. /**
  72062. * Interface for updraft event data
  72063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72064. */
  72065. export interface PhysicsUpdraftEventData {
  72066. /**
  72067. * A cylinder used for the updraft event
  72068. */
  72069. cylinder: Mesh;
  72070. }
  72071. /**
  72072. * Interface for vortex event data
  72073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72074. */
  72075. export interface PhysicsVortexEventData {
  72076. /**
  72077. * A cylinder used for the vortex event
  72078. */
  72079. cylinder: Mesh;
  72080. }
  72081. /**
  72082. * Interface for an affected physics impostor
  72083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72084. */
  72085. export interface PhysicsAffectedImpostorWithData {
  72086. /**
  72087. * The impostor affected by the effect
  72088. */
  72089. impostor: PhysicsImpostor;
  72090. /**
  72091. * The data about the hit/horce from the explosion
  72092. */
  72093. hitData: PhysicsHitData;
  72094. }
  72095. }
  72096. declare module "babylonjs/Physics/Plugins/index" {
  72097. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72098. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72099. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72100. }
  72101. declare module "babylonjs/Physics/index" {
  72102. export * from "babylonjs/Physics/IPhysicsEngine";
  72103. export * from "babylonjs/Physics/physicsEngine";
  72104. export * from "babylonjs/Physics/physicsEngineComponent";
  72105. export * from "babylonjs/Physics/physicsHelper";
  72106. export * from "babylonjs/Physics/physicsImpostor";
  72107. export * from "babylonjs/Physics/physicsJoint";
  72108. export * from "babylonjs/Physics/Plugins/index";
  72109. }
  72110. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72111. /** @hidden */
  72112. export var blackAndWhitePixelShader: {
  72113. name: string;
  72114. shader: string;
  72115. };
  72116. }
  72117. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72119. import { Camera } from "babylonjs/Cameras/camera";
  72120. import { Engine } from "babylonjs/Engines/engine";
  72121. import "babylonjs/Shaders/blackAndWhite.fragment";
  72122. /**
  72123. * Post process used to render in black and white
  72124. */
  72125. export class BlackAndWhitePostProcess extends PostProcess {
  72126. /**
  72127. * Linear about to convert he result to black and white (default: 1)
  72128. */
  72129. degree: number;
  72130. /**
  72131. * Creates a black and white post process
  72132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72133. * @param name The name of the effect.
  72134. * @param options The required width/height ratio to downsize to before computing the render pass.
  72135. * @param camera The camera to apply the render pass to.
  72136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72137. * @param engine The engine which the post process will be applied. (default: current engine)
  72138. * @param reusable If the post process can be reused on the same frame. (default: false)
  72139. */
  72140. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72141. }
  72142. }
  72143. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72144. import { Nullable } from "babylonjs/types";
  72145. import { Camera } from "babylonjs/Cameras/camera";
  72146. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72147. import { Engine } from "babylonjs/Engines/engine";
  72148. /**
  72149. * This represents a set of one or more post processes in Babylon.
  72150. * A post process can be used to apply a shader to a texture after it is rendered.
  72151. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72152. */
  72153. export class PostProcessRenderEffect {
  72154. private _postProcesses;
  72155. private _getPostProcesses;
  72156. private _singleInstance;
  72157. private _cameras;
  72158. private _indicesForCamera;
  72159. /**
  72160. * Name of the effect
  72161. * @hidden
  72162. */
  72163. _name: string;
  72164. /**
  72165. * Instantiates a post process render effect.
  72166. * A post process can be used to apply a shader to a texture after it is rendered.
  72167. * @param engine The engine the effect is tied to
  72168. * @param name The name of the effect
  72169. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72170. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72171. */
  72172. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72173. /**
  72174. * Checks if all the post processes in the effect are supported.
  72175. */
  72176. get isSupported(): boolean;
  72177. /**
  72178. * Updates the current state of the effect
  72179. * @hidden
  72180. */
  72181. _update(): void;
  72182. /**
  72183. * Attaches the effect on cameras
  72184. * @param cameras The camera to attach to.
  72185. * @hidden
  72186. */
  72187. _attachCameras(cameras: Camera): void;
  72188. /**
  72189. * Attaches the effect on cameras
  72190. * @param cameras The camera to attach to.
  72191. * @hidden
  72192. */
  72193. _attachCameras(cameras: Camera[]): void;
  72194. /**
  72195. * Detaches the effect on cameras
  72196. * @param cameras The camera to detatch from.
  72197. * @hidden
  72198. */
  72199. _detachCameras(cameras: Camera): void;
  72200. /**
  72201. * Detatches the effect on cameras
  72202. * @param cameras The camera to detatch from.
  72203. * @hidden
  72204. */
  72205. _detachCameras(cameras: Camera[]): void;
  72206. /**
  72207. * Enables the effect on given cameras
  72208. * @param cameras The camera to enable.
  72209. * @hidden
  72210. */
  72211. _enable(cameras: Camera): void;
  72212. /**
  72213. * Enables the effect on given cameras
  72214. * @param cameras The camera to enable.
  72215. * @hidden
  72216. */
  72217. _enable(cameras: Nullable<Camera[]>): void;
  72218. /**
  72219. * Disables the effect on the given cameras
  72220. * @param cameras The camera to disable.
  72221. * @hidden
  72222. */
  72223. _disable(cameras: Camera): void;
  72224. /**
  72225. * Disables the effect on the given cameras
  72226. * @param cameras The camera to disable.
  72227. * @hidden
  72228. */
  72229. _disable(cameras: Nullable<Camera[]>): void;
  72230. /**
  72231. * Gets a list of the post processes contained in the effect.
  72232. * @param camera The camera to get the post processes on.
  72233. * @returns The list of the post processes in the effect.
  72234. */
  72235. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72236. }
  72237. }
  72238. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72239. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72240. /** @hidden */
  72241. export var extractHighlightsPixelShader: {
  72242. name: string;
  72243. shader: string;
  72244. };
  72245. }
  72246. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72247. import { Nullable } from "babylonjs/types";
  72248. import { Camera } from "babylonjs/Cameras/camera";
  72249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72250. import { Engine } from "babylonjs/Engines/engine";
  72251. import "babylonjs/Shaders/extractHighlights.fragment";
  72252. /**
  72253. * 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.
  72254. */
  72255. export class ExtractHighlightsPostProcess extends PostProcess {
  72256. /**
  72257. * The luminance threshold, pixels below this value will be set to black.
  72258. */
  72259. threshold: number;
  72260. /** @hidden */
  72261. _exposure: number;
  72262. /**
  72263. * Post process which has the input texture to be used when performing highlight extraction
  72264. * @hidden
  72265. */
  72266. _inputPostProcess: Nullable<PostProcess>;
  72267. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72268. }
  72269. }
  72270. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72271. /** @hidden */
  72272. export var bloomMergePixelShader: {
  72273. name: string;
  72274. shader: string;
  72275. };
  72276. }
  72277. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72278. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72279. import { Nullable } from "babylonjs/types";
  72280. import { Engine } from "babylonjs/Engines/engine";
  72281. import { Camera } from "babylonjs/Cameras/camera";
  72282. import "babylonjs/Shaders/bloomMerge.fragment";
  72283. /**
  72284. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72285. */
  72286. export class BloomMergePostProcess extends PostProcess {
  72287. /** Weight of the bloom to be added to the original input. */
  72288. weight: number;
  72289. /**
  72290. * Creates a new instance of @see BloomMergePostProcess
  72291. * @param name The name of the effect.
  72292. * @param originalFromInput Post process which's input will be used for the merge.
  72293. * @param blurred Blurred highlights post process which's output will be used.
  72294. * @param weight Weight of the bloom to be added to the original input.
  72295. * @param options The required width/height ratio to downsize to before computing the render pass.
  72296. * @param camera The camera to apply the render pass to.
  72297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72298. * @param engine The engine which the post process will be applied. (default: current engine)
  72299. * @param reusable If the post process can be reused on the same frame. (default: false)
  72300. * @param textureType Type of textures used when performing the post process. (default: 0)
  72301. * @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)
  72302. */
  72303. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72304. /** Weight of the bloom to be added to the original input. */
  72305. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72306. }
  72307. }
  72308. declare module "babylonjs/PostProcesses/bloomEffect" {
  72309. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72310. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72311. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72312. import { Camera } from "babylonjs/Cameras/camera";
  72313. import { Scene } from "babylonjs/scene";
  72314. /**
  72315. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72316. */
  72317. export class BloomEffect extends PostProcessRenderEffect {
  72318. private bloomScale;
  72319. /**
  72320. * @hidden Internal
  72321. */
  72322. _effects: Array<PostProcess>;
  72323. /**
  72324. * @hidden Internal
  72325. */
  72326. _downscale: ExtractHighlightsPostProcess;
  72327. private _blurX;
  72328. private _blurY;
  72329. private _merge;
  72330. /**
  72331. * The luminance threshold to find bright areas of the image to bloom.
  72332. */
  72333. get threshold(): number;
  72334. set threshold(value: number);
  72335. /**
  72336. * The strength of the bloom.
  72337. */
  72338. get weight(): number;
  72339. set weight(value: number);
  72340. /**
  72341. * Specifies the size of the bloom blur kernel, relative to the final output size
  72342. */
  72343. get kernel(): number;
  72344. set kernel(value: number);
  72345. /**
  72346. * Creates a new instance of @see BloomEffect
  72347. * @param scene The scene the effect belongs to.
  72348. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72349. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72350. * @param bloomWeight The the strength of bloom.
  72351. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72352. * @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)
  72353. */
  72354. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72355. /**
  72356. * Disposes each of the internal effects for a given camera.
  72357. * @param camera The camera to dispose the effect on.
  72358. */
  72359. disposeEffects(camera: Camera): void;
  72360. /**
  72361. * @hidden Internal
  72362. */
  72363. _updateEffects(): void;
  72364. /**
  72365. * Internal
  72366. * @returns if all the contained post processes are ready.
  72367. * @hidden
  72368. */
  72369. _isReady(): boolean;
  72370. }
  72371. }
  72372. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72373. /** @hidden */
  72374. export var chromaticAberrationPixelShader: {
  72375. name: string;
  72376. shader: string;
  72377. };
  72378. }
  72379. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72380. import { Vector2 } from "babylonjs/Maths/math.vector";
  72381. import { Nullable } from "babylonjs/types";
  72382. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72383. import { Camera } from "babylonjs/Cameras/camera";
  72384. import { Engine } from "babylonjs/Engines/engine";
  72385. import "babylonjs/Shaders/chromaticAberration.fragment";
  72386. /**
  72387. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72388. */
  72389. export class ChromaticAberrationPostProcess extends PostProcess {
  72390. /**
  72391. * The amount of seperation of rgb channels (default: 30)
  72392. */
  72393. aberrationAmount: number;
  72394. /**
  72395. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72396. */
  72397. radialIntensity: number;
  72398. /**
  72399. * 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))
  72400. */
  72401. direction: Vector2;
  72402. /**
  72403. * 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))
  72404. */
  72405. centerPosition: Vector2;
  72406. /**
  72407. * Creates a new instance ChromaticAberrationPostProcess
  72408. * @param name The name of the effect.
  72409. * @param screenWidth The width of the screen to apply the effect on.
  72410. * @param screenHeight The height of the screen to apply the effect on.
  72411. * @param options The required width/height ratio to downsize to before computing the render pass.
  72412. * @param camera The camera to apply the render pass to.
  72413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72414. * @param engine The engine which the post process will be applied. (default: current engine)
  72415. * @param reusable If the post process can be reused on the same frame. (default: false)
  72416. * @param textureType Type of textures used when performing the post process. (default: 0)
  72417. * @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)
  72418. */
  72419. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72420. }
  72421. }
  72422. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72423. /** @hidden */
  72424. export var circleOfConfusionPixelShader: {
  72425. name: string;
  72426. shader: string;
  72427. };
  72428. }
  72429. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72430. import { Nullable } from "babylonjs/types";
  72431. import { Engine } from "babylonjs/Engines/engine";
  72432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72433. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72434. import { Camera } from "babylonjs/Cameras/camera";
  72435. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72436. /**
  72437. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72438. */
  72439. export class CircleOfConfusionPostProcess extends PostProcess {
  72440. /**
  72441. * 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.
  72442. */
  72443. lensSize: number;
  72444. /**
  72445. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72446. */
  72447. fStop: number;
  72448. /**
  72449. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72450. */
  72451. focusDistance: number;
  72452. /**
  72453. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72454. */
  72455. focalLength: number;
  72456. private _depthTexture;
  72457. /**
  72458. * Creates a new instance CircleOfConfusionPostProcess
  72459. * @param name The name of the effect.
  72460. * @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.
  72461. * @param options The required width/height ratio to downsize to before computing the render pass.
  72462. * @param camera The camera to apply the render pass to.
  72463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72464. * @param engine The engine which the post process will be applied. (default: current engine)
  72465. * @param reusable If the post process can be reused on the same frame. (default: false)
  72466. * @param textureType Type of textures used when performing the post process. (default: 0)
  72467. * @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)
  72468. */
  72469. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72470. /**
  72471. * 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.
  72472. */
  72473. set depthTexture(value: RenderTargetTexture);
  72474. }
  72475. }
  72476. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72477. /** @hidden */
  72478. export var colorCorrectionPixelShader: {
  72479. name: string;
  72480. shader: string;
  72481. };
  72482. }
  72483. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72485. import { Engine } from "babylonjs/Engines/engine";
  72486. import { Camera } from "babylonjs/Cameras/camera";
  72487. import "babylonjs/Shaders/colorCorrection.fragment";
  72488. /**
  72489. *
  72490. * This post-process allows the modification of rendered colors by using
  72491. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72492. *
  72493. * The object needs to be provided an url to a texture containing the color
  72494. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72495. * Use an image editing software to tweak the LUT to match your needs.
  72496. *
  72497. * For an example of a color LUT, see here:
  72498. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72499. * For explanations on color grading, see here:
  72500. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72501. *
  72502. */
  72503. export class ColorCorrectionPostProcess extends PostProcess {
  72504. private _colorTableTexture;
  72505. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72506. }
  72507. }
  72508. declare module "babylonjs/Shaders/convolution.fragment" {
  72509. /** @hidden */
  72510. export var convolutionPixelShader: {
  72511. name: string;
  72512. shader: string;
  72513. };
  72514. }
  72515. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72516. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72517. import { Nullable } from "babylonjs/types";
  72518. import { Camera } from "babylonjs/Cameras/camera";
  72519. import { Engine } from "babylonjs/Engines/engine";
  72520. import "babylonjs/Shaders/convolution.fragment";
  72521. /**
  72522. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72523. * input texture to perform effects such as edge detection or sharpening
  72524. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72525. */
  72526. export class ConvolutionPostProcess extends PostProcess {
  72527. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72528. kernel: number[];
  72529. /**
  72530. * Creates a new instance ConvolutionPostProcess
  72531. * @param name The name of the effect.
  72532. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72533. * @param options The required width/height ratio to downsize to before computing the render pass.
  72534. * @param camera The camera to apply the render pass to.
  72535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72536. * @param engine The engine which the post process will be applied. (default: current engine)
  72537. * @param reusable If the post process can be reused on the same frame. (default: false)
  72538. * @param textureType Type of textures used when performing the post process. (default: 0)
  72539. */
  72540. constructor(name: string,
  72541. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72542. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72543. /**
  72544. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72545. */
  72546. static EdgeDetect0Kernel: number[];
  72547. /**
  72548. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72549. */
  72550. static EdgeDetect1Kernel: number[];
  72551. /**
  72552. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72553. */
  72554. static EdgeDetect2Kernel: number[];
  72555. /**
  72556. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72557. */
  72558. static SharpenKernel: number[];
  72559. /**
  72560. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72561. */
  72562. static EmbossKernel: number[];
  72563. /**
  72564. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72565. */
  72566. static GaussianKernel: number[];
  72567. }
  72568. }
  72569. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72570. import { Nullable } from "babylonjs/types";
  72571. import { Vector2 } from "babylonjs/Maths/math.vector";
  72572. import { Camera } from "babylonjs/Cameras/camera";
  72573. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72574. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72575. import { Engine } from "babylonjs/Engines/engine";
  72576. import { Scene } from "babylonjs/scene";
  72577. /**
  72578. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72579. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72580. * based on samples that have a large difference in distance than the center pixel.
  72581. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72582. */
  72583. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72584. direction: Vector2;
  72585. /**
  72586. * Creates a new instance CircleOfConfusionPostProcess
  72587. * @param name The name of the effect.
  72588. * @param scene The scene the effect belongs to.
  72589. * @param direction The direction the blur should be applied.
  72590. * @param kernel The size of the kernel used to blur.
  72591. * @param options The required width/height ratio to downsize to before computing the render pass.
  72592. * @param camera The camera to apply the render pass to.
  72593. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72594. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72596. * @param engine The engine which the post process will be applied. (default: current engine)
  72597. * @param reusable If the post process can be reused on the same frame. (default: false)
  72598. * @param textureType Type of textures used when performing the post process. (default: 0)
  72599. * @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)
  72600. */
  72601. 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);
  72602. }
  72603. }
  72604. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72605. /** @hidden */
  72606. export var depthOfFieldMergePixelShader: {
  72607. name: string;
  72608. shader: string;
  72609. };
  72610. }
  72611. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72612. import { Nullable } from "babylonjs/types";
  72613. import { Camera } from "babylonjs/Cameras/camera";
  72614. import { Effect } from "babylonjs/Materials/effect";
  72615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72616. import { Engine } from "babylonjs/Engines/engine";
  72617. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72618. /**
  72619. * Options to be set when merging outputs from the default pipeline.
  72620. */
  72621. export class DepthOfFieldMergePostProcessOptions {
  72622. /**
  72623. * The original image to merge on top of
  72624. */
  72625. originalFromInput: PostProcess;
  72626. /**
  72627. * Parameters to perform the merge of the depth of field effect
  72628. */
  72629. depthOfField?: {
  72630. circleOfConfusion: PostProcess;
  72631. blurSteps: Array<PostProcess>;
  72632. };
  72633. /**
  72634. * Parameters to perform the merge of bloom effect
  72635. */
  72636. bloom?: {
  72637. blurred: PostProcess;
  72638. weight: number;
  72639. };
  72640. }
  72641. /**
  72642. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72643. */
  72644. export class DepthOfFieldMergePostProcess extends PostProcess {
  72645. private blurSteps;
  72646. /**
  72647. * Creates a new instance of DepthOfFieldMergePostProcess
  72648. * @param name The name of the effect.
  72649. * @param originalFromInput Post process which's input will be used for the merge.
  72650. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72651. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72652. * @param options The required width/height ratio to downsize to before computing the render pass.
  72653. * @param camera The camera to apply the render pass to.
  72654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72655. * @param engine The engine which the post process will be applied. (default: current engine)
  72656. * @param reusable If the post process can be reused on the same frame. (default: false)
  72657. * @param textureType Type of textures used when performing the post process. (default: 0)
  72658. * @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)
  72659. */
  72660. 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);
  72661. /**
  72662. * Updates the effect with the current post process compile time values and recompiles the shader.
  72663. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72664. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72665. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72666. * @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
  72667. * @param onCompiled Called when the shader has been compiled.
  72668. * @param onError Called if there is an error when compiling a shader.
  72669. */
  72670. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72671. }
  72672. }
  72673. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72674. import { Nullable } from "babylonjs/types";
  72675. import { Camera } from "babylonjs/Cameras/camera";
  72676. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72677. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72678. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72679. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72680. import { Scene } from "babylonjs/scene";
  72681. /**
  72682. * Specifies the level of max blur that should be applied when using the depth of field effect
  72683. */
  72684. export enum DepthOfFieldEffectBlurLevel {
  72685. /**
  72686. * Subtle blur
  72687. */
  72688. Low = 0,
  72689. /**
  72690. * Medium blur
  72691. */
  72692. Medium = 1,
  72693. /**
  72694. * Large blur
  72695. */
  72696. High = 2
  72697. }
  72698. /**
  72699. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72700. */
  72701. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72702. private _circleOfConfusion;
  72703. /**
  72704. * @hidden Internal, blurs from high to low
  72705. */
  72706. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72707. private _depthOfFieldBlurY;
  72708. private _dofMerge;
  72709. /**
  72710. * @hidden Internal post processes in depth of field effect
  72711. */
  72712. _effects: Array<PostProcess>;
  72713. /**
  72714. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72715. */
  72716. set focalLength(value: number);
  72717. get focalLength(): number;
  72718. /**
  72719. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72720. */
  72721. set fStop(value: number);
  72722. get fStop(): number;
  72723. /**
  72724. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72725. */
  72726. set focusDistance(value: number);
  72727. get focusDistance(): number;
  72728. /**
  72729. * 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.
  72730. */
  72731. set lensSize(value: number);
  72732. get lensSize(): number;
  72733. /**
  72734. * Creates a new instance DepthOfFieldEffect
  72735. * @param scene The scene the effect belongs to.
  72736. * @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.
  72737. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72738. * @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)
  72739. */
  72740. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72741. /**
  72742. * Get the current class name of the current effet
  72743. * @returns "DepthOfFieldEffect"
  72744. */
  72745. getClassName(): string;
  72746. /**
  72747. * 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.
  72748. */
  72749. set depthTexture(value: RenderTargetTexture);
  72750. /**
  72751. * Disposes each of the internal effects for a given camera.
  72752. * @param camera The camera to dispose the effect on.
  72753. */
  72754. disposeEffects(camera: Camera): void;
  72755. /**
  72756. * @hidden Internal
  72757. */
  72758. _updateEffects(): void;
  72759. /**
  72760. * Internal
  72761. * @returns if all the contained post processes are ready.
  72762. * @hidden
  72763. */
  72764. _isReady(): boolean;
  72765. }
  72766. }
  72767. declare module "babylonjs/Shaders/displayPass.fragment" {
  72768. /** @hidden */
  72769. export var displayPassPixelShader: {
  72770. name: string;
  72771. shader: string;
  72772. };
  72773. }
  72774. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72775. import { Nullable } from "babylonjs/types";
  72776. import { Camera } from "babylonjs/Cameras/camera";
  72777. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72778. import { Engine } from "babylonjs/Engines/engine";
  72779. import "babylonjs/Shaders/displayPass.fragment";
  72780. /**
  72781. * DisplayPassPostProcess which produces an output the same as it's input
  72782. */
  72783. export class DisplayPassPostProcess extends PostProcess {
  72784. /**
  72785. * Creates the DisplayPassPostProcess
  72786. * @param name The name of the effect.
  72787. * @param options The required width/height ratio to downsize to before computing the render pass.
  72788. * @param camera The camera to apply the render pass to.
  72789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72790. * @param engine The engine which the post process will be applied. (default: current engine)
  72791. * @param reusable If the post process can be reused on the same frame. (default: false)
  72792. */
  72793. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72794. }
  72795. }
  72796. declare module "babylonjs/Shaders/filter.fragment" {
  72797. /** @hidden */
  72798. export var filterPixelShader: {
  72799. name: string;
  72800. shader: string;
  72801. };
  72802. }
  72803. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72804. import { Nullable } from "babylonjs/types";
  72805. import { Matrix } from "babylonjs/Maths/math.vector";
  72806. import { Camera } from "babylonjs/Cameras/camera";
  72807. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72808. import { Engine } from "babylonjs/Engines/engine";
  72809. import "babylonjs/Shaders/filter.fragment";
  72810. /**
  72811. * Applies a kernel filter to the image
  72812. */
  72813. export class FilterPostProcess extends PostProcess {
  72814. /** The matrix to be applied to the image */
  72815. kernelMatrix: Matrix;
  72816. /**
  72817. *
  72818. * @param name The name of the effect.
  72819. * @param kernelMatrix The matrix to be applied to the image
  72820. * @param options The required width/height ratio to downsize to before computing the render pass.
  72821. * @param camera The camera to apply the render pass to.
  72822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72823. * @param engine The engine which the post process will be applied. (default: current engine)
  72824. * @param reusable If the post process can be reused on the same frame. (default: false)
  72825. */
  72826. constructor(name: string,
  72827. /** The matrix to be applied to the image */
  72828. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72829. }
  72830. }
  72831. declare module "babylonjs/Shaders/fxaa.fragment" {
  72832. /** @hidden */
  72833. export var fxaaPixelShader: {
  72834. name: string;
  72835. shader: string;
  72836. };
  72837. }
  72838. declare module "babylonjs/Shaders/fxaa.vertex" {
  72839. /** @hidden */
  72840. export var fxaaVertexShader: {
  72841. name: string;
  72842. shader: string;
  72843. };
  72844. }
  72845. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72846. import { Nullable } from "babylonjs/types";
  72847. import { Camera } from "babylonjs/Cameras/camera";
  72848. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72849. import { Engine } from "babylonjs/Engines/engine";
  72850. import "babylonjs/Shaders/fxaa.fragment";
  72851. import "babylonjs/Shaders/fxaa.vertex";
  72852. /**
  72853. * Fxaa post process
  72854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72855. */
  72856. export class FxaaPostProcess extends PostProcess {
  72857. /** @hidden */
  72858. texelWidth: number;
  72859. /** @hidden */
  72860. texelHeight: number;
  72861. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72862. private _getDefines;
  72863. }
  72864. }
  72865. declare module "babylonjs/Shaders/grain.fragment" {
  72866. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72867. /** @hidden */
  72868. export var grainPixelShader: {
  72869. name: string;
  72870. shader: string;
  72871. };
  72872. }
  72873. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72874. import { Nullable } from "babylonjs/types";
  72875. import { Camera } from "babylonjs/Cameras/camera";
  72876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72877. import { Engine } from "babylonjs/Engines/engine";
  72878. import "babylonjs/Shaders/grain.fragment";
  72879. /**
  72880. * The GrainPostProcess adds noise to the image at mid luminance levels
  72881. */
  72882. export class GrainPostProcess extends PostProcess {
  72883. /**
  72884. * The intensity of the grain added (default: 30)
  72885. */
  72886. intensity: number;
  72887. /**
  72888. * If the grain should be randomized on every frame
  72889. */
  72890. animated: boolean;
  72891. /**
  72892. * Creates a new instance of @see GrainPostProcess
  72893. * @param name The name of the effect.
  72894. * @param options The required width/height ratio to downsize to before computing the render pass.
  72895. * @param camera The camera to apply the render pass to.
  72896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72897. * @param engine The engine which the post process will be applied. (default: current engine)
  72898. * @param reusable If the post process can be reused on the same frame. (default: false)
  72899. * @param textureType Type of textures used when performing the post process. (default: 0)
  72900. * @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)
  72901. */
  72902. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72903. }
  72904. }
  72905. declare module "babylonjs/Shaders/highlights.fragment" {
  72906. /** @hidden */
  72907. export var highlightsPixelShader: {
  72908. name: string;
  72909. shader: string;
  72910. };
  72911. }
  72912. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72913. import { Nullable } from "babylonjs/types";
  72914. import { Camera } from "babylonjs/Cameras/camera";
  72915. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72916. import { Engine } from "babylonjs/Engines/engine";
  72917. import "babylonjs/Shaders/highlights.fragment";
  72918. /**
  72919. * Extracts highlights from the image
  72920. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72921. */
  72922. export class HighlightsPostProcess extends PostProcess {
  72923. /**
  72924. * Extracts highlights from the image
  72925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72926. * @param name The name of the effect.
  72927. * @param options The required width/height ratio to downsize to before computing the render pass.
  72928. * @param camera The camera to apply the render pass to.
  72929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72930. * @param engine The engine which the post process will be applied. (default: current engine)
  72931. * @param reusable If the post process can be reused on the same frame. (default: false)
  72932. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72933. */
  72934. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72935. }
  72936. }
  72937. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72938. /** @hidden */
  72939. export var mrtFragmentDeclaration: {
  72940. name: string;
  72941. shader: string;
  72942. };
  72943. }
  72944. declare module "babylonjs/Shaders/geometry.fragment" {
  72945. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72946. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72947. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72948. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72949. /** @hidden */
  72950. export var geometryPixelShader: {
  72951. name: string;
  72952. shader: string;
  72953. };
  72954. }
  72955. declare module "babylonjs/Shaders/geometry.vertex" {
  72956. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72957. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72958. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72959. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72960. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72961. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72962. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72963. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72964. /** @hidden */
  72965. export var geometryVertexShader: {
  72966. name: string;
  72967. shader: string;
  72968. };
  72969. }
  72970. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72971. import { Matrix } from "babylonjs/Maths/math.vector";
  72972. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72973. import { Mesh } from "babylonjs/Meshes/mesh";
  72974. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72975. import { Effect } from "babylonjs/Materials/effect";
  72976. import { Scene } from "babylonjs/scene";
  72977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72978. import "babylonjs/Shaders/geometry.fragment";
  72979. import "babylonjs/Shaders/geometry.vertex";
  72980. /** @hidden */
  72981. interface ISavedTransformationMatrix {
  72982. world: Matrix;
  72983. viewProjection: Matrix;
  72984. }
  72985. /**
  72986. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72987. */
  72988. export class GeometryBufferRenderer {
  72989. /**
  72990. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72991. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72992. */
  72993. static readonly POSITION_TEXTURE_TYPE: number;
  72994. /**
  72995. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72996. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72997. */
  72998. static readonly VELOCITY_TEXTURE_TYPE: number;
  72999. /**
  73000. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73001. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73002. */
  73003. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73004. /**
  73005. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73006. * in order to compute objects velocities when enableVelocity is set to "true"
  73007. * @hidden
  73008. */
  73009. _previousTransformationMatrices: {
  73010. [index: number]: ISavedTransformationMatrix;
  73011. };
  73012. /**
  73013. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73014. * in order to compute objects velocities when enableVelocity is set to "true"
  73015. * @hidden
  73016. */
  73017. _previousBonesTransformationMatrices: {
  73018. [index: number]: Float32Array;
  73019. };
  73020. /**
  73021. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73022. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73023. */
  73024. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73025. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73026. renderTransparentMeshes: boolean;
  73027. private _scene;
  73028. private _resizeObserver;
  73029. private _multiRenderTarget;
  73030. private _ratio;
  73031. private _enablePosition;
  73032. private _enableVelocity;
  73033. private _enableReflectivity;
  73034. private _positionIndex;
  73035. private _velocityIndex;
  73036. private _reflectivityIndex;
  73037. protected _effect: Effect;
  73038. protected _cachedDefines: string;
  73039. /**
  73040. * Set the render list (meshes to be rendered) used in the G buffer.
  73041. */
  73042. set renderList(meshes: Mesh[]);
  73043. /**
  73044. * Gets wether or not G buffer are supported by the running hardware.
  73045. * This requires draw buffer supports
  73046. */
  73047. get isSupported(): boolean;
  73048. /**
  73049. * Returns the index of the given texture type in the G-Buffer textures array
  73050. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73051. * @returns the index of the given texture type in the G-Buffer textures array
  73052. */
  73053. getTextureIndex(textureType: number): number;
  73054. /**
  73055. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73056. */
  73057. get enablePosition(): boolean;
  73058. /**
  73059. * Sets whether or not objects positions are enabled for the G buffer.
  73060. */
  73061. set enablePosition(enable: boolean);
  73062. /**
  73063. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73064. */
  73065. get enableVelocity(): boolean;
  73066. /**
  73067. * Sets wether or not objects velocities are enabled for the G buffer.
  73068. */
  73069. set enableVelocity(enable: boolean);
  73070. /**
  73071. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73072. */
  73073. get enableReflectivity(): boolean;
  73074. /**
  73075. * Sets wether or not objects roughness are enabled for the G buffer.
  73076. */
  73077. set enableReflectivity(enable: boolean);
  73078. /**
  73079. * Gets the scene associated with the buffer.
  73080. */
  73081. get scene(): Scene;
  73082. /**
  73083. * Gets the ratio used by the buffer during its creation.
  73084. * How big is the buffer related to the main canvas.
  73085. */
  73086. get ratio(): number;
  73087. /** @hidden */
  73088. static _SceneComponentInitialization: (scene: Scene) => void;
  73089. /**
  73090. * Creates a new G Buffer for the scene
  73091. * @param scene The scene the buffer belongs to
  73092. * @param ratio How big is the buffer related to the main canvas.
  73093. */
  73094. constructor(scene: Scene, ratio?: number);
  73095. /**
  73096. * Checks wether everything is ready to render a submesh to the G buffer.
  73097. * @param subMesh the submesh to check readiness for
  73098. * @param useInstances is the mesh drawn using instance or not
  73099. * @returns true if ready otherwise false
  73100. */
  73101. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73102. /**
  73103. * Gets the current underlying G Buffer.
  73104. * @returns the buffer
  73105. */
  73106. getGBuffer(): MultiRenderTarget;
  73107. /**
  73108. * Gets the number of samples used to render the buffer (anti aliasing).
  73109. */
  73110. get samples(): number;
  73111. /**
  73112. * Sets the number of samples used to render the buffer (anti aliasing).
  73113. */
  73114. set samples(value: number);
  73115. /**
  73116. * Disposes the renderer and frees up associated resources.
  73117. */
  73118. dispose(): void;
  73119. protected _createRenderTargets(): void;
  73120. private _copyBonesTransformationMatrices;
  73121. }
  73122. }
  73123. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73124. import { Nullable } from "babylonjs/types";
  73125. import { Scene } from "babylonjs/scene";
  73126. import { ISceneComponent } from "babylonjs/sceneComponent";
  73127. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73128. module "babylonjs/scene" {
  73129. interface Scene {
  73130. /** @hidden (Backing field) */
  73131. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73132. /**
  73133. * Gets or Sets the current geometry buffer associated to the scene.
  73134. */
  73135. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73136. /**
  73137. * Enables a GeometryBufferRender and associates it with the scene
  73138. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73139. * @returns the GeometryBufferRenderer
  73140. */
  73141. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73142. /**
  73143. * Disables the GeometryBufferRender associated with the scene
  73144. */
  73145. disableGeometryBufferRenderer(): void;
  73146. }
  73147. }
  73148. /**
  73149. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73150. * in several rendering techniques.
  73151. */
  73152. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73153. /**
  73154. * The component name helpful to identify the component in the list of scene components.
  73155. */
  73156. readonly name: string;
  73157. /**
  73158. * The scene the component belongs to.
  73159. */
  73160. scene: Scene;
  73161. /**
  73162. * Creates a new instance of the component for the given scene
  73163. * @param scene Defines the scene to register the component in
  73164. */
  73165. constructor(scene: Scene);
  73166. /**
  73167. * Registers the component in a given scene
  73168. */
  73169. register(): void;
  73170. /**
  73171. * Rebuilds the elements related to this component in case of
  73172. * context lost for instance.
  73173. */
  73174. rebuild(): void;
  73175. /**
  73176. * Disposes the component and the associated ressources
  73177. */
  73178. dispose(): void;
  73179. private _gatherRenderTargets;
  73180. }
  73181. }
  73182. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73183. /** @hidden */
  73184. export var motionBlurPixelShader: {
  73185. name: string;
  73186. shader: string;
  73187. };
  73188. }
  73189. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73190. import { Nullable } from "babylonjs/types";
  73191. import { Camera } from "babylonjs/Cameras/camera";
  73192. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73193. import { Scene } from "babylonjs/scene";
  73194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73195. import "babylonjs/Animations/animatable";
  73196. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73197. import "babylonjs/Shaders/motionBlur.fragment";
  73198. import { Engine } from "babylonjs/Engines/engine";
  73199. /**
  73200. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73201. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73202. * As an example, all you have to do is to create the post-process:
  73203. * var mb = new BABYLON.MotionBlurPostProcess(
  73204. * 'mb', // The name of the effect.
  73205. * scene, // The scene containing the objects to blur according to their velocity.
  73206. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73207. * camera // The camera to apply the render pass to.
  73208. * );
  73209. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73210. */
  73211. export class MotionBlurPostProcess extends PostProcess {
  73212. /**
  73213. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73214. */
  73215. motionStrength: number;
  73216. /**
  73217. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73218. */
  73219. get motionBlurSamples(): number;
  73220. /**
  73221. * Sets the number of iterations to be used for motion blur quality
  73222. */
  73223. set motionBlurSamples(samples: number);
  73224. private _motionBlurSamples;
  73225. private _geometryBufferRenderer;
  73226. /**
  73227. * Creates a new instance MotionBlurPostProcess
  73228. * @param name The name of the effect.
  73229. * @param scene The scene containing the objects to blur according to their velocity.
  73230. * @param options The required width/height ratio to downsize to before computing the render pass.
  73231. * @param camera The camera to apply the render pass to.
  73232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73233. * @param engine The engine which the post process will be applied. (default: current engine)
  73234. * @param reusable If the post process can be reused on the same frame. (default: false)
  73235. * @param textureType Type of textures used when performing the post process. (default: 0)
  73236. * @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)
  73237. */
  73238. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73239. /**
  73240. * Excludes the given skinned mesh from computing bones velocities.
  73241. * 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.
  73242. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73243. */
  73244. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73245. /**
  73246. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73247. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73248. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73249. */
  73250. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73251. /**
  73252. * Disposes the post process.
  73253. * @param camera The camera to dispose the post process on.
  73254. */
  73255. dispose(camera?: Camera): void;
  73256. }
  73257. }
  73258. declare module "babylonjs/Shaders/refraction.fragment" {
  73259. /** @hidden */
  73260. export var refractionPixelShader: {
  73261. name: string;
  73262. shader: string;
  73263. };
  73264. }
  73265. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73266. import { Color3 } from "babylonjs/Maths/math.color";
  73267. import { Camera } from "babylonjs/Cameras/camera";
  73268. import { Texture } from "babylonjs/Materials/Textures/texture";
  73269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73270. import { Engine } from "babylonjs/Engines/engine";
  73271. import "babylonjs/Shaders/refraction.fragment";
  73272. /**
  73273. * Post process which applies a refractin texture
  73274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73275. */
  73276. export class RefractionPostProcess extends PostProcess {
  73277. /** the base color of the refraction (used to taint the rendering) */
  73278. color: Color3;
  73279. /** simulated refraction depth */
  73280. depth: number;
  73281. /** the coefficient of the base color (0 to remove base color tainting) */
  73282. colorLevel: number;
  73283. private _refTexture;
  73284. private _ownRefractionTexture;
  73285. /**
  73286. * Gets or sets the refraction texture
  73287. * Please note that you are responsible for disposing the texture if you set it manually
  73288. */
  73289. get refractionTexture(): Texture;
  73290. set refractionTexture(value: Texture);
  73291. /**
  73292. * Initializes the RefractionPostProcess
  73293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73294. * @param name The name of the effect.
  73295. * @param refractionTextureUrl Url of the refraction texture to use
  73296. * @param color the base color of the refraction (used to taint the rendering)
  73297. * @param depth simulated refraction depth
  73298. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73299. * @param camera The camera to apply the render pass to.
  73300. * @param options The required width/height ratio to downsize to before computing the render pass.
  73301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73302. * @param engine The engine which the post process will be applied. (default: current engine)
  73303. * @param reusable If the post process can be reused on the same frame. (default: false)
  73304. */
  73305. constructor(name: string, refractionTextureUrl: string,
  73306. /** the base color of the refraction (used to taint the rendering) */
  73307. color: Color3,
  73308. /** simulated refraction depth */
  73309. depth: number,
  73310. /** the coefficient of the base color (0 to remove base color tainting) */
  73311. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73312. /**
  73313. * Disposes of the post process
  73314. * @param camera Camera to dispose post process on
  73315. */
  73316. dispose(camera: Camera): void;
  73317. }
  73318. }
  73319. declare module "babylonjs/Shaders/sharpen.fragment" {
  73320. /** @hidden */
  73321. export var sharpenPixelShader: {
  73322. name: string;
  73323. shader: string;
  73324. };
  73325. }
  73326. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73327. import { Nullable } from "babylonjs/types";
  73328. import { Camera } from "babylonjs/Cameras/camera";
  73329. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73330. import "babylonjs/Shaders/sharpen.fragment";
  73331. import { Engine } from "babylonjs/Engines/engine";
  73332. /**
  73333. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73334. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73335. */
  73336. export class SharpenPostProcess extends PostProcess {
  73337. /**
  73338. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73339. */
  73340. colorAmount: number;
  73341. /**
  73342. * How much sharpness should be applied (default: 0.3)
  73343. */
  73344. edgeAmount: number;
  73345. /**
  73346. * Creates a new instance ConvolutionPostProcess
  73347. * @param name The name of the effect.
  73348. * @param options The required width/height ratio to downsize to before computing the render pass.
  73349. * @param camera The camera to apply the render pass to.
  73350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73351. * @param engine The engine which the post process will be applied. (default: current engine)
  73352. * @param reusable If the post process can be reused on the same frame. (default: false)
  73353. * @param textureType Type of textures used when performing the post process. (default: 0)
  73354. * @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)
  73355. */
  73356. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73357. }
  73358. }
  73359. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73360. import { Nullable } from "babylonjs/types";
  73361. import { Camera } from "babylonjs/Cameras/camera";
  73362. import { Engine } from "babylonjs/Engines/engine";
  73363. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73364. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73365. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73366. /**
  73367. * PostProcessRenderPipeline
  73368. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73369. */
  73370. export class PostProcessRenderPipeline {
  73371. private engine;
  73372. private _renderEffects;
  73373. private _renderEffectsForIsolatedPass;
  73374. /**
  73375. * List of inspectable custom properties (used by the Inspector)
  73376. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73377. */
  73378. inspectableCustomProperties: IInspectable[];
  73379. /**
  73380. * @hidden
  73381. */
  73382. protected _cameras: Camera[];
  73383. /** @hidden */
  73384. _name: string;
  73385. /**
  73386. * Gets pipeline name
  73387. */
  73388. get name(): string;
  73389. /** Gets the list of attached cameras */
  73390. get cameras(): Camera[];
  73391. /**
  73392. * Initializes a PostProcessRenderPipeline
  73393. * @param engine engine to add the pipeline to
  73394. * @param name name of the pipeline
  73395. */
  73396. constructor(engine: Engine, name: string);
  73397. /**
  73398. * Gets the class name
  73399. * @returns "PostProcessRenderPipeline"
  73400. */
  73401. getClassName(): string;
  73402. /**
  73403. * If all the render effects in the pipeline are supported
  73404. */
  73405. get isSupported(): boolean;
  73406. /**
  73407. * Adds an effect to the pipeline
  73408. * @param renderEffect the effect to add
  73409. */
  73410. addEffect(renderEffect: PostProcessRenderEffect): void;
  73411. /** @hidden */
  73412. _rebuild(): void;
  73413. /** @hidden */
  73414. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73415. /** @hidden */
  73416. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73417. /** @hidden */
  73418. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73419. /** @hidden */
  73420. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73421. /** @hidden */
  73422. _attachCameras(cameras: Camera, unique: boolean): void;
  73423. /** @hidden */
  73424. _attachCameras(cameras: Camera[], unique: boolean): void;
  73425. /** @hidden */
  73426. _detachCameras(cameras: Camera): void;
  73427. /** @hidden */
  73428. _detachCameras(cameras: Nullable<Camera[]>): void;
  73429. /** @hidden */
  73430. _update(): void;
  73431. /** @hidden */
  73432. _reset(): void;
  73433. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73434. /**
  73435. * Sets the required values to the prepass renderer.
  73436. * @param prePassRenderer defines the prepass renderer to setup.
  73437. * @returns true if the pre pass is needed.
  73438. */
  73439. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73440. /**
  73441. * Disposes of the pipeline
  73442. */
  73443. dispose(): void;
  73444. }
  73445. }
  73446. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73447. import { Camera } from "babylonjs/Cameras/camera";
  73448. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73449. /**
  73450. * PostProcessRenderPipelineManager class
  73451. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73452. */
  73453. export class PostProcessRenderPipelineManager {
  73454. private _renderPipelines;
  73455. /**
  73456. * Initializes a PostProcessRenderPipelineManager
  73457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73458. */
  73459. constructor();
  73460. /**
  73461. * Gets the list of supported render pipelines
  73462. */
  73463. get supportedPipelines(): PostProcessRenderPipeline[];
  73464. /**
  73465. * Adds a pipeline to the manager
  73466. * @param renderPipeline The pipeline to add
  73467. */
  73468. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73469. /**
  73470. * Attaches a camera to the pipeline
  73471. * @param renderPipelineName The name of the pipeline to attach to
  73472. * @param cameras the camera to attach
  73473. * @param unique if the camera can be attached multiple times to the pipeline
  73474. */
  73475. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73476. /**
  73477. * Detaches a camera from the pipeline
  73478. * @param renderPipelineName The name of the pipeline to detach from
  73479. * @param cameras the camera to detach
  73480. */
  73481. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73482. /**
  73483. * Enables an effect by name on a pipeline
  73484. * @param renderPipelineName the name of the pipeline to enable the effect in
  73485. * @param renderEffectName the name of the effect to enable
  73486. * @param cameras the cameras that the effect should be enabled on
  73487. */
  73488. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73489. /**
  73490. * Disables an effect by name on a pipeline
  73491. * @param renderPipelineName the name of the pipeline to disable the effect in
  73492. * @param renderEffectName the name of the effect to disable
  73493. * @param cameras the cameras that the effect should be disabled on
  73494. */
  73495. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73496. /**
  73497. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73498. */
  73499. update(): void;
  73500. /** @hidden */
  73501. _rebuild(): void;
  73502. /**
  73503. * Disposes of the manager and pipelines
  73504. */
  73505. dispose(): void;
  73506. }
  73507. }
  73508. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73509. import { ISceneComponent } from "babylonjs/sceneComponent";
  73510. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73511. import { Scene } from "babylonjs/scene";
  73512. module "babylonjs/scene" {
  73513. interface Scene {
  73514. /** @hidden (Backing field) */
  73515. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73516. /**
  73517. * Gets the postprocess render pipeline manager
  73518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73519. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73520. */
  73521. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73522. }
  73523. }
  73524. /**
  73525. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73526. */
  73527. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73528. /**
  73529. * The component name helpfull to identify the component in the list of scene components.
  73530. */
  73531. readonly name: string;
  73532. /**
  73533. * The scene the component belongs to.
  73534. */
  73535. scene: Scene;
  73536. /**
  73537. * Creates a new instance of the component for the given scene
  73538. * @param scene Defines the scene to register the component in
  73539. */
  73540. constructor(scene: Scene);
  73541. /**
  73542. * Registers the component in a given scene
  73543. */
  73544. register(): void;
  73545. /**
  73546. * Rebuilds the elements related to this component in case of
  73547. * context lost for instance.
  73548. */
  73549. rebuild(): void;
  73550. /**
  73551. * Disposes the component and the associated ressources
  73552. */
  73553. dispose(): void;
  73554. private _gatherRenderTargets;
  73555. }
  73556. }
  73557. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73558. import { Nullable } from "babylonjs/types";
  73559. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73560. import { Camera } from "babylonjs/Cameras/camera";
  73561. import { IDisposable } from "babylonjs/scene";
  73562. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73563. import { Scene } from "babylonjs/scene";
  73564. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73565. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73566. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73567. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73568. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73569. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73570. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73571. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73572. import { Animation } from "babylonjs/Animations/animation";
  73573. /**
  73574. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73575. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73576. */
  73577. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73578. private _scene;
  73579. private _camerasToBeAttached;
  73580. /**
  73581. * ID of the sharpen post process,
  73582. */
  73583. private readonly SharpenPostProcessId;
  73584. /**
  73585. * @ignore
  73586. * ID of the image processing post process;
  73587. */
  73588. readonly ImageProcessingPostProcessId: string;
  73589. /**
  73590. * @ignore
  73591. * ID of the Fast Approximate Anti-Aliasing post process;
  73592. */
  73593. readonly FxaaPostProcessId: string;
  73594. /**
  73595. * ID of the chromatic aberration post process,
  73596. */
  73597. private readonly ChromaticAberrationPostProcessId;
  73598. /**
  73599. * ID of the grain post process
  73600. */
  73601. private readonly GrainPostProcessId;
  73602. /**
  73603. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73604. */
  73605. sharpen: SharpenPostProcess;
  73606. private _sharpenEffect;
  73607. private bloom;
  73608. /**
  73609. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73610. */
  73611. depthOfField: DepthOfFieldEffect;
  73612. /**
  73613. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73614. */
  73615. fxaa: FxaaPostProcess;
  73616. /**
  73617. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73618. */
  73619. imageProcessing: ImageProcessingPostProcess;
  73620. /**
  73621. * Chromatic aberration post process which will shift rgb colors in the image
  73622. */
  73623. chromaticAberration: ChromaticAberrationPostProcess;
  73624. private _chromaticAberrationEffect;
  73625. /**
  73626. * Grain post process which add noise to the image
  73627. */
  73628. grain: GrainPostProcess;
  73629. private _grainEffect;
  73630. /**
  73631. * Glow post process which adds a glow to emissive areas of the image
  73632. */
  73633. private _glowLayer;
  73634. /**
  73635. * Animations which can be used to tweak settings over a period of time
  73636. */
  73637. animations: Animation[];
  73638. private _imageProcessingConfigurationObserver;
  73639. private _sharpenEnabled;
  73640. private _bloomEnabled;
  73641. private _depthOfFieldEnabled;
  73642. private _depthOfFieldBlurLevel;
  73643. private _fxaaEnabled;
  73644. private _imageProcessingEnabled;
  73645. private _defaultPipelineTextureType;
  73646. private _bloomScale;
  73647. private _chromaticAberrationEnabled;
  73648. private _grainEnabled;
  73649. private _buildAllowed;
  73650. /**
  73651. * Gets active scene
  73652. */
  73653. get scene(): Scene;
  73654. /**
  73655. * Enable or disable the sharpen process from the pipeline
  73656. */
  73657. set sharpenEnabled(enabled: boolean);
  73658. get sharpenEnabled(): boolean;
  73659. private _resizeObserver;
  73660. private _hardwareScaleLevel;
  73661. private _bloomKernel;
  73662. /**
  73663. * Specifies the size of the bloom blur kernel, relative to the final output size
  73664. */
  73665. get bloomKernel(): number;
  73666. set bloomKernel(value: number);
  73667. /**
  73668. * Specifies the weight of the bloom in the final rendering
  73669. */
  73670. private _bloomWeight;
  73671. /**
  73672. * Specifies the luma threshold for the area that will be blurred by the bloom
  73673. */
  73674. private _bloomThreshold;
  73675. private _hdr;
  73676. /**
  73677. * The strength of the bloom.
  73678. */
  73679. set bloomWeight(value: number);
  73680. get bloomWeight(): number;
  73681. /**
  73682. * The strength of the bloom.
  73683. */
  73684. set bloomThreshold(value: number);
  73685. get bloomThreshold(): number;
  73686. /**
  73687. * The scale of the bloom, lower value will provide better performance.
  73688. */
  73689. set bloomScale(value: number);
  73690. get bloomScale(): number;
  73691. /**
  73692. * Enable or disable the bloom from the pipeline
  73693. */
  73694. set bloomEnabled(enabled: boolean);
  73695. get bloomEnabled(): boolean;
  73696. private _rebuildBloom;
  73697. /**
  73698. * If the depth of field is enabled.
  73699. */
  73700. get depthOfFieldEnabled(): boolean;
  73701. set depthOfFieldEnabled(enabled: boolean);
  73702. /**
  73703. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73704. */
  73705. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73706. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73707. /**
  73708. * If the anti aliasing is enabled.
  73709. */
  73710. set fxaaEnabled(enabled: boolean);
  73711. get fxaaEnabled(): boolean;
  73712. private _samples;
  73713. /**
  73714. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73715. */
  73716. set samples(sampleCount: number);
  73717. get samples(): number;
  73718. /**
  73719. * If image processing is enabled.
  73720. */
  73721. set imageProcessingEnabled(enabled: boolean);
  73722. get imageProcessingEnabled(): boolean;
  73723. /**
  73724. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73725. */
  73726. set glowLayerEnabled(enabled: boolean);
  73727. get glowLayerEnabled(): boolean;
  73728. /**
  73729. * Gets the glow layer (or null if not defined)
  73730. */
  73731. get glowLayer(): Nullable<GlowLayer>;
  73732. /**
  73733. * Enable or disable the chromaticAberration process from the pipeline
  73734. */
  73735. set chromaticAberrationEnabled(enabled: boolean);
  73736. get chromaticAberrationEnabled(): boolean;
  73737. /**
  73738. * Enable or disable the grain process from the pipeline
  73739. */
  73740. set grainEnabled(enabled: boolean);
  73741. get grainEnabled(): boolean;
  73742. /**
  73743. * @constructor
  73744. * @param name - The rendering pipeline name (default: "")
  73745. * @param hdr - If high dynamic range textures should be used (default: true)
  73746. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73747. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73748. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73749. */
  73750. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73751. /**
  73752. * Get the class name
  73753. * @returns "DefaultRenderingPipeline"
  73754. */
  73755. getClassName(): string;
  73756. /**
  73757. * Force the compilation of the entire pipeline.
  73758. */
  73759. prepare(): void;
  73760. private _hasCleared;
  73761. private _prevPostProcess;
  73762. private _prevPrevPostProcess;
  73763. private _setAutoClearAndTextureSharing;
  73764. private _depthOfFieldSceneObserver;
  73765. private _buildPipeline;
  73766. private _disposePostProcesses;
  73767. /**
  73768. * Adds a camera to the pipeline
  73769. * @param camera the camera to be added
  73770. */
  73771. addCamera(camera: Camera): void;
  73772. /**
  73773. * Removes a camera from the pipeline
  73774. * @param camera the camera to remove
  73775. */
  73776. removeCamera(camera: Camera): void;
  73777. /**
  73778. * Dispose of the pipeline and stop all post processes
  73779. */
  73780. dispose(): void;
  73781. /**
  73782. * Serialize the rendering pipeline (Used when exporting)
  73783. * @returns the serialized object
  73784. */
  73785. serialize(): any;
  73786. /**
  73787. * Parse the serialized pipeline
  73788. * @param source Source pipeline.
  73789. * @param scene The scene to load the pipeline to.
  73790. * @param rootUrl The URL of the serialized pipeline.
  73791. * @returns An instantiated pipeline from the serialized object.
  73792. */
  73793. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73794. }
  73795. }
  73796. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73797. /** @hidden */
  73798. export var lensHighlightsPixelShader: {
  73799. name: string;
  73800. shader: string;
  73801. };
  73802. }
  73803. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73804. /** @hidden */
  73805. export var depthOfFieldPixelShader: {
  73806. name: string;
  73807. shader: string;
  73808. };
  73809. }
  73810. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73811. import { Camera } from "babylonjs/Cameras/camera";
  73812. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73813. import { Scene } from "babylonjs/scene";
  73814. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73815. import "babylonjs/Shaders/chromaticAberration.fragment";
  73816. import "babylonjs/Shaders/lensHighlights.fragment";
  73817. import "babylonjs/Shaders/depthOfField.fragment";
  73818. /**
  73819. * BABYLON.JS Chromatic Aberration GLSL Shader
  73820. * Author: Olivier Guyot
  73821. * Separates very slightly R, G and B colors on the edges of the screen
  73822. * Inspired by Francois Tarlier & Martins Upitis
  73823. */
  73824. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73825. /**
  73826. * @ignore
  73827. * The chromatic aberration PostProcess id in the pipeline
  73828. */
  73829. LensChromaticAberrationEffect: string;
  73830. /**
  73831. * @ignore
  73832. * The highlights enhancing PostProcess id in the pipeline
  73833. */
  73834. HighlightsEnhancingEffect: string;
  73835. /**
  73836. * @ignore
  73837. * The depth-of-field PostProcess id in the pipeline
  73838. */
  73839. LensDepthOfFieldEffect: string;
  73840. private _scene;
  73841. private _depthTexture;
  73842. private _grainTexture;
  73843. private _chromaticAberrationPostProcess;
  73844. private _highlightsPostProcess;
  73845. private _depthOfFieldPostProcess;
  73846. private _edgeBlur;
  73847. private _grainAmount;
  73848. private _chromaticAberration;
  73849. private _distortion;
  73850. private _highlightsGain;
  73851. private _highlightsThreshold;
  73852. private _dofDistance;
  73853. private _dofAperture;
  73854. private _dofDarken;
  73855. private _dofPentagon;
  73856. private _blurNoise;
  73857. /**
  73858. * @constructor
  73859. *
  73860. * Effect parameters are as follow:
  73861. * {
  73862. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73863. * edge_blur: number; // from 0 to x (1 for realism)
  73864. * distortion: number; // from 0 to x (1 for realism)
  73865. * grain_amount: number; // from 0 to 1
  73866. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73867. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73868. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73869. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73870. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73871. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73872. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73873. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73874. * }
  73875. * Note: if an effect parameter is unset, effect is disabled
  73876. *
  73877. * @param name The rendering pipeline name
  73878. * @param parameters - An object containing all parameters (see above)
  73879. * @param scene The scene linked to this pipeline
  73880. * @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)
  73881. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73882. */
  73883. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73884. /**
  73885. * Get the class name
  73886. * @returns "LensRenderingPipeline"
  73887. */
  73888. getClassName(): string;
  73889. /**
  73890. * Gets associated scene
  73891. */
  73892. get scene(): Scene;
  73893. /**
  73894. * Gets or sets the edge blur
  73895. */
  73896. get edgeBlur(): number;
  73897. set edgeBlur(value: number);
  73898. /**
  73899. * Gets or sets the grain amount
  73900. */
  73901. get grainAmount(): number;
  73902. set grainAmount(value: number);
  73903. /**
  73904. * Gets or sets the chromatic aberration amount
  73905. */
  73906. get chromaticAberration(): number;
  73907. set chromaticAberration(value: number);
  73908. /**
  73909. * Gets or sets the depth of field aperture
  73910. */
  73911. get dofAperture(): number;
  73912. set dofAperture(value: number);
  73913. /**
  73914. * Gets or sets the edge distortion
  73915. */
  73916. get edgeDistortion(): number;
  73917. set edgeDistortion(value: number);
  73918. /**
  73919. * Gets or sets the depth of field distortion
  73920. */
  73921. get dofDistortion(): number;
  73922. set dofDistortion(value: number);
  73923. /**
  73924. * Gets or sets the darken out of focus amount
  73925. */
  73926. get darkenOutOfFocus(): number;
  73927. set darkenOutOfFocus(value: number);
  73928. /**
  73929. * Gets or sets a boolean indicating if blur noise is enabled
  73930. */
  73931. get blurNoise(): boolean;
  73932. set blurNoise(value: boolean);
  73933. /**
  73934. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73935. */
  73936. get pentagonBokeh(): boolean;
  73937. set pentagonBokeh(value: boolean);
  73938. /**
  73939. * Gets or sets the highlight grain amount
  73940. */
  73941. get highlightsGain(): number;
  73942. set highlightsGain(value: number);
  73943. /**
  73944. * Gets or sets the highlight threshold
  73945. */
  73946. get highlightsThreshold(): number;
  73947. set highlightsThreshold(value: number);
  73948. /**
  73949. * Sets the amount of blur at the edges
  73950. * @param amount blur amount
  73951. */
  73952. setEdgeBlur(amount: number): void;
  73953. /**
  73954. * Sets edge blur to 0
  73955. */
  73956. disableEdgeBlur(): void;
  73957. /**
  73958. * Sets the amout of grain
  73959. * @param amount Amount of grain
  73960. */
  73961. setGrainAmount(amount: number): void;
  73962. /**
  73963. * Set grain amount to 0
  73964. */
  73965. disableGrain(): void;
  73966. /**
  73967. * Sets the chromatic aberration amount
  73968. * @param amount amount of chromatic aberration
  73969. */
  73970. setChromaticAberration(amount: number): void;
  73971. /**
  73972. * Sets chromatic aberration amount to 0
  73973. */
  73974. disableChromaticAberration(): void;
  73975. /**
  73976. * Sets the EdgeDistortion amount
  73977. * @param amount amount of EdgeDistortion
  73978. */
  73979. setEdgeDistortion(amount: number): void;
  73980. /**
  73981. * Sets edge distortion to 0
  73982. */
  73983. disableEdgeDistortion(): void;
  73984. /**
  73985. * Sets the FocusDistance amount
  73986. * @param amount amount of FocusDistance
  73987. */
  73988. setFocusDistance(amount: number): void;
  73989. /**
  73990. * Disables depth of field
  73991. */
  73992. disableDepthOfField(): void;
  73993. /**
  73994. * Sets the Aperture amount
  73995. * @param amount amount of Aperture
  73996. */
  73997. setAperture(amount: number): void;
  73998. /**
  73999. * Sets the DarkenOutOfFocus amount
  74000. * @param amount amount of DarkenOutOfFocus
  74001. */
  74002. setDarkenOutOfFocus(amount: number): void;
  74003. private _pentagonBokehIsEnabled;
  74004. /**
  74005. * Creates a pentagon bokeh effect
  74006. */
  74007. enablePentagonBokeh(): void;
  74008. /**
  74009. * Disables the pentagon bokeh effect
  74010. */
  74011. disablePentagonBokeh(): void;
  74012. /**
  74013. * Enables noise blur
  74014. */
  74015. enableNoiseBlur(): void;
  74016. /**
  74017. * Disables noise blur
  74018. */
  74019. disableNoiseBlur(): void;
  74020. /**
  74021. * Sets the HighlightsGain amount
  74022. * @param amount amount of HighlightsGain
  74023. */
  74024. setHighlightsGain(amount: number): void;
  74025. /**
  74026. * Sets the HighlightsThreshold amount
  74027. * @param amount amount of HighlightsThreshold
  74028. */
  74029. setHighlightsThreshold(amount: number): void;
  74030. /**
  74031. * Disables highlights
  74032. */
  74033. disableHighlights(): void;
  74034. /**
  74035. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74036. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74037. */
  74038. dispose(disableDepthRender?: boolean): void;
  74039. private _createChromaticAberrationPostProcess;
  74040. private _createHighlightsPostProcess;
  74041. private _createDepthOfFieldPostProcess;
  74042. private _createGrainTexture;
  74043. }
  74044. }
  74045. declare module "babylonjs/Shaders/ssao2.fragment" {
  74046. /** @hidden */
  74047. export var ssao2PixelShader: {
  74048. name: string;
  74049. shader: string;
  74050. };
  74051. }
  74052. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74053. /** @hidden */
  74054. export var ssaoCombinePixelShader: {
  74055. name: string;
  74056. shader: string;
  74057. };
  74058. }
  74059. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74060. import { Camera } from "babylonjs/Cameras/camera";
  74061. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74062. import { Scene } from "babylonjs/scene";
  74063. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74064. import "babylonjs/Shaders/ssao2.fragment";
  74065. import "babylonjs/Shaders/ssaoCombine.fragment";
  74066. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74067. /**
  74068. * Render pipeline to produce ssao effect
  74069. */
  74070. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74071. /**
  74072. * @ignore
  74073. * The PassPostProcess id in the pipeline that contains the original scene color
  74074. */
  74075. SSAOOriginalSceneColorEffect: string;
  74076. /**
  74077. * @ignore
  74078. * The SSAO PostProcess id in the pipeline
  74079. */
  74080. SSAORenderEffect: string;
  74081. /**
  74082. * @ignore
  74083. * The horizontal blur PostProcess id in the pipeline
  74084. */
  74085. SSAOBlurHRenderEffect: string;
  74086. /**
  74087. * @ignore
  74088. * The vertical blur PostProcess id in the pipeline
  74089. */
  74090. SSAOBlurVRenderEffect: string;
  74091. /**
  74092. * @ignore
  74093. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74094. */
  74095. SSAOCombineRenderEffect: string;
  74096. /**
  74097. * The output strength of the SSAO post-process. Default value is 1.0.
  74098. */
  74099. totalStrength: number;
  74100. /**
  74101. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74102. */
  74103. maxZ: number;
  74104. /**
  74105. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74106. */
  74107. minZAspect: number;
  74108. private _samples;
  74109. /**
  74110. * Number of samples used for the SSAO calculations. Default value is 8
  74111. */
  74112. set samples(n: number);
  74113. get samples(): number;
  74114. private _textureSamples;
  74115. /**
  74116. * Number of samples to use for antialiasing
  74117. */
  74118. set textureSamples(n: number);
  74119. get textureSamples(): number;
  74120. /**
  74121. * Force rendering the geometry through geometry buffer
  74122. */
  74123. private _forceGeometryBuffer;
  74124. /**
  74125. * Ratio object used for SSAO ratio and blur ratio
  74126. */
  74127. private _ratio;
  74128. /**
  74129. * Dynamically generated sphere sampler.
  74130. */
  74131. private _sampleSphere;
  74132. /**
  74133. * Blur filter offsets
  74134. */
  74135. private _samplerOffsets;
  74136. private _expensiveBlur;
  74137. /**
  74138. * If bilateral blur should be used
  74139. */
  74140. set expensiveBlur(b: boolean);
  74141. get expensiveBlur(): boolean;
  74142. /**
  74143. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74144. */
  74145. radius: number;
  74146. /**
  74147. * The base color of the SSAO post-process
  74148. * The final result is "base + ssao" between [0, 1]
  74149. */
  74150. base: number;
  74151. /**
  74152. * Support test.
  74153. */
  74154. static get IsSupported(): boolean;
  74155. private _scene;
  74156. private _randomTexture;
  74157. private _originalColorPostProcess;
  74158. private _ssaoPostProcess;
  74159. private _blurHPostProcess;
  74160. private _blurVPostProcess;
  74161. private _ssaoCombinePostProcess;
  74162. private _prePassRenderer;
  74163. /**
  74164. * Gets active scene
  74165. */
  74166. get scene(): Scene;
  74167. /**
  74168. * @constructor
  74169. * @param name The rendering pipeline name
  74170. * @param scene The scene linked to this pipeline
  74171. * @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 }
  74172. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74173. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74174. */
  74175. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74176. /**
  74177. * Get the class name
  74178. * @returns "SSAO2RenderingPipeline"
  74179. */
  74180. getClassName(): string;
  74181. /**
  74182. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74183. */
  74184. dispose(disableGeometryBufferRenderer?: boolean): void;
  74185. private _createBlurPostProcess;
  74186. /** @hidden */
  74187. _rebuild(): void;
  74188. private _bits;
  74189. private _radicalInverse_VdC;
  74190. private _hammersley;
  74191. private _hemisphereSample_uniform;
  74192. private _generateHemisphere;
  74193. private _getDefinesForSSAO;
  74194. private _createSSAOPostProcess;
  74195. private _createSSAOCombinePostProcess;
  74196. private _createRandomTexture;
  74197. /**
  74198. * Serialize the rendering pipeline (Used when exporting)
  74199. * @returns the serialized object
  74200. */
  74201. serialize(): any;
  74202. /**
  74203. * Parse the serialized pipeline
  74204. * @param source Source pipeline.
  74205. * @param scene The scene to load the pipeline to.
  74206. * @param rootUrl The URL of the serialized pipeline.
  74207. * @returns An instantiated pipeline from the serialized object.
  74208. */
  74209. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74210. /**
  74211. * Sets the required values to the prepass renderer.
  74212. * @param prePassRenderer defines the prepass renderer to setup
  74213. * @returns true if the pre pass is needed.
  74214. */
  74215. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74216. }
  74217. }
  74218. declare module "babylonjs/Shaders/ssao.fragment" {
  74219. /** @hidden */
  74220. export var ssaoPixelShader: {
  74221. name: string;
  74222. shader: string;
  74223. };
  74224. }
  74225. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74226. import { Camera } from "babylonjs/Cameras/camera";
  74227. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74228. import { Scene } from "babylonjs/scene";
  74229. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74230. import "babylonjs/Shaders/ssao.fragment";
  74231. import "babylonjs/Shaders/ssaoCombine.fragment";
  74232. /**
  74233. * Render pipeline to produce ssao effect
  74234. */
  74235. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74236. /**
  74237. * @ignore
  74238. * The PassPostProcess id in the pipeline that contains the original scene color
  74239. */
  74240. SSAOOriginalSceneColorEffect: string;
  74241. /**
  74242. * @ignore
  74243. * The SSAO PostProcess id in the pipeline
  74244. */
  74245. SSAORenderEffect: string;
  74246. /**
  74247. * @ignore
  74248. * The horizontal blur PostProcess id in the pipeline
  74249. */
  74250. SSAOBlurHRenderEffect: string;
  74251. /**
  74252. * @ignore
  74253. * The vertical blur PostProcess id in the pipeline
  74254. */
  74255. SSAOBlurVRenderEffect: string;
  74256. /**
  74257. * @ignore
  74258. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74259. */
  74260. SSAOCombineRenderEffect: string;
  74261. /**
  74262. * The output strength of the SSAO post-process. Default value is 1.0.
  74263. */
  74264. totalStrength: number;
  74265. /**
  74266. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74267. */
  74268. radius: number;
  74269. /**
  74270. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74271. * Must not be equal to fallOff and superior to fallOff.
  74272. * Default value is 0.0075
  74273. */
  74274. area: number;
  74275. /**
  74276. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74277. * Must not be equal to area and inferior to area.
  74278. * Default value is 0.000001
  74279. */
  74280. fallOff: number;
  74281. /**
  74282. * The base color of the SSAO post-process
  74283. * The final result is "base + ssao" between [0, 1]
  74284. */
  74285. base: number;
  74286. private _scene;
  74287. private _depthTexture;
  74288. private _randomTexture;
  74289. private _originalColorPostProcess;
  74290. private _ssaoPostProcess;
  74291. private _blurHPostProcess;
  74292. private _blurVPostProcess;
  74293. private _ssaoCombinePostProcess;
  74294. private _firstUpdate;
  74295. /**
  74296. * Gets active scene
  74297. */
  74298. get scene(): Scene;
  74299. /**
  74300. * @constructor
  74301. * @param name - The rendering pipeline name
  74302. * @param scene - The scene linked to this pipeline
  74303. * @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 }
  74304. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74305. */
  74306. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74307. /**
  74308. * Get the class name
  74309. * @returns "SSAORenderingPipeline"
  74310. */
  74311. getClassName(): string;
  74312. /**
  74313. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74314. */
  74315. dispose(disableDepthRender?: boolean): void;
  74316. private _createBlurPostProcess;
  74317. /** @hidden */
  74318. _rebuild(): void;
  74319. private _createSSAOPostProcess;
  74320. private _createSSAOCombinePostProcess;
  74321. private _createRandomTexture;
  74322. }
  74323. }
  74324. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74325. /** @hidden */
  74326. export var screenSpaceReflectionPixelShader: {
  74327. name: string;
  74328. shader: string;
  74329. };
  74330. }
  74331. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74332. import { Nullable } from "babylonjs/types";
  74333. import { Camera } from "babylonjs/Cameras/camera";
  74334. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74335. import { Scene } from "babylonjs/scene";
  74336. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74337. import { Engine } from "babylonjs/Engines/engine";
  74338. /**
  74339. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74340. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74341. */
  74342. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74343. /**
  74344. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74345. */
  74346. threshold: number;
  74347. /**
  74348. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74349. */
  74350. strength: number;
  74351. /**
  74352. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74353. */
  74354. reflectionSpecularFalloffExponent: number;
  74355. /**
  74356. * 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]
  74357. */
  74358. step: number;
  74359. /**
  74360. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74361. */
  74362. roughnessFactor: number;
  74363. private _geometryBufferRenderer;
  74364. private _enableSmoothReflections;
  74365. private _reflectionSamples;
  74366. private _smoothSteps;
  74367. /**
  74368. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74369. * @param name The name of the effect.
  74370. * @param scene The scene containing the objects to calculate reflections.
  74371. * @param options The required width/height ratio to downsize to before computing the render pass.
  74372. * @param camera The camera to apply the render pass to.
  74373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74374. * @param engine The engine which the post process will be applied. (default: current engine)
  74375. * @param reusable If the post process can be reused on the same frame. (default: false)
  74376. * @param textureType Type of textures used when performing the post process. (default: 0)
  74377. * @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)
  74378. */
  74379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74380. /**
  74381. * Gets wether or not smoothing reflections is enabled.
  74382. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74383. */
  74384. get enableSmoothReflections(): boolean;
  74385. /**
  74386. * Sets wether or not smoothing reflections is enabled.
  74387. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74388. */
  74389. set enableSmoothReflections(enabled: boolean);
  74390. /**
  74391. * Gets the number of samples taken while computing reflections. More samples count is high,
  74392. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74393. */
  74394. get reflectionSamples(): number;
  74395. /**
  74396. * Sets the number of samples taken while computing reflections. More samples count is high,
  74397. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74398. */
  74399. set reflectionSamples(samples: number);
  74400. /**
  74401. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74402. * more the post-process will require GPU power and can generate a drop in FPS.
  74403. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74404. */
  74405. get smoothSteps(): number;
  74406. set smoothSteps(steps: number);
  74407. private _updateEffectDefines;
  74408. }
  74409. }
  74410. declare module "babylonjs/Shaders/standard.fragment" {
  74411. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74412. /** @hidden */
  74413. export var standardPixelShader: {
  74414. name: string;
  74415. shader: string;
  74416. };
  74417. }
  74418. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74419. import { Nullable } from "babylonjs/types";
  74420. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74421. import { Camera } from "babylonjs/Cameras/camera";
  74422. import { Texture } from "babylonjs/Materials/Textures/texture";
  74423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74424. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74425. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74426. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74427. import { IDisposable } from "babylonjs/scene";
  74428. import { SpotLight } from "babylonjs/Lights/spotLight";
  74429. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74430. import { Scene } from "babylonjs/scene";
  74431. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74432. import { Animation } from "babylonjs/Animations/animation";
  74433. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74434. import "babylonjs/Shaders/standard.fragment";
  74435. /**
  74436. * Standard rendering pipeline
  74437. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74438. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74439. */
  74440. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74441. /**
  74442. * Public members
  74443. */
  74444. /**
  74445. * Post-process which contains the original scene color before the pipeline applies all the effects
  74446. */
  74447. originalPostProcess: Nullable<PostProcess>;
  74448. /**
  74449. * Post-process used to down scale an image x4
  74450. */
  74451. downSampleX4PostProcess: Nullable<PostProcess>;
  74452. /**
  74453. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74454. */
  74455. brightPassPostProcess: Nullable<PostProcess>;
  74456. /**
  74457. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74458. */
  74459. blurHPostProcesses: PostProcess[];
  74460. /**
  74461. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74462. */
  74463. blurVPostProcesses: PostProcess[];
  74464. /**
  74465. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74466. */
  74467. textureAdderPostProcess: Nullable<PostProcess>;
  74468. /**
  74469. * Post-process used to create volumetric lighting effect
  74470. */
  74471. volumetricLightPostProcess: Nullable<PostProcess>;
  74472. /**
  74473. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74474. */
  74475. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74476. /**
  74477. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74478. */
  74479. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74480. /**
  74481. * Post-process used to merge the volumetric light effect and the real scene color
  74482. */
  74483. volumetricLightMergePostProces: Nullable<PostProcess>;
  74484. /**
  74485. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74486. */
  74487. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74488. /**
  74489. * Base post-process used to calculate the average luminance of the final image for HDR
  74490. */
  74491. luminancePostProcess: Nullable<PostProcess>;
  74492. /**
  74493. * Post-processes used to create down sample post-processes in order to get
  74494. * the average luminance of the final image for HDR
  74495. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74496. */
  74497. luminanceDownSamplePostProcesses: PostProcess[];
  74498. /**
  74499. * Post-process used to create a HDR effect (light adaptation)
  74500. */
  74501. hdrPostProcess: Nullable<PostProcess>;
  74502. /**
  74503. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74504. */
  74505. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74506. /**
  74507. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74508. */
  74509. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74510. /**
  74511. * Post-process used to merge the final HDR post-process and the real scene color
  74512. */
  74513. hdrFinalPostProcess: Nullable<PostProcess>;
  74514. /**
  74515. * Post-process used to create a lens flare effect
  74516. */
  74517. lensFlarePostProcess: Nullable<PostProcess>;
  74518. /**
  74519. * Post-process that merges the result of the lens flare post-process and the real scene color
  74520. */
  74521. lensFlareComposePostProcess: Nullable<PostProcess>;
  74522. /**
  74523. * Post-process used to create a motion blur effect
  74524. */
  74525. motionBlurPostProcess: Nullable<PostProcess>;
  74526. /**
  74527. * Post-process used to create a depth of field effect
  74528. */
  74529. depthOfFieldPostProcess: Nullable<PostProcess>;
  74530. /**
  74531. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74532. */
  74533. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74534. /**
  74535. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74536. */
  74537. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74538. /**
  74539. * Represents the brightness threshold in order to configure the illuminated surfaces
  74540. */
  74541. brightThreshold: number;
  74542. /**
  74543. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74544. */
  74545. blurWidth: number;
  74546. /**
  74547. * Sets if the blur for highlighted surfaces must be only horizontal
  74548. */
  74549. horizontalBlur: boolean;
  74550. /**
  74551. * Gets the overall exposure used by the pipeline
  74552. */
  74553. get exposure(): number;
  74554. /**
  74555. * Sets the overall exposure used by the pipeline
  74556. */
  74557. set exposure(value: number);
  74558. /**
  74559. * Texture used typically to simulate "dirty" on camera lens
  74560. */
  74561. lensTexture: Nullable<Texture>;
  74562. /**
  74563. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74564. */
  74565. volumetricLightCoefficient: number;
  74566. /**
  74567. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74568. */
  74569. volumetricLightPower: number;
  74570. /**
  74571. * Used the set the blur intensity to smooth the volumetric lights
  74572. */
  74573. volumetricLightBlurScale: number;
  74574. /**
  74575. * Light (spot or directional) used to generate the volumetric lights rays
  74576. * The source light must have a shadow generate so the pipeline can get its
  74577. * depth map
  74578. */
  74579. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74580. /**
  74581. * For eye adaptation, represents the minimum luminance the eye can see
  74582. */
  74583. hdrMinimumLuminance: number;
  74584. /**
  74585. * For eye adaptation, represents the decrease luminance speed
  74586. */
  74587. hdrDecreaseRate: number;
  74588. /**
  74589. * For eye adaptation, represents the increase luminance speed
  74590. */
  74591. hdrIncreaseRate: number;
  74592. /**
  74593. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74594. */
  74595. get hdrAutoExposure(): boolean;
  74596. /**
  74597. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74598. */
  74599. set hdrAutoExposure(value: boolean);
  74600. /**
  74601. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74602. */
  74603. lensColorTexture: Nullable<Texture>;
  74604. /**
  74605. * The overall strengh for the lens flare effect
  74606. */
  74607. lensFlareStrength: number;
  74608. /**
  74609. * Dispersion coefficient for lens flare ghosts
  74610. */
  74611. lensFlareGhostDispersal: number;
  74612. /**
  74613. * Main lens flare halo width
  74614. */
  74615. lensFlareHaloWidth: number;
  74616. /**
  74617. * Based on the lens distortion effect, defines how much the lens flare result
  74618. * is distorted
  74619. */
  74620. lensFlareDistortionStrength: number;
  74621. /**
  74622. * Configures the blur intensity used for for lens flare (halo)
  74623. */
  74624. lensFlareBlurWidth: number;
  74625. /**
  74626. * Lens star texture must be used to simulate rays on the flares and is available
  74627. * in the documentation
  74628. */
  74629. lensStarTexture: Nullable<Texture>;
  74630. /**
  74631. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74632. * flare effect by taking account of the dirt texture
  74633. */
  74634. lensFlareDirtTexture: Nullable<Texture>;
  74635. /**
  74636. * Represents the focal length for the depth of field effect
  74637. */
  74638. depthOfFieldDistance: number;
  74639. /**
  74640. * Represents the blur intensity for the blurred part of the depth of field effect
  74641. */
  74642. depthOfFieldBlurWidth: number;
  74643. /**
  74644. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74645. */
  74646. get motionStrength(): number;
  74647. /**
  74648. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74649. */
  74650. set motionStrength(strength: number);
  74651. /**
  74652. * Gets wether or not the motion blur post-process is object based or screen based.
  74653. */
  74654. get objectBasedMotionBlur(): boolean;
  74655. /**
  74656. * Sets wether or not the motion blur post-process should be object based or screen based
  74657. */
  74658. set objectBasedMotionBlur(value: boolean);
  74659. /**
  74660. * List of animations for the pipeline (IAnimatable implementation)
  74661. */
  74662. animations: Animation[];
  74663. /**
  74664. * Private members
  74665. */
  74666. private _scene;
  74667. private _currentDepthOfFieldSource;
  74668. private _basePostProcess;
  74669. private _fixedExposure;
  74670. private _currentExposure;
  74671. private _hdrAutoExposure;
  74672. private _hdrCurrentLuminance;
  74673. private _motionStrength;
  74674. private _isObjectBasedMotionBlur;
  74675. private _floatTextureType;
  74676. private _camerasToBeAttached;
  74677. private _ratio;
  74678. private _bloomEnabled;
  74679. private _depthOfFieldEnabled;
  74680. private _vlsEnabled;
  74681. private _lensFlareEnabled;
  74682. private _hdrEnabled;
  74683. private _motionBlurEnabled;
  74684. private _fxaaEnabled;
  74685. private _screenSpaceReflectionsEnabled;
  74686. private _motionBlurSamples;
  74687. private _volumetricLightStepsCount;
  74688. private _samples;
  74689. /**
  74690. * @ignore
  74691. * Specifies if the bloom pipeline is enabled
  74692. */
  74693. get BloomEnabled(): boolean;
  74694. set BloomEnabled(enabled: boolean);
  74695. /**
  74696. * @ignore
  74697. * Specifies if the depth of field pipeline is enabed
  74698. */
  74699. get DepthOfFieldEnabled(): boolean;
  74700. set DepthOfFieldEnabled(enabled: boolean);
  74701. /**
  74702. * @ignore
  74703. * Specifies if the lens flare pipeline is enabed
  74704. */
  74705. get LensFlareEnabled(): boolean;
  74706. set LensFlareEnabled(enabled: boolean);
  74707. /**
  74708. * @ignore
  74709. * Specifies if the HDR pipeline is enabled
  74710. */
  74711. get HDREnabled(): boolean;
  74712. set HDREnabled(enabled: boolean);
  74713. /**
  74714. * @ignore
  74715. * Specifies if the volumetric lights scattering effect is enabled
  74716. */
  74717. get VLSEnabled(): boolean;
  74718. set VLSEnabled(enabled: boolean);
  74719. /**
  74720. * @ignore
  74721. * Specifies if the motion blur effect is enabled
  74722. */
  74723. get MotionBlurEnabled(): boolean;
  74724. set MotionBlurEnabled(enabled: boolean);
  74725. /**
  74726. * Specifies if anti-aliasing is enabled
  74727. */
  74728. get fxaaEnabled(): boolean;
  74729. set fxaaEnabled(enabled: boolean);
  74730. /**
  74731. * Specifies if screen space reflections are enabled.
  74732. */
  74733. get screenSpaceReflectionsEnabled(): boolean;
  74734. set screenSpaceReflectionsEnabled(enabled: boolean);
  74735. /**
  74736. * Specifies the number of steps used to calculate the volumetric lights
  74737. * Typically in interval [50, 200]
  74738. */
  74739. get volumetricLightStepsCount(): number;
  74740. set volumetricLightStepsCount(count: number);
  74741. /**
  74742. * Specifies the number of samples used for the motion blur effect
  74743. * Typically in interval [16, 64]
  74744. */
  74745. get motionBlurSamples(): number;
  74746. set motionBlurSamples(samples: number);
  74747. /**
  74748. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74749. */
  74750. get samples(): number;
  74751. set samples(sampleCount: number);
  74752. /**
  74753. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74754. * @constructor
  74755. * @param name The rendering pipeline name
  74756. * @param scene The scene linked to this pipeline
  74757. * @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)
  74758. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74759. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74760. */
  74761. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74762. private _buildPipeline;
  74763. private _createDownSampleX4PostProcess;
  74764. private _createBrightPassPostProcess;
  74765. private _createBlurPostProcesses;
  74766. private _createTextureAdderPostProcess;
  74767. private _createVolumetricLightPostProcess;
  74768. private _createLuminancePostProcesses;
  74769. private _createHdrPostProcess;
  74770. private _createLensFlarePostProcess;
  74771. private _createDepthOfFieldPostProcess;
  74772. private _createMotionBlurPostProcess;
  74773. private _getDepthTexture;
  74774. private _disposePostProcesses;
  74775. /**
  74776. * Dispose of the pipeline and stop all post processes
  74777. */
  74778. dispose(): void;
  74779. /**
  74780. * Serialize the rendering pipeline (Used when exporting)
  74781. * @returns the serialized object
  74782. */
  74783. serialize(): any;
  74784. /**
  74785. * Parse the serialized pipeline
  74786. * @param source Source pipeline.
  74787. * @param scene The scene to load the pipeline to.
  74788. * @param rootUrl The URL of the serialized pipeline.
  74789. * @returns An instantiated pipeline from the serialized object.
  74790. */
  74791. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74792. /**
  74793. * Luminance steps
  74794. */
  74795. static LuminanceSteps: number;
  74796. }
  74797. }
  74798. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74799. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74800. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74801. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74802. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74803. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74804. }
  74805. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74806. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74807. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74808. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74809. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74810. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74811. }
  74812. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74813. /** @hidden */
  74814. export var stereoscopicInterlacePixelShader: {
  74815. name: string;
  74816. shader: string;
  74817. };
  74818. }
  74819. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74820. import { Camera } from "babylonjs/Cameras/camera";
  74821. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74822. import { Engine } from "babylonjs/Engines/engine";
  74823. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74824. /**
  74825. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74826. */
  74827. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74828. private _stepSize;
  74829. private _passedProcess;
  74830. /**
  74831. * Initializes a StereoscopicInterlacePostProcessI
  74832. * @param name The name of the effect.
  74833. * @param rigCameras The rig cameras to be appled to the post process
  74834. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74835. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74837. * @param engine The engine which the post process will be applied. (default: current engine)
  74838. * @param reusable If the post process can be reused on the same frame. (default: false)
  74839. */
  74840. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74841. }
  74842. /**
  74843. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74844. */
  74845. export class StereoscopicInterlacePostProcess extends PostProcess {
  74846. private _stepSize;
  74847. private _passedProcess;
  74848. /**
  74849. * Initializes a StereoscopicInterlacePostProcess
  74850. * @param name The name of the effect.
  74851. * @param rigCameras The rig cameras to be appled to the post process
  74852. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74854. * @param engine The engine which the post process will be applied. (default: current engine)
  74855. * @param reusable If the post process can be reused on the same frame. (default: false)
  74856. */
  74857. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74858. }
  74859. }
  74860. declare module "babylonjs/Shaders/tonemap.fragment" {
  74861. /** @hidden */
  74862. export var tonemapPixelShader: {
  74863. name: string;
  74864. shader: string;
  74865. };
  74866. }
  74867. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74868. import { Camera } from "babylonjs/Cameras/camera";
  74869. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74870. import "babylonjs/Shaders/tonemap.fragment";
  74871. import { Engine } from "babylonjs/Engines/engine";
  74872. /** Defines operator used for tonemapping */
  74873. export enum TonemappingOperator {
  74874. /** Hable */
  74875. Hable = 0,
  74876. /** Reinhard */
  74877. Reinhard = 1,
  74878. /** HejiDawson */
  74879. HejiDawson = 2,
  74880. /** Photographic */
  74881. Photographic = 3
  74882. }
  74883. /**
  74884. * Defines a post process to apply tone mapping
  74885. */
  74886. export class TonemapPostProcess extends PostProcess {
  74887. private _operator;
  74888. /** Defines the required exposure adjustement */
  74889. exposureAdjustment: number;
  74890. /**
  74891. * Creates a new TonemapPostProcess
  74892. * @param name defines the name of the postprocess
  74893. * @param _operator defines the operator to use
  74894. * @param exposureAdjustment defines the required exposure adjustement
  74895. * @param camera defines the camera to use (can be null)
  74896. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74897. * @param engine defines the hosting engine (can be ignore if camera is set)
  74898. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74899. */
  74900. constructor(name: string, _operator: TonemappingOperator,
  74901. /** Defines the required exposure adjustement */
  74902. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74903. }
  74904. }
  74905. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74906. /** @hidden */
  74907. export var volumetricLightScatteringPixelShader: {
  74908. name: string;
  74909. shader: string;
  74910. };
  74911. }
  74912. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74913. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74914. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74916. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74918. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74919. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74920. /** @hidden */
  74921. export var volumetricLightScatteringPassVertexShader: {
  74922. name: string;
  74923. shader: string;
  74924. };
  74925. }
  74926. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74927. /** @hidden */
  74928. export var volumetricLightScatteringPassPixelShader: {
  74929. name: string;
  74930. shader: string;
  74931. };
  74932. }
  74933. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74934. import { Vector3 } from "babylonjs/Maths/math.vector";
  74935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74936. import { Mesh } from "babylonjs/Meshes/mesh";
  74937. import { Camera } from "babylonjs/Cameras/camera";
  74938. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74939. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74940. import { Scene } from "babylonjs/scene";
  74941. import "babylonjs/Meshes/Builders/planeBuilder";
  74942. import "babylonjs/Shaders/depth.vertex";
  74943. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74944. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74945. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74946. import { Engine } from "babylonjs/Engines/engine";
  74947. /**
  74948. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74949. */
  74950. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74951. private _volumetricLightScatteringPass;
  74952. private _volumetricLightScatteringRTT;
  74953. private _viewPort;
  74954. private _screenCoordinates;
  74955. private _cachedDefines;
  74956. /**
  74957. * If not undefined, the mesh position is computed from the attached node position
  74958. */
  74959. attachedNode: {
  74960. position: Vector3;
  74961. };
  74962. /**
  74963. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74964. */
  74965. customMeshPosition: Vector3;
  74966. /**
  74967. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74968. */
  74969. useCustomMeshPosition: boolean;
  74970. /**
  74971. * If the post-process should inverse the light scattering direction
  74972. */
  74973. invert: boolean;
  74974. /**
  74975. * The internal mesh used by the post-process
  74976. */
  74977. mesh: Mesh;
  74978. /**
  74979. * @hidden
  74980. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74981. */
  74982. get useDiffuseColor(): boolean;
  74983. set useDiffuseColor(useDiffuseColor: boolean);
  74984. /**
  74985. * Array containing the excluded meshes not rendered in the internal pass
  74986. */
  74987. excludedMeshes: AbstractMesh[];
  74988. /**
  74989. * Controls the overall intensity of the post-process
  74990. */
  74991. exposure: number;
  74992. /**
  74993. * Dissipates each sample's contribution in range [0, 1]
  74994. */
  74995. decay: number;
  74996. /**
  74997. * Controls the overall intensity of each sample
  74998. */
  74999. weight: number;
  75000. /**
  75001. * Controls the density of each sample
  75002. */
  75003. density: number;
  75004. /**
  75005. * @constructor
  75006. * @param name The post-process name
  75007. * @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)
  75008. * @param camera The camera that the post-process will be attached to
  75009. * @param mesh The mesh used to create the light scattering
  75010. * @param samples The post-process quality, default 100
  75011. * @param samplingModeThe post-process filtering mode
  75012. * @param engine The babylon engine
  75013. * @param reusable If the post-process is reusable
  75014. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75015. */
  75016. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75017. /**
  75018. * Returns the string "VolumetricLightScatteringPostProcess"
  75019. * @returns "VolumetricLightScatteringPostProcess"
  75020. */
  75021. getClassName(): string;
  75022. private _isReady;
  75023. /**
  75024. * Sets the new light position for light scattering effect
  75025. * @param position The new custom light position
  75026. */
  75027. setCustomMeshPosition(position: Vector3): void;
  75028. /**
  75029. * Returns the light position for light scattering effect
  75030. * @return Vector3 The custom light position
  75031. */
  75032. getCustomMeshPosition(): Vector3;
  75033. /**
  75034. * Disposes the internal assets and detaches the post-process from the camera
  75035. */
  75036. dispose(camera: Camera): void;
  75037. /**
  75038. * Returns the render target texture used by the post-process
  75039. * @return the render target texture used by the post-process
  75040. */
  75041. getPass(): RenderTargetTexture;
  75042. private _meshExcluded;
  75043. private _createPass;
  75044. private _updateMeshScreenCoordinates;
  75045. /**
  75046. * Creates a default mesh for the Volumeric Light Scattering post-process
  75047. * @param name The mesh name
  75048. * @param scene The scene where to create the mesh
  75049. * @return the default mesh
  75050. */
  75051. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75052. }
  75053. }
  75054. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75055. /** @hidden */
  75056. export var screenSpaceCurvaturePixelShader: {
  75057. name: string;
  75058. shader: string;
  75059. };
  75060. }
  75061. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75062. import { Nullable } from "babylonjs/types";
  75063. import { Camera } from "babylonjs/Cameras/camera";
  75064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75065. import { Scene } from "babylonjs/scene";
  75066. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75067. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75068. import { Engine } from "babylonjs/Engines/engine";
  75069. /**
  75070. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75071. */
  75072. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75073. /**
  75074. * Defines how much ridge the curvature effect displays.
  75075. */
  75076. ridge: number;
  75077. /**
  75078. * Defines how much valley the curvature effect displays.
  75079. */
  75080. valley: number;
  75081. private _geometryBufferRenderer;
  75082. /**
  75083. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75084. * @param name The name of the effect.
  75085. * @param scene The scene containing the objects to blur according to their velocity.
  75086. * @param options The required width/height ratio to downsize to before computing the render pass.
  75087. * @param camera The camera to apply the render pass to.
  75088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75089. * @param engine The engine which the post process will be applied. (default: current engine)
  75090. * @param reusable If the post process can be reused on the same frame. (default: false)
  75091. * @param textureType Type of textures used when performing the post process. (default: 0)
  75092. * @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)
  75093. */
  75094. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75095. /**
  75096. * Support test.
  75097. */
  75098. static get IsSupported(): boolean;
  75099. }
  75100. }
  75101. declare module "babylonjs/PostProcesses/index" {
  75102. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75103. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75104. export * from "babylonjs/PostProcesses/bloomEffect";
  75105. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75106. export * from "babylonjs/PostProcesses/blurPostProcess";
  75107. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75108. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75109. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75110. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75111. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75112. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75113. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75114. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75115. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75116. export * from "babylonjs/PostProcesses/filterPostProcess";
  75117. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75118. export * from "babylonjs/PostProcesses/grainPostProcess";
  75119. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75120. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75121. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75122. export * from "babylonjs/PostProcesses/passPostProcess";
  75123. export * from "babylonjs/PostProcesses/postProcess";
  75124. export * from "babylonjs/PostProcesses/postProcessManager";
  75125. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75126. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75127. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75128. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75129. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75130. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75131. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75132. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75133. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75134. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75135. }
  75136. declare module "babylonjs/Probes/index" {
  75137. export * from "babylonjs/Probes/reflectionProbe";
  75138. }
  75139. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75140. import { Scene } from "babylonjs/scene";
  75141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75142. import { SmartArray } from "babylonjs/Misc/smartArray";
  75143. import { ISceneComponent } from "babylonjs/sceneComponent";
  75144. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75145. import "babylonjs/Meshes/Builders/boxBuilder";
  75146. import "babylonjs/Shaders/color.fragment";
  75147. import "babylonjs/Shaders/color.vertex";
  75148. import { Color3 } from "babylonjs/Maths/math.color";
  75149. import { Observable } from "babylonjs/Misc/observable";
  75150. module "babylonjs/scene" {
  75151. interface Scene {
  75152. /** @hidden (Backing field) */
  75153. _boundingBoxRenderer: BoundingBoxRenderer;
  75154. /** @hidden (Backing field) */
  75155. _forceShowBoundingBoxes: boolean;
  75156. /**
  75157. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75158. */
  75159. forceShowBoundingBoxes: boolean;
  75160. /**
  75161. * Gets the bounding box renderer associated with the scene
  75162. * @returns a BoundingBoxRenderer
  75163. */
  75164. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75165. }
  75166. }
  75167. module "babylonjs/Meshes/abstractMesh" {
  75168. interface AbstractMesh {
  75169. /** @hidden (Backing field) */
  75170. _showBoundingBox: boolean;
  75171. /**
  75172. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75173. */
  75174. showBoundingBox: boolean;
  75175. }
  75176. }
  75177. /**
  75178. * Component responsible of rendering the bounding box of the meshes in a scene.
  75179. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75180. */
  75181. export class BoundingBoxRenderer implements ISceneComponent {
  75182. /**
  75183. * The component name helpfull to identify the component in the list of scene components.
  75184. */
  75185. readonly name: string;
  75186. /**
  75187. * The scene the component belongs to.
  75188. */
  75189. scene: Scene;
  75190. /**
  75191. * Color of the bounding box lines placed in front of an object
  75192. */
  75193. frontColor: Color3;
  75194. /**
  75195. * Color of the bounding box lines placed behind an object
  75196. */
  75197. backColor: Color3;
  75198. /**
  75199. * Defines if the renderer should show the back lines or not
  75200. */
  75201. showBackLines: boolean;
  75202. /**
  75203. * Observable raised before rendering a bounding box
  75204. */
  75205. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75206. /**
  75207. * Observable raised after rendering a bounding box
  75208. */
  75209. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75210. /**
  75211. * @hidden
  75212. */
  75213. renderList: SmartArray<BoundingBox>;
  75214. private _colorShader;
  75215. private _vertexBuffers;
  75216. private _indexBuffer;
  75217. private _fillIndexBuffer;
  75218. private _fillIndexData;
  75219. /**
  75220. * Instantiates a new bounding box renderer in a scene.
  75221. * @param scene the scene the renderer renders in
  75222. */
  75223. constructor(scene: Scene);
  75224. /**
  75225. * Registers the component in a given scene
  75226. */
  75227. register(): void;
  75228. private _evaluateSubMesh;
  75229. private _activeMesh;
  75230. private _prepareRessources;
  75231. private _createIndexBuffer;
  75232. /**
  75233. * Rebuilds the elements related to this component in case of
  75234. * context lost for instance.
  75235. */
  75236. rebuild(): void;
  75237. /**
  75238. * @hidden
  75239. */
  75240. reset(): void;
  75241. /**
  75242. * Render the bounding boxes of a specific rendering group
  75243. * @param renderingGroupId defines the rendering group to render
  75244. */
  75245. render(renderingGroupId: number): void;
  75246. /**
  75247. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75248. * @param mesh Define the mesh to render the occlusion bounding box for
  75249. */
  75250. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75251. /**
  75252. * Dispose and release the resources attached to this renderer.
  75253. */
  75254. dispose(): void;
  75255. }
  75256. }
  75257. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75258. import { Nullable } from "babylonjs/types";
  75259. import { Scene } from "babylonjs/scene";
  75260. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75261. import { Camera } from "babylonjs/Cameras/camera";
  75262. import { ISceneComponent } from "babylonjs/sceneComponent";
  75263. module "babylonjs/scene" {
  75264. interface Scene {
  75265. /** @hidden (Backing field) */
  75266. _depthRenderer: {
  75267. [id: string]: DepthRenderer;
  75268. };
  75269. /**
  75270. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75271. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75272. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75273. * @returns the created depth renderer
  75274. */
  75275. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75276. /**
  75277. * Disables a depth renderer for a given camera
  75278. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75279. */
  75280. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75281. }
  75282. }
  75283. /**
  75284. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75285. * in several rendering techniques.
  75286. */
  75287. export class DepthRendererSceneComponent implements ISceneComponent {
  75288. /**
  75289. * The component name helpfull to identify the component in the list of scene components.
  75290. */
  75291. readonly name: string;
  75292. /**
  75293. * The scene the component belongs to.
  75294. */
  75295. scene: Scene;
  75296. /**
  75297. * Creates a new instance of the component for the given scene
  75298. * @param scene Defines the scene to register the component in
  75299. */
  75300. constructor(scene: Scene);
  75301. /**
  75302. * Registers the component in a given scene
  75303. */
  75304. register(): void;
  75305. /**
  75306. * Rebuilds the elements related to this component in case of
  75307. * context lost for instance.
  75308. */
  75309. rebuild(): void;
  75310. /**
  75311. * Disposes the component and the associated ressources
  75312. */
  75313. dispose(): void;
  75314. private _gatherRenderTargets;
  75315. private _gatherActiveCameraRenderTargets;
  75316. }
  75317. }
  75318. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75319. import { Nullable } from "babylonjs/types";
  75320. import { Scene } from "babylonjs/scene";
  75321. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75322. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75323. import { AbstractScene } from "babylonjs/abstractScene";
  75324. module "babylonjs/abstractScene" {
  75325. interface AbstractScene {
  75326. /** @hidden (Backing field) */
  75327. _prePassRenderer: Nullable<PrePassRenderer>;
  75328. /**
  75329. * Gets or Sets the current prepass renderer associated to the scene.
  75330. */
  75331. prePassRenderer: Nullable<PrePassRenderer>;
  75332. /**
  75333. * Enables the prepass and associates it with the scene
  75334. * @returns the PrePassRenderer
  75335. */
  75336. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75337. /**
  75338. * Disables the prepass associated with the scene
  75339. */
  75340. disablePrePassRenderer(): void;
  75341. }
  75342. }
  75343. /**
  75344. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75345. * in several rendering techniques.
  75346. */
  75347. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75348. /**
  75349. * The component name helpful to identify the component in the list of scene components.
  75350. */
  75351. readonly name: string;
  75352. /**
  75353. * The scene the component belongs to.
  75354. */
  75355. scene: Scene;
  75356. /**
  75357. * Creates a new instance of the component for the given scene
  75358. * @param scene Defines the scene to register the component in
  75359. */
  75360. constructor(scene: Scene);
  75361. /**
  75362. * Registers the component in a given scene
  75363. */
  75364. register(): void;
  75365. private _beforeCameraDraw;
  75366. private _afterCameraDraw;
  75367. private _beforeClearStage;
  75368. /**
  75369. * Serializes the component data to the specified json object
  75370. * @param serializationObject The object to serialize to
  75371. */
  75372. serialize(serializationObject: any): void;
  75373. /**
  75374. * Adds all the elements from the container to the scene
  75375. * @param container the container holding the elements
  75376. */
  75377. addFromContainer(container: AbstractScene): void;
  75378. /**
  75379. * Removes all the elements in the container from the scene
  75380. * @param container contains the elements to remove
  75381. * @param dispose if the removed element should be disposed (default: false)
  75382. */
  75383. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75384. /**
  75385. * Rebuilds the elements related to this component in case of
  75386. * context lost for instance.
  75387. */
  75388. rebuild(): void;
  75389. /**
  75390. * Disposes the component and the associated ressources
  75391. */
  75392. dispose(): void;
  75393. }
  75394. }
  75395. declare module "babylonjs/Shaders/outline.fragment" {
  75396. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75397. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75398. /** @hidden */
  75399. export var outlinePixelShader: {
  75400. name: string;
  75401. shader: string;
  75402. };
  75403. }
  75404. declare module "babylonjs/Shaders/outline.vertex" {
  75405. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75406. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75407. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75408. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75409. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75411. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75412. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75413. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75414. /** @hidden */
  75415. export var outlineVertexShader: {
  75416. name: string;
  75417. shader: string;
  75418. };
  75419. }
  75420. declare module "babylonjs/Rendering/outlineRenderer" {
  75421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75422. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75423. import { Scene } from "babylonjs/scene";
  75424. import { ISceneComponent } from "babylonjs/sceneComponent";
  75425. import "babylonjs/Shaders/outline.fragment";
  75426. import "babylonjs/Shaders/outline.vertex";
  75427. module "babylonjs/scene" {
  75428. interface Scene {
  75429. /** @hidden */
  75430. _outlineRenderer: OutlineRenderer;
  75431. /**
  75432. * Gets the outline renderer associated with the scene
  75433. * @returns a OutlineRenderer
  75434. */
  75435. getOutlineRenderer(): OutlineRenderer;
  75436. }
  75437. }
  75438. module "babylonjs/Meshes/abstractMesh" {
  75439. interface AbstractMesh {
  75440. /** @hidden (Backing field) */
  75441. _renderOutline: boolean;
  75442. /**
  75443. * Gets or sets a boolean indicating if the outline must be rendered as well
  75444. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75445. */
  75446. renderOutline: boolean;
  75447. /** @hidden (Backing field) */
  75448. _renderOverlay: boolean;
  75449. /**
  75450. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75451. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75452. */
  75453. renderOverlay: boolean;
  75454. }
  75455. }
  75456. /**
  75457. * This class is responsible to draw bothe outline/overlay of meshes.
  75458. * It should not be used directly but through the available method on mesh.
  75459. */
  75460. export class OutlineRenderer implements ISceneComponent {
  75461. /**
  75462. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75463. */
  75464. private static _StencilReference;
  75465. /**
  75466. * The name of the component. Each component must have a unique name.
  75467. */
  75468. name: string;
  75469. /**
  75470. * The scene the component belongs to.
  75471. */
  75472. scene: Scene;
  75473. /**
  75474. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75475. */
  75476. zOffset: number;
  75477. private _engine;
  75478. private _effect;
  75479. private _cachedDefines;
  75480. private _savedDepthWrite;
  75481. /**
  75482. * Instantiates a new outline renderer. (There could be only one per scene).
  75483. * @param scene Defines the scene it belongs to
  75484. */
  75485. constructor(scene: Scene);
  75486. /**
  75487. * Register the component to one instance of a scene.
  75488. */
  75489. register(): void;
  75490. /**
  75491. * Rebuilds the elements related to this component in case of
  75492. * context lost for instance.
  75493. */
  75494. rebuild(): void;
  75495. /**
  75496. * Disposes the component and the associated ressources.
  75497. */
  75498. dispose(): void;
  75499. /**
  75500. * Renders the outline in the canvas.
  75501. * @param subMesh Defines the sumesh to render
  75502. * @param batch Defines the batch of meshes in case of instances
  75503. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75504. */
  75505. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75506. /**
  75507. * Returns whether or not the outline renderer is ready for a given submesh.
  75508. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75509. * @param subMesh Defines the submesh to check readyness for
  75510. * @param useInstances Defines wheter wee are trying to render instances or not
  75511. * @returns true if ready otherwise false
  75512. */
  75513. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75514. private _beforeRenderingMesh;
  75515. private _afterRenderingMesh;
  75516. }
  75517. }
  75518. declare module "babylonjs/Rendering/index" {
  75519. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75520. export * from "babylonjs/Rendering/depthRenderer";
  75521. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75522. export * from "babylonjs/Rendering/edgesRenderer";
  75523. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75524. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75525. export * from "babylonjs/Rendering/prePassRenderer";
  75526. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75527. export * from "babylonjs/Rendering/outlineRenderer";
  75528. export * from "babylonjs/Rendering/renderingGroup";
  75529. export * from "babylonjs/Rendering/renderingManager";
  75530. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75531. }
  75532. declare module "babylonjs/Sprites/ISprites" {
  75533. /**
  75534. * Defines the basic options interface of a Sprite Frame Source Size.
  75535. */
  75536. export interface ISpriteJSONSpriteSourceSize {
  75537. /**
  75538. * number of the original width of the Frame
  75539. */
  75540. w: number;
  75541. /**
  75542. * number of the original height of the Frame
  75543. */
  75544. h: number;
  75545. }
  75546. /**
  75547. * Defines the basic options interface of a Sprite Frame Data.
  75548. */
  75549. export interface ISpriteJSONSpriteFrameData {
  75550. /**
  75551. * number of the x offset of the Frame
  75552. */
  75553. x: number;
  75554. /**
  75555. * number of the y offset of the Frame
  75556. */
  75557. y: number;
  75558. /**
  75559. * number of the width of the Frame
  75560. */
  75561. w: number;
  75562. /**
  75563. * number of the height of the Frame
  75564. */
  75565. h: number;
  75566. }
  75567. /**
  75568. * Defines the basic options interface of a JSON Sprite.
  75569. */
  75570. export interface ISpriteJSONSprite {
  75571. /**
  75572. * string name of the Frame
  75573. */
  75574. filename: string;
  75575. /**
  75576. * ISpriteJSONSpriteFrame basic object of the frame data
  75577. */
  75578. frame: ISpriteJSONSpriteFrameData;
  75579. /**
  75580. * boolean to flag is the frame was rotated.
  75581. */
  75582. rotated: boolean;
  75583. /**
  75584. * boolean to flag is the frame was trimmed.
  75585. */
  75586. trimmed: boolean;
  75587. /**
  75588. * ISpriteJSONSpriteFrame basic object of the source data
  75589. */
  75590. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75591. /**
  75592. * ISpriteJSONSpriteFrame basic object of the source data
  75593. */
  75594. sourceSize: ISpriteJSONSpriteSourceSize;
  75595. }
  75596. /**
  75597. * Defines the basic options interface of a JSON atlas.
  75598. */
  75599. export interface ISpriteJSONAtlas {
  75600. /**
  75601. * Array of objects that contain the frame data.
  75602. */
  75603. frames: Array<ISpriteJSONSprite>;
  75604. /**
  75605. * object basic object containing the sprite meta data.
  75606. */
  75607. meta?: object;
  75608. }
  75609. }
  75610. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75611. /** @hidden */
  75612. export var spriteMapPixelShader: {
  75613. name: string;
  75614. shader: string;
  75615. };
  75616. }
  75617. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75618. /** @hidden */
  75619. export var spriteMapVertexShader: {
  75620. name: string;
  75621. shader: string;
  75622. };
  75623. }
  75624. declare module "babylonjs/Sprites/spriteMap" {
  75625. import { IDisposable, Scene } from "babylonjs/scene";
  75626. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75627. import { Texture } from "babylonjs/Materials/Textures/texture";
  75628. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75629. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75630. import "babylonjs/Meshes/Builders/planeBuilder";
  75631. import "babylonjs/Shaders/spriteMap.fragment";
  75632. import "babylonjs/Shaders/spriteMap.vertex";
  75633. /**
  75634. * Defines the basic options interface of a SpriteMap
  75635. */
  75636. export interface ISpriteMapOptions {
  75637. /**
  75638. * Vector2 of the number of cells in the grid.
  75639. */
  75640. stageSize?: Vector2;
  75641. /**
  75642. * Vector2 of the size of the output plane in World Units.
  75643. */
  75644. outputSize?: Vector2;
  75645. /**
  75646. * Vector3 of the position of the output plane in World Units.
  75647. */
  75648. outputPosition?: Vector3;
  75649. /**
  75650. * Vector3 of the rotation of the output plane.
  75651. */
  75652. outputRotation?: Vector3;
  75653. /**
  75654. * number of layers that the system will reserve in resources.
  75655. */
  75656. layerCount?: number;
  75657. /**
  75658. * number of max animation frames a single cell will reserve in resources.
  75659. */
  75660. maxAnimationFrames?: number;
  75661. /**
  75662. * number cell index of the base tile when the system compiles.
  75663. */
  75664. baseTile?: number;
  75665. /**
  75666. * boolean flip the sprite after its been repositioned by the framing data.
  75667. */
  75668. flipU?: boolean;
  75669. /**
  75670. * Vector3 scalar of the global RGB values of the SpriteMap.
  75671. */
  75672. colorMultiply?: Vector3;
  75673. }
  75674. /**
  75675. * Defines the IDisposable interface in order to be cleanable from resources.
  75676. */
  75677. export interface ISpriteMap extends IDisposable {
  75678. /**
  75679. * String name of the SpriteMap.
  75680. */
  75681. name: string;
  75682. /**
  75683. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75684. */
  75685. atlasJSON: ISpriteJSONAtlas;
  75686. /**
  75687. * Texture of the SpriteMap.
  75688. */
  75689. spriteSheet: Texture;
  75690. /**
  75691. * The parameters to initialize the SpriteMap with.
  75692. */
  75693. options: ISpriteMapOptions;
  75694. }
  75695. /**
  75696. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75697. */
  75698. export class SpriteMap implements ISpriteMap {
  75699. /** The Name of the spriteMap */
  75700. name: string;
  75701. /** The JSON file with the frame and meta data */
  75702. atlasJSON: ISpriteJSONAtlas;
  75703. /** The systems Sprite Sheet Texture */
  75704. spriteSheet: Texture;
  75705. /** Arguments passed with the Constructor */
  75706. options: ISpriteMapOptions;
  75707. /** Public Sprite Storage array, parsed from atlasJSON */
  75708. sprites: Array<ISpriteJSONSprite>;
  75709. /** Returns the Number of Sprites in the System */
  75710. get spriteCount(): number;
  75711. /** Returns the Position of Output Plane*/
  75712. get position(): Vector3;
  75713. /** Returns the Position of Output Plane*/
  75714. set position(v: Vector3);
  75715. /** Returns the Rotation of Output Plane*/
  75716. get rotation(): Vector3;
  75717. /** Returns the Rotation of Output Plane*/
  75718. set rotation(v: Vector3);
  75719. /** Sets the AnimationMap*/
  75720. get animationMap(): RawTexture;
  75721. /** Sets the AnimationMap*/
  75722. set animationMap(v: RawTexture);
  75723. /** Scene that the SpriteMap was created in */
  75724. private _scene;
  75725. /** Texture Buffer of Float32 that holds tile frame data*/
  75726. private _frameMap;
  75727. /** Texture Buffers of Float32 that holds tileMap data*/
  75728. private _tileMaps;
  75729. /** Texture Buffer of Float32 that holds Animation Data*/
  75730. private _animationMap;
  75731. /** Custom ShaderMaterial Central to the System*/
  75732. private _material;
  75733. /** Custom ShaderMaterial Central to the System*/
  75734. private _output;
  75735. /** Systems Time Ticker*/
  75736. private _time;
  75737. /**
  75738. * Creates a new SpriteMap
  75739. * @param name defines the SpriteMaps Name
  75740. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75741. * @param spriteSheet is the Texture that the Sprites are on.
  75742. * @param options a basic deployment configuration
  75743. * @param scene The Scene that the map is deployed on
  75744. */
  75745. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75746. /**
  75747. * Returns tileID location
  75748. * @returns Vector2 the cell position ID
  75749. */
  75750. getTileID(): Vector2;
  75751. /**
  75752. * Gets the UV location of the mouse over the SpriteMap.
  75753. * @returns Vector2 the UV position of the mouse interaction
  75754. */
  75755. getMousePosition(): Vector2;
  75756. /**
  75757. * Creates the "frame" texture Buffer
  75758. * -------------------------------------
  75759. * Structure of frames
  75760. * "filename": "Falling-Water-2.png",
  75761. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75762. * "rotated": true,
  75763. * "trimmed": true,
  75764. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75765. * "sourceSize": {"w":32,"h":32}
  75766. * @returns RawTexture of the frameMap
  75767. */
  75768. private _createFrameBuffer;
  75769. /**
  75770. * Creates the tileMap texture Buffer
  75771. * @param buffer normally and array of numbers, or a false to generate from scratch
  75772. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75773. * @returns RawTexture of the tileMap
  75774. */
  75775. private _createTileBuffer;
  75776. /**
  75777. * Modifies the data of the tileMaps
  75778. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75779. * @param pos is the iVector2 Coordinates of the Tile
  75780. * @param tile The SpriteIndex of the new Tile
  75781. */
  75782. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75783. /**
  75784. * Creates the animationMap texture Buffer
  75785. * @param buffer normally and array of numbers, or a false to generate from scratch
  75786. * @returns RawTexture of the animationMap
  75787. */
  75788. private _createTileAnimationBuffer;
  75789. /**
  75790. * Modifies the data of the animationMap
  75791. * @param cellID is the Index of the Sprite
  75792. * @param _frame is the target Animation frame
  75793. * @param toCell is the Target Index of the next frame of the animation
  75794. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75795. * @param speed is a global scalar of the time variable on the map.
  75796. */
  75797. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75798. /**
  75799. * Exports the .tilemaps file
  75800. */
  75801. saveTileMaps(): void;
  75802. /**
  75803. * Imports the .tilemaps file
  75804. * @param url of the .tilemaps file
  75805. */
  75806. loadTileMaps(url: string): void;
  75807. /**
  75808. * Release associated resources
  75809. */
  75810. dispose(): void;
  75811. }
  75812. }
  75813. declare module "babylonjs/Sprites/spritePackedManager" {
  75814. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75815. import { Scene } from "babylonjs/scene";
  75816. /**
  75817. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75818. * @see https://doc.babylonjs.com/babylon101/sprites
  75819. */
  75820. export class SpritePackedManager extends SpriteManager {
  75821. /** defines the packed manager's name */
  75822. name: string;
  75823. /**
  75824. * Creates a new sprite manager from a packed sprite sheet
  75825. * @param name defines the manager's name
  75826. * @param imgUrl defines the sprite sheet url
  75827. * @param capacity defines the maximum allowed number of sprites
  75828. * @param scene defines the hosting scene
  75829. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75830. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75831. * @param samplingMode defines the smapling mode to use with spritesheet
  75832. * @param fromPacked set to true; do not alter
  75833. */
  75834. constructor(
  75835. /** defines the packed manager's name */
  75836. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75837. }
  75838. }
  75839. declare module "babylonjs/Sprites/index" {
  75840. export * from "babylonjs/Sprites/sprite";
  75841. export * from "babylonjs/Sprites/ISprites";
  75842. export * from "babylonjs/Sprites/spriteManager";
  75843. export * from "babylonjs/Sprites/spriteMap";
  75844. export * from "babylonjs/Sprites/spritePackedManager";
  75845. export * from "babylonjs/Sprites/spriteSceneComponent";
  75846. }
  75847. declare module "babylonjs/States/index" {
  75848. export * from "babylonjs/States/alphaCullingState";
  75849. export * from "babylonjs/States/depthCullingState";
  75850. export * from "babylonjs/States/stencilState";
  75851. }
  75852. declare module "babylonjs/Misc/assetsManager" {
  75853. import { Scene } from "babylonjs/scene";
  75854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75856. import { Skeleton } from "babylonjs/Bones/skeleton";
  75857. import { Observable } from "babylonjs/Misc/observable";
  75858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75859. import { Texture } from "babylonjs/Materials/Textures/texture";
  75860. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75861. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75862. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75863. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75864. import { AssetContainer } from "babylonjs/assetContainer";
  75865. /**
  75866. * Defines the list of states available for a task inside a AssetsManager
  75867. */
  75868. export enum AssetTaskState {
  75869. /**
  75870. * Initialization
  75871. */
  75872. INIT = 0,
  75873. /**
  75874. * Running
  75875. */
  75876. RUNNING = 1,
  75877. /**
  75878. * Done
  75879. */
  75880. DONE = 2,
  75881. /**
  75882. * Error
  75883. */
  75884. ERROR = 3
  75885. }
  75886. /**
  75887. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75888. */
  75889. export abstract class AbstractAssetTask {
  75890. /**
  75891. * Task name
  75892. */ name: string;
  75893. /**
  75894. * Callback called when the task is successful
  75895. */
  75896. onSuccess: (task: any) => void;
  75897. /**
  75898. * Callback called when the task is not successful
  75899. */
  75900. onError: (task: any, message?: string, exception?: any) => void;
  75901. /**
  75902. * Creates a new AssetsManager
  75903. * @param name defines the name of the task
  75904. */
  75905. constructor(
  75906. /**
  75907. * Task name
  75908. */ name: string);
  75909. private _isCompleted;
  75910. private _taskState;
  75911. private _errorObject;
  75912. /**
  75913. * Get if the task is completed
  75914. */
  75915. get isCompleted(): boolean;
  75916. /**
  75917. * Gets the current state of the task
  75918. */
  75919. get taskState(): AssetTaskState;
  75920. /**
  75921. * Gets the current error object (if task is in error)
  75922. */
  75923. get errorObject(): {
  75924. message?: string;
  75925. exception?: any;
  75926. };
  75927. /**
  75928. * Internal only
  75929. * @hidden
  75930. */
  75931. _setErrorObject(message?: string, exception?: any): void;
  75932. /**
  75933. * Execute the current task
  75934. * @param scene defines the scene where you want your assets to be loaded
  75935. * @param onSuccess is a callback called when the task is successfully executed
  75936. * @param onError is a callback called if an error occurs
  75937. */
  75938. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75939. /**
  75940. * Execute the current task
  75941. * @param scene defines the scene where you want your assets to be loaded
  75942. * @param onSuccess is a callback called when the task is successfully executed
  75943. * @param onError is a callback called if an error occurs
  75944. */
  75945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75946. /**
  75947. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75948. * This can be used with failed tasks that have the reason for failure fixed.
  75949. */
  75950. reset(): void;
  75951. private onErrorCallback;
  75952. private onDoneCallback;
  75953. }
  75954. /**
  75955. * Define the interface used by progress events raised during assets loading
  75956. */
  75957. export interface IAssetsProgressEvent {
  75958. /**
  75959. * Defines the number of remaining tasks to process
  75960. */
  75961. remainingCount: number;
  75962. /**
  75963. * Defines the total number of tasks
  75964. */
  75965. totalCount: number;
  75966. /**
  75967. * Defines the task that was just processed
  75968. */
  75969. task: AbstractAssetTask;
  75970. }
  75971. /**
  75972. * Class used to share progress information about assets loading
  75973. */
  75974. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75975. /**
  75976. * Defines the number of remaining tasks to process
  75977. */
  75978. remainingCount: number;
  75979. /**
  75980. * Defines the total number of tasks
  75981. */
  75982. totalCount: number;
  75983. /**
  75984. * Defines the task that was just processed
  75985. */
  75986. task: AbstractAssetTask;
  75987. /**
  75988. * Creates a AssetsProgressEvent
  75989. * @param remainingCount defines the number of remaining tasks to process
  75990. * @param totalCount defines the total number of tasks
  75991. * @param task defines the task that was just processed
  75992. */
  75993. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75994. }
  75995. /**
  75996. * Define a task used by AssetsManager to load assets into a container
  75997. */
  75998. export class ContainerAssetTask extends AbstractAssetTask {
  75999. /**
  76000. * Defines the name of the task
  76001. */
  76002. name: string;
  76003. /**
  76004. * Defines the list of mesh's names you want to load
  76005. */
  76006. meshesNames: any;
  76007. /**
  76008. * Defines the root url to use as a base to load your meshes and associated resources
  76009. */
  76010. rootUrl: string;
  76011. /**
  76012. * Defines the filename or File of the scene to load from
  76013. */
  76014. sceneFilename: string | File;
  76015. /**
  76016. * Get the loaded asset container
  76017. */
  76018. loadedContainer: AssetContainer;
  76019. /**
  76020. * Gets the list of loaded meshes
  76021. */
  76022. loadedMeshes: Array<AbstractMesh>;
  76023. /**
  76024. * Gets the list of loaded particle systems
  76025. */
  76026. loadedParticleSystems: Array<IParticleSystem>;
  76027. /**
  76028. * Gets the list of loaded skeletons
  76029. */
  76030. loadedSkeletons: Array<Skeleton>;
  76031. /**
  76032. * Gets the list of loaded animation groups
  76033. */
  76034. loadedAnimationGroups: Array<AnimationGroup>;
  76035. /**
  76036. * Callback called when the task is successful
  76037. */
  76038. onSuccess: (task: ContainerAssetTask) => void;
  76039. /**
  76040. * Callback called when the task is successful
  76041. */
  76042. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76043. /**
  76044. * Creates a new ContainerAssetTask
  76045. * @param name defines the name of the task
  76046. * @param meshesNames defines the list of mesh's names you want to load
  76047. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76048. * @param sceneFilename defines the filename or File of the scene to load from
  76049. */
  76050. constructor(
  76051. /**
  76052. * Defines the name of the task
  76053. */
  76054. name: string,
  76055. /**
  76056. * Defines the list of mesh's names you want to load
  76057. */
  76058. meshesNames: any,
  76059. /**
  76060. * Defines the root url to use as a base to load your meshes and associated resources
  76061. */
  76062. rootUrl: string,
  76063. /**
  76064. * Defines the filename or File of the scene to load from
  76065. */
  76066. sceneFilename: string | File);
  76067. /**
  76068. * Execute the current task
  76069. * @param scene defines the scene where you want your assets to be loaded
  76070. * @param onSuccess is a callback called when the task is successfully executed
  76071. * @param onError is a callback called if an error occurs
  76072. */
  76073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76074. }
  76075. /**
  76076. * Define a task used by AssetsManager to load meshes
  76077. */
  76078. export class MeshAssetTask extends AbstractAssetTask {
  76079. /**
  76080. * Defines the name of the task
  76081. */
  76082. name: string;
  76083. /**
  76084. * Defines the list of mesh's names you want to load
  76085. */
  76086. meshesNames: any;
  76087. /**
  76088. * Defines the root url to use as a base to load your meshes and associated resources
  76089. */
  76090. rootUrl: string;
  76091. /**
  76092. * Defines the filename or File of the scene to load from
  76093. */
  76094. sceneFilename: string | File;
  76095. /**
  76096. * Gets the list of loaded meshes
  76097. */
  76098. loadedMeshes: Array<AbstractMesh>;
  76099. /**
  76100. * Gets the list of loaded particle systems
  76101. */
  76102. loadedParticleSystems: Array<IParticleSystem>;
  76103. /**
  76104. * Gets the list of loaded skeletons
  76105. */
  76106. loadedSkeletons: Array<Skeleton>;
  76107. /**
  76108. * Gets the list of loaded animation groups
  76109. */
  76110. loadedAnimationGroups: Array<AnimationGroup>;
  76111. /**
  76112. * Callback called when the task is successful
  76113. */
  76114. onSuccess: (task: MeshAssetTask) => void;
  76115. /**
  76116. * Callback called when the task is successful
  76117. */
  76118. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76119. /**
  76120. * Creates a new MeshAssetTask
  76121. * @param name defines the name of the task
  76122. * @param meshesNames defines the list of mesh's names you want to load
  76123. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76124. * @param sceneFilename defines the filename or File of the scene to load from
  76125. */
  76126. constructor(
  76127. /**
  76128. * Defines the name of the task
  76129. */
  76130. name: string,
  76131. /**
  76132. * Defines the list of mesh's names you want to load
  76133. */
  76134. meshesNames: any,
  76135. /**
  76136. * Defines the root url to use as a base to load your meshes and associated resources
  76137. */
  76138. rootUrl: string,
  76139. /**
  76140. * Defines the filename or File of the scene to load from
  76141. */
  76142. sceneFilename: string | File);
  76143. /**
  76144. * Execute the current task
  76145. * @param scene defines the scene where you want your assets to be loaded
  76146. * @param onSuccess is a callback called when the task is successfully executed
  76147. * @param onError is a callback called if an error occurs
  76148. */
  76149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76150. }
  76151. /**
  76152. * Define a task used by AssetsManager to load text content
  76153. */
  76154. export class TextFileAssetTask extends AbstractAssetTask {
  76155. /**
  76156. * Defines the name of the task
  76157. */
  76158. name: string;
  76159. /**
  76160. * Defines the location of the file to load
  76161. */
  76162. url: string;
  76163. /**
  76164. * Gets the loaded text string
  76165. */
  76166. text: string;
  76167. /**
  76168. * Callback called when the task is successful
  76169. */
  76170. onSuccess: (task: TextFileAssetTask) => void;
  76171. /**
  76172. * Callback called when the task is successful
  76173. */
  76174. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76175. /**
  76176. * Creates a new TextFileAssetTask object
  76177. * @param name defines the name of the task
  76178. * @param url defines the location of the file to load
  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. * Execute the current task
  76191. * @param scene defines the scene where you want your assets to be loaded
  76192. * @param onSuccess is a callback called when the task is successfully executed
  76193. * @param onError is a callback called if an error occurs
  76194. */
  76195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76196. }
  76197. /**
  76198. * Define a task used by AssetsManager to load binary data
  76199. */
  76200. export class BinaryFileAssetTask extends AbstractAssetTask {
  76201. /**
  76202. * Defines the name of the task
  76203. */
  76204. name: string;
  76205. /**
  76206. * Defines the location of the file to load
  76207. */
  76208. url: string;
  76209. /**
  76210. * Gets the lodaded data (as an array buffer)
  76211. */
  76212. data: ArrayBuffer;
  76213. /**
  76214. * Callback called when the task is successful
  76215. */
  76216. onSuccess: (task: BinaryFileAssetTask) => void;
  76217. /**
  76218. * Callback called when the task is successful
  76219. */
  76220. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76221. /**
  76222. * Creates a new BinaryFileAssetTask object
  76223. * @param name defines the name of the new task
  76224. * @param url defines the location of the file to load
  76225. */
  76226. constructor(
  76227. /**
  76228. * Defines the name of the task
  76229. */
  76230. name: string,
  76231. /**
  76232. * Defines the location of the file to load
  76233. */
  76234. url: string);
  76235. /**
  76236. * Execute the current task
  76237. * @param scene defines the scene where you want your assets to be loaded
  76238. * @param onSuccess is a callback called when the task is successfully executed
  76239. * @param onError is a callback called if an error occurs
  76240. */
  76241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76242. }
  76243. /**
  76244. * Define a task used by AssetsManager to load images
  76245. */
  76246. export class ImageAssetTask extends AbstractAssetTask {
  76247. /**
  76248. * Defines the name of the task
  76249. */
  76250. name: string;
  76251. /**
  76252. * Defines the location of the image to load
  76253. */
  76254. url: string;
  76255. /**
  76256. * Gets the loaded images
  76257. */
  76258. image: HTMLImageElement;
  76259. /**
  76260. * Callback called when the task is successful
  76261. */
  76262. onSuccess: (task: ImageAssetTask) => void;
  76263. /**
  76264. * Callback called when the task is successful
  76265. */
  76266. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76267. /**
  76268. * Creates a new ImageAssetTask
  76269. * @param name defines the name of the task
  76270. * @param url defines the location of the image to load
  76271. */
  76272. constructor(
  76273. /**
  76274. * Defines the name of the task
  76275. */
  76276. name: string,
  76277. /**
  76278. * Defines the location of the image to load
  76279. */
  76280. url: string);
  76281. /**
  76282. * Execute the current task
  76283. * @param scene defines the scene where you want your assets to be loaded
  76284. * @param onSuccess is a callback called when the task is successfully executed
  76285. * @param onError is a callback called if an error occurs
  76286. */
  76287. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76288. }
  76289. /**
  76290. * Defines the interface used by texture loading tasks
  76291. */
  76292. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76293. /**
  76294. * Gets the loaded texture
  76295. */
  76296. texture: TEX;
  76297. }
  76298. /**
  76299. * Define a task used by AssetsManager to load 2D textures
  76300. */
  76301. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76302. /**
  76303. * Defines the name of the task
  76304. */
  76305. name: string;
  76306. /**
  76307. * Defines the location of the file to load
  76308. */
  76309. url: string;
  76310. /**
  76311. * Defines if mipmap should not be generated (default is false)
  76312. */
  76313. noMipmap?: boolean | undefined;
  76314. /**
  76315. * Defines if texture must be inverted on Y axis (default is true)
  76316. */
  76317. invertY: boolean;
  76318. /**
  76319. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76320. */
  76321. samplingMode: number;
  76322. /**
  76323. * Gets the loaded texture
  76324. */
  76325. texture: Texture;
  76326. /**
  76327. * Callback called when the task is successful
  76328. */
  76329. onSuccess: (task: TextureAssetTask) => void;
  76330. /**
  76331. * Callback called when the task is successful
  76332. */
  76333. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76334. /**
  76335. * Creates a new TextureAssetTask object
  76336. * @param name defines the name of the task
  76337. * @param url defines the location of the file to load
  76338. * @param noMipmap defines if mipmap should not be generated (default is false)
  76339. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76340. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76341. */
  76342. constructor(
  76343. /**
  76344. * Defines the name of the task
  76345. */
  76346. name: string,
  76347. /**
  76348. * Defines the location of the file to load
  76349. */
  76350. url: string,
  76351. /**
  76352. * Defines if mipmap should not be generated (default is false)
  76353. */
  76354. noMipmap?: boolean | undefined,
  76355. /**
  76356. * Defines if texture must be inverted on Y axis (default is true)
  76357. */
  76358. invertY?: boolean,
  76359. /**
  76360. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76361. */
  76362. samplingMode?: number);
  76363. /**
  76364. * Execute the current task
  76365. * @param scene defines the scene where you want your assets to be loaded
  76366. * @param onSuccess is a callback called when the task is successfully executed
  76367. * @param onError is a callback called if an error occurs
  76368. */
  76369. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76370. }
  76371. /**
  76372. * Define a task used by AssetsManager to load cube textures
  76373. */
  76374. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76375. /**
  76376. * Defines the name of the task
  76377. */
  76378. name: string;
  76379. /**
  76380. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76381. */
  76382. url: string;
  76383. /**
  76384. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76385. */
  76386. extensions?: string[] | undefined;
  76387. /**
  76388. * Defines if mipmaps should not be generated (default is false)
  76389. */
  76390. noMipmap?: boolean | undefined;
  76391. /**
  76392. * Defines the explicit list of files (undefined by default)
  76393. */
  76394. files?: string[] | undefined;
  76395. /**
  76396. * Gets the loaded texture
  76397. */
  76398. texture: CubeTexture;
  76399. /**
  76400. * Callback called when the task is successful
  76401. */
  76402. onSuccess: (task: CubeTextureAssetTask) => void;
  76403. /**
  76404. * Callback called when the task is successful
  76405. */
  76406. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76407. /**
  76408. * Creates a new CubeTextureAssetTask
  76409. * @param name defines the name of the task
  76410. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76411. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76412. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76413. * @param files defines the explicit list of files (undefined by default)
  76414. */
  76415. constructor(
  76416. /**
  76417. * Defines the name of the task
  76418. */
  76419. name: string,
  76420. /**
  76421. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76422. */
  76423. url: string,
  76424. /**
  76425. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76426. */
  76427. extensions?: string[] | undefined,
  76428. /**
  76429. * Defines if mipmaps should not be generated (default is false)
  76430. */
  76431. noMipmap?: boolean | undefined,
  76432. /**
  76433. * Defines the explicit list of files (undefined by default)
  76434. */
  76435. files?: string[] | undefined);
  76436. /**
  76437. * Execute the current task
  76438. * @param scene defines the scene where you want your assets to be loaded
  76439. * @param onSuccess is a callback called when the task is successfully executed
  76440. * @param onError is a callback called if an error occurs
  76441. */
  76442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76443. }
  76444. /**
  76445. * Define a task used by AssetsManager to load HDR cube textures
  76446. */
  76447. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76448. /**
  76449. * Defines the name of the task
  76450. */
  76451. name: string;
  76452. /**
  76453. * Defines the location of the file to load
  76454. */
  76455. url: string;
  76456. /**
  76457. * Defines the desired size (the more it increases the longer the generation will be)
  76458. */
  76459. size: number;
  76460. /**
  76461. * Defines if mipmaps should not be generated (default is false)
  76462. */
  76463. noMipmap: boolean;
  76464. /**
  76465. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76466. */
  76467. generateHarmonics: boolean;
  76468. /**
  76469. * 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)
  76470. */
  76471. gammaSpace: boolean;
  76472. /**
  76473. * Internal Use Only
  76474. */
  76475. reserved: boolean;
  76476. /**
  76477. * Gets the loaded texture
  76478. */
  76479. texture: HDRCubeTexture;
  76480. /**
  76481. * Callback called when the task is successful
  76482. */
  76483. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76484. /**
  76485. * Callback called when the task is successful
  76486. */
  76487. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76488. /**
  76489. * Creates a new HDRCubeTextureAssetTask object
  76490. * @param name defines the name of the task
  76491. * @param url defines the location of the file to load
  76492. * @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.
  76493. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76494. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76495. * @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)
  76496. * @param reserved Internal use only
  76497. */
  76498. constructor(
  76499. /**
  76500. * Defines the name of the task
  76501. */
  76502. name: string,
  76503. /**
  76504. * Defines the location of the file to load
  76505. */
  76506. url: string,
  76507. /**
  76508. * Defines the desired size (the more it increases the longer the generation will be)
  76509. */
  76510. size: number,
  76511. /**
  76512. * Defines if mipmaps should not be generated (default is false)
  76513. */
  76514. noMipmap?: boolean,
  76515. /**
  76516. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76517. */
  76518. generateHarmonics?: boolean,
  76519. /**
  76520. * 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)
  76521. */
  76522. gammaSpace?: boolean,
  76523. /**
  76524. * Internal Use Only
  76525. */
  76526. reserved?: boolean);
  76527. /**
  76528. * Execute the current task
  76529. * @param scene defines the scene where you want your assets to be loaded
  76530. * @param onSuccess is a callback called when the task is successfully executed
  76531. * @param onError is a callback called if an error occurs
  76532. */
  76533. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76534. }
  76535. /**
  76536. * Define a task used by AssetsManager to load Equirectangular cube textures
  76537. */
  76538. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76539. /**
  76540. * Defines the name of the task
  76541. */
  76542. name: string;
  76543. /**
  76544. * Defines the location of the file to load
  76545. */
  76546. url: string;
  76547. /**
  76548. * Defines the desired size (the more it increases the longer the generation will be)
  76549. */
  76550. size: number;
  76551. /**
  76552. * Defines if mipmaps should not be generated (default is false)
  76553. */
  76554. noMipmap: boolean;
  76555. /**
  76556. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76557. * but the standard material would require them in Gamma space) (default is true)
  76558. */
  76559. gammaSpace: boolean;
  76560. /**
  76561. * Gets the loaded texture
  76562. */
  76563. texture: EquiRectangularCubeTexture;
  76564. /**
  76565. * Callback called when the task is successful
  76566. */
  76567. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76568. /**
  76569. * Callback called when the task is successful
  76570. */
  76571. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76572. /**
  76573. * Creates a new EquiRectangularCubeTextureAssetTask object
  76574. * @param name defines the name of the task
  76575. * @param url defines the location of the file to load
  76576. * @param size defines the desired size (the more it increases the longer the generation will be)
  76577. * If the size is omitted this implies you are using a preprocessed cubemap.
  76578. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76579. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76580. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76581. * (default is true)
  76582. */
  76583. constructor(
  76584. /**
  76585. * Defines the name of the task
  76586. */
  76587. name: string,
  76588. /**
  76589. * Defines the location of the file to load
  76590. */
  76591. url: string,
  76592. /**
  76593. * Defines the desired size (the more it increases the longer the generation will be)
  76594. */
  76595. size: number,
  76596. /**
  76597. * Defines if mipmaps should not be generated (default is false)
  76598. */
  76599. noMipmap?: boolean,
  76600. /**
  76601. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76602. * but the standard material would require them in Gamma space) (default is true)
  76603. */
  76604. gammaSpace?: boolean);
  76605. /**
  76606. * Execute the current task
  76607. * @param scene defines the scene where you want your assets to be loaded
  76608. * @param onSuccess is a callback called when the task is successfully executed
  76609. * @param onError is a callback called if an error occurs
  76610. */
  76611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76612. }
  76613. /**
  76614. * This class can be used to easily import assets into a scene
  76615. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76616. */
  76617. export class AssetsManager {
  76618. private _scene;
  76619. private _isLoading;
  76620. protected _tasks: AbstractAssetTask[];
  76621. protected _waitingTasksCount: number;
  76622. protected _totalTasksCount: number;
  76623. /**
  76624. * Callback called when all tasks are processed
  76625. */
  76626. onFinish: (tasks: AbstractAssetTask[]) => void;
  76627. /**
  76628. * Callback called when a task is successful
  76629. */
  76630. onTaskSuccess: (task: AbstractAssetTask) => void;
  76631. /**
  76632. * Callback called when a task had an error
  76633. */
  76634. onTaskError: (task: AbstractAssetTask) => void;
  76635. /**
  76636. * Callback called when a task is done (whatever the result is)
  76637. */
  76638. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76639. /**
  76640. * Observable called when all tasks are processed
  76641. */
  76642. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76643. /**
  76644. * Observable called when a task had an error
  76645. */
  76646. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76647. /**
  76648. * Observable called when all tasks were executed
  76649. */
  76650. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76651. /**
  76652. * Observable called when a task is done (whatever the result is)
  76653. */
  76654. onProgressObservable: Observable<IAssetsProgressEvent>;
  76655. /**
  76656. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76657. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76658. */
  76659. useDefaultLoadingScreen: boolean;
  76660. /**
  76661. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76662. * when all assets have been downloaded.
  76663. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76664. */
  76665. autoHideLoadingUI: boolean;
  76666. /**
  76667. * Creates a new AssetsManager
  76668. * @param scene defines the scene to work on
  76669. */
  76670. constructor(scene: Scene);
  76671. /**
  76672. * Add a ContainerAssetTask to the list of active tasks
  76673. * @param taskName defines the name of the new task
  76674. * @param meshesNames defines the name of meshes to load
  76675. * @param rootUrl defines the root url to use to locate files
  76676. * @param sceneFilename defines the filename of the scene file
  76677. * @returns a new ContainerAssetTask object
  76678. */
  76679. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  76680. /**
  76681. * Add a MeshAssetTask to the list of active tasks
  76682. * @param taskName defines the name of the new task
  76683. * @param meshesNames defines the name of meshes to load
  76684. * @param rootUrl defines the root url to use to locate files
  76685. * @param sceneFilename defines the filename of the scene file
  76686. * @returns a new MeshAssetTask object
  76687. */
  76688. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76689. /**
  76690. * Add a TextFileAssetTask to the list of active tasks
  76691. * @param taskName defines the name of the new task
  76692. * @param url defines the url of the file to load
  76693. * @returns a new TextFileAssetTask object
  76694. */
  76695. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76696. /**
  76697. * Add a BinaryFileAssetTask to the list of active tasks
  76698. * @param taskName defines the name of the new task
  76699. * @param url defines the url of the file to load
  76700. * @returns a new BinaryFileAssetTask object
  76701. */
  76702. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76703. /**
  76704. * Add a ImageAssetTask to the list of active tasks
  76705. * @param taskName defines the name of the new task
  76706. * @param url defines the url of the file to load
  76707. * @returns a new ImageAssetTask object
  76708. */
  76709. addImageTask(taskName: string, url: string): ImageAssetTask;
  76710. /**
  76711. * Add a TextureAssetTask to the list of active tasks
  76712. * @param taskName defines the name of the new task
  76713. * @param url defines the url of the file to load
  76714. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76715. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76716. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76717. * @returns a new TextureAssetTask object
  76718. */
  76719. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76720. /**
  76721. * Add a CubeTextureAssetTask to the list of active tasks
  76722. * @param taskName defines the name of the new task
  76723. * @param url defines the url of the file to load
  76724. * @param extensions defines the extension to use to load the cube map (can be null)
  76725. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76726. * @param files defines the list of files to load (can be null)
  76727. * @returns a new CubeTextureAssetTask object
  76728. */
  76729. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76730. /**
  76731. *
  76732. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76733. * @param taskName defines the name of the new task
  76734. * @param url defines the url of the file to load
  76735. * @param size defines the size you want for the cubemap (can be null)
  76736. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76737. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76738. * @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)
  76739. * @param reserved Internal use only
  76740. * @returns a new HDRCubeTextureAssetTask object
  76741. */
  76742. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76743. /**
  76744. *
  76745. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76746. * @param taskName defines the name of the new task
  76747. * @param url defines the url of the file to load
  76748. * @param size defines the size you want for the cubemap (can be null)
  76749. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76750. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76751. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76752. * @returns a new EquiRectangularCubeTextureAssetTask object
  76753. */
  76754. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76755. /**
  76756. * Remove a task from the assets manager.
  76757. * @param task the task to remove
  76758. */
  76759. removeTask(task: AbstractAssetTask): void;
  76760. private _decreaseWaitingTasksCount;
  76761. private _runTask;
  76762. /**
  76763. * Reset the AssetsManager and remove all tasks
  76764. * @return the current instance of the AssetsManager
  76765. */
  76766. reset(): AssetsManager;
  76767. /**
  76768. * Start the loading process
  76769. * @return the current instance of the AssetsManager
  76770. */
  76771. load(): AssetsManager;
  76772. /**
  76773. * Start the loading process as an async operation
  76774. * @return a promise returning the list of failed tasks
  76775. */
  76776. loadAsync(): Promise<void>;
  76777. }
  76778. }
  76779. declare module "babylonjs/Misc/deferred" {
  76780. /**
  76781. * Wrapper class for promise with external resolve and reject.
  76782. */
  76783. export class Deferred<T> {
  76784. /**
  76785. * The promise associated with this deferred object.
  76786. */
  76787. readonly promise: Promise<T>;
  76788. private _resolve;
  76789. private _reject;
  76790. /**
  76791. * The resolve method of the promise associated with this deferred object.
  76792. */
  76793. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76794. /**
  76795. * The reject method of the promise associated with this deferred object.
  76796. */
  76797. get reject(): (reason?: any) => void;
  76798. /**
  76799. * Constructor for this deferred object.
  76800. */
  76801. constructor();
  76802. }
  76803. }
  76804. declare module "babylonjs/Misc/meshExploder" {
  76805. import { Mesh } from "babylonjs/Meshes/mesh";
  76806. /**
  76807. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76808. */
  76809. export class MeshExploder {
  76810. private _centerMesh;
  76811. private _meshes;
  76812. private _meshesOrigins;
  76813. private _toCenterVectors;
  76814. private _scaledDirection;
  76815. private _newPosition;
  76816. private _centerPosition;
  76817. /**
  76818. * Explodes meshes from a center mesh.
  76819. * @param meshes The meshes to explode.
  76820. * @param centerMesh The mesh to be center of explosion.
  76821. */
  76822. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76823. private _setCenterMesh;
  76824. /**
  76825. * Get class name
  76826. * @returns "MeshExploder"
  76827. */
  76828. getClassName(): string;
  76829. /**
  76830. * "Exploded meshes"
  76831. * @returns Array of meshes with the centerMesh at index 0.
  76832. */
  76833. getMeshes(): Array<Mesh>;
  76834. /**
  76835. * Explodes meshes giving a specific direction
  76836. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76837. */
  76838. explode(direction?: number): void;
  76839. }
  76840. }
  76841. declare module "babylonjs/Misc/filesInput" {
  76842. import { Engine } from "babylonjs/Engines/engine";
  76843. import { Scene } from "babylonjs/scene";
  76844. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76845. import { Nullable } from "babylonjs/types";
  76846. /**
  76847. * Class used to help managing file picking and drag'n'drop
  76848. */
  76849. export class FilesInput {
  76850. /**
  76851. * List of files ready to be loaded
  76852. */
  76853. static get FilesToLoad(): {
  76854. [key: string]: File;
  76855. };
  76856. /**
  76857. * Callback called when a file is processed
  76858. */
  76859. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76860. private _engine;
  76861. private _currentScene;
  76862. private _sceneLoadedCallback;
  76863. private _progressCallback;
  76864. private _additionalRenderLoopLogicCallback;
  76865. private _textureLoadingCallback;
  76866. private _startingProcessingFilesCallback;
  76867. private _onReloadCallback;
  76868. private _errorCallback;
  76869. private _elementToMonitor;
  76870. private _sceneFileToLoad;
  76871. private _filesToLoad;
  76872. /**
  76873. * Creates a new FilesInput
  76874. * @param engine defines the rendering engine
  76875. * @param scene defines the hosting scene
  76876. * @param sceneLoadedCallback callback called when scene is loaded
  76877. * @param progressCallback callback called to track progress
  76878. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76879. * @param textureLoadingCallback callback called when a texture is loading
  76880. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76881. * @param onReloadCallback callback called when a reload is requested
  76882. * @param errorCallback callback call if an error occurs
  76883. */
  76884. 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>);
  76885. private _dragEnterHandler;
  76886. private _dragOverHandler;
  76887. private _dropHandler;
  76888. /**
  76889. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76890. * @param elementToMonitor defines the DOM element to track
  76891. */
  76892. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76893. /** Gets the current list of files to load */
  76894. get filesToLoad(): File[];
  76895. /**
  76896. * Release all associated resources
  76897. */
  76898. dispose(): void;
  76899. private renderFunction;
  76900. private drag;
  76901. private drop;
  76902. private _traverseFolder;
  76903. private _processFiles;
  76904. /**
  76905. * Load files from a drop event
  76906. * @param event defines the drop event to use as source
  76907. */
  76908. loadFiles(event: any): void;
  76909. private _processReload;
  76910. /**
  76911. * Reload the current scene from the loaded files
  76912. */
  76913. reload(): void;
  76914. }
  76915. }
  76916. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76917. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76918. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76919. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76920. }
  76921. declare module "babylonjs/Misc/sceneOptimizer" {
  76922. import { Scene, IDisposable } from "babylonjs/scene";
  76923. import { Observable } from "babylonjs/Misc/observable";
  76924. /**
  76925. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76926. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76927. */
  76928. export class SceneOptimization {
  76929. /**
  76930. * Defines the priority of this optimization (0 by default which means first in the list)
  76931. */
  76932. priority: number;
  76933. /**
  76934. * Gets a string describing the action executed by the current optimization
  76935. * @returns description string
  76936. */
  76937. getDescription(): string;
  76938. /**
  76939. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76940. * @param scene defines the current scene where to apply this optimization
  76941. * @param optimizer defines the current optimizer
  76942. * @returns true if everything that can be done was applied
  76943. */
  76944. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76945. /**
  76946. * Creates the SceneOptimization object
  76947. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76948. * @param desc defines the description associated with the optimization
  76949. */
  76950. constructor(
  76951. /**
  76952. * Defines the priority of this optimization (0 by default which means first in the list)
  76953. */
  76954. priority?: number);
  76955. }
  76956. /**
  76957. * Defines an optimization used to reduce the size of render target textures
  76958. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76959. */
  76960. export class TextureOptimization extends SceneOptimization {
  76961. /**
  76962. * Defines the priority of this optimization (0 by default which means first in the list)
  76963. */
  76964. priority: number;
  76965. /**
  76966. * 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
  76967. */
  76968. maximumSize: number;
  76969. /**
  76970. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76971. */
  76972. step: number;
  76973. /**
  76974. * Gets a string describing the action executed by the current optimization
  76975. * @returns description string
  76976. */
  76977. getDescription(): string;
  76978. /**
  76979. * Creates the TextureOptimization object
  76980. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76981. * @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
  76982. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76983. */
  76984. constructor(
  76985. /**
  76986. * Defines the priority of this optimization (0 by default which means first in the list)
  76987. */
  76988. priority?: number,
  76989. /**
  76990. * 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
  76991. */
  76992. maximumSize?: number,
  76993. /**
  76994. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76995. */
  76996. step?: number);
  76997. /**
  76998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76999. * @param scene defines the current scene where to apply this optimization
  77000. * @param optimizer defines the current optimizer
  77001. * @returns true if everything that can be done was applied
  77002. */
  77003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77004. }
  77005. /**
  77006. * Defines an optimization used to increase or decrease the rendering resolution
  77007. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77008. */
  77009. export class HardwareScalingOptimization extends SceneOptimization {
  77010. /**
  77011. * Defines the priority of this optimization (0 by default which means first in the list)
  77012. */
  77013. priority: number;
  77014. /**
  77015. * Defines the maximum scale to use (2 by default)
  77016. */
  77017. maximumScale: number;
  77018. /**
  77019. * Defines the step to use between two passes (0.5 by default)
  77020. */
  77021. step: number;
  77022. private _currentScale;
  77023. private _directionOffset;
  77024. /**
  77025. * Gets a string describing the action executed by the current optimization
  77026. * @return description string
  77027. */
  77028. getDescription(): string;
  77029. /**
  77030. * Creates the HardwareScalingOptimization object
  77031. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77032. * @param maximumScale defines the maximum scale to use (2 by default)
  77033. * @param step defines the step to use between two passes (0.5 by default)
  77034. */
  77035. constructor(
  77036. /**
  77037. * Defines the priority of this optimization (0 by default which means first in the list)
  77038. */
  77039. priority?: number,
  77040. /**
  77041. * Defines the maximum scale to use (2 by default)
  77042. */
  77043. maximumScale?: number,
  77044. /**
  77045. * Defines the step to use between two passes (0.5 by default)
  77046. */
  77047. step?: number);
  77048. /**
  77049. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77050. * @param scene defines the current scene where to apply this optimization
  77051. * @param optimizer defines the current optimizer
  77052. * @returns true if everything that can be done was applied
  77053. */
  77054. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77055. }
  77056. /**
  77057. * Defines an optimization used to remove shadows
  77058. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77059. */
  77060. export class ShadowsOptimization extends SceneOptimization {
  77061. /**
  77062. * Gets a string describing the action executed by the current optimization
  77063. * @return description string
  77064. */
  77065. getDescription(): string;
  77066. /**
  77067. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77068. * @param scene defines the current scene where to apply this optimization
  77069. * @param optimizer defines the current optimizer
  77070. * @returns true if everything that can be done was applied
  77071. */
  77072. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77073. }
  77074. /**
  77075. * Defines an optimization used to turn post-processes off
  77076. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77077. */
  77078. export class PostProcessesOptimization extends SceneOptimization {
  77079. /**
  77080. * Gets a string describing the action executed by the current optimization
  77081. * @return description string
  77082. */
  77083. getDescription(): string;
  77084. /**
  77085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77086. * @param scene defines the current scene where to apply this optimization
  77087. * @param optimizer defines the current optimizer
  77088. * @returns true if everything that can be done was applied
  77089. */
  77090. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77091. }
  77092. /**
  77093. * Defines an optimization used to turn lens flares off
  77094. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77095. */
  77096. export class LensFlaresOptimization extends SceneOptimization {
  77097. /**
  77098. * Gets a string describing the action executed by the current optimization
  77099. * @return description string
  77100. */
  77101. getDescription(): string;
  77102. /**
  77103. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77104. * @param scene defines the current scene where to apply this optimization
  77105. * @param optimizer defines the current optimizer
  77106. * @returns true if everything that can be done was applied
  77107. */
  77108. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77109. }
  77110. /**
  77111. * Defines an optimization based on user defined callback.
  77112. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77113. */
  77114. export class CustomOptimization extends SceneOptimization {
  77115. /**
  77116. * Callback called to apply the custom optimization.
  77117. */
  77118. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77119. /**
  77120. * Callback called to get custom description
  77121. */
  77122. onGetDescription: () => string;
  77123. /**
  77124. * Gets a string describing the action executed by the current optimization
  77125. * @returns description string
  77126. */
  77127. getDescription(): string;
  77128. /**
  77129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77130. * @param scene defines the current scene where to apply this optimization
  77131. * @param optimizer defines the current optimizer
  77132. * @returns true if everything that can be done was applied
  77133. */
  77134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77135. }
  77136. /**
  77137. * Defines an optimization used to turn particles off
  77138. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77139. */
  77140. export class ParticlesOptimization extends SceneOptimization {
  77141. /**
  77142. * Gets a string describing the action executed by the current optimization
  77143. * @return description string
  77144. */
  77145. getDescription(): string;
  77146. /**
  77147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77148. * @param scene defines the current scene where to apply this optimization
  77149. * @param optimizer defines the current optimizer
  77150. * @returns true if everything that can be done was applied
  77151. */
  77152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77153. }
  77154. /**
  77155. * Defines an optimization used to turn render targets off
  77156. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77157. */
  77158. export class RenderTargetsOptimization extends SceneOptimization {
  77159. /**
  77160. * Gets a string describing the action executed by the current optimization
  77161. * @return description string
  77162. */
  77163. getDescription(): string;
  77164. /**
  77165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77166. * @param scene defines the current scene where to apply this optimization
  77167. * @param optimizer defines the current optimizer
  77168. * @returns true if everything that can be done was applied
  77169. */
  77170. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77171. }
  77172. /**
  77173. * Defines an optimization used to merge meshes with compatible materials
  77174. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77175. */
  77176. export class MergeMeshesOptimization extends SceneOptimization {
  77177. private static _UpdateSelectionTree;
  77178. /**
  77179. * Gets or sets a boolean which defines if optimization octree has to be updated
  77180. */
  77181. static get UpdateSelectionTree(): boolean;
  77182. /**
  77183. * Gets or sets a boolean which defines if optimization octree has to be updated
  77184. */
  77185. static set UpdateSelectionTree(value: boolean);
  77186. /**
  77187. * Gets a string describing the action executed by the current optimization
  77188. * @return description string
  77189. */
  77190. getDescription(): string;
  77191. private _canBeMerged;
  77192. /**
  77193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77194. * @param scene defines the current scene where to apply this optimization
  77195. * @param optimizer defines the current optimizer
  77196. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77197. * @returns true if everything that can be done was applied
  77198. */
  77199. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77200. }
  77201. /**
  77202. * Defines a list of options used by SceneOptimizer
  77203. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77204. */
  77205. export class SceneOptimizerOptions {
  77206. /**
  77207. * Defines the target frame rate to reach (60 by default)
  77208. */
  77209. targetFrameRate: number;
  77210. /**
  77211. * Defines the interval between two checkes (2000ms by default)
  77212. */
  77213. trackerDuration: number;
  77214. /**
  77215. * Gets the list of optimizations to apply
  77216. */
  77217. optimizations: SceneOptimization[];
  77218. /**
  77219. * Creates a new list of options used by SceneOptimizer
  77220. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77221. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77222. */
  77223. constructor(
  77224. /**
  77225. * Defines the target frame rate to reach (60 by default)
  77226. */
  77227. targetFrameRate?: number,
  77228. /**
  77229. * Defines the interval between two checkes (2000ms by default)
  77230. */
  77231. trackerDuration?: number);
  77232. /**
  77233. * Add a new optimization
  77234. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77235. * @returns the current SceneOptimizerOptions
  77236. */
  77237. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77238. /**
  77239. * Add a new custom optimization
  77240. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77241. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77242. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77243. * @returns the current SceneOptimizerOptions
  77244. */
  77245. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77246. /**
  77247. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77248. * @param targetFrameRate defines the target frame rate (60 by default)
  77249. * @returns a SceneOptimizerOptions object
  77250. */
  77251. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77252. /**
  77253. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77254. * @param targetFrameRate defines the target frame rate (60 by default)
  77255. * @returns a SceneOptimizerOptions object
  77256. */
  77257. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77258. /**
  77259. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77260. * @param targetFrameRate defines the target frame rate (60 by default)
  77261. * @returns a SceneOptimizerOptions object
  77262. */
  77263. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77264. }
  77265. /**
  77266. * Class used to run optimizations in order to reach a target frame rate
  77267. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77268. */
  77269. export class SceneOptimizer implements IDisposable {
  77270. private _isRunning;
  77271. private _options;
  77272. private _scene;
  77273. private _currentPriorityLevel;
  77274. private _targetFrameRate;
  77275. private _trackerDuration;
  77276. private _currentFrameRate;
  77277. private _sceneDisposeObserver;
  77278. private _improvementMode;
  77279. /**
  77280. * Defines an observable called when the optimizer reaches the target frame rate
  77281. */
  77282. onSuccessObservable: Observable<SceneOptimizer>;
  77283. /**
  77284. * Defines an observable called when the optimizer enables an optimization
  77285. */
  77286. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77287. /**
  77288. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77289. */
  77290. onFailureObservable: Observable<SceneOptimizer>;
  77291. /**
  77292. * Gets a boolean indicating if the optimizer is in improvement mode
  77293. */
  77294. get isInImprovementMode(): boolean;
  77295. /**
  77296. * Gets the current priority level (0 at start)
  77297. */
  77298. get currentPriorityLevel(): number;
  77299. /**
  77300. * Gets the current frame rate checked by the SceneOptimizer
  77301. */
  77302. get currentFrameRate(): number;
  77303. /**
  77304. * Gets or sets the current target frame rate (60 by default)
  77305. */
  77306. get targetFrameRate(): number;
  77307. /**
  77308. * Gets or sets the current target frame rate (60 by default)
  77309. */
  77310. set targetFrameRate(value: number);
  77311. /**
  77312. * Gets or sets the current interval between two checks (every 2000ms by default)
  77313. */
  77314. get trackerDuration(): number;
  77315. /**
  77316. * Gets or sets the current interval between two checks (every 2000ms by default)
  77317. */
  77318. set trackerDuration(value: number);
  77319. /**
  77320. * Gets the list of active optimizations
  77321. */
  77322. get optimizations(): SceneOptimization[];
  77323. /**
  77324. * Creates a new SceneOptimizer
  77325. * @param scene defines the scene to work on
  77326. * @param options defines the options to use with the SceneOptimizer
  77327. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77328. * @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)
  77329. */
  77330. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77331. /**
  77332. * Stops the current optimizer
  77333. */
  77334. stop(): void;
  77335. /**
  77336. * Reset the optimizer to initial step (current priority level = 0)
  77337. */
  77338. reset(): void;
  77339. /**
  77340. * Start the optimizer. By default it will try to reach a specific framerate
  77341. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77342. */
  77343. start(): void;
  77344. private _checkCurrentState;
  77345. /**
  77346. * Release all resources
  77347. */
  77348. dispose(): void;
  77349. /**
  77350. * Helper function to create a SceneOptimizer with one single line of code
  77351. * @param scene defines the scene to work on
  77352. * @param options defines the options to use with the SceneOptimizer
  77353. * @param onSuccess defines a callback to call on success
  77354. * @param onFailure defines a callback to call on failure
  77355. * @returns the new SceneOptimizer object
  77356. */
  77357. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77358. }
  77359. }
  77360. declare module "babylonjs/Misc/sceneSerializer" {
  77361. import { Scene } from "babylonjs/scene";
  77362. /**
  77363. * Class used to serialize a scene into a string
  77364. */
  77365. export class SceneSerializer {
  77366. /**
  77367. * Clear cache used by a previous serialization
  77368. */
  77369. static ClearCache(): void;
  77370. /**
  77371. * Serialize a scene into a JSON compatible object
  77372. * @param scene defines the scene to serialize
  77373. * @returns a JSON compatible object
  77374. */
  77375. static Serialize(scene: Scene): any;
  77376. /**
  77377. * Serialize a mesh into a JSON compatible object
  77378. * @param toSerialize defines the mesh to serialize
  77379. * @param withParents defines if parents must be serialized as well
  77380. * @param withChildren defines if children must be serialized as well
  77381. * @returns a JSON compatible object
  77382. */
  77383. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77384. }
  77385. }
  77386. declare module "babylonjs/Misc/textureTools" {
  77387. import { Texture } from "babylonjs/Materials/Textures/texture";
  77388. /**
  77389. * Class used to host texture specific utilities
  77390. */
  77391. export class TextureTools {
  77392. /**
  77393. * Uses the GPU to create a copy texture rescaled at a given size
  77394. * @param texture Texture to copy from
  77395. * @param width defines the desired width
  77396. * @param height defines the desired height
  77397. * @param useBilinearMode defines if bilinear mode has to be used
  77398. * @return the generated texture
  77399. */
  77400. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77401. }
  77402. }
  77403. declare module "babylonjs/Misc/videoRecorder" {
  77404. import { Nullable } from "babylonjs/types";
  77405. import { Engine } from "babylonjs/Engines/engine";
  77406. /**
  77407. * This represents the different options available for the video capture.
  77408. */
  77409. export interface VideoRecorderOptions {
  77410. /** Defines the mime type of the video. */
  77411. mimeType: string;
  77412. /** Defines the FPS the video should be recorded at. */
  77413. fps: number;
  77414. /** Defines the chunk size for the recording data. */
  77415. recordChunckSize: number;
  77416. /** The audio tracks to attach to the recording. */
  77417. audioTracks?: MediaStreamTrack[];
  77418. }
  77419. /**
  77420. * This can help with recording videos from BabylonJS.
  77421. * This is based on the available WebRTC functionalities of the browser.
  77422. *
  77423. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77424. */
  77425. export class VideoRecorder {
  77426. private static readonly _defaultOptions;
  77427. /**
  77428. * Returns whether or not the VideoRecorder is available in your browser.
  77429. * @param engine Defines the Babylon Engine.
  77430. * @returns true if supported otherwise false.
  77431. */
  77432. static IsSupported(engine: Engine): boolean;
  77433. private readonly _options;
  77434. private _canvas;
  77435. private _mediaRecorder;
  77436. private _recordedChunks;
  77437. private _fileName;
  77438. private _resolve;
  77439. private _reject;
  77440. /**
  77441. * True when a recording is already in progress.
  77442. */
  77443. get isRecording(): boolean;
  77444. /**
  77445. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77446. * @param engine Defines the BabylonJS Engine you wish to record.
  77447. * @param options Defines options that can be used to customize the capture.
  77448. */
  77449. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77450. /**
  77451. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77452. */
  77453. stopRecording(): void;
  77454. /**
  77455. * Starts recording the canvas for a max duration specified in parameters.
  77456. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77457. * If null no automatic download will start and you can rely on the promise to get the data back.
  77458. * @param maxDuration Defines the maximum recording time in seconds.
  77459. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77460. * @return A promise callback at the end of the recording with the video data in Blob.
  77461. */
  77462. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77463. /**
  77464. * Releases internal resources used during the recording.
  77465. */
  77466. dispose(): void;
  77467. private _handleDataAvailable;
  77468. private _handleError;
  77469. private _handleStop;
  77470. }
  77471. }
  77472. declare module "babylonjs/Misc/screenshotTools" {
  77473. import { Camera } from "babylonjs/Cameras/camera";
  77474. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77475. import { Engine } from "babylonjs/Engines/engine";
  77476. /**
  77477. * Class containing a set of static utilities functions for screenshots
  77478. */
  77479. export class ScreenshotTools {
  77480. /**
  77481. * Captures a screenshot of the current rendering
  77482. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77483. * @param engine defines the rendering engine
  77484. * @param camera defines the source camera
  77485. * @param size This parameter can be set to a single number or to an object with the
  77486. * following (optional) properties: precision, width, height. If a single number is passed,
  77487. * it will be used for both width and height. If an object is passed, the screenshot size
  77488. * will be derived from the parameters. The precision property is a multiplier allowing
  77489. * rendering at a higher or lower resolution
  77490. * @param successCallback defines the callback receives a single parameter which contains the
  77491. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77492. * src parameter of an <img> to display it
  77493. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77494. * Check your browser for supported MIME types
  77495. */
  77496. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77497. /**
  77498. * Captures a screenshot of the current rendering
  77499. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77500. * @param engine defines the rendering engine
  77501. * @param camera defines the source camera
  77502. * @param size This parameter can be set to a single number or to an object with the
  77503. * following (optional) properties: precision, width, height. If a single number is passed,
  77504. * it will be used for both width and height. If an object is passed, the screenshot size
  77505. * will be derived from the parameters. The precision property is a multiplier allowing
  77506. * rendering at a higher or lower resolution
  77507. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77508. * Check your browser for supported MIME types
  77509. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77510. * to the src parameter of an <img> to display it
  77511. */
  77512. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77513. /**
  77514. * Generates an image screenshot from the specified camera.
  77515. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77516. * @param engine The engine to use for rendering
  77517. * @param camera The camera to use for rendering
  77518. * @param size This parameter can be set to a single number or to an object with the
  77519. * following (optional) properties: precision, width, height. If a single number is passed,
  77520. * it will be used for both width and height. If an object is passed, the screenshot size
  77521. * will be derived from the parameters. The precision property is a multiplier allowing
  77522. * rendering at a higher or lower resolution
  77523. * @param successCallback The callback receives a single parameter which contains the
  77524. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77525. * src parameter of an <img> to display it
  77526. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77527. * Check your browser for supported MIME types
  77528. * @param samples Texture samples (default: 1)
  77529. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77530. * @param fileName A name for for the downloaded file.
  77531. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77532. */
  77533. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77534. /**
  77535. * Generates an image screenshot from the specified camera.
  77536. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77537. * @param engine The engine to use for rendering
  77538. * @param camera The camera to use for rendering
  77539. * @param size This parameter can be set to a single number or to an object with the
  77540. * following (optional) properties: precision, width, height. If a single number is passed,
  77541. * it will be used for both width and height. If an object is passed, the screenshot size
  77542. * will be derived from the parameters. The precision property is a multiplier allowing
  77543. * rendering at a higher or lower resolution
  77544. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77545. * Check your browser for supported MIME types
  77546. * @param samples Texture samples (default: 1)
  77547. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77548. * @param fileName A name for for the downloaded file.
  77549. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77550. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77551. * to the src parameter of an <img> to display it
  77552. */
  77553. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77554. /**
  77555. * Gets height and width for screenshot size
  77556. * @private
  77557. */
  77558. private static _getScreenshotSize;
  77559. }
  77560. }
  77561. declare module "babylonjs/Misc/dataReader" {
  77562. /**
  77563. * Interface for a data buffer
  77564. */
  77565. export interface IDataBuffer {
  77566. /**
  77567. * Reads bytes from the data buffer.
  77568. * @param byteOffset The byte offset to read
  77569. * @param byteLength The byte length to read
  77570. * @returns A promise that resolves when the bytes are read
  77571. */
  77572. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77573. /**
  77574. * The byte length of the buffer.
  77575. */
  77576. readonly byteLength: number;
  77577. }
  77578. /**
  77579. * Utility class for reading from a data buffer
  77580. */
  77581. export class DataReader {
  77582. /**
  77583. * The data buffer associated with this data reader.
  77584. */
  77585. readonly buffer: IDataBuffer;
  77586. /**
  77587. * The current byte offset from the beginning of the data buffer.
  77588. */
  77589. byteOffset: number;
  77590. private _dataView;
  77591. private _dataByteOffset;
  77592. /**
  77593. * Constructor
  77594. * @param buffer The buffer to read
  77595. */
  77596. constructor(buffer: IDataBuffer);
  77597. /**
  77598. * Loads the given byte length.
  77599. * @param byteLength The byte length to load
  77600. * @returns A promise that resolves when the load is complete
  77601. */
  77602. loadAsync(byteLength: number): Promise<void>;
  77603. /**
  77604. * Read a unsigned 32-bit integer from the currently loaded data range.
  77605. * @returns The 32-bit integer read
  77606. */
  77607. readUint32(): number;
  77608. /**
  77609. * Read a byte array from the currently loaded data range.
  77610. * @param byteLength The byte length to read
  77611. * @returns The byte array read
  77612. */
  77613. readUint8Array(byteLength: number): Uint8Array;
  77614. /**
  77615. * Read a string from the currently loaded data range.
  77616. * @param byteLength The byte length to read
  77617. * @returns The string read
  77618. */
  77619. readString(byteLength: number): string;
  77620. /**
  77621. * Skips the given byte length the currently loaded data range.
  77622. * @param byteLength The byte length to skip
  77623. */
  77624. skipBytes(byteLength: number): void;
  77625. }
  77626. }
  77627. declare module "babylonjs/Misc/dataStorage" {
  77628. /**
  77629. * Class for storing data to local storage if available or in-memory storage otherwise
  77630. */
  77631. export class DataStorage {
  77632. private static _Storage;
  77633. private static _GetStorage;
  77634. /**
  77635. * Reads a string from the data storage
  77636. * @param key The key to read
  77637. * @param defaultValue The value if the key doesn't exist
  77638. * @returns The string value
  77639. */
  77640. static ReadString(key: string, defaultValue: string): string;
  77641. /**
  77642. * Writes a string to the data storage
  77643. * @param key The key to write
  77644. * @param value The value to write
  77645. */
  77646. static WriteString(key: string, value: string): void;
  77647. /**
  77648. * Reads a boolean from the data storage
  77649. * @param key The key to read
  77650. * @param defaultValue The value if the key doesn't exist
  77651. * @returns The boolean value
  77652. */
  77653. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77654. /**
  77655. * Writes a boolean to the data storage
  77656. * @param key The key to write
  77657. * @param value The value to write
  77658. */
  77659. static WriteBoolean(key: string, value: boolean): void;
  77660. /**
  77661. * Reads a number from the data storage
  77662. * @param key The key to read
  77663. * @param defaultValue The value if the key doesn't exist
  77664. * @returns The number value
  77665. */
  77666. static ReadNumber(key: string, defaultValue: number): number;
  77667. /**
  77668. * Writes a number to the data storage
  77669. * @param key The key to write
  77670. * @param value The value to write
  77671. */
  77672. static WriteNumber(key: string, value: number): void;
  77673. }
  77674. }
  77675. declare module "babylonjs/Misc/sceneRecorder" {
  77676. import { Scene } from "babylonjs/scene";
  77677. /**
  77678. * Class used to record delta files between 2 scene states
  77679. */
  77680. export class SceneRecorder {
  77681. private _trackedScene;
  77682. private _savedJSON;
  77683. /**
  77684. * Track a given scene. This means the current scene state will be considered the original state
  77685. * @param scene defines the scene to track
  77686. */
  77687. track(scene: Scene): void;
  77688. /**
  77689. * Get the delta between current state and original state
  77690. * @returns a string containing the delta
  77691. */
  77692. getDelta(): any;
  77693. private _compareArray;
  77694. private _compareObjects;
  77695. private _compareCollections;
  77696. private static GetShadowGeneratorById;
  77697. /**
  77698. * Apply a given delta to a given scene
  77699. * @param deltaJSON defines the JSON containing the delta
  77700. * @param scene defines the scene to apply the delta to
  77701. */
  77702. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  77703. private static _ApplyPropertiesToEntity;
  77704. private static _ApplyDeltaForEntity;
  77705. }
  77706. }
  77707. declare module "babylonjs/Misc/index" {
  77708. export * from "babylonjs/Misc/andOrNotEvaluator";
  77709. export * from "babylonjs/Misc/assetsManager";
  77710. export * from "babylonjs/Misc/basis";
  77711. export * from "babylonjs/Misc/dds";
  77712. export * from "babylonjs/Misc/decorators";
  77713. export * from "babylonjs/Misc/deferred";
  77714. export * from "babylonjs/Misc/environmentTextureTools";
  77715. export * from "babylonjs/Misc/meshExploder";
  77716. export * from "babylonjs/Misc/filesInput";
  77717. export * from "babylonjs/Misc/HighDynamicRange/index";
  77718. export * from "babylonjs/Misc/khronosTextureContainer";
  77719. export * from "babylonjs/Misc/observable";
  77720. export * from "babylonjs/Misc/performanceMonitor";
  77721. export * from "babylonjs/Misc/promise";
  77722. export * from "babylonjs/Misc/sceneOptimizer";
  77723. export * from "babylonjs/Misc/sceneSerializer";
  77724. export * from "babylonjs/Misc/smartArray";
  77725. export * from "babylonjs/Misc/stringDictionary";
  77726. export * from "babylonjs/Misc/tags";
  77727. export * from "babylonjs/Misc/textureTools";
  77728. export * from "babylonjs/Misc/tga";
  77729. export * from "babylonjs/Misc/tools";
  77730. export * from "babylonjs/Misc/videoRecorder";
  77731. export * from "babylonjs/Misc/virtualJoystick";
  77732. export * from "babylonjs/Misc/workerPool";
  77733. export * from "babylonjs/Misc/logger";
  77734. export * from "babylonjs/Misc/typeStore";
  77735. export * from "babylonjs/Misc/filesInputStore";
  77736. export * from "babylonjs/Misc/deepCopier";
  77737. export * from "babylonjs/Misc/pivotTools";
  77738. export * from "babylonjs/Misc/precisionDate";
  77739. export * from "babylonjs/Misc/screenshotTools";
  77740. export * from "babylonjs/Misc/typeStore";
  77741. export * from "babylonjs/Misc/webRequest";
  77742. export * from "babylonjs/Misc/iInspectable";
  77743. export * from "babylonjs/Misc/brdfTextureTools";
  77744. export * from "babylonjs/Misc/rgbdTextureTools";
  77745. export * from "babylonjs/Misc/gradients";
  77746. export * from "babylonjs/Misc/perfCounter";
  77747. export * from "babylonjs/Misc/fileRequest";
  77748. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77749. export * from "babylonjs/Misc/retryStrategy";
  77750. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77751. export * from "babylonjs/Misc/canvasGenerator";
  77752. export * from "babylonjs/Misc/fileTools";
  77753. export * from "babylonjs/Misc/stringTools";
  77754. export * from "babylonjs/Misc/dataReader";
  77755. export * from "babylonjs/Misc/minMaxReducer";
  77756. export * from "babylonjs/Misc/depthReducer";
  77757. export * from "babylonjs/Misc/dataStorage";
  77758. export * from "babylonjs/Misc/sceneRecorder";
  77759. }
  77760. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77761. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77762. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77763. import { Observable } from "babylonjs/Misc/observable";
  77764. import { Matrix } from "babylonjs/Maths/math.vector";
  77765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77766. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77767. /**
  77768. * An interface for all Hit test features
  77769. */
  77770. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77771. /**
  77772. * Triggered when new babylon (transformed) hit test results are available
  77773. */
  77774. onHitTestResultObservable: Observable<T[]>;
  77775. }
  77776. /**
  77777. * Options used for hit testing
  77778. */
  77779. export interface IWebXRLegacyHitTestOptions {
  77780. /**
  77781. * Only test when user interacted with the scene. Default - hit test every frame
  77782. */
  77783. testOnPointerDownOnly?: boolean;
  77784. /**
  77785. * The node to use to transform the local results to world coordinates
  77786. */
  77787. worldParentNode?: TransformNode;
  77788. }
  77789. /**
  77790. * Interface defining the babylon result of raycasting/hit-test
  77791. */
  77792. export interface IWebXRLegacyHitResult {
  77793. /**
  77794. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77795. */
  77796. transformationMatrix: Matrix;
  77797. /**
  77798. * The native hit test result
  77799. */
  77800. xrHitResult: XRHitResult | XRHitTestResult;
  77801. }
  77802. /**
  77803. * The currently-working hit-test module.
  77804. * Hit test (or Ray-casting) is used to interact with the real world.
  77805. * For further information read here - https://github.com/immersive-web/hit-test
  77806. */
  77807. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77808. /**
  77809. * options to use when constructing this feature
  77810. */
  77811. readonly options: IWebXRLegacyHitTestOptions;
  77812. private _direction;
  77813. private _mat;
  77814. private _onSelectEnabled;
  77815. private _origin;
  77816. /**
  77817. * The module's name
  77818. */
  77819. static readonly Name: string;
  77820. /**
  77821. * The (Babylon) version of this module.
  77822. * This is an integer representing the implementation version.
  77823. * This number does not correspond to the WebXR specs version
  77824. */
  77825. static readonly Version: number;
  77826. /**
  77827. * Populated with the last native XR Hit Results
  77828. */
  77829. lastNativeXRHitResults: XRHitResult[];
  77830. /**
  77831. * Triggered when new babylon (transformed) hit test results are available
  77832. */
  77833. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77834. /**
  77835. * Creates a new instance of the (legacy version) hit test feature
  77836. * @param _xrSessionManager an instance of WebXRSessionManager
  77837. * @param options options to use when constructing this feature
  77838. */
  77839. constructor(_xrSessionManager: WebXRSessionManager,
  77840. /**
  77841. * options to use when constructing this feature
  77842. */
  77843. options?: IWebXRLegacyHitTestOptions);
  77844. /**
  77845. * execute a hit test with an XR Ray
  77846. *
  77847. * @param xrSession a native xrSession that will execute this hit test
  77848. * @param xrRay the ray (position and direction) to use for ray-casting
  77849. * @param referenceSpace native XR reference space to use for the hit-test
  77850. * @param filter filter function that will filter the results
  77851. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77852. */
  77853. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77854. /**
  77855. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77856. * @param event the (select) event to use to select with
  77857. * @param referenceSpace the reference space to use for this hit test
  77858. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77859. */
  77860. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77861. /**
  77862. * attach this feature
  77863. * Will usually be called by the features manager
  77864. *
  77865. * @returns true if successful.
  77866. */
  77867. attach(): boolean;
  77868. /**
  77869. * detach this feature.
  77870. * Will usually be called by the features manager
  77871. *
  77872. * @returns true if successful.
  77873. */
  77874. detach(): boolean;
  77875. /**
  77876. * Dispose this feature and all of the resources attached
  77877. */
  77878. dispose(): void;
  77879. protected _onXRFrame(frame: XRFrame): void;
  77880. private _onHitTestResults;
  77881. private _onSelect;
  77882. }
  77883. }
  77884. declare module "babylonjs/XR/features/WebXRHitTest" {
  77885. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77886. import { Observable } from "babylonjs/Misc/observable";
  77887. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77888. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77889. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77890. /**
  77891. * Options used for hit testing (version 2)
  77892. */
  77893. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77894. /**
  77895. * Do not create a permanent hit test. Will usually be used when only
  77896. * transient inputs are needed.
  77897. */
  77898. disablePermanentHitTest?: boolean;
  77899. /**
  77900. * Enable transient (for example touch-based) hit test inspections
  77901. */
  77902. enableTransientHitTest?: boolean;
  77903. /**
  77904. * Offset ray for the permanent hit test
  77905. */
  77906. offsetRay?: Vector3;
  77907. /**
  77908. * Offset ray for the transient hit test
  77909. */
  77910. transientOffsetRay?: Vector3;
  77911. /**
  77912. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77913. */
  77914. useReferenceSpace?: boolean;
  77915. }
  77916. /**
  77917. * Interface defining the babylon result of hit-test
  77918. */
  77919. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77920. /**
  77921. * The input source that generated this hit test (if transient)
  77922. */
  77923. inputSource?: XRInputSource;
  77924. /**
  77925. * Is this a transient hit test
  77926. */
  77927. isTransient?: boolean;
  77928. /**
  77929. * Position of the hit test result
  77930. */
  77931. position: Vector3;
  77932. /**
  77933. * Rotation of the hit test result
  77934. */
  77935. rotationQuaternion: Quaternion;
  77936. /**
  77937. * The native hit test result
  77938. */
  77939. xrHitResult: XRHitTestResult;
  77940. }
  77941. /**
  77942. * The currently-working hit-test module.
  77943. * Hit test (or Ray-casting) is used to interact with the real world.
  77944. * For further information read here - https://github.com/immersive-web/hit-test
  77945. *
  77946. * Tested on chrome (mobile) 80.
  77947. */
  77948. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77949. /**
  77950. * options to use when constructing this feature
  77951. */
  77952. readonly options: IWebXRHitTestOptions;
  77953. private _tmpMat;
  77954. private _tmpPos;
  77955. private _tmpQuat;
  77956. private _transientXrHitTestSource;
  77957. private _xrHitTestSource;
  77958. private initHitTestSource;
  77959. /**
  77960. * The module's name
  77961. */
  77962. static readonly Name: string;
  77963. /**
  77964. * The (Babylon) version of this module.
  77965. * This is an integer representing the implementation version.
  77966. * This number does not correspond to the WebXR specs version
  77967. */
  77968. static readonly Version: number;
  77969. /**
  77970. * When set to true, each hit test will have its own position/rotation objects
  77971. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77972. * the developers will clone them or copy them as they see fit.
  77973. */
  77974. autoCloneTransformation: boolean;
  77975. /**
  77976. * Triggered when new babylon (transformed) hit test results are available
  77977. */
  77978. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77979. /**
  77980. * Use this to temporarily pause hit test checks.
  77981. */
  77982. paused: boolean;
  77983. /**
  77984. * Creates a new instance of the hit test feature
  77985. * @param _xrSessionManager an instance of WebXRSessionManager
  77986. * @param options options to use when constructing this feature
  77987. */
  77988. constructor(_xrSessionManager: WebXRSessionManager,
  77989. /**
  77990. * options to use when constructing this feature
  77991. */
  77992. options?: IWebXRHitTestOptions);
  77993. /**
  77994. * attach this feature
  77995. * Will usually be called by the features manager
  77996. *
  77997. * @returns true if successful.
  77998. */
  77999. attach(): boolean;
  78000. /**
  78001. * detach this feature.
  78002. * Will usually be called by the features manager
  78003. *
  78004. * @returns true if successful.
  78005. */
  78006. detach(): boolean;
  78007. /**
  78008. * Dispose this feature and all of the resources attached
  78009. */
  78010. dispose(): void;
  78011. protected _onXRFrame(frame: XRFrame): void;
  78012. private _processWebXRHitTestResult;
  78013. }
  78014. }
  78015. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78016. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78017. import { Observable } from "babylonjs/Misc/observable";
  78018. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78020. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78021. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78022. /**
  78023. * Configuration options of the anchor system
  78024. */
  78025. export interface IWebXRAnchorSystemOptions {
  78026. /**
  78027. * a node that will be used to convert local to world coordinates
  78028. */
  78029. worldParentNode?: TransformNode;
  78030. /**
  78031. * If set to true a reference of the created anchors will be kept until the next session starts
  78032. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78033. */
  78034. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78035. }
  78036. /**
  78037. * A babylon container for an XR Anchor
  78038. */
  78039. export interface IWebXRAnchor {
  78040. /**
  78041. * A babylon-assigned ID for this anchor
  78042. */
  78043. id: number;
  78044. /**
  78045. * Transformation matrix to apply to an object attached to this anchor
  78046. */
  78047. transformationMatrix: Matrix;
  78048. /**
  78049. * The native anchor object
  78050. */
  78051. xrAnchor: XRAnchor;
  78052. /**
  78053. * if defined, this object will be constantly updated by the anchor's position and rotation
  78054. */
  78055. attachedNode?: TransformNode;
  78056. }
  78057. /**
  78058. * An implementation of the anchor system for WebXR.
  78059. * For further information see https://github.com/immersive-web/anchors/
  78060. */
  78061. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78062. private _options;
  78063. private _lastFrameDetected;
  78064. private _trackedAnchors;
  78065. private _referenceSpaceForFrameAnchors;
  78066. private _futureAnchors;
  78067. /**
  78068. * The module's name
  78069. */
  78070. static readonly Name: string;
  78071. /**
  78072. * The (Babylon) version of this module.
  78073. * This is an integer representing the implementation version.
  78074. * This number does not correspond to the WebXR specs version
  78075. */
  78076. static readonly Version: number;
  78077. /**
  78078. * Observers registered here will be executed when a new anchor was added to the session
  78079. */
  78080. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78081. /**
  78082. * Observers registered here will be executed when an anchor was removed from the session
  78083. */
  78084. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78085. /**
  78086. * Observers registered here will be executed when an existing anchor updates
  78087. * This can execute N times every frame
  78088. */
  78089. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78090. /**
  78091. * Set the reference space to use for anchor creation, when not using a hit test.
  78092. * Will default to the session's reference space if not defined
  78093. */
  78094. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78095. /**
  78096. * constructs a new anchor system
  78097. * @param _xrSessionManager an instance of WebXRSessionManager
  78098. * @param _options configuration object for this feature
  78099. */
  78100. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78101. private _tmpVector;
  78102. private _tmpQuaternion;
  78103. private _populateTmpTransformation;
  78104. /**
  78105. * Create a new anchor point using a hit test result at a specific point in the scene
  78106. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78107. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78108. *
  78109. * @param hitTestResult The hit test result to use for this anchor creation
  78110. * @param position an optional position offset for this anchor
  78111. * @param rotationQuaternion an optional rotation offset for this anchor
  78112. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78113. */
  78114. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78115. /**
  78116. * Add a new anchor at a specific position and rotation
  78117. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78118. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78119. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78120. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78121. *
  78122. * @param position the position in which to add an anchor
  78123. * @param rotationQuaternion an optional rotation for the anchor transformation
  78124. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78125. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78126. */
  78127. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78128. /**
  78129. * detach this feature.
  78130. * Will usually be called by the features manager
  78131. *
  78132. * @returns true if successful.
  78133. */
  78134. detach(): boolean;
  78135. /**
  78136. * Dispose this feature and all of the resources attached
  78137. */
  78138. dispose(): void;
  78139. protected _onXRFrame(frame: XRFrame): void;
  78140. /**
  78141. * avoiding using Array.find for global support.
  78142. * @param xrAnchor the plane to find in the array
  78143. */
  78144. private _findIndexInAnchorArray;
  78145. private _updateAnchorWithXRFrame;
  78146. private _createAnchorAtTransformation;
  78147. }
  78148. }
  78149. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78150. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78151. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78152. import { Observable } from "babylonjs/Misc/observable";
  78153. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78154. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78155. /**
  78156. * Options used in the plane detector module
  78157. */
  78158. export interface IWebXRPlaneDetectorOptions {
  78159. /**
  78160. * The node to use to transform the local results to world coordinates
  78161. */
  78162. worldParentNode?: TransformNode;
  78163. /**
  78164. * If set to true a reference of the created planes will be kept until the next session starts
  78165. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78166. */
  78167. doNotRemovePlanesOnSessionEnded?: boolean;
  78168. }
  78169. /**
  78170. * A babylon interface for a WebXR plane.
  78171. * A Plane is actually a polygon, built from N points in space
  78172. *
  78173. * Supported in chrome 79, not supported in canary 81 ATM
  78174. */
  78175. export interface IWebXRPlane {
  78176. /**
  78177. * a babylon-assigned ID for this polygon
  78178. */
  78179. id: number;
  78180. /**
  78181. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78182. */
  78183. polygonDefinition: Array<Vector3>;
  78184. /**
  78185. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78186. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78187. */
  78188. transformationMatrix: Matrix;
  78189. /**
  78190. * the native xr-plane object
  78191. */
  78192. xrPlane: XRPlane;
  78193. }
  78194. /**
  78195. * The plane detector is used to detect planes in the real world when in AR
  78196. * For more information see https://github.com/immersive-web/real-world-geometry/
  78197. */
  78198. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78199. private _options;
  78200. private _detectedPlanes;
  78201. private _enabled;
  78202. private _lastFrameDetected;
  78203. /**
  78204. * The module's name
  78205. */
  78206. static readonly Name: string;
  78207. /**
  78208. * The (Babylon) version of this module.
  78209. * This is an integer representing the implementation version.
  78210. * This number does not correspond to the WebXR specs version
  78211. */
  78212. static readonly Version: number;
  78213. /**
  78214. * Observers registered here will be executed when a new plane was added to the session
  78215. */
  78216. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78217. /**
  78218. * Observers registered here will be executed when a plane is no longer detected in the session
  78219. */
  78220. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78221. /**
  78222. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78223. * This can execute N times every frame
  78224. */
  78225. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78226. /**
  78227. * construct a new Plane Detector
  78228. * @param _xrSessionManager an instance of xr Session manager
  78229. * @param _options configuration to use when constructing this feature
  78230. */
  78231. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78232. /**
  78233. * detach this feature.
  78234. * Will usually be called by the features manager
  78235. *
  78236. * @returns true if successful.
  78237. */
  78238. detach(): boolean;
  78239. /**
  78240. * Dispose this feature and all of the resources attached
  78241. */
  78242. dispose(): void;
  78243. protected _onXRFrame(frame: XRFrame): void;
  78244. private _init;
  78245. private _updatePlaneWithXRPlane;
  78246. /**
  78247. * avoiding using Array.find for global support.
  78248. * @param xrPlane the plane to find in the array
  78249. */
  78250. private findIndexInPlaneArray;
  78251. }
  78252. }
  78253. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78254. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78256. import { Observable } from "babylonjs/Misc/observable";
  78257. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78258. /**
  78259. * Options interface for the background remover plugin
  78260. */
  78261. export interface IWebXRBackgroundRemoverOptions {
  78262. /**
  78263. * Further background meshes to disable when entering AR
  78264. */
  78265. backgroundMeshes?: AbstractMesh[];
  78266. /**
  78267. * flags to configure the removal of the environment helper.
  78268. * If not set, the entire background will be removed. If set, flags should be set as well.
  78269. */
  78270. environmentHelperRemovalFlags?: {
  78271. /**
  78272. * Should the skybox be removed (default false)
  78273. */
  78274. skyBox?: boolean;
  78275. /**
  78276. * Should the ground be removed (default false)
  78277. */
  78278. ground?: boolean;
  78279. };
  78280. /**
  78281. * don't disable the environment helper
  78282. */
  78283. ignoreEnvironmentHelper?: boolean;
  78284. }
  78285. /**
  78286. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78287. */
  78288. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78289. /**
  78290. * read-only options to be used in this module
  78291. */
  78292. readonly options: IWebXRBackgroundRemoverOptions;
  78293. /**
  78294. * The module's name
  78295. */
  78296. static readonly Name: string;
  78297. /**
  78298. * The (Babylon) version of this module.
  78299. * This is an integer representing the implementation version.
  78300. * This number does not correspond to the WebXR specs version
  78301. */
  78302. static readonly Version: number;
  78303. /**
  78304. * registered observers will be triggered when the background state changes
  78305. */
  78306. onBackgroundStateChangedObservable: Observable<boolean>;
  78307. /**
  78308. * constructs a new background remover module
  78309. * @param _xrSessionManager the session manager for this module
  78310. * @param options read-only options to be used in this module
  78311. */
  78312. constructor(_xrSessionManager: WebXRSessionManager,
  78313. /**
  78314. * read-only options to be used in this module
  78315. */
  78316. options?: IWebXRBackgroundRemoverOptions);
  78317. /**
  78318. * attach this feature
  78319. * Will usually be called by the features manager
  78320. *
  78321. * @returns true if successful.
  78322. */
  78323. attach(): boolean;
  78324. /**
  78325. * detach this feature.
  78326. * Will usually be called by the features manager
  78327. *
  78328. * @returns true if successful.
  78329. */
  78330. detach(): boolean;
  78331. /**
  78332. * Dispose this feature and all of the resources attached
  78333. */
  78334. dispose(): void;
  78335. protected _onXRFrame(_xrFrame: XRFrame): void;
  78336. private _setBackgroundState;
  78337. }
  78338. }
  78339. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78340. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78341. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78342. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78343. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78344. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78345. import { Nullable } from "babylonjs/types";
  78346. /**
  78347. * Options for the controller physics feature
  78348. */
  78349. export class IWebXRControllerPhysicsOptions {
  78350. /**
  78351. * Should the headset get its own impostor
  78352. */
  78353. enableHeadsetImpostor?: boolean;
  78354. /**
  78355. * Optional parameters for the headset impostor
  78356. */
  78357. headsetImpostorParams?: {
  78358. /**
  78359. * The type of impostor to create. Default is sphere
  78360. */
  78361. impostorType: number;
  78362. /**
  78363. * the size of the impostor. Defaults to 10cm
  78364. */
  78365. impostorSize?: number | {
  78366. width: number;
  78367. height: number;
  78368. depth: number;
  78369. };
  78370. /**
  78371. * Friction definitions
  78372. */
  78373. friction?: number;
  78374. /**
  78375. * Restitution
  78376. */
  78377. restitution?: number;
  78378. };
  78379. /**
  78380. * The physics properties of the future impostors
  78381. */
  78382. physicsProperties?: {
  78383. /**
  78384. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78385. * Note that this requires a physics engine that supports mesh impostors!
  78386. */
  78387. useControllerMesh?: boolean;
  78388. /**
  78389. * The type of impostor to create. Default is sphere
  78390. */
  78391. impostorType?: number;
  78392. /**
  78393. * the size of the impostor. Defaults to 10cm
  78394. */
  78395. impostorSize?: number | {
  78396. width: number;
  78397. height: number;
  78398. depth: number;
  78399. };
  78400. /**
  78401. * Friction definitions
  78402. */
  78403. friction?: number;
  78404. /**
  78405. * Restitution
  78406. */
  78407. restitution?: number;
  78408. };
  78409. /**
  78410. * the xr input to use with this pointer selection
  78411. */
  78412. xrInput: WebXRInput;
  78413. }
  78414. /**
  78415. * Add physics impostor to your webxr controllers,
  78416. * including naive calculation of their linear and angular velocity
  78417. */
  78418. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78419. private readonly _options;
  78420. private _attachController;
  78421. private _controllers;
  78422. private _debugMode;
  78423. private _delta;
  78424. private _headsetImpostor?;
  78425. private _headsetMesh?;
  78426. private _lastTimestamp;
  78427. private _tmpQuaternion;
  78428. private _tmpVector;
  78429. /**
  78430. * The module's name
  78431. */
  78432. static readonly Name: string;
  78433. /**
  78434. * The (Babylon) version of this module.
  78435. * This is an integer representing the implementation version.
  78436. * This number does not correspond to the webxr specs version
  78437. */
  78438. static readonly Version: number;
  78439. /**
  78440. * Construct a new Controller Physics Feature
  78441. * @param _xrSessionManager the corresponding xr session manager
  78442. * @param _options options to create this feature with
  78443. */
  78444. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78445. /**
  78446. * @hidden
  78447. * enable debugging - will show console outputs and the impostor mesh
  78448. */
  78449. _enablePhysicsDebug(): void;
  78450. /**
  78451. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78452. * @param xrController the controller to add
  78453. */
  78454. addController(xrController: WebXRInputSource): void;
  78455. /**
  78456. * attach this feature
  78457. * Will usually be called by the features manager
  78458. *
  78459. * @returns true if successful.
  78460. */
  78461. attach(): boolean;
  78462. /**
  78463. * detach this feature.
  78464. * Will usually be called by the features manager
  78465. *
  78466. * @returns true if successful.
  78467. */
  78468. detach(): boolean;
  78469. /**
  78470. * Get the headset impostor, if enabled
  78471. * @returns the impostor
  78472. */
  78473. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78474. /**
  78475. * Get the physics impostor of a specific controller.
  78476. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78477. * @param controller the controller or the controller id of which to get the impostor
  78478. * @returns the impostor or null
  78479. */
  78480. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78481. /**
  78482. * Update the physics properties provided in the constructor
  78483. * @param newProperties the new properties object
  78484. */
  78485. setPhysicsProperties(newProperties: {
  78486. impostorType?: number;
  78487. impostorSize?: number | {
  78488. width: number;
  78489. height: number;
  78490. depth: number;
  78491. };
  78492. friction?: number;
  78493. restitution?: number;
  78494. }): void;
  78495. protected _onXRFrame(_xrFrame: any): void;
  78496. private _detachController;
  78497. }
  78498. }
  78499. declare module "babylonjs/XR/features/index" {
  78500. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78501. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78502. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78503. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78504. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78505. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78506. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78507. export * from "babylonjs/XR/features/WebXRHitTest";
  78508. }
  78509. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78510. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78512. import { Scene } from "babylonjs/scene";
  78513. /**
  78514. * The motion controller class for all microsoft mixed reality controllers
  78515. */
  78516. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78517. protected readonly _mapping: {
  78518. defaultButton: {
  78519. valueNodeName: string;
  78520. unpressedNodeName: string;
  78521. pressedNodeName: string;
  78522. };
  78523. defaultAxis: {
  78524. valueNodeName: string;
  78525. minNodeName: string;
  78526. maxNodeName: string;
  78527. };
  78528. buttons: {
  78529. "xr-standard-trigger": {
  78530. rootNodeName: string;
  78531. componentProperty: string;
  78532. states: string[];
  78533. };
  78534. "xr-standard-squeeze": {
  78535. rootNodeName: string;
  78536. componentProperty: string;
  78537. states: string[];
  78538. };
  78539. "xr-standard-touchpad": {
  78540. rootNodeName: string;
  78541. labelAnchorNodeName: string;
  78542. touchPointNodeName: string;
  78543. };
  78544. "xr-standard-thumbstick": {
  78545. rootNodeName: string;
  78546. componentProperty: string;
  78547. states: string[];
  78548. };
  78549. };
  78550. axes: {
  78551. "xr-standard-touchpad": {
  78552. "x-axis": {
  78553. rootNodeName: string;
  78554. };
  78555. "y-axis": {
  78556. rootNodeName: string;
  78557. };
  78558. };
  78559. "xr-standard-thumbstick": {
  78560. "x-axis": {
  78561. rootNodeName: string;
  78562. };
  78563. "y-axis": {
  78564. rootNodeName: string;
  78565. };
  78566. };
  78567. };
  78568. };
  78569. /**
  78570. * The base url used to load the left and right controller models
  78571. */
  78572. static MODEL_BASE_URL: string;
  78573. /**
  78574. * The name of the left controller model file
  78575. */
  78576. static MODEL_LEFT_FILENAME: string;
  78577. /**
  78578. * The name of the right controller model file
  78579. */
  78580. static MODEL_RIGHT_FILENAME: string;
  78581. profileId: string;
  78582. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78583. protected _getFilenameAndPath(): {
  78584. filename: string;
  78585. path: string;
  78586. };
  78587. protected _getModelLoadingConstraints(): boolean;
  78588. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78589. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78590. protected _updateModel(): void;
  78591. }
  78592. }
  78593. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78594. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78596. import { Scene } from "babylonjs/scene";
  78597. /**
  78598. * The motion controller class for oculus touch (quest, rift).
  78599. * This class supports legacy mapping as well the standard xr mapping
  78600. */
  78601. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78602. private _forceLegacyControllers;
  78603. private _modelRootNode;
  78604. /**
  78605. * The base url used to load the left and right controller models
  78606. */
  78607. static MODEL_BASE_URL: string;
  78608. /**
  78609. * The name of the left controller model file
  78610. */
  78611. static MODEL_LEFT_FILENAME: string;
  78612. /**
  78613. * The name of the right controller model file
  78614. */
  78615. static MODEL_RIGHT_FILENAME: string;
  78616. /**
  78617. * Base Url for the Quest controller model.
  78618. */
  78619. static QUEST_MODEL_BASE_URL: string;
  78620. profileId: string;
  78621. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78622. protected _getFilenameAndPath(): {
  78623. filename: string;
  78624. path: string;
  78625. };
  78626. protected _getModelLoadingConstraints(): boolean;
  78627. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78628. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78629. protected _updateModel(): void;
  78630. /**
  78631. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78632. * between the touch and touch 2.
  78633. */
  78634. private _isQuest;
  78635. }
  78636. }
  78637. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78638. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78639. import { Scene } from "babylonjs/scene";
  78640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78641. /**
  78642. * The motion controller class for the standard HTC-Vive controllers
  78643. */
  78644. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78645. private _modelRootNode;
  78646. /**
  78647. * The base url used to load the left and right controller models
  78648. */
  78649. static MODEL_BASE_URL: string;
  78650. /**
  78651. * File name for the controller model.
  78652. */
  78653. static MODEL_FILENAME: string;
  78654. profileId: string;
  78655. /**
  78656. * Create a new Vive motion controller object
  78657. * @param scene the scene to use to create this controller
  78658. * @param gamepadObject the corresponding gamepad object
  78659. * @param handedness the handedness of the controller
  78660. */
  78661. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78662. protected _getFilenameAndPath(): {
  78663. filename: string;
  78664. path: string;
  78665. };
  78666. protected _getModelLoadingConstraints(): boolean;
  78667. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78668. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78669. protected _updateModel(): void;
  78670. }
  78671. }
  78672. declare module "babylonjs/XR/motionController/index" {
  78673. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78674. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78675. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78676. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78677. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78678. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78679. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78680. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78681. }
  78682. declare module "babylonjs/XR/index" {
  78683. export * from "babylonjs/XR/webXRCamera";
  78684. export * from "babylonjs/XR/webXREnterExitUI";
  78685. export * from "babylonjs/XR/webXRExperienceHelper";
  78686. export * from "babylonjs/XR/webXRInput";
  78687. export * from "babylonjs/XR/webXRInputSource";
  78688. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78689. export * from "babylonjs/XR/webXRTypes";
  78690. export * from "babylonjs/XR/webXRSessionManager";
  78691. export * from "babylonjs/XR/webXRDefaultExperience";
  78692. export * from "babylonjs/XR/webXRFeaturesManager";
  78693. export * from "babylonjs/XR/features/index";
  78694. export * from "babylonjs/XR/motionController/index";
  78695. }
  78696. declare module "babylonjs/index" {
  78697. export * from "babylonjs/abstractScene";
  78698. export * from "babylonjs/Actions/index";
  78699. export * from "babylonjs/Animations/index";
  78700. export * from "babylonjs/assetContainer";
  78701. export * from "babylonjs/Audio/index";
  78702. export * from "babylonjs/Behaviors/index";
  78703. export * from "babylonjs/Bones/index";
  78704. export * from "babylonjs/Cameras/index";
  78705. export * from "babylonjs/Collisions/index";
  78706. export * from "babylonjs/Culling/index";
  78707. export * from "babylonjs/Debug/index";
  78708. export * from "babylonjs/DeviceInput/index";
  78709. export * from "babylonjs/Engines/index";
  78710. export * from "babylonjs/Events/index";
  78711. export * from "babylonjs/Gamepads/index";
  78712. export * from "babylonjs/Gizmos/index";
  78713. export * from "babylonjs/Helpers/index";
  78714. export * from "babylonjs/Instrumentation/index";
  78715. export * from "babylonjs/Layers/index";
  78716. export * from "babylonjs/LensFlares/index";
  78717. export * from "babylonjs/Lights/index";
  78718. export * from "babylonjs/Loading/index";
  78719. export * from "babylonjs/Materials/index";
  78720. export * from "babylonjs/Maths/index";
  78721. export * from "babylonjs/Meshes/index";
  78722. export * from "babylonjs/Morph/index";
  78723. export * from "babylonjs/Navigation/index";
  78724. export * from "babylonjs/node";
  78725. export * from "babylonjs/Offline/index";
  78726. export * from "babylonjs/Particles/index";
  78727. export * from "babylonjs/Physics/index";
  78728. export * from "babylonjs/PostProcesses/index";
  78729. export * from "babylonjs/Probes/index";
  78730. export * from "babylonjs/Rendering/index";
  78731. export * from "babylonjs/scene";
  78732. export * from "babylonjs/sceneComponent";
  78733. export * from "babylonjs/Sprites/index";
  78734. export * from "babylonjs/States/index";
  78735. export * from "babylonjs/Misc/index";
  78736. export * from "babylonjs/XR/index";
  78737. export * from "babylonjs/types";
  78738. }
  78739. declare module "babylonjs/Animations/pathCursor" {
  78740. import { Vector3 } from "babylonjs/Maths/math.vector";
  78741. import { Path2 } from "babylonjs/Maths/math.path";
  78742. /**
  78743. * A cursor which tracks a point on a path
  78744. */
  78745. export class PathCursor {
  78746. private path;
  78747. /**
  78748. * Stores path cursor callbacks for when an onchange event is triggered
  78749. */
  78750. private _onchange;
  78751. /**
  78752. * The value of the path cursor
  78753. */
  78754. value: number;
  78755. /**
  78756. * The animation array of the path cursor
  78757. */
  78758. animations: Animation[];
  78759. /**
  78760. * Initializes the path cursor
  78761. * @param path The path to track
  78762. */
  78763. constructor(path: Path2);
  78764. /**
  78765. * Gets the cursor point on the path
  78766. * @returns A point on the path cursor at the cursor location
  78767. */
  78768. getPoint(): Vector3;
  78769. /**
  78770. * Moves the cursor ahead by the step amount
  78771. * @param step The amount to move the cursor forward
  78772. * @returns This path cursor
  78773. */
  78774. moveAhead(step?: number): PathCursor;
  78775. /**
  78776. * Moves the cursor behind by the step amount
  78777. * @param step The amount to move the cursor back
  78778. * @returns This path cursor
  78779. */
  78780. moveBack(step?: number): PathCursor;
  78781. /**
  78782. * Moves the cursor by the step amount
  78783. * If the step amount is greater than one, an exception is thrown
  78784. * @param step The amount to move the cursor
  78785. * @returns This path cursor
  78786. */
  78787. move(step: number): PathCursor;
  78788. /**
  78789. * Ensures that the value is limited between zero and one
  78790. * @returns This path cursor
  78791. */
  78792. private ensureLimits;
  78793. /**
  78794. * Runs onchange callbacks on change (used by the animation engine)
  78795. * @returns This path cursor
  78796. */
  78797. private raiseOnChange;
  78798. /**
  78799. * Executes a function on change
  78800. * @param f A path cursor onchange callback
  78801. * @returns This path cursor
  78802. */
  78803. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78804. }
  78805. }
  78806. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78807. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78808. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78809. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78810. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78811. }
  78812. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78813. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78814. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78815. }
  78816. declare module "babylonjs/Engines/Processors/index" {
  78817. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78818. export * from "babylonjs/Engines/Processors/Expressions/index";
  78819. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78820. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78821. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78822. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78823. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78824. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78825. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78826. }
  78827. declare module "babylonjs/Legacy/legacy" {
  78828. import * as Babylon from "babylonjs/index";
  78829. export * from "babylonjs/index";
  78830. }
  78831. declare module "babylonjs/Shaders/blur.fragment" {
  78832. /** @hidden */
  78833. export var blurPixelShader: {
  78834. name: string;
  78835. shader: string;
  78836. };
  78837. }
  78838. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78839. /** @hidden */
  78840. export var pointCloudVertexDeclaration: {
  78841. name: string;
  78842. shader: string;
  78843. };
  78844. }
  78845. declare module "babylonjs" {
  78846. export * from "babylonjs/Legacy/legacy";
  78847. }
  78848. declare module BABYLON {
  78849. /** Alias type for value that can be null */
  78850. export type Nullable<T> = T | null;
  78851. /**
  78852. * Alias type for number that are floats
  78853. * @ignorenaming
  78854. */
  78855. export type float = number;
  78856. /**
  78857. * Alias type for number that are doubles.
  78858. * @ignorenaming
  78859. */
  78860. export type double = number;
  78861. /**
  78862. * Alias type for number that are integer
  78863. * @ignorenaming
  78864. */
  78865. export type int = number;
  78866. /** Alias type for number array or Float32Array */
  78867. export type FloatArray = number[] | Float32Array;
  78868. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78869. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78870. /**
  78871. * Alias for types that can be used by a Buffer or VertexBuffer.
  78872. */
  78873. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78874. /**
  78875. * Alias type for primitive types
  78876. * @ignorenaming
  78877. */
  78878. type Primitive = undefined | null | boolean | string | number | Function;
  78879. /**
  78880. * Type modifier to make all the properties of an object Readonly
  78881. */
  78882. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78883. /**
  78884. * Type modifier to make all the properties of an object Readonly recursively
  78885. */
  78886. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78887. /**
  78888. * Type modifier to make object properties readonly.
  78889. */
  78890. export type DeepImmutableObject<T> = {
  78891. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78892. };
  78893. /** @hidden */
  78894. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78895. }
  78896. }
  78897. declare module BABYLON {
  78898. /**
  78899. * A class serves as a medium between the observable and its observers
  78900. */
  78901. export class EventState {
  78902. /**
  78903. * Create a new EventState
  78904. * @param mask defines the mask associated with this state
  78905. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78906. * @param target defines the original target of the state
  78907. * @param currentTarget defines the current target of the state
  78908. */
  78909. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78910. /**
  78911. * Initialize the current event state
  78912. * @param mask defines the mask associated with this state
  78913. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78914. * @param target defines the original target of the state
  78915. * @param currentTarget defines the current target of the state
  78916. * @returns the current event state
  78917. */
  78918. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78919. /**
  78920. * An Observer can set this property to true to prevent subsequent observers of being notified
  78921. */
  78922. skipNextObservers: boolean;
  78923. /**
  78924. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78925. */
  78926. mask: number;
  78927. /**
  78928. * The object that originally notified the event
  78929. */
  78930. target?: any;
  78931. /**
  78932. * The current object in the bubbling phase
  78933. */
  78934. currentTarget?: any;
  78935. /**
  78936. * This will be populated with the return value of the last function that was executed.
  78937. * If it is the first function in the callback chain it will be the event data.
  78938. */
  78939. lastReturnValue?: any;
  78940. }
  78941. /**
  78942. * Represent an Observer registered to a given Observable object.
  78943. */
  78944. export class Observer<T> {
  78945. /**
  78946. * Defines the callback to call when the observer is notified
  78947. */
  78948. callback: (eventData: T, eventState: EventState) => void;
  78949. /**
  78950. * Defines the mask of the observer (used to filter notifications)
  78951. */
  78952. mask: number;
  78953. /**
  78954. * Defines the current scope used to restore the JS context
  78955. */
  78956. scope: any;
  78957. /** @hidden */
  78958. _willBeUnregistered: boolean;
  78959. /**
  78960. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78961. */
  78962. unregisterOnNextCall: boolean;
  78963. /**
  78964. * Creates a new observer
  78965. * @param callback defines the callback to call when the observer is notified
  78966. * @param mask defines the mask of the observer (used to filter notifications)
  78967. * @param scope defines the current scope used to restore the JS context
  78968. */
  78969. constructor(
  78970. /**
  78971. * Defines the callback to call when the observer is notified
  78972. */
  78973. callback: (eventData: T, eventState: EventState) => void,
  78974. /**
  78975. * Defines the mask of the observer (used to filter notifications)
  78976. */
  78977. mask: number,
  78978. /**
  78979. * Defines the current scope used to restore the JS context
  78980. */
  78981. scope?: any);
  78982. }
  78983. /**
  78984. * Represent a list of observers registered to multiple Observables object.
  78985. */
  78986. export class MultiObserver<T> {
  78987. private _observers;
  78988. private _observables;
  78989. /**
  78990. * Release associated resources
  78991. */
  78992. dispose(): void;
  78993. /**
  78994. * Raise a callback when one of the observable will notify
  78995. * @param observables defines a list of observables to watch
  78996. * @param callback defines the callback to call on notification
  78997. * @param mask defines the mask used to filter notifications
  78998. * @param scope defines the current scope used to restore the JS context
  78999. * @returns the new MultiObserver
  79000. */
  79001. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79002. }
  79003. /**
  79004. * The Observable class is a simple implementation of the Observable pattern.
  79005. *
  79006. * 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.
  79007. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79008. * 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).
  79009. * 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.
  79010. */
  79011. export class Observable<T> {
  79012. private _observers;
  79013. private _eventState;
  79014. private _onObserverAdded;
  79015. /**
  79016. * Gets the list of observers
  79017. */
  79018. get observers(): Array<Observer<T>>;
  79019. /**
  79020. * Creates a new observable
  79021. * @param onObserverAdded defines a callback to call when a new observer is added
  79022. */
  79023. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79024. /**
  79025. * Create a new Observer with the specified callback
  79026. * @param callback the callback that will be executed for that Observer
  79027. * @param mask the mask used to filter observers
  79028. * @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.
  79029. * @param scope optional scope for the callback to be called from
  79030. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79031. * @returns the new observer created for the callback
  79032. */
  79033. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79034. /**
  79035. * Create a new Observer with the specified callback and unregisters after the next notification
  79036. * @param callback the callback that will be executed for that Observer
  79037. * @returns the new observer created for the callback
  79038. */
  79039. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79040. /**
  79041. * Remove an Observer from the Observable object
  79042. * @param observer the instance of the Observer to remove
  79043. * @returns false if it doesn't belong to this Observable
  79044. */
  79045. remove(observer: Nullable<Observer<T>>): boolean;
  79046. /**
  79047. * Remove a callback from the Observable object
  79048. * @param callback the callback to remove
  79049. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79050. * @returns false if it doesn't belong to this Observable
  79051. */
  79052. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79053. private _deferUnregister;
  79054. private _remove;
  79055. /**
  79056. * Moves the observable to the top of the observer list making it get called first when notified
  79057. * @param observer the observer to move
  79058. */
  79059. makeObserverTopPriority(observer: Observer<T>): void;
  79060. /**
  79061. * Moves the observable to the bottom of the observer list making it get called last when notified
  79062. * @param observer the observer to move
  79063. */
  79064. makeObserverBottomPriority(observer: Observer<T>): void;
  79065. /**
  79066. * Notify all Observers by calling their respective callback with the given data
  79067. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79068. * @param eventData defines the data to send to all observers
  79069. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79070. * @param target defines the original target of the state
  79071. * @param currentTarget defines the current target of the state
  79072. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79073. */
  79074. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79075. /**
  79076. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79077. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79078. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79079. * and it is crucial that all callbacks will be executed.
  79080. * The order of the callbacks is kept, callbacks are not executed parallel.
  79081. *
  79082. * @param eventData The data to be sent to each callback
  79083. * @param mask is used to filter observers defaults to -1
  79084. * @param target defines the callback target (see EventState)
  79085. * @param currentTarget defines he current object in the bubbling phase
  79086. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79087. */
  79088. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79089. /**
  79090. * Notify a specific observer
  79091. * @param observer defines the observer to notify
  79092. * @param eventData defines the data to be sent to each callback
  79093. * @param mask is used to filter observers defaults to -1
  79094. */
  79095. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79096. /**
  79097. * Gets a boolean indicating if the observable has at least one observer
  79098. * @returns true is the Observable has at least one Observer registered
  79099. */
  79100. hasObservers(): boolean;
  79101. /**
  79102. * Clear the list of observers
  79103. */
  79104. clear(): void;
  79105. /**
  79106. * Clone the current observable
  79107. * @returns a new observable
  79108. */
  79109. clone(): Observable<T>;
  79110. /**
  79111. * Does this observable handles observer registered with a given mask
  79112. * @param mask defines the mask to be tested
  79113. * @return whether or not one observer registered with the given mask is handeled
  79114. **/
  79115. hasSpecificMask(mask?: number): boolean;
  79116. }
  79117. }
  79118. declare module BABYLON {
  79119. /**
  79120. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79121. * Babylon.js
  79122. */
  79123. export class DomManagement {
  79124. /**
  79125. * Checks if the window object exists
  79126. * @returns true if the window object exists
  79127. */
  79128. static IsWindowObjectExist(): boolean;
  79129. /**
  79130. * Checks if the navigator object exists
  79131. * @returns true if the navigator object exists
  79132. */
  79133. static IsNavigatorAvailable(): boolean;
  79134. /**
  79135. * Check if the document object exists
  79136. * @returns true if the document object exists
  79137. */
  79138. static IsDocumentAvailable(): boolean;
  79139. /**
  79140. * Extracts text content from a DOM element hierarchy
  79141. * @param element defines the root element
  79142. * @returns a string
  79143. */
  79144. static GetDOMTextContent(element: HTMLElement): string;
  79145. }
  79146. }
  79147. declare module BABYLON {
  79148. /**
  79149. * Logger used througouht the application to allow configuration of
  79150. * the log level required for the messages.
  79151. */
  79152. export class Logger {
  79153. /**
  79154. * No log
  79155. */
  79156. static readonly NoneLogLevel: number;
  79157. /**
  79158. * Only message logs
  79159. */
  79160. static readonly MessageLogLevel: number;
  79161. /**
  79162. * Only warning logs
  79163. */
  79164. static readonly WarningLogLevel: number;
  79165. /**
  79166. * Only error logs
  79167. */
  79168. static readonly ErrorLogLevel: number;
  79169. /**
  79170. * All logs
  79171. */
  79172. static readonly AllLogLevel: number;
  79173. private static _LogCache;
  79174. /**
  79175. * Gets a value indicating the number of loading errors
  79176. * @ignorenaming
  79177. */
  79178. static errorsCount: number;
  79179. /**
  79180. * Callback called when a new log is added
  79181. */
  79182. static OnNewCacheEntry: (entry: string) => void;
  79183. private static _AddLogEntry;
  79184. private static _FormatMessage;
  79185. private static _LogDisabled;
  79186. private static _LogEnabled;
  79187. private static _WarnDisabled;
  79188. private static _WarnEnabled;
  79189. private static _ErrorDisabled;
  79190. private static _ErrorEnabled;
  79191. /**
  79192. * Log a message to the console
  79193. */
  79194. static Log: (message: string) => void;
  79195. /**
  79196. * Write a warning message to the console
  79197. */
  79198. static Warn: (message: string) => void;
  79199. /**
  79200. * Write an error message to the console
  79201. */
  79202. static Error: (message: string) => void;
  79203. /**
  79204. * Gets current log cache (list of logs)
  79205. */
  79206. static get LogCache(): string;
  79207. /**
  79208. * Clears the log cache
  79209. */
  79210. static ClearLogCache(): void;
  79211. /**
  79212. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79213. */
  79214. static set LogLevels(level: number);
  79215. }
  79216. }
  79217. declare module BABYLON {
  79218. /** @hidden */
  79219. export class _TypeStore {
  79220. /** @hidden */
  79221. static RegisteredTypes: {
  79222. [key: string]: Object;
  79223. };
  79224. /** @hidden */
  79225. static GetClass(fqdn: string): any;
  79226. }
  79227. }
  79228. declare module BABYLON {
  79229. /**
  79230. * Helper to manipulate strings
  79231. */
  79232. export class StringTools {
  79233. /**
  79234. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79235. * @param str Source string
  79236. * @param suffix Suffix to search for in the source string
  79237. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79238. */
  79239. static EndsWith(str: string, suffix: string): boolean;
  79240. /**
  79241. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79242. * @param str Source string
  79243. * @param suffix Suffix to search for in the source string
  79244. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79245. */
  79246. static StartsWith(str: string, suffix: string): boolean;
  79247. /**
  79248. * Decodes a buffer into a string
  79249. * @param buffer The buffer to decode
  79250. * @returns The decoded string
  79251. */
  79252. static Decode(buffer: Uint8Array | Uint16Array): string;
  79253. /**
  79254. * Encode a buffer to a base64 string
  79255. * @param buffer defines the buffer to encode
  79256. * @returns the encoded string
  79257. */
  79258. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79259. /**
  79260. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79261. * @param num the number to convert and pad
  79262. * @param length the expected length of the string
  79263. * @returns the padded string
  79264. */
  79265. static PadNumber(num: number, length: number): string;
  79266. }
  79267. }
  79268. declare module BABYLON {
  79269. /**
  79270. * Class containing a set of static utilities functions for deep copy.
  79271. */
  79272. export class DeepCopier {
  79273. /**
  79274. * Tries to copy an object by duplicating every property
  79275. * @param source defines the source object
  79276. * @param destination defines the target object
  79277. * @param doNotCopyList defines a list of properties to avoid
  79278. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79279. */
  79280. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79281. }
  79282. }
  79283. declare module BABYLON {
  79284. /**
  79285. * Class containing a set of static utilities functions for precision date
  79286. */
  79287. export class PrecisionDate {
  79288. /**
  79289. * Gets either window.performance.now() if supported or Date.now() else
  79290. */
  79291. static get Now(): number;
  79292. }
  79293. }
  79294. declare module BABYLON {
  79295. /** @hidden */
  79296. export class _DevTools {
  79297. static WarnImport(name: string): string;
  79298. }
  79299. }
  79300. declare module BABYLON {
  79301. /**
  79302. * Interface used to define the mechanism to get data from the network
  79303. */
  79304. export interface IWebRequest {
  79305. /**
  79306. * Returns client's response url
  79307. */
  79308. responseURL: string;
  79309. /**
  79310. * Returns client's status
  79311. */
  79312. status: number;
  79313. /**
  79314. * Returns client's status as a text
  79315. */
  79316. statusText: string;
  79317. }
  79318. }
  79319. declare module BABYLON {
  79320. /**
  79321. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79322. */
  79323. export class WebRequest implements IWebRequest {
  79324. private _xhr;
  79325. /**
  79326. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79327. * i.e. when loading files, where the server/service expects an Authorization header
  79328. */
  79329. static CustomRequestHeaders: {
  79330. [key: string]: string;
  79331. };
  79332. /**
  79333. * Add callback functions in this array to update all the requests before they get sent to the network
  79334. */
  79335. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79336. private _injectCustomRequestHeaders;
  79337. /**
  79338. * Gets or sets a function to be called when loading progress changes
  79339. */
  79340. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79341. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79342. /**
  79343. * Returns client's state
  79344. */
  79345. get readyState(): number;
  79346. /**
  79347. * Returns client's status
  79348. */
  79349. get status(): number;
  79350. /**
  79351. * Returns client's status as a text
  79352. */
  79353. get statusText(): string;
  79354. /**
  79355. * Returns client's response
  79356. */
  79357. get response(): any;
  79358. /**
  79359. * Returns client's response url
  79360. */
  79361. get responseURL(): string;
  79362. /**
  79363. * Returns client's response as text
  79364. */
  79365. get responseText(): string;
  79366. /**
  79367. * Gets or sets the expected response type
  79368. */
  79369. get responseType(): XMLHttpRequestResponseType;
  79370. set responseType(value: XMLHttpRequestResponseType);
  79371. /** @hidden */
  79372. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79373. /** @hidden */
  79374. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79375. /**
  79376. * Cancels any network activity
  79377. */
  79378. abort(): void;
  79379. /**
  79380. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79381. * @param body defines an optional request body
  79382. */
  79383. send(body?: Document | BodyInit | null): void;
  79384. /**
  79385. * Sets the request method, request URL
  79386. * @param method defines the method to use (GET, POST, etc..)
  79387. * @param url defines the url to connect with
  79388. */
  79389. open(method: string, url: string): void;
  79390. /**
  79391. * Sets the value of a request header.
  79392. * @param name The name of the header whose value is to be set
  79393. * @param value The value to set as the body of the header
  79394. */
  79395. setRequestHeader(name: string, value: string): void;
  79396. /**
  79397. * Get the string containing the text of a particular header's value.
  79398. * @param name The name of the header
  79399. * @returns The string containing the text of the given header name
  79400. */
  79401. getResponseHeader(name: string): Nullable<string>;
  79402. }
  79403. }
  79404. declare module BABYLON {
  79405. /**
  79406. * File request interface
  79407. */
  79408. export interface IFileRequest {
  79409. /**
  79410. * Raised when the request is complete (success or error).
  79411. */
  79412. onCompleteObservable: Observable<IFileRequest>;
  79413. /**
  79414. * Aborts the request for a file.
  79415. */
  79416. abort: () => void;
  79417. }
  79418. }
  79419. declare module BABYLON {
  79420. /**
  79421. * Define options used to create a render target texture
  79422. */
  79423. export class RenderTargetCreationOptions {
  79424. /**
  79425. * Specifies is mipmaps must be generated
  79426. */
  79427. generateMipMaps?: boolean;
  79428. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79429. generateDepthBuffer?: boolean;
  79430. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79431. generateStencilBuffer?: boolean;
  79432. /** Defines texture type (int by default) */
  79433. type?: number;
  79434. /** Defines sampling mode (trilinear by default) */
  79435. samplingMode?: number;
  79436. /** Defines format (RGBA by default) */
  79437. format?: number;
  79438. }
  79439. }
  79440. declare module BABYLON {
  79441. /** Defines the cross module used constants to avoid circular dependncies */
  79442. export class Constants {
  79443. /** Defines that alpha blending is disabled */
  79444. static readonly ALPHA_DISABLE: number;
  79445. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79446. static readonly ALPHA_ADD: number;
  79447. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79448. static readonly ALPHA_COMBINE: number;
  79449. /** Defines that alpha blending is DEST - SRC * DEST */
  79450. static readonly ALPHA_SUBTRACT: number;
  79451. /** Defines that alpha blending is SRC * DEST */
  79452. static readonly ALPHA_MULTIPLY: number;
  79453. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79454. static readonly ALPHA_MAXIMIZED: number;
  79455. /** Defines that alpha blending is SRC + DEST */
  79456. static readonly ALPHA_ONEONE: number;
  79457. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79458. static readonly ALPHA_PREMULTIPLIED: number;
  79459. /**
  79460. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79461. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79462. */
  79463. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79464. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79465. static readonly ALPHA_INTERPOLATE: number;
  79466. /**
  79467. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79468. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79469. */
  79470. static readonly ALPHA_SCREENMODE: number;
  79471. /**
  79472. * Defines that alpha blending is SRC + DST
  79473. * Alpha will be set to SRC ALPHA + DST ALPHA
  79474. */
  79475. static readonly ALPHA_ONEONE_ONEONE: number;
  79476. /**
  79477. * Defines that alpha blending is SRC * DST ALPHA + DST
  79478. * Alpha will be set to 0
  79479. */
  79480. static readonly ALPHA_ALPHATOCOLOR: number;
  79481. /**
  79482. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79483. */
  79484. static readonly ALPHA_REVERSEONEMINUS: number;
  79485. /**
  79486. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79487. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79488. */
  79489. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79490. /**
  79491. * Defines that alpha blending is SRC + DST
  79492. * Alpha will be set to SRC ALPHA
  79493. */
  79494. static readonly ALPHA_ONEONE_ONEZERO: number;
  79495. /**
  79496. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79497. * Alpha will be set to DST ALPHA
  79498. */
  79499. static readonly ALPHA_EXCLUSION: number;
  79500. /** Defines that alpha blending equation a SUM */
  79501. static readonly ALPHA_EQUATION_ADD: number;
  79502. /** Defines that alpha blending equation a SUBSTRACTION */
  79503. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79504. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79505. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79506. /** Defines that alpha blending equation a MAX operation */
  79507. static readonly ALPHA_EQUATION_MAX: number;
  79508. /** Defines that alpha blending equation a MIN operation */
  79509. static readonly ALPHA_EQUATION_MIN: number;
  79510. /**
  79511. * Defines that alpha blending equation a DARKEN operation:
  79512. * It takes the min of the src and sums the alpha channels.
  79513. */
  79514. static readonly ALPHA_EQUATION_DARKEN: number;
  79515. /** Defines that the ressource is not delayed*/
  79516. static readonly DELAYLOADSTATE_NONE: number;
  79517. /** Defines that the ressource was successfully delay loaded */
  79518. static readonly DELAYLOADSTATE_LOADED: number;
  79519. /** Defines that the ressource is currently delay loading */
  79520. static readonly DELAYLOADSTATE_LOADING: number;
  79521. /** Defines that the ressource is delayed and has not started loading */
  79522. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79523. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79524. static readonly NEVER: number;
  79525. /** 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 */
  79526. static readonly ALWAYS: number;
  79527. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79528. static readonly LESS: number;
  79529. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79530. static readonly EQUAL: number;
  79531. /** 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 */
  79532. static readonly LEQUAL: number;
  79533. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79534. static readonly GREATER: number;
  79535. /** 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 */
  79536. static readonly GEQUAL: number;
  79537. /** 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 */
  79538. static readonly NOTEQUAL: number;
  79539. /** Passed to stencilOperation to specify that stencil value must be kept */
  79540. static readonly KEEP: number;
  79541. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79542. static readonly REPLACE: number;
  79543. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79544. static readonly INCR: number;
  79545. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79546. static readonly DECR: number;
  79547. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79548. static readonly INVERT: number;
  79549. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79550. static readonly INCR_WRAP: number;
  79551. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79552. static readonly DECR_WRAP: number;
  79553. /** Texture is not repeating outside of 0..1 UVs */
  79554. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79555. /** Texture is repeating outside of 0..1 UVs */
  79556. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79557. /** Texture is repeating and mirrored */
  79558. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79559. /** ALPHA */
  79560. static readonly TEXTUREFORMAT_ALPHA: number;
  79561. /** LUMINANCE */
  79562. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79563. /** LUMINANCE_ALPHA */
  79564. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79565. /** RGB */
  79566. static readonly TEXTUREFORMAT_RGB: number;
  79567. /** RGBA */
  79568. static readonly TEXTUREFORMAT_RGBA: number;
  79569. /** RED */
  79570. static readonly TEXTUREFORMAT_RED: number;
  79571. /** RED (2nd reference) */
  79572. static readonly TEXTUREFORMAT_R: number;
  79573. /** RG */
  79574. static readonly TEXTUREFORMAT_RG: number;
  79575. /** RED_INTEGER */
  79576. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79577. /** RED_INTEGER (2nd reference) */
  79578. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79579. /** RG_INTEGER */
  79580. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79581. /** RGB_INTEGER */
  79582. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79583. /** RGBA_INTEGER */
  79584. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79585. /** UNSIGNED_BYTE */
  79586. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79587. /** UNSIGNED_BYTE (2nd reference) */
  79588. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79589. /** FLOAT */
  79590. static readonly TEXTURETYPE_FLOAT: number;
  79591. /** HALF_FLOAT */
  79592. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79593. /** BYTE */
  79594. static readonly TEXTURETYPE_BYTE: number;
  79595. /** SHORT */
  79596. static readonly TEXTURETYPE_SHORT: number;
  79597. /** UNSIGNED_SHORT */
  79598. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79599. /** INT */
  79600. static readonly TEXTURETYPE_INT: number;
  79601. /** UNSIGNED_INT */
  79602. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79603. /** UNSIGNED_SHORT_4_4_4_4 */
  79604. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79605. /** UNSIGNED_SHORT_5_5_5_1 */
  79606. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79607. /** UNSIGNED_SHORT_5_6_5 */
  79608. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79609. /** UNSIGNED_INT_2_10_10_10_REV */
  79610. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79611. /** UNSIGNED_INT_24_8 */
  79612. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79613. /** UNSIGNED_INT_10F_11F_11F_REV */
  79614. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79615. /** UNSIGNED_INT_5_9_9_9_REV */
  79616. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79617. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79618. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79619. /** nearest is mag = nearest and min = nearest and no mip */
  79620. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79621. /** mag = nearest and min = nearest and mip = none */
  79622. static readonly TEXTURE_NEAREST_NEAREST: number;
  79623. /** Bilinear is mag = linear and min = linear and no mip */
  79624. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79625. /** mag = linear and min = linear and mip = none */
  79626. static readonly TEXTURE_LINEAR_LINEAR: number;
  79627. /** Trilinear is mag = linear and min = linear and mip = linear */
  79628. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79629. /** Trilinear is mag = linear and min = linear and mip = linear */
  79630. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79631. /** mag = nearest and min = nearest and mip = nearest */
  79632. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79633. /** mag = nearest and min = linear and mip = nearest */
  79634. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79635. /** mag = nearest and min = linear and mip = linear */
  79636. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79637. /** mag = nearest and min = linear and mip = none */
  79638. static readonly TEXTURE_NEAREST_LINEAR: number;
  79639. /** nearest is mag = nearest and min = nearest and mip = linear */
  79640. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79641. /** mag = linear and min = nearest and mip = nearest */
  79642. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79643. /** mag = linear and min = nearest and mip = linear */
  79644. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79645. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79646. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79647. /** mag = linear and min = nearest and mip = none */
  79648. static readonly TEXTURE_LINEAR_NEAREST: number;
  79649. /** Explicit coordinates mode */
  79650. static readonly TEXTURE_EXPLICIT_MODE: number;
  79651. /** Spherical coordinates mode */
  79652. static readonly TEXTURE_SPHERICAL_MODE: number;
  79653. /** Planar coordinates mode */
  79654. static readonly TEXTURE_PLANAR_MODE: number;
  79655. /** Cubic coordinates mode */
  79656. static readonly TEXTURE_CUBIC_MODE: number;
  79657. /** Projection coordinates mode */
  79658. static readonly TEXTURE_PROJECTION_MODE: number;
  79659. /** Skybox coordinates mode */
  79660. static readonly TEXTURE_SKYBOX_MODE: number;
  79661. /** Inverse Cubic coordinates mode */
  79662. static readonly TEXTURE_INVCUBIC_MODE: number;
  79663. /** Equirectangular coordinates mode */
  79664. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79665. /** Equirectangular Fixed coordinates mode */
  79666. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79667. /** Equirectangular Fixed Mirrored coordinates mode */
  79668. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79669. /** Offline (baking) quality for texture filtering */
  79670. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79671. /** High quality for texture filtering */
  79672. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79673. /** Medium quality for texture filtering */
  79674. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79675. /** Low quality for texture filtering */
  79676. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79677. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79678. static readonly SCALEMODE_FLOOR: number;
  79679. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79680. static readonly SCALEMODE_NEAREST: number;
  79681. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79682. static readonly SCALEMODE_CEILING: number;
  79683. /**
  79684. * The dirty texture flag value
  79685. */
  79686. static readonly MATERIAL_TextureDirtyFlag: number;
  79687. /**
  79688. * The dirty light flag value
  79689. */
  79690. static readonly MATERIAL_LightDirtyFlag: number;
  79691. /**
  79692. * The dirty fresnel flag value
  79693. */
  79694. static readonly MATERIAL_FresnelDirtyFlag: number;
  79695. /**
  79696. * The dirty attribute flag value
  79697. */
  79698. static readonly MATERIAL_AttributesDirtyFlag: number;
  79699. /**
  79700. * The dirty misc flag value
  79701. */
  79702. static readonly MATERIAL_MiscDirtyFlag: number;
  79703. /**
  79704. * The all dirty flag value
  79705. */
  79706. static readonly MATERIAL_AllDirtyFlag: number;
  79707. /**
  79708. * Returns the triangle fill mode
  79709. */
  79710. static readonly MATERIAL_TriangleFillMode: number;
  79711. /**
  79712. * Returns the wireframe mode
  79713. */
  79714. static readonly MATERIAL_WireFrameFillMode: number;
  79715. /**
  79716. * Returns the point fill mode
  79717. */
  79718. static readonly MATERIAL_PointFillMode: number;
  79719. /**
  79720. * Returns the point list draw mode
  79721. */
  79722. static readonly MATERIAL_PointListDrawMode: number;
  79723. /**
  79724. * Returns the line list draw mode
  79725. */
  79726. static readonly MATERIAL_LineListDrawMode: number;
  79727. /**
  79728. * Returns the line loop draw mode
  79729. */
  79730. static readonly MATERIAL_LineLoopDrawMode: number;
  79731. /**
  79732. * Returns the line strip draw mode
  79733. */
  79734. static readonly MATERIAL_LineStripDrawMode: number;
  79735. /**
  79736. * Returns the triangle strip draw mode
  79737. */
  79738. static readonly MATERIAL_TriangleStripDrawMode: number;
  79739. /**
  79740. * Returns the triangle fan draw mode
  79741. */
  79742. static readonly MATERIAL_TriangleFanDrawMode: number;
  79743. /**
  79744. * Stores the clock-wise side orientation
  79745. */
  79746. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79747. /**
  79748. * Stores the counter clock-wise side orientation
  79749. */
  79750. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79751. /**
  79752. * Nothing
  79753. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79754. */
  79755. static readonly ACTION_NothingTrigger: number;
  79756. /**
  79757. * On pick
  79758. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79759. */
  79760. static readonly ACTION_OnPickTrigger: number;
  79761. /**
  79762. * On left pick
  79763. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79764. */
  79765. static readonly ACTION_OnLeftPickTrigger: number;
  79766. /**
  79767. * On right pick
  79768. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79769. */
  79770. static readonly ACTION_OnRightPickTrigger: number;
  79771. /**
  79772. * On center pick
  79773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79774. */
  79775. static readonly ACTION_OnCenterPickTrigger: number;
  79776. /**
  79777. * On pick down
  79778. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79779. */
  79780. static readonly ACTION_OnPickDownTrigger: number;
  79781. /**
  79782. * On double pick
  79783. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79784. */
  79785. static readonly ACTION_OnDoublePickTrigger: number;
  79786. /**
  79787. * On pick up
  79788. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79789. */
  79790. static readonly ACTION_OnPickUpTrigger: number;
  79791. /**
  79792. * On pick out.
  79793. * This trigger will only be raised if you also declared a OnPickDown
  79794. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79795. */
  79796. static readonly ACTION_OnPickOutTrigger: number;
  79797. /**
  79798. * On long press
  79799. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79800. */
  79801. static readonly ACTION_OnLongPressTrigger: number;
  79802. /**
  79803. * On pointer over
  79804. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79805. */
  79806. static readonly ACTION_OnPointerOverTrigger: number;
  79807. /**
  79808. * On pointer out
  79809. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79810. */
  79811. static readonly ACTION_OnPointerOutTrigger: number;
  79812. /**
  79813. * On every frame
  79814. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79815. */
  79816. static readonly ACTION_OnEveryFrameTrigger: number;
  79817. /**
  79818. * On intersection enter
  79819. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79820. */
  79821. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79822. /**
  79823. * On intersection exit
  79824. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79825. */
  79826. static readonly ACTION_OnIntersectionExitTrigger: number;
  79827. /**
  79828. * On key down
  79829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79830. */
  79831. static readonly ACTION_OnKeyDownTrigger: number;
  79832. /**
  79833. * On key up
  79834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79835. */
  79836. static readonly ACTION_OnKeyUpTrigger: number;
  79837. /**
  79838. * Billboard mode will only apply to Y axis
  79839. */
  79840. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79841. /**
  79842. * Billboard mode will apply to all axes
  79843. */
  79844. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79845. /**
  79846. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79847. */
  79848. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79849. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79850. * Test order :
  79851. * Is the bounding sphere outside the frustum ?
  79852. * If not, are the bounding box vertices outside the frustum ?
  79853. * It not, then the cullable object is in the frustum.
  79854. */
  79855. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79856. /** Culling strategy : Bounding Sphere Only.
  79857. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79858. * It's also less accurate than the standard because some not visible objects can still be selected.
  79859. * Test : is the bounding sphere outside the frustum ?
  79860. * If not, then the cullable object is in the frustum.
  79861. */
  79862. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79863. /** Culling strategy : Optimistic Inclusion.
  79864. * This in an inclusion test first, then the standard exclusion test.
  79865. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79866. * 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.
  79867. * Anyway, it's as accurate as the standard strategy.
  79868. * Test :
  79869. * Is the cullable object bounding sphere center in the frustum ?
  79870. * If not, apply the default culling strategy.
  79871. */
  79872. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79873. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79874. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79875. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79876. * 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.
  79877. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79878. * Test :
  79879. * Is the cullable object bounding sphere center in the frustum ?
  79880. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79881. */
  79882. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79883. /**
  79884. * No logging while loading
  79885. */
  79886. static readonly SCENELOADER_NO_LOGGING: number;
  79887. /**
  79888. * Minimal logging while loading
  79889. */
  79890. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79891. /**
  79892. * Summary logging while loading
  79893. */
  79894. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79895. /**
  79896. * Detailled logging while loading
  79897. */
  79898. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79899. /**
  79900. * Prepass texture index for color
  79901. */
  79902. static readonly PREPASS_COLOR_INDEX: number;
  79903. /**
  79904. * Prepass texture index for irradiance
  79905. */
  79906. static readonly PREPASS_IRRADIANCE_INDEX: number;
  79907. /**
  79908. * Prepass texture index for depth + normal
  79909. */
  79910. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  79911. /**
  79912. * Prepass texture index for albedo
  79913. */
  79914. static readonly PREPASS_ALBEDO_INDEX: number;
  79915. }
  79916. }
  79917. declare module BABYLON {
  79918. /**
  79919. * This represents the required contract to create a new type of texture loader.
  79920. */
  79921. export interface IInternalTextureLoader {
  79922. /**
  79923. * Defines wether the loader supports cascade loading the different faces.
  79924. */
  79925. supportCascades: boolean;
  79926. /**
  79927. * This returns if the loader support the current file information.
  79928. * @param extension defines the file extension of the file being loaded
  79929. * @param mimeType defines the optional mime type of the file being loaded
  79930. * @returns true if the loader can load the specified file
  79931. */
  79932. canLoad(extension: string, mimeType?: string): boolean;
  79933. /**
  79934. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79935. * @param data contains the texture data
  79936. * @param texture defines the BabylonJS internal texture
  79937. * @param createPolynomials will be true if polynomials have been requested
  79938. * @param onLoad defines the callback to trigger once the texture is ready
  79939. * @param onError defines the callback to trigger in case of error
  79940. */
  79941. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79942. /**
  79943. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79944. * @param data contains the texture data
  79945. * @param texture defines the BabylonJS internal texture
  79946. * @param callback defines the method to call once ready to upload
  79947. */
  79948. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79949. }
  79950. }
  79951. declare module BABYLON {
  79952. /**
  79953. * Class used to store and describe the pipeline context associated with an effect
  79954. */
  79955. export interface IPipelineContext {
  79956. /**
  79957. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79958. */
  79959. isAsync: boolean;
  79960. /**
  79961. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79962. */
  79963. isReady: boolean;
  79964. /** @hidden */
  79965. _getVertexShaderCode(): string | null;
  79966. /** @hidden */
  79967. _getFragmentShaderCode(): string | null;
  79968. /** @hidden */
  79969. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79970. }
  79971. }
  79972. declare module BABYLON {
  79973. /**
  79974. * Class used to store gfx data (like WebGLBuffer)
  79975. */
  79976. export class DataBuffer {
  79977. /**
  79978. * Gets or sets the number of objects referencing this buffer
  79979. */
  79980. references: number;
  79981. /** Gets or sets the size of the underlying buffer */
  79982. capacity: number;
  79983. /**
  79984. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79985. */
  79986. is32Bits: boolean;
  79987. /**
  79988. * Gets the underlying buffer
  79989. */
  79990. get underlyingResource(): any;
  79991. }
  79992. }
  79993. declare module BABYLON {
  79994. /** @hidden */
  79995. export interface IShaderProcessor {
  79996. attributeProcessor?: (attribute: string) => string;
  79997. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79998. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79999. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80000. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80001. lineProcessor?: (line: string, isFragment: boolean) => string;
  80002. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80003. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80004. }
  80005. }
  80006. declare module BABYLON {
  80007. /** @hidden */
  80008. export interface ProcessingOptions {
  80009. defines: string[];
  80010. indexParameters: any;
  80011. isFragment: boolean;
  80012. shouldUseHighPrecisionShader: boolean;
  80013. supportsUniformBuffers: boolean;
  80014. shadersRepository: string;
  80015. includesShadersStore: {
  80016. [key: string]: string;
  80017. };
  80018. processor?: IShaderProcessor;
  80019. version: string;
  80020. platformName: string;
  80021. lookForClosingBracketForUniformBuffer?: boolean;
  80022. }
  80023. }
  80024. declare module BABYLON {
  80025. /** @hidden */
  80026. export class ShaderCodeNode {
  80027. line: string;
  80028. children: ShaderCodeNode[];
  80029. additionalDefineKey?: string;
  80030. additionalDefineValue?: string;
  80031. isValid(preprocessors: {
  80032. [key: string]: string;
  80033. }): boolean;
  80034. process(preprocessors: {
  80035. [key: string]: string;
  80036. }, options: ProcessingOptions): string;
  80037. }
  80038. }
  80039. declare module BABYLON {
  80040. /** @hidden */
  80041. export class ShaderCodeCursor {
  80042. private _lines;
  80043. lineIndex: number;
  80044. get currentLine(): string;
  80045. get canRead(): boolean;
  80046. set lines(value: string[]);
  80047. }
  80048. }
  80049. declare module BABYLON {
  80050. /** @hidden */
  80051. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80052. process(preprocessors: {
  80053. [key: string]: string;
  80054. }, options: ProcessingOptions): string;
  80055. }
  80056. }
  80057. declare module BABYLON {
  80058. /** @hidden */
  80059. export class ShaderDefineExpression {
  80060. isTrue(preprocessors: {
  80061. [key: string]: string;
  80062. }): boolean;
  80063. private static _OperatorPriority;
  80064. private static _Stack;
  80065. static postfixToInfix(postfix: string[]): string;
  80066. static infixToPostfix(infix: string): string[];
  80067. }
  80068. }
  80069. declare module BABYLON {
  80070. /** @hidden */
  80071. export class ShaderCodeTestNode extends ShaderCodeNode {
  80072. testExpression: ShaderDefineExpression;
  80073. isValid(preprocessors: {
  80074. [key: string]: string;
  80075. }): boolean;
  80076. }
  80077. }
  80078. declare module BABYLON {
  80079. /** @hidden */
  80080. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80081. define: string;
  80082. not: boolean;
  80083. constructor(define: string, not?: boolean);
  80084. isTrue(preprocessors: {
  80085. [key: string]: string;
  80086. }): boolean;
  80087. }
  80088. }
  80089. declare module BABYLON {
  80090. /** @hidden */
  80091. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80092. leftOperand: ShaderDefineExpression;
  80093. rightOperand: ShaderDefineExpression;
  80094. isTrue(preprocessors: {
  80095. [key: string]: string;
  80096. }): boolean;
  80097. }
  80098. }
  80099. declare module BABYLON {
  80100. /** @hidden */
  80101. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80102. leftOperand: ShaderDefineExpression;
  80103. rightOperand: ShaderDefineExpression;
  80104. isTrue(preprocessors: {
  80105. [key: string]: string;
  80106. }): boolean;
  80107. }
  80108. }
  80109. declare module BABYLON {
  80110. /** @hidden */
  80111. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80112. define: string;
  80113. operand: string;
  80114. testValue: string;
  80115. constructor(define: string, operand: string, testValue: string);
  80116. isTrue(preprocessors: {
  80117. [key: string]: string;
  80118. }): boolean;
  80119. }
  80120. }
  80121. declare module BABYLON {
  80122. /**
  80123. * Class used to enable access to offline support
  80124. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80125. */
  80126. export interface IOfflineProvider {
  80127. /**
  80128. * Gets a boolean indicating if scene must be saved in the database
  80129. */
  80130. enableSceneOffline: boolean;
  80131. /**
  80132. * Gets a boolean indicating if textures must be saved in the database
  80133. */
  80134. enableTexturesOffline: boolean;
  80135. /**
  80136. * Open the offline support and make it available
  80137. * @param successCallback defines the callback to call on success
  80138. * @param errorCallback defines the callback to call on error
  80139. */
  80140. open(successCallback: () => void, errorCallback: () => void): void;
  80141. /**
  80142. * Loads an image from the offline support
  80143. * @param url defines the url to load from
  80144. * @param image defines the target DOM image
  80145. */
  80146. loadImage(url: string, image: HTMLImageElement): void;
  80147. /**
  80148. * Loads a file from offline support
  80149. * @param url defines the URL to load from
  80150. * @param sceneLoaded defines a callback to call on success
  80151. * @param progressCallBack defines a callback to call when progress changed
  80152. * @param errorCallback defines a callback to call on error
  80153. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80154. */
  80155. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80156. }
  80157. }
  80158. declare module BABYLON {
  80159. /**
  80160. * Class used to help managing file picking and drag'n'drop
  80161. * File Storage
  80162. */
  80163. export class FilesInputStore {
  80164. /**
  80165. * List of files ready to be loaded
  80166. */
  80167. static FilesToLoad: {
  80168. [key: string]: File;
  80169. };
  80170. }
  80171. }
  80172. declare module BABYLON {
  80173. /**
  80174. * Class used to define a retry strategy when error happens while loading assets
  80175. */
  80176. export class RetryStrategy {
  80177. /**
  80178. * Function used to defines an exponential back off strategy
  80179. * @param maxRetries defines the maximum number of retries (3 by default)
  80180. * @param baseInterval defines the interval between retries
  80181. * @returns the strategy function to use
  80182. */
  80183. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80184. }
  80185. }
  80186. declare module BABYLON {
  80187. /**
  80188. * @ignore
  80189. * Application error to support additional information when loading a file
  80190. */
  80191. export abstract class BaseError extends Error {
  80192. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80193. }
  80194. }
  80195. declare module BABYLON {
  80196. /** @ignore */
  80197. export class LoadFileError extends BaseError {
  80198. request?: WebRequest;
  80199. file?: File;
  80200. /**
  80201. * Creates a new LoadFileError
  80202. * @param message defines the message of the error
  80203. * @param request defines the optional web request
  80204. * @param file defines the optional file
  80205. */
  80206. constructor(message: string, object?: WebRequest | File);
  80207. }
  80208. /** @ignore */
  80209. export class RequestFileError extends BaseError {
  80210. request: WebRequest;
  80211. /**
  80212. * Creates a new LoadFileError
  80213. * @param message defines the message of the error
  80214. * @param request defines the optional web request
  80215. */
  80216. constructor(message: string, request: WebRequest);
  80217. }
  80218. /** @ignore */
  80219. export class ReadFileError extends BaseError {
  80220. file: File;
  80221. /**
  80222. * Creates a new ReadFileError
  80223. * @param message defines the message of the error
  80224. * @param file defines the optional file
  80225. */
  80226. constructor(message: string, file: File);
  80227. }
  80228. /**
  80229. * @hidden
  80230. */
  80231. export class FileTools {
  80232. /**
  80233. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80234. */
  80235. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80236. /**
  80237. * Gets or sets the base URL to use to load assets
  80238. */
  80239. static BaseUrl: string;
  80240. /**
  80241. * Default behaviour for cors in the application.
  80242. * It can be a string if the expected behavior is identical in the entire app.
  80243. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80244. */
  80245. static CorsBehavior: string | ((url: string | string[]) => string);
  80246. /**
  80247. * Gets or sets a function used to pre-process url before using them to load assets
  80248. */
  80249. static PreprocessUrl: (url: string) => string;
  80250. /**
  80251. * Removes unwanted characters from an url
  80252. * @param url defines the url to clean
  80253. * @returns the cleaned url
  80254. */
  80255. private static _CleanUrl;
  80256. /**
  80257. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80258. * @param url define the url we are trying
  80259. * @param element define the dom element where to configure the cors policy
  80260. */
  80261. static SetCorsBehavior(url: string | string[], element: {
  80262. crossOrigin: string | null;
  80263. }): void;
  80264. /**
  80265. * Loads an image as an HTMLImageElement.
  80266. * @param input url string, ArrayBuffer, or Blob to load
  80267. * @param onLoad callback called when the image successfully loads
  80268. * @param onError callback called when the image fails to load
  80269. * @param offlineProvider offline provider for caching
  80270. * @param mimeType optional mime type
  80271. * @returns the HTMLImageElement of the loaded image
  80272. */
  80273. 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>;
  80274. /**
  80275. * Reads a file from a File object
  80276. * @param file defines the file to load
  80277. * @param onSuccess defines the callback to call when data is loaded
  80278. * @param onProgress defines the callback to call during loading process
  80279. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80280. * @param onError defines the callback to call when an error occurs
  80281. * @returns a file request object
  80282. */
  80283. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80284. /**
  80285. * Loads a file from a url
  80286. * @param url url to load
  80287. * @param onSuccess callback called when the file successfully loads
  80288. * @param onProgress callback called while file is loading (if the server supports this mode)
  80289. * @param offlineProvider defines the offline provider for caching
  80290. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80291. * @param onError callback called when the file fails to load
  80292. * @returns a file request object
  80293. */
  80294. 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;
  80295. /**
  80296. * Loads a file
  80297. * @param url url to load
  80298. * @param onSuccess callback called when the file successfully loads
  80299. * @param onProgress callback called while file is loading (if the server supports this mode)
  80300. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80301. * @param onError callback called when the file fails to load
  80302. * @param onOpened callback called when the web request is opened
  80303. * @returns a file request object
  80304. */
  80305. 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;
  80306. /**
  80307. * Checks if the loaded document was accessed via `file:`-Protocol.
  80308. * @returns boolean
  80309. */
  80310. static IsFileURL(): boolean;
  80311. }
  80312. }
  80313. declare module BABYLON {
  80314. /** @hidden */
  80315. export class ShaderProcessor {
  80316. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80317. private static _ProcessPrecision;
  80318. private static _ExtractOperation;
  80319. private static _BuildSubExpression;
  80320. private static _BuildExpression;
  80321. private static _MoveCursorWithinIf;
  80322. private static _MoveCursor;
  80323. private static _EvaluatePreProcessors;
  80324. private static _PreparePreProcessors;
  80325. private static _ProcessShaderConversion;
  80326. private static _ProcessIncludes;
  80327. /**
  80328. * Loads a file from a url
  80329. * @param url url to load
  80330. * @param onSuccess callback called when the file successfully loads
  80331. * @param onProgress callback called while file is loading (if the server supports this mode)
  80332. * @param offlineProvider defines the offline provider for caching
  80333. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80334. * @param onError callback called when the file fails to load
  80335. * @returns a file request object
  80336. * @hidden
  80337. */
  80338. 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;
  80339. }
  80340. }
  80341. declare module BABYLON {
  80342. /**
  80343. * @hidden
  80344. */
  80345. export interface IColor4Like {
  80346. r: float;
  80347. g: float;
  80348. b: float;
  80349. a: float;
  80350. }
  80351. /**
  80352. * @hidden
  80353. */
  80354. export interface IColor3Like {
  80355. r: float;
  80356. g: float;
  80357. b: float;
  80358. }
  80359. /**
  80360. * @hidden
  80361. */
  80362. export interface IVector4Like {
  80363. x: float;
  80364. y: float;
  80365. z: float;
  80366. w: float;
  80367. }
  80368. /**
  80369. * @hidden
  80370. */
  80371. export interface IVector3Like {
  80372. x: float;
  80373. y: float;
  80374. z: float;
  80375. }
  80376. /**
  80377. * @hidden
  80378. */
  80379. export interface IVector2Like {
  80380. x: float;
  80381. y: float;
  80382. }
  80383. /**
  80384. * @hidden
  80385. */
  80386. export interface IMatrixLike {
  80387. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80388. updateFlag: int;
  80389. }
  80390. /**
  80391. * @hidden
  80392. */
  80393. export interface IViewportLike {
  80394. x: float;
  80395. y: float;
  80396. width: float;
  80397. height: float;
  80398. }
  80399. /**
  80400. * @hidden
  80401. */
  80402. export interface IPlaneLike {
  80403. normal: IVector3Like;
  80404. d: float;
  80405. normalize(): void;
  80406. }
  80407. }
  80408. declare module BABYLON {
  80409. /**
  80410. * Interface used to define common properties for effect fallbacks
  80411. */
  80412. export interface IEffectFallbacks {
  80413. /**
  80414. * Removes the defines that should be removed when falling back.
  80415. * @param currentDefines defines the current define statements for the shader.
  80416. * @param effect defines the current effect we try to compile
  80417. * @returns The resulting defines with defines of the current rank removed.
  80418. */
  80419. reduce(currentDefines: string, effect: Effect): string;
  80420. /**
  80421. * Removes the fallback from the bound mesh.
  80422. */
  80423. unBindMesh(): void;
  80424. /**
  80425. * Checks to see if more fallbacks are still availible.
  80426. */
  80427. hasMoreFallbacks: boolean;
  80428. }
  80429. }
  80430. declare module BABYLON {
  80431. /**
  80432. * Class used to evalaute queries containing `and` and `or` operators
  80433. */
  80434. export class AndOrNotEvaluator {
  80435. /**
  80436. * Evaluate a query
  80437. * @param query defines the query to evaluate
  80438. * @param evaluateCallback defines the callback used to filter result
  80439. * @returns true if the query matches
  80440. */
  80441. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80442. private static _HandleParenthesisContent;
  80443. private static _SimplifyNegation;
  80444. }
  80445. }
  80446. declare module BABYLON {
  80447. /**
  80448. * Class used to store custom tags
  80449. */
  80450. export class Tags {
  80451. /**
  80452. * Adds support for tags on the given object
  80453. * @param obj defines the object to use
  80454. */
  80455. static EnableFor(obj: any): void;
  80456. /**
  80457. * Removes tags support
  80458. * @param obj defines the object to use
  80459. */
  80460. static DisableFor(obj: any): void;
  80461. /**
  80462. * Gets a boolean indicating if the given object has tags
  80463. * @param obj defines the object to use
  80464. * @returns a boolean
  80465. */
  80466. static HasTags(obj: any): boolean;
  80467. /**
  80468. * Gets the tags available on a given object
  80469. * @param obj defines the object to use
  80470. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80471. * @returns the tags
  80472. */
  80473. static GetTags(obj: any, asString?: boolean): any;
  80474. /**
  80475. * Adds tags to an object
  80476. * @param obj defines the object to use
  80477. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80478. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80479. */
  80480. static AddTagsTo(obj: any, tagsString: string): void;
  80481. /**
  80482. * @hidden
  80483. */
  80484. static _AddTagTo(obj: any, tag: string): void;
  80485. /**
  80486. * Removes specific tags from a specific object
  80487. * @param obj defines the object to use
  80488. * @param tagsString defines the tags to remove
  80489. */
  80490. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80491. /**
  80492. * @hidden
  80493. */
  80494. static _RemoveTagFrom(obj: any, tag: string): void;
  80495. /**
  80496. * Defines if tags hosted on an object match a given query
  80497. * @param obj defines the object to use
  80498. * @param tagsQuery defines the tag query
  80499. * @returns a boolean
  80500. */
  80501. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80502. }
  80503. }
  80504. declare module BABYLON {
  80505. /**
  80506. * Scalar computation library
  80507. */
  80508. export class Scalar {
  80509. /**
  80510. * Two pi constants convenient for computation.
  80511. */
  80512. static TwoPi: number;
  80513. /**
  80514. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80515. * @param a number
  80516. * @param b number
  80517. * @param epsilon (default = 1.401298E-45)
  80518. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80519. */
  80520. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80521. /**
  80522. * Returns a string : the upper case translation of the number i to hexadecimal.
  80523. * @param i number
  80524. * @returns the upper case translation of the number i to hexadecimal.
  80525. */
  80526. static ToHex(i: number): string;
  80527. /**
  80528. * Returns -1 if value is negative and +1 is value is positive.
  80529. * @param value the value
  80530. * @returns the value itself if it's equal to zero.
  80531. */
  80532. static Sign(value: number): number;
  80533. /**
  80534. * Returns the value itself if it's between min and max.
  80535. * Returns min if the value is lower than min.
  80536. * Returns max if the value is greater than max.
  80537. * @param value the value to clmap
  80538. * @param min the min value to clamp to (default: 0)
  80539. * @param max the max value to clamp to (default: 1)
  80540. * @returns the clamped value
  80541. */
  80542. static Clamp(value: number, min?: number, max?: number): number;
  80543. /**
  80544. * the log2 of value.
  80545. * @param value the value to compute log2 of
  80546. * @returns the log2 of value.
  80547. */
  80548. static Log2(value: number): number;
  80549. /**
  80550. * Loops the value, so that it is never larger than length and never smaller than 0.
  80551. *
  80552. * This is similar to the modulo operator but it works with floating point numbers.
  80553. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80554. * With t = 5 and length = 2.5, the result would be 0.0.
  80555. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80556. * @param value the value
  80557. * @param length the length
  80558. * @returns the looped value
  80559. */
  80560. static Repeat(value: number, length: number): number;
  80561. /**
  80562. * Normalize the value between 0.0 and 1.0 using min and max values
  80563. * @param value value to normalize
  80564. * @param min max to normalize between
  80565. * @param max min to normalize between
  80566. * @returns the normalized value
  80567. */
  80568. static Normalize(value: number, min: number, max: number): number;
  80569. /**
  80570. * Denormalize the value from 0.0 and 1.0 using min and max values
  80571. * @param normalized value to denormalize
  80572. * @param min max to denormalize between
  80573. * @param max min to denormalize between
  80574. * @returns the denormalized value
  80575. */
  80576. static Denormalize(normalized: number, min: number, max: number): number;
  80577. /**
  80578. * Calculates the shortest difference between two given angles given in degrees.
  80579. * @param current current angle in degrees
  80580. * @param target target angle in degrees
  80581. * @returns the delta
  80582. */
  80583. static DeltaAngle(current: number, target: number): number;
  80584. /**
  80585. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80586. * @param tx value
  80587. * @param length length
  80588. * @returns The returned value will move back and forth between 0 and length
  80589. */
  80590. static PingPong(tx: number, length: number): number;
  80591. /**
  80592. * Interpolates between min and max with smoothing at the limits.
  80593. *
  80594. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80595. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80596. * @param from from
  80597. * @param to to
  80598. * @param tx value
  80599. * @returns the smooth stepped value
  80600. */
  80601. static SmoothStep(from: number, to: number, tx: number): number;
  80602. /**
  80603. * Moves a value current towards target.
  80604. *
  80605. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80606. * Negative values of maxDelta pushes the value away from target.
  80607. * @param current current value
  80608. * @param target target value
  80609. * @param maxDelta max distance to move
  80610. * @returns resulting value
  80611. */
  80612. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80613. /**
  80614. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80615. *
  80616. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80617. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80618. * @param current current value
  80619. * @param target target value
  80620. * @param maxDelta max distance to move
  80621. * @returns resulting angle
  80622. */
  80623. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80624. /**
  80625. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80626. * @param start start value
  80627. * @param end target value
  80628. * @param amount amount to lerp between
  80629. * @returns the lerped value
  80630. */
  80631. static Lerp(start: number, end: number, amount: number): number;
  80632. /**
  80633. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80634. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80635. * @param start start value
  80636. * @param end target value
  80637. * @param amount amount to lerp between
  80638. * @returns the lerped value
  80639. */
  80640. static LerpAngle(start: number, end: number, amount: number): number;
  80641. /**
  80642. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80643. * @param a start value
  80644. * @param b target value
  80645. * @param value value between a and b
  80646. * @returns the inverseLerp value
  80647. */
  80648. static InverseLerp(a: number, b: number, value: number): number;
  80649. /**
  80650. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80651. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80652. * @param value1 spline value
  80653. * @param tangent1 spline value
  80654. * @param value2 spline value
  80655. * @param tangent2 spline value
  80656. * @param amount input value
  80657. * @returns hermite result
  80658. */
  80659. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80660. /**
  80661. * Returns a random float number between and min and max values
  80662. * @param min min value of random
  80663. * @param max max value of random
  80664. * @returns random value
  80665. */
  80666. static RandomRange(min: number, max: number): number;
  80667. /**
  80668. * This function returns percentage of a number in a given range.
  80669. *
  80670. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80671. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80672. * @param number to convert to percentage
  80673. * @param min min range
  80674. * @param max max range
  80675. * @returns the percentage
  80676. */
  80677. static RangeToPercent(number: number, min: number, max: number): number;
  80678. /**
  80679. * This function returns number that corresponds to the percentage in a given range.
  80680. *
  80681. * PercentToRange(0.34,0,100) will return 34.
  80682. * @param percent to convert to number
  80683. * @param min min range
  80684. * @param max max range
  80685. * @returns the number
  80686. */
  80687. static PercentToRange(percent: number, min: number, max: number): number;
  80688. /**
  80689. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80690. * @param angle The angle to normalize in radian.
  80691. * @return The converted angle.
  80692. */
  80693. static NormalizeRadians(angle: number): number;
  80694. }
  80695. }
  80696. declare module BABYLON {
  80697. /**
  80698. * Constant used to convert a value to gamma space
  80699. * @ignorenaming
  80700. */
  80701. export const ToGammaSpace: number;
  80702. /**
  80703. * Constant used to convert a value to linear space
  80704. * @ignorenaming
  80705. */
  80706. export const ToLinearSpace = 2.2;
  80707. /**
  80708. * Constant used to define the minimal number value in Babylon.js
  80709. * @ignorenaming
  80710. */
  80711. let Epsilon: number;
  80712. }
  80713. declare module BABYLON {
  80714. /**
  80715. * Class used to represent a viewport on screen
  80716. */
  80717. export class Viewport {
  80718. /** viewport left coordinate */
  80719. x: number;
  80720. /** viewport top coordinate */
  80721. y: number;
  80722. /**viewport width */
  80723. width: number;
  80724. /** viewport height */
  80725. height: number;
  80726. /**
  80727. * Creates a Viewport object located at (x, y) and sized (width, height)
  80728. * @param x defines viewport left coordinate
  80729. * @param y defines viewport top coordinate
  80730. * @param width defines the viewport width
  80731. * @param height defines the viewport height
  80732. */
  80733. constructor(
  80734. /** viewport left coordinate */
  80735. x: number,
  80736. /** viewport top coordinate */
  80737. y: number,
  80738. /**viewport width */
  80739. width: number,
  80740. /** viewport height */
  80741. height: number);
  80742. /**
  80743. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80744. * @param renderWidth defines the rendering width
  80745. * @param renderHeight defines the rendering height
  80746. * @returns a new Viewport
  80747. */
  80748. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80749. /**
  80750. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80751. * @param renderWidth defines the rendering width
  80752. * @param renderHeight defines the rendering height
  80753. * @param ref defines the target viewport
  80754. * @returns the current viewport
  80755. */
  80756. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80757. /**
  80758. * Returns a new Viewport copied from the current one
  80759. * @returns a new Viewport
  80760. */
  80761. clone(): Viewport;
  80762. }
  80763. }
  80764. declare module BABYLON {
  80765. /**
  80766. * Class containing a set of static utilities functions for arrays.
  80767. */
  80768. export class ArrayTools {
  80769. /**
  80770. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80771. * @param size the number of element to construct and put in the array
  80772. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80773. * @returns a new array filled with new objects
  80774. */
  80775. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80776. }
  80777. }
  80778. declare module BABYLON {
  80779. /**
  80780. * Represents a plane by the equation ax + by + cz + d = 0
  80781. */
  80782. export class Plane {
  80783. private static _TmpMatrix;
  80784. /**
  80785. * Normal of the plane (a,b,c)
  80786. */
  80787. normal: Vector3;
  80788. /**
  80789. * d component of the plane
  80790. */
  80791. d: number;
  80792. /**
  80793. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80794. * @param a a component of the plane
  80795. * @param b b component of the plane
  80796. * @param c c component of the plane
  80797. * @param d d component of the plane
  80798. */
  80799. constructor(a: number, b: number, c: number, d: number);
  80800. /**
  80801. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80802. */
  80803. asArray(): number[];
  80804. /**
  80805. * @returns a new plane copied from the current Plane.
  80806. */
  80807. clone(): Plane;
  80808. /**
  80809. * @returns the string "Plane".
  80810. */
  80811. getClassName(): string;
  80812. /**
  80813. * @returns the Plane hash code.
  80814. */
  80815. getHashCode(): number;
  80816. /**
  80817. * Normalize the current Plane in place.
  80818. * @returns the updated Plane.
  80819. */
  80820. normalize(): Plane;
  80821. /**
  80822. * Applies a transformation the plane and returns the result
  80823. * @param transformation the transformation matrix to be applied to the plane
  80824. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80825. */
  80826. transform(transformation: DeepImmutable<Matrix>): Plane;
  80827. /**
  80828. * Compute the dot product between the point and the plane normal
  80829. * @param point point to calculate the dot product with
  80830. * @returns the dot product (float) of the point coordinates and the plane normal.
  80831. */
  80832. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80833. /**
  80834. * Updates the current Plane from the plane defined by the three given points.
  80835. * @param point1 one of the points used to contruct the plane
  80836. * @param point2 one of the points used to contruct the plane
  80837. * @param point3 one of the points used to contruct the plane
  80838. * @returns the updated Plane.
  80839. */
  80840. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80841. /**
  80842. * Checks if the plane is facing a given direction
  80843. * @param direction the direction to check if the plane is facing
  80844. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80845. * @returns True is the vector "direction" is the same side than the plane normal.
  80846. */
  80847. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80848. /**
  80849. * Calculates the distance to a point
  80850. * @param point point to calculate distance to
  80851. * @returns the signed distance (float) from the given point to the Plane.
  80852. */
  80853. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80854. /**
  80855. * Creates a plane from an array
  80856. * @param array the array to create a plane from
  80857. * @returns a new Plane from the given array.
  80858. */
  80859. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80860. /**
  80861. * Creates a plane from three points
  80862. * @param point1 point used to create the plane
  80863. * @param point2 point used to create the plane
  80864. * @param point3 point used to create the plane
  80865. * @returns a new Plane defined by the three given points.
  80866. */
  80867. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80868. /**
  80869. * Creates a plane from an origin point and a normal
  80870. * @param origin origin of the plane to be constructed
  80871. * @param normal normal of the plane to be constructed
  80872. * @returns a new Plane the normal vector to this plane at the given origin point.
  80873. * Note : the vector "normal" is updated because normalized.
  80874. */
  80875. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80876. /**
  80877. * Calculates the distance from a plane and a point
  80878. * @param origin origin of the plane to be constructed
  80879. * @param normal normal of the plane to be constructed
  80880. * @param point point to calculate distance to
  80881. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80882. */
  80883. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80884. }
  80885. }
  80886. declare module BABYLON {
  80887. /** @hidden */
  80888. export class PerformanceConfigurator {
  80889. /** @hidden */
  80890. static MatrixUse64Bits: boolean;
  80891. /** @hidden */
  80892. static MatrixTrackPrecisionChange: boolean;
  80893. /** @hidden */
  80894. static MatrixCurrentType: any;
  80895. /** @hidden */
  80896. static MatrixTrackedMatrices: Array<any> | null;
  80897. /** @hidden */
  80898. static SetMatrixPrecision(use64bits: boolean): void;
  80899. }
  80900. }
  80901. declare module BABYLON {
  80902. /**
  80903. * Class representing a vector containing 2 coordinates
  80904. */
  80905. export class Vector2 {
  80906. /** defines the first coordinate */
  80907. x: number;
  80908. /** defines the second coordinate */
  80909. y: number;
  80910. /**
  80911. * Creates a new Vector2 from the given x and y coordinates
  80912. * @param x defines the first coordinate
  80913. * @param y defines the second coordinate
  80914. */
  80915. constructor(
  80916. /** defines the first coordinate */
  80917. x?: number,
  80918. /** defines the second coordinate */
  80919. y?: number);
  80920. /**
  80921. * Gets a string with the Vector2 coordinates
  80922. * @returns a string with the Vector2 coordinates
  80923. */
  80924. toString(): string;
  80925. /**
  80926. * Gets class name
  80927. * @returns the string "Vector2"
  80928. */
  80929. getClassName(): string;
  80930. /**
  80931. * Gets current vector hash code
  80932. * @returns the Vector2 hash code as a number
  80933. */
  80934. getHashCode(): number;
  80935. /**
  80936. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80937. * @param array defines the source array
  80938. * @param index defines the offset in source array
  80939. * @returns the current Vector2
  80940. */
  80941. toArray(array: FloatArray, index?: number): Vector2;
  80942. /**
  80943. * Update the current vector from an array
  80944. * @param array defines the destination array
  80945. * @param index defines the offset in the destination array
  80946. * @returns the current Vector3
  80947. */
  80948. fromArray(array: FloatArray, index?: number): Vector2;
  80949. /**
  80950. * Copy the current vector to an array
  80951. * @returns a new array with 2 elements: the Vector2 coordinates.
  80952. */
  80953. asArray(): number[];
  80954. /**
  80955. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80956. * @param source defines the source Vector2
  80957. * @returns the current updated Vector2
  80958. */
  80959. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80960. /**
  80961. * Sets the Vector2 coordinates with the given floats
  80962. * @param x defines the first coordinate
  80963. * @param y defines the second coordinate
  80964. * @returns the current updated Vector2
  80965. */
  80966. copyFromFloats(x: number, y: number): Vector2;
  80967. /**
  80968. * Sets the Vector2 coordinates with the given floats
  80969. * @param x defines the first coordinate
  80970. * @param y defines the second coordinate
  80971. * @returns the current updated Vector2
  80972. */
  80973. set(x: number, y: number): Vector2;
  80974. /**
  80975. * Add another vector with the current one
  80976. * @param otherVector defines the other vector
  80977. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80978. */
  80979. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80980. /**
  80981. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80982. * @param otherVector defines the other vector
  80983. * @param result defines the target vector
  80984. * @returns the unmodified current Vector2
  80985. */
  80986. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80987. /**
  80988. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80989. * @param otherVector defines the other vector
  80990. * @returns the current updated Vector2
  80991. */
  80992. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80993. /**
  80994. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80995. * @param otherVector defines the other vector
  80996. * @returns a new Vector2
  80997. */
  80998. addVector3(otherVector: Vector3): Vector2;
  80999. /**
  81000. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81001. * @param otherVector defines the other vector
  81002. * @returns a new Vector2
  81003. */
  81004. subtract(otherVector: Vector2): Vector2;
  81005. /**
  81006. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81007. * @param otherVector defines the other vector
  81008. * @param result defines the target vector
  81009. * @returns the unmodified current Vector2
  81010. */
  81011. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81012. /**
  81013. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81014. * @param otherVector defines the other vector
  81015. * @returns the current updated Vector2
  81016. */
  81017. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81018. /**
  81019. * Multiplies in place the current Vector2 coordinates by the given ones
  81020. * @param otherVector defines the other vector
  81021. * @returns the current updated Vector2
  81022. */
  81023. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81024. /**
  81025. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81026. * @param otherVector defines the other vector
  81027. * @returns a new Vector2
  81028. */
  81029. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81030. /**
  81031. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81032. * @param otherVector defines the other vector
  81033. * @param result defines the target vector
  81034. * @returns the unmodified current Vector2
  81035. */
  81036. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81037. /**
  81038. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81039. * @param x defines the first coordinate
  81040. * @param y defines the second coordinate
  81041. * @returns a new Vector2
  81042. */
  81043. multiplyByFloats(x: number, y: number): Vector2;
  81044. /**
  81045. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81046. * @param otherVector defines the other vector
  81047. * @returns a new Vector2
  81048. */
  81049. divide(otherVector: Vector2): Vector2;
  81050. /**
  81051. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81052. * @param otherVector defines the other vector
  81053. * @param result defines the target vector
  81054. * @returns the unmodified current Vector2
  81055. */
  81056. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81057. /**
  81058. * Divides the current Vector2 coordinates by the given ones
  81059. * @param otherVector defines the other vector
  81060. * @returns the current updated Vector2
  81061. */
  81062. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81063. /**
  81064. * Gets a new Vector2 with current Vector2 negated coordinates
  81065. * @returns a new Vector2
  81066. */
  81067. negate(): Vector2;
  81068. /**
  81069. * Negate this vector in place
  81070. * @returns this
  81071. */
  81072. negateInPlace(): Vector2;
  81073. /**
  81074. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81075. * @param result defines the Vector3 object where to store the result
  81076. * @returns the current Vector2
  81077. */
  81078. negateToRef(result: Vector2): Vector2;
  81079. /**
  81080. * Multiply the Vector2 coordinates by scale
  81081. * @param scale defines the scaling factor
  81082. * @returns the current updated Vector2
  81083. */
  81084. scaleInPlace(scale: number): Vector2;
  81085. /**
  81086. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81087. * @param scale defines the scaling factor
  81088. * @returns a new Vector2
  81089. */
  81090. scale(scale: number): Vector2;
  81091. /**
  81092. * Scale the current Vector2 values by a factor to a given Vector2
  81093. * @param scale defines the scale factor
  81094. * @param result defines the Vector2 object where to store the result
  81095. * @returns the unmodified current Vector2
  81096. */
  81097. scaleToRef(scale: number, result: Vector2): Vector2;
  81098. /**
  81099. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81100. * @param scale defines the scale factor
  81101. * @param result defines the Vector2 object where to store the result
  81102. * @returns the unmodified current Vector2
  81103. */
  81104. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81105. /**
  81106. * Gets a boolean if two vectors are equals
  81107. * @param otherVector defines the other vector
  81108. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81109. */
  81110. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81111. /**
  81112. * Gets a boolean if two vectors are equals (using an epsilon value)
  81113. * @param otherVector defines the other vector
  81114. * @param epsilon defines the minimal distance to consider equality
  81115. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81116. */
  81117. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81118. /**
  81119. * Gets a new Vector2 from current Vector2 floored values
  81120. * @returns a new Vector2
  81121. */
  81122. floor(): Vector2;
  81123. /**
  81124. * Gets a new Vector2 from current Vector2 floored values
  81125. * @returns a new Vector2
  81126. */
  81127. fract(): Vector2;
  81128. /**
  81129. * Gets the length of the vector
  81130. * @returns the vector length (float)
  81131. */
  81132. length(): number;
  81133. /**
  81134. * Gets the vector squared length
  81135. * @returns the vector squared length (float)
  81136. */
  81137. lengthSquared(): number;
  81138. /**
  81139. * Normalize the vector
  81140. * @returns the current updated Vector2
  81141. */
  81142. normalize(): Vector2;
  81143. /**
  81144. * Gets a new Vector2 copied from the Vector2
  81145. * @returns a new Vector2
  81146. */
  81147. clone(): Vector2;
  81148. /**
  81149. * Gets a new Vector2(0, 0)
  81150. * @returns a new Vector2
  81151. */
  81152. static Zero(): Vector2;
  81153. /**
  81154. * Gets a new Vector2(1, 1)
  81155. * @returns a new Vector2
  81156. */
  81157. static One(): Vector2;
  81158. /**
  81159. * Gets a new Vector2 set from the given index element of the given array
  81160. * @param array defines the data source
  81161. * @param offset defines the offset in the data source
  81162. * @returns a new Vector2
  81163. */
  81164. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81165. /**
  81166. * Sets "result" from the given index element of the given array
  81167. * @param array defines the data source
  81168. * @param offset defines the offset in the data source
  81169. * @param result defines the target vector
  81170. */
  81171. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81172. /**
  81173. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81174. * @param value1 defines 1st point of control
  81175. * @param value2 defines 2nd point of control
  81176. * @param value3 defines 3rd point of control
  81177. * @param value4 defines 4th point of control
  81178. * @param amount defines the interpolation factor
  81179. * @returns a new Vector2
  81180. */
  81181. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81182. /**
  81183. * 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".
  81184. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81185. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81186. * @param value defines the value to clamp
  81187. * @param min defines the lower limit
  81188. * @param max defines the upper limit
  81189. * @returns a new Vector2
  81190. */
  81191. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81192. /**
  81193. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81194. * @param value1 defines the 1st control point
  81195. * @param tangent1 defines the outgoing tangent
  81196. * @param value2 defines the 2nd control point
  81197. * @param tangent2 defines the incoming tangent
  81198. * @param amount defines the interpolation factor
  81199. * @returns a new Vector2
  81200. */
  81201. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81202. /**
  81203. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81204. * @param start defines the start vector
  81205. * @param end defines the end vector
  81206. * @param amount defines the interpolation factor
  81207. * @returns a new Vector2
  81208. */
  81209. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81210. /**
  81211. * Gets the dot product of the vector "left" and the vector "right"
  81212. * @param left defines first vector
  81213. * @param right defines second vector
  81214. * @returns the dot product (float)
  81215. */
  81216. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81217. /**
  81218. * Returns a new Vector2 equal to the normalized given vector
  81219. * @param vector defines the vector to normalize
  81220. * @returns a new Vector2
  81221. */
  81222. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81223. /**
  81224. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81225. * @param left defines 1st vector
  81226. * @param right defines 2nd vector
  81227. * @returns a new Vector2
  81228. */
  81229. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81230. /**
  81231. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81232. * @param left defines 1st vector
  81233. * @param right defines 2nd vector
  81234. * @returns a new Vector2
  81235. */
  81236. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81237. /**
  81238. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81239. * @param vector defines the vector to transform
  81240. * @param transformation defines the matrix to apply
  81241. * @returns a new Vector2
  81242. */
  81243. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81244. /**
  81245. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81246. * @param vector defines the vector to transform
  81247. * @param transformation defines the matrix to apply
  81248. * @param result defines the target vector
  81249. */
  81250. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81251. /**
  81252. * Determines if a given vector is included in a triangle
  81253. * @param p defines the vector to test
  81254. * @param p0 defines 1st triangle point
  81255. * @param p1 defines 2nd triangle point
  81256. * @param p2 defines 3rd triangle point
  81257. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81258. */
  81259. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81260. /**
  81261. * Gets the distance between the vectors "value1" and "value2"
  81262. * @param value1 defines first vector
  81263. * @param value2 defines second vector
  81264. * @returns the distance between vectors
  81265. */
  81266. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81267. /**
  81268. * Returns the squared distance between the vectors "value1" and "value2"
  81269. * @param value1 defines first vector
  81270. * @param value2 defines second vector
  81271. * @returns the squared distance between vectors
  81272. */
  81273. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81274. /**
  81275. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81276. * @param value1 defines first vector
  81277. * @param value2 defines second vector
  81278. * @returns a new Vector2
  81279. */
  81280. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81281. /**
  81282. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81283. * @param p defines the middle point
  81284. * @param segA defines one point of the segment
  81285. * @param segB defines the other point of the segment
  81286. * @returns the shortest distance
  81287. */
  81288. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81289. }
  81290. /**
  81291. * Class used to store (x,y,z) vector representation
  81292. * A Vector3 is the main object used in 3D geometry
  81293. * It can represent etiher the coordinates of a point the space, either a direction
  81294. * Reminder: js uses a left handed forward facing system
  81295. */
  81296. export class Vector3 {
  81297. private static _UpReadOnly;
  81298. private static _ZeroReadOnly;
  81299. /** @hidden */
  81300. _x: number;
  81301. /** @hidden */
  81302. _y: number;
  81303. /** @hidden */
  81304. _z: number;
  81305. /** @hidden */
  81306. _isDirty: boolean;
  81307. /** Gets or sets the x coordinate */
  81308. get x(): number;
  81309. set x(value: number);
  81310. /** Gets or sets the y coordinate */
  81311. get y(): number;
  81312. set y(value: number);
  81313. /** Gets or sets the z coordinate */
  81314. get z(): number;
  81315. set z(value: number);
  81316. /**
  81317. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81318. * @param x defines the first coordinates (on X axis)
  81319. * @param y defines the second coordinates (on Y axis)
  81320. * @param z defines the third coordinates (on Z axis)
  81321. */
  81322. constructor(x?: number, y?: number, z?: number);
  81323. /**
  81324. * Creates a string representation of the Vector3
  81325. * @returns a string with the Vector3 coordinates.
  81326. */
  81327. toString(): string;
  81328. /**
  81329. * Gets the class name
  81330. * @returns the string "Vector3"
  81331. */
  81332. getClassName(): string;
  81333. /**
  81334. * Creates the Vector3 hash code
  81335. * @returns a number which tends to be unique between Vector3 instances
  81336. */
  81337. getHashCode(): number;
  81338. /**
  81339. * Creates an array containing three elements : the coordinates of the Vector3
  81340. * @returns a new array of numbers
  81341. */
  81342. asArray(): number[];
  81343. /**
  81344. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81345. * @param array defines the destination array
  81346. * @param index defines the offset in the destination array
  81347. * @returns the current Vector3
  81348. */
  81349. toArray(array: FloatArray, index?: number): Vector3;
  81350. /**
  81351. * Update the current vector from an array
  81352. * @param array defines the destination array
  81353. * @param index defines the offset in the destination array
  81354. * @returns the current Vector3
  81355. */
  81356. fromArray(array: FloatArray, index?: number): Vector3;
  81357. /**
  81358. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81359. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81360. */
  81361. toQuaternion(): Quaternion;
  81362. /**
  81363. * Adds the given vector to the current Vector3
  81364. * @param otherVector defines the second operand
  81365. * @returns the current updated Vector3
  81366. */
  81367. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81368. /**
  81369. * Adds the given coordinates to the current Vector3
  81370. * @param x defines the x coordinate of the operand
  81371. * @param y defines the y coordinate of the operand
  81372. * @param z defines the z coordinate of the operand
  81373. * @returns the current updated Vector3
  81374. */
  81375. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81376. /**
  81377. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81378. * @param otherVector defines the second operand
  81379. * @returns the resulting Vector3
  81380. */
  81381. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81382. /**
  81383. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81384. * @param otherVector defines the second operand
  81385. * @param result defines the Vector3 object where to store the result
  81386. * @returns the current Vector3
  81387. */
  81388. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81389. /**
  81390. * Subtract the given vector from the current Vector3
  81391. * @param otherVector defines the second operand
  81392. * @returns the current updated Vector3
  81393. */
  81394. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81395. /**
  81396. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81397. * @param otherVector defines the second operand
  81398. * @returns the resulting Vector3
  81399. */
  81400. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81401. /**
  81402. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81403. * @param otherVector defines the second operand
  81404. * @param result defines the Vector3 object where to store the result
  81405. * @returns the current Vector3
  81406. */
  81407. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81408. /**
  81409. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81410. * @param x defines the x coordinate of the operand
  81411. * @param y defines the y coordinate of the operand
  81412. * @param z defines the z coordinate of the operand
  81413. * @returns the resulting Vector3
  81414. */
  81415. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81416. /**
  81417. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81418. * @param x defines the x coordinate of the operand
  81419. * @param y defines the y coordinate of the operand
  81420. * @param z defines the z coordinate of the operand
  81421. * @param result defines the Vector3 object where to store the result
  81422. * @returns the current Vector3
  81423. */
  81424. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81425. /**
  81426. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81427. * @returns a new Vector3
  81428. */
  81429. negate(): Vector3;
  81430. /**
  81431. * Negate this vector in place
  81432. * @returns this
  81433. */
  81434. negateInPlace(): Vector3;
  81435. /**
  81436. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81437. * @param result defines the Vector3 object where to store the result
  81438. * @returns the current Vector3
  81439. */
  81440. negateToRef(result: Vector3): Vector3;
  81441. /**
  81442. * Multiplies the Vector3 coordinates by the float "scale"
  81443. * @param scale defines the multiplier factor
  81444. * @returns the current updated Vector3
  81445. */
  81446. scaleInPlace(scale: number): Vector3;
  81447. /**
  81448. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81449. * @param scale defines the multiplier factor
  81450. * @returns a new Vector3
  81451. */
  81452. scale(scale: number): Vector3;
  81453. /**
  81454. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81455. * @param scale defines the multiplier factor
  81456. * @param result defines the Vector3 object where to store the result
  81457. * @returns the current Vector3
  81458. */
  81459. scaleToRef(scale: number, result: Vector3): Vector3;
  81460. /**
  81461. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81462. * @param scale defines the scale factor
  81463. * @param result defines the Vector3 object where to store the result
  81464. * @returns the unmodified current Vector3
  81465. */
  81466. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81467. /**
  81468. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81469. * @param origin defines the origin of the projection ray
  81470. * @param plane defines the plane to project to
  81471. * @returns the projected vector3
  81472. */
  81473. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81474. /**
  81475. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81476. * @param origin defines the origin of the projection ray
  81477. * @param plane defines the plane to project to
  81478. * @param result defines the Vector3 where to store the result
  81479. */
  81480. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81481. /**
  81482. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81483. * @param otherVector defines the second operand
  81484. * @returns true if both vectors are equals
  81485. */
  81486. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81487. /**
  81488. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81489. * @param otherVector defines the second operand
  81490. * @param epsilon defines the minimal distance to define values as equals
  81491. * @returns true if both vectors are distant less than epsilon
  81492. */
  81493. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81494. /**
  81495. * Returns true if the current Vector3 coordinates equals the given floats
  81496. * @param x defines the x coordinate of the operand
  81497. * @param y defines the y coordinate of the operand
  81498. * @param z defines the z coordinate of the operand
  81499. * @returns true if both vectors are equals
  81500. */
  81501. equalsToFloats(x: number, y: number, z: number): boolean;
  81502. /**
  81503. * Multiplies the current Vector3 coordinates by the given ones
  81504. * @param otherVector defines the second operand
  81505. * @returns the current updated Vector3
  81506. */
  81507. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81508. /**
  81509. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81510. * @param otherVector defines the second operand
  81511. * @returns the new Vector3
  81512. */
  81513. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81514. /**
  81515. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81516. * @param otherVector defines the second operand
  81517. * @param result defines the Vector3 object where to store the result
  81518. * @returns the current Vector3
  81519. */
  81520. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81521. /**
  81522. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81523. * @param x defines the x coordinate of the operand
  81524. * @param y defines the y coordinate of the operand
  81525. * @param z defines the z coordinate of the operand
  81526. * @returns the new Vector3
  81527. */
  81528. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81529. /**
  81530. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81531. * @param otherVector defines the second operand
  81532. * @returns the new Vector3
  81533. */
  81534. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81535. /**
  81536. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81537. * @param otherVector defines the second operand
  81538. * @param result defines the Vector3 object where to store the result
  81539. * @returns the current Vector3
  81540. */
  81541. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81542. /**
  81543. * Divides the current Vector3 coordinates by the given ones.
  81544. * @param otherVector defines the second operand
  81545. * @returns the current updated Vector3
  81546. */
  81547. divideInPlace(otherVector: Vector3): Vector3;
  81548. /**
  81549. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81550. * @param other defines the second operand
  81551. * @returns the current updated Vector3
  81552. */
  81553. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81554. /**
  81555. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81556. * @param other defines the second operand
  81557. * @returns the current updated Vector3
  81558. */
  81559. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81560. /**
  81561. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81562. * @param x defines the x coordinate of the operand
  81563. * @param y defines the y coordinate of the operand
  81564. * @param z defines the z coordinate of the operand
  81565. * @returns the current updated Vector3
  81566. */
  81567. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81568. /**
  81569. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81570. * @param x defines the x coordinate of the operand
  81571. * @param y defines the y coordinate of the operand
  81572. * @param z defines the z coordinate of the operand
  81573. * @returns the current updated Vector3
  81574. */
  81575. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81576. /**
  81577. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81578. * Check if is non uniform within a certain amount of decimal places to account for this
  81579. * @param epsilon the amount the values can differ
  81580. * @returns if the the vector is non uniform to a certain number of decimal places
  81581. */
  81582. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81583. /**
  81584. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81585. */
  81586. get isNonUniform(): boolean;
  81587. /**
  81588. * Gets a new Vector3 from current Vector3 floored values
  81589. * @returns a new Vector3
  81590. */
  81591. floor(): Vector3;
  81592. /**
  81593. * Gets a new Vector3 from current Vector3 floored values
  81594. * @returns a new Vector3
  81595. */
  81596. fract(): Vector3;
  81597. /**
  81598. * Gets the length of the Vector3
  81599. * @returns the length of the Vector3
  81600. */
  81601. length(): number;
  81602. /**
  81603. * Gets the squared length of the Vector3
  81604. * @returns squared length of the Vector3
  81605. */
  81606. lengthSquared(): number;
  81607. /**
  81608. * Normalize the current Vector3.
  81609. * Please note that this is an in place operation.
  81610. * @returns the current updated Vector3
  81611. */
  81612. normalize(): Vector3;
  81613. /**
  81614. * Reorders the x y z properties of the vector in place
  81615. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81616. * @returns the current updated vector
  81617. */
  81618. reorderInPlace(order: string): this;
  81619. /**
  81620. * Rotates the vector around 0,0,0 by a quaternion
  81621. * @param quaternion the rotation quaternion
  81622. * @param result vector to store the result
  81623. * @returns the resulting vector
  81624. */
  81625. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81626. /**
  81627. * Rotates a vector around a given point
  81628. * @param quaternion the rotation quaternion
  81629. * @param point the point to rotate around
  81630. * @param result vector to store the result
  81631. * @returns the resulting vector
  81632. */
  81633. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81634. /**
  81635. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81636. * The cross product is then orthogonal to both current and "other"
  81637. * @param other defines the right operand
  81638. * @returns the cross product
  81639. */
  81640. cross(other: Vector3): Vector3;
  81641. /**
  81642. * Normalize the current Vector3 with the given input length.
  81643. * Please note that this is an in place operation.
  81644. * @param len the length of the vector
  81645. * @returns the current updated Vector3
  81646. */
  81647. normalizeFromLength(len: number): Vector3;
  81648. /**
  81649. * Normalize the current Vector3 to a new vector
  81650. * @returns the new Vector3
  81651. */
  81652. normalizeToNew(): Vector3;
  81653. /**
  81654. * Normalize the current Vector3 to the reference
  81655. * @param reference define the Vector3 to update
  81656. * @returns the updated Vector3
  81657. */
  81658. normalizeToRef(reference: Vector3): Vector3;
  81659. /**
  81660. * Creates a new Vector3 copied from the current Vector3
  81661. * @returns the new Vector3
  81662. */
  81663. clone(): Vector3;
  81664. /**
  81665. * Copies the given vector coordinates to the current Vector3 ones
  81666. * @param source defines the source Vector3
  81667. * @returns the current updated Vector3
  81668. */
  81669. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81670. /**
  81671. * Copies the given floats to the current Vector3 coordinates
  81672. * @param x defines the x coordinate of the operand
  81673. * @param y defines the y coordinate of the operand
  81674. * @param z defines the z coordinate of the operand
  81675. * @returns the current updated Vector3
  81676. */
  81677. copyFromFloats(x: number, y: number, z: number): Vector3;
  81678. /**
  81679. * Copies the given floats to the current Vector3 coordinates
  81680. * @param x defines the x coordinate of the operand
  81681. * @param y defines the y coordinate of the operand
  81682. * @param z defines the z coordinate of the operand
  81683. * @returns the current updated Vector3
  81684. */
  81685. set(x: number, y: number, z: number): Vector3;
  81686. /**
  81687. * Copies the given float to the current Vector3 coordinates
  81688. * @param v defines the x, y and z coordinates of the operand
  81689. * @returns the current updated Vector3
  81690. */
  81691. setAll(v: number): Vector3;
  81692. /**
  81693. * Get the clip factor between two vectors
  81694. * @param vector0 defines the first operand
  81695. * @param vector1 defines the second operand
  81696. * @param axis defines the axis to use
  81697. * @param size defines the size along the axis
  81698. * @returns the clip factor
  81699. */
  81700. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81701. /**
  81702. * Get angle between two vectors
  81703. * @param vector0 angle between vector0 and vector1
  81704. * @param vector1 angle between vector0 and vector1
  81705. * @param normal direction of the normal
  81706. * @return the angle between vector0 and vector1
  81707. */
  81708. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81709. /**
  81710. * Returns a new Vector3 set from the index "offset" of the given array
  81711. * @param array defines the source array
  81712. * @param offset defines the offset in the source array
  81713. * @returns the new Vector3
  81714. */
  81715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81716. /**
  81717. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81718. * @param array defines the source array
  81719. * @param offset defines the offset in the source array
  81720. * @returns the new Vector3
  81721. * @deprecated Please use FromArray instead.
  81722. */
  81723. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81724. /**
  81725. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81726. * @param array defines the source array
  81727. * @param offset defines the offset in the source array
  81728. * @param result defines the Vector3 where to store the result
  81729. */
  81730. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81731. /**
  81732. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81733. * @param array defines the source array
  81734. * @param offset defines the offset in the source array
  81735. * @param result defines the Vector3 where to store the result
  81736. * @deprecated Please use FromArrayToRef instead.
  81737. */
  81738. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81739. /**
  81740. * Sets the given vector "result" with the given floats.
  81741. * @param x defines the x coordinate of the source
  81742. * @param y defines the y coordinate of the source
  81743. * @param z defines the z coordinate of the source
  81744. * @param result defines the Vector3 where to store the result
  81745. */
  81746. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81747. /**
  81748. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81749. * @returns a new empty Vector3
  81750. */
  81751. static Zero(): Vector3;
  81752. /**
  81753. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81754. * @returns a new unit Vector3
  81755. */
  81756. static One(): Vector3;
  81757. /**
  81758. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81759. * @returns a new up Vector3
  81760. */
  81761. static Up(): Vector3;
  81762. /**
  81763. * Gets a up Vector3 that must not be updated
  81764. */
  81765. static get UpReadOnly(): DeepImmutable<Vector3>;
  81766. /**
  81767. * Gets a zero Vector3 that must not be updated
  81768. */
  81769. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81770. /**
  81771. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81772. * @returns a new down Vector3
  81773. */
  81774. static Down(): Vector3;
  81775. /**
  81776. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81777. * @param rightHandedSystem is the scene right-handed (negative z)
  81778. * @returns a new forward Vector3
  81779. */
  81780. static Forward(rightHandedSystem?: boolean): Vector3;
  81781. /**
  81782. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81783. * @param rightHandedSystem is the scene right-handed (negative-z)
  81784. * @returns a new forward Vector3
  81785. */
  81786. static Backward(rightHandedSystem?: boolean): Vector3;
  81787. /**
  81788. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81789. * @returns a new right Vector3
  81790. */
  81791. static Right(): Vector3;
  81792. /**
  81793. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81794. * @returns a new left Vector3
  81795. */
  81796. static Left(): Vector3;
  81797. /**
  81798. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81799. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81800. * @param vector defines the Vector3 to transform
  81801. * @param transformation defines the transformation matrix
  81802. * @returns the transformed Vector3
  81803. */
  81804. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81805. /**
  81806. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81807. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81808. * @param vector defines the Vector3 to transform
  81809. * @param transformation defines the transformation matrix
  81810. * @param result defines the Vector3 where to store the result
  81811. */
  81812. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81813. /**
  81814. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81815. * This method computes tranformed coordinates only, not transformed direction vectors
  81816. * @param x define the x coordinate of the source vector
  81817. * @param y define the y coordinate of the source vector
  81818. * @param z define the z coordinate of the source vector
  81819. * @param transformation defines the transformation matrix
  81820. * @param result defines the Vector3 where to store the result
  81821. */
  81822. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81823. /**
  81824. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81825. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81826. * @param vector defines the Vector3 to transform
  81827. * @param transformation defines the transformation matrix
  81828. * @returns the new Vector3
  81829. */
  81830. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81831. /**
  81832. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81833. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81834. * @param vector defines the Vector3 to transform
  81835. * @param transformation defines the transformation matrix
  81836. * @param result defines the Vector3 where to store the result
  81837. */
  81838. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81839. /**
  81840. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81841. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81842. * @param x define the x coordinate of the source vector
  81843. * @param y define the y coordinate of the source vector
  81844. * @param z define the z coordinate of the source vector
  81845. * @param transformation defines the transformation matrix
  81846. * @param result defines the Vector3 where to store the result
  81847. */
  81848. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81849. /**
  81850. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81851. * @param value1 defines the first control point
  81852. * @param value2 defines the second control point
  81853. * @param value3 defines the third control point
  81854. * @param value4 defines the fourth control point
  81855. * @param amount defines the amount on the spline to use
  81856. * @returns the new Vector3
  81857. */
  81858. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81859. /**
  81860. * 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"
  81861. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81862. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81863. * @param value defines the current value
  81864. * @param min defines the lower range value
  81865. * @param max defines the upper range value
  81866. * @returns the new Vector3
  81867. */
  81868. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81869. /**
  81870. * 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"
  81871. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81872. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81873. * @param value defines the current value
  81874. * @param min defines the lower range value
  81875. * @param max defines the upper range value
  81876. * @param result defines the Vector3 where to store the result
  81877. */
  81878. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81879. /**
  81880. * Checks if a given vector is inside a specific range
  81881. * @param v defines the vector to test
  81882. * @param min defines the minimum range
  81883. * @param max defines the maximum range
  81884. */
  81885. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81886. /**
  81887. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81888. * @param value1 defines the first control point
  81889. * @param tangent1 defines the first tangent vector
  81890. * @param value2 defines the second control point
  81891. * @param tangent2 defines the second tangent vector
  81892. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81893. * @returns the new Vector3
  81894. */
  81895. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81896. /**
  81897. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81898. * @param start defines the start value
  81899. * @param end defines the end value
  81900. * @param amount max defines amount between both (between 0 and 1)
  81901. * @returns the new Vector3
  81902. */
  81903. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81904. /**
  81905. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81906. * @param start defines the start value
  81907. * @param end defines the end value
  81908. * @param amount max defines amount between both (between 0 and 1)
  81909. * @param result defines the Vector3 where to store the result
  81910. */
  81911. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81912. /**
  81913. * Returns the dot product (float) between the vectors "left" and "right"
  81914. * @param left defines the left operand
  81915. * @param right defines the right operand
  81916. * @returns the dot product
  81917. */
  81918. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81919. /**
  81920. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81921. * The cross product is then orthogonal to both "left" and "right"
  81922. * @param left defines the left operand
  81923. * @param right defines the right operand
  81924. * @returns the cross product
  81925. */
  81926. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81927. /**
  81928. * Sets the given vector "result" with the cross product of "left" and "right"
  81929. * The cross product is then orthogonal to both "left" and "right"
  81930. * @param left defines the left operand
  81931. * @param right defines the right operand
  81932. * @param result defines the Vector3 where to store the result
  81933. */
  81934. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81935. /**
  81936. * Returns a new Vector3 as the normalization of the given vector
  81937. * @param vector defines the Vector3 to normalize
  81938. * @returns the new Vector3
  81939. */
  81940. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81941. /**
  81942. * Sets the given vector "result" with the normalization of the given first vector
  81943. * @param vector defines the Vector3 to normalize
  81944. * @param result defines the Vector3 where to store the result
  81945. */
  81946. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81947. /**
  81948. * Project a Vector3 onto screen space
  81949. * @param vector defines the Vector3 to project
  81950. * @param world defines the world matrix to use
  81951. * @param transform defines the transform (view x projection) matrix to use
  81952. * @param viewport defines the screen viewport to use
  81953. * @returns the new Vector3
  81954. */
  81955. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81956. /** @hidden */
  81957. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81958. /**
  81959. * Unproject from screen space to object space
  81960. * @param source defines the screen space Vector3 to use
  81961. * @param viewportWidth defines the current width of the viewport
  81962. * @param viewportHeight defines the current height of the viewport
  81963. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81964. * @param transform defines the transform (view x projection) matrix to use
  81965. * @returns the new Vector3
  81966. */
  81967. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81968. /**
  81969. * Unproject from screen space to object space
  81970. * @param source defines the screen space Vector3 to use
  81971. * @param viewportWidth defines the current width of the viewport
  81972. * @param viewportHeight defines the current height of the viewport
  81973. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81974. * @param view defines the view matrix to use
  81975. * @param projection defines the projection matrix to use
  81976. * @returns the new Vector3
  81977. */
  81978. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81979. /**
  81980. * Unproject from screen space to object space
  81981. * @param source defines the screen space Vector3 to use
  81982. * @param viewportWidth defines the current width of the viewport
  81983. * @param viewportHeight defines the current height of the viewport
  81984. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81985. * @param view defines the view matrix to use
  81986. * @param projection defines the projection matrix to use
  81987. * @param result defines the Vector3 where to store the result
  81988. */
  81989. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81990. /**
  81991. * Unproject from screen space to object space
  81992. * @param sourceX defines the screen space x coordinate to use
  81993. * @param sourceY defines the screen space y coordinate to use
  81994. * @param sourceZ defines the screen space z coordinate to use
  81995. * @param viewportWidth defines the current width of the viewport
  81996. * @param viewportHeight defines the current height of the viewport
  81997. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81998. * @param view defines the view matrix to use
  81999. * @param projection defines the projection matrix to use
  82000. * @param result defines the Vector3 where to store the result
  82001. */
  82002. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82003. /**
  82004. * Gets the minimal coordinate values between two Vector3
  82005. * @param left defines the first operand
  82006. * @param right defines the second operand
  82007. * @returns the new Vector3
  82008. */
  82009. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82010. /**
  82011. * Gets the maximal coordinate values between two Vector3
  82012. * @param left defines the first operand
  82013. * @param right defines the second operand
  82014. * @returns the new Vector3
  82015. */
  82016. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82017. /**
  82018. * Returns the distance between the vectors "value1" and "value2"
  82019. * @param value1 defines the first operand
  82020. * @param value2 defines the second operand
  82021. * @returns the distance
  82022. */
  82023. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82024. /**
  82025. * Returns the squared distance between the vectors "value1" and "value2"
  82026. * @param value1 defines the first operand
  82027. * @param value2 defines the second operand
  82028. * @returns the squared distance
  82029. */
  82030. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82031. /**
  82032. * Returns a new Vector3 located at the center between "value1" and "value2"
  82033. * @param value1 defines the first operand
  82034. * @param value2 defines the second operand
  82035. * @returns the new Vector3
  82036. */
  82037. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82038. /**
  82039. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82040. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82041. * to something in order to rotate it from its local system to the given target system
  82042. * Note: axis1, axis2 and axis3 are normalized during this operation
  82043. * @param axis1 defines the first axis
  82044. * @param axis2 defines the second axis
  82045. * @param axis3 defines the third axis
  82046. * @returns a new Vector3
  82047. */
  82048. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82049. /**
  82050. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82051. * @param axis1 defines the first axis
  82052. * @param axis2 defines the second axis
  82053. * @param axis3 defines the third axis
  82054. * @param ref defines the Vector3 where to store the result
  82055. */
  82056. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82057. }
  82058. /**
  82059. * Vector4 class created for EulerAngle class conversion to Quaternion
  82060. */
  82061. export class Vector4 {
  82062. /** x value of the vector */
  82063. x: number;
  82064. /** y value of the vector */
  82065. y: number;
  82066. /** z value of the vector */
  82067. z: number;
  82068. /** w value of the vector */
  82069. w: number;
  82070. /**
  82071. * Creates a Vector4 object from the given floats.
  82072. * @param x x value of the vector
  82073. * @param y y value of the vector
  82074. * @param z z value of the vector
  82075. * @param w w value of the vector
  82076. */
  82077. constructor(
  82078. /** x value of the vector */
  82079. x: number,
  82080. /** y value of the vector */
  82081. y: number,
  82082. /** z value of the vector */
  82083. z: number,
  82084. /** w value of the vector */
  82085. w: number);
  82086. /**
  82087. * Returns the string with the Vector4 coordinates.
  82088. * @returns a string containing all the vector values
  82089. */
  82090. toString(): string;
  82091. /**
  82092. * Returns the string "Vector4".
  82093. * @returns "Vector4"
  82094. */
  82095. getClassName(): string;
  82096. /**
  82097. * Returns the Vector4 hash code.
  82098. * @returns a unique hash code
  82099. */
  82100. getHashCode(): number;
  82101. /**
  82102. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82103. * @returns the resulting array
  82104. */
  82105. asArray(): number[];
  82106. /**
  82107. * Populates the given array from the given index with the Vector4 coordinates.
  82108. * @param array array to populate
  82109. * @param index index of the array to start at (default: 0)
  82110. * @returns the Vector4.
  82111. */
  82112. toArray(array: FloatArray, index?: number): Vector4;
  82113. /**
  82114. * Update the current vector from an array
  82115. * @param array defines the destination array
  82116. * @param index defines the offset in the destination array
  82117. * @returns the current Vector3
  82118. */
  82119. fromArray(array: FloatArray, index?: number): Vector4;
  82120. /**
  82121. * Adds the given vector to the current Vector4.
  82122. * @param otherVector the vector to add
  82123. * @returns the updated Vector4.
  82124. */
  82125. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82126. /**
  82127. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82128. * @param otherVector the vector to add
  82129. * @returns the resulting vector
  82130. */
  82131. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82132. /**
  82133. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82134. * @param otherVector the vector to add
  82135. * @param result the vector to store the result
  82136. * @returns the current Vector4.
  82137. */
  82138. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82139. /**
  82140. * Subtract in place the given vector from the current Vector4.
  82141. * @param otherVector the vector to subtract
  82142. * @returns the updated Vector4.
  82143. */
  82144. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82145. /**
  82146. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82147. * @param otherVector the vector to add
  82148. * @returns the new vector with the result
  82149. */
  82150. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82151. /**
  82152. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82153. * @param otherVector the vector to subtract
  82154. * @param result the vector to store the result
  82155. * @returns the current Vector4.
  82156. */
  82157. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82158. /**
  82159. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82160. */
  82161. /**
  82162. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82163. * @param x value to subtract
  82164. * @param y value to subtract
  82165. * @param z value to subtract
  82166. * @param w value to subtract
  82167. * @returns new vector containing the result
  82168. */
  82169. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82170. /**
  82171. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82172. * @param x value to subtract
  82173. * @param y value to subtract
  82174. * @param z value to subtract
  82175. * @param w value to subtract
  82176. * @param result the vector to store the result in
  82177. * @returns the current Vector4.
  82178. */
  82179. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82180. /**
  82181. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82182. * @returns a new vector with the negated values
  82183. */
  82184. negate(): Vector4;
  82185. /**
  82186. * Negate this vector in place
  82187. * @returns this
  82188. */
  82189. negateInPlace(): Vector4;
  82190. /**
  82191. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82192. * @param result defines the Vector3 object where to store the result
  82193. * @returns the current Vector4
  82194. */
  82195. negateToRef(result: Vector4): Vector4;
  82196. /**
  82197. * Multiplies the current Vector4 coordinates by scale (float).
  82198. * @param scale the number to scale with
  82199. * @returns the updated Vector4.
  82200. */
  82201. scaleInPlace(scale: number): Vector4;
  82202. /**
  82203. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82204. * @param scale the number to scale with
  82205. * @returns a new vector with the result
  82206. */
  82207. scale(scale: number): Vector4;
  82208. /**
  82209. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82210. * @param scale the number to scale with
  82211. * @param result a vector to store the result in
  82212. * @returns the current Vector4.
  82213. */
  82214. scaleToRef(scale: number, result: Vector4): Vector4;
  82215. /**
  82216. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82217. * @param scale defines the scale factor
  82218. * @param result defines the Vector4 object where to store the result
  82219. * @returns the unmodified current Vector4
  82220. */
  82221. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82222. /**
  82223. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82224. * @param otherVector the vector to compare against
  82225. * @returns true if they are equal
  82226. */
  82227. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82228. /**
  82229. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82230. * @param otherVector vector to compare against
  82231. * @param epsilon (Default: very small number)
  82232. * @returns true if they are equal
  82233. */
  82234. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82235. /**
  82236. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82237. * @param x x value to compare against
  82238. * @param y y value to compare against
  82239. * @param z z value to compare against
  82240. * @param w w value to compare against
  82241. * @returns true if equal
  82242. */
  82243. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82244. /**
  82245. * Multiplies in place the current Vector4 by the given one.
  82246. * @param otherVector vector to multiple with
  82247. * @returns the updated Vector4.
  82248. */
  82249. multiplyInPlace(otherVector: Vector4): Vector4;
  82250. /**
  82251. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82252. * @param otherVector vector to multiple with
  82253. * @returns resulting new vector
  82254. */
  82255. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82256. /**
  82257. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82258. * @param otherVector vector to multiple with
  82259. * @param result vector to store the result
  82260. * @returns the current Vector4.
  82261. */
  82262. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82263. /**
  82264. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82265. * @param x x value multiply with
  82266. * @param y y value multiply with
  82267. * @param z z value multiply with
  82268. * @param w w value multiply with
  82269. * @returns resulting new vector
  82270. */
  82271. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82272. /**
  82273. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82274. * @param otherVector vector to devide with
  82275. * @returns resulting new vector
  82276. */
  82277. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82278. /**
  82279. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82280. * @param otherVector vector to devide with
  82281. * @param result vector to store the result
  82282. * @returns the current Vector4.
  82283. */
  82284. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82285. /**
  82286. * Divides the current Vector3 coordinates by the given ones.
  82287. * @param otherVector vector to devide with
  82288. * @returns the updated Vector3.
  82289. */
  82290. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82291. /**
  82292. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82293. * @param other defines the second operand
  82294. * @returns the current updated Vector4
  82295. */
  82296. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82297. /**
  82298. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82299. * @param other defines the second operand
  82300. * @returns the current updated Vector4
  82301. */
  82302. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82303. /**
  82304. * Gets a new Vector4 from current Vector4 floored values
  82305. * @returns a new Vector4
  82306. */
  82307. floor(): Vector4;
  82308. /**
  82309. * Gets a new Vector4 from current Vector3 floored values
  82310. * @returns a new Vector4
  82311. */
  82312. fract(): Vector4;
  82313. /**
  82314. * Returns the Vector4 length (float).
  82315. * @returns the length
  82316. */
  82317. length(): number;
  82318. /**
  82319. * Returns the Vector4 squared length (float).
  82320. * @returns the length squared
  82321. */
  82322. lengthSquared(): number;
  82323. /**
  82324. * Normalizes in place the Vector4.
  82325. * @returns the updated Vector4.
  82326. */
  82327. normalize(): Vector4;
  82328. /**
  82329. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82330. * @returns this converted to a new vector3
  82331. */
  82332. toVector3(): Vector3;
  82333. /**
  82334. * Returns a new Vector4 copied from the current one.
  82335. * @returns the new cloned vector
  82336. */
  82337. clone(): Vector4;
  82338. /**
  82339. * Updates the current Vector4 with the given one coordinates.
  82340. * @param source the source vector to copy from
  82341. * @returns the updated Vector4.
  82342. */
  82343. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82344. /**
  82345. * Updates the current Vector4 coordinates with the given floats.
  82346. * @param x float to copy from
  82347. * @param y float to copy from
  82348. * @param z float to copy from
  82349. * @param w float to copy from
  82350. * @returns the updated Vector4.
  82351. */
  82352. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82353. /**
  82354. * Updates the current Vector4 coordinates with the given floats.
  82355. * @param x float to set from
  82356. * @param y float to set from
  82357. * @param z float to set from
  82358. * @param w float to set from
  82359. * @returns the updated Vector4.
  82360. */
  82361. set(x: number, y: number, z: number, w: number): Vector4;
  82362. /**
  82363. * Copies the given float to the current Vector3 coordinates
  82364. * @param v defines the x, y, z and w coordinates of the operand
  82365. * @returns the current updated Vector3
  82366. */
  82367. setAll(v: number): Vector4;
  82368. /**
  82369. * Returns a new Vector4 set from the starting index of the given array.
  82370. * @param array the array to pull values from
  82371. * @param offset the offset into the array to start at
  82372. * @returns the new vector
  82373. */
  82374. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82375. /**
  82376. * Updates the given vector "result" from the starting index of the given array.
  82377. * @param array the array to pull values from
  82378. * @param offset the offset into the array to start at
  82379. * @param result the vector to store the result in
  82380. */
  82381. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82382. /**
  82383. * Updates the given vector "result" from the starting index of the given Float32Array.
  82384. * @param array the array to pull values from
  82385. * @param offset the offset into the array to start at
  82386. * @param result the vector to store the result in
  82387. */
  82388. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82389. /**
  82390. * Updates the given vector "result" coordinates from the given floats.
  82391. * @param x float to set from
  82392. * @param y float to set from
  82393. * @param z float to set from
  82394. * @param w float to set from
  82395. * @param result the vector to the floats in
  82396. */
  82397. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82398. /**
  82399. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82400. * @returns the new vector
  82401. */
  82402. static Zero(): Vector4;
  82403. /**
  82404. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82405. * @returns the new vector
  82406. */
  82407. static One(): Vector4;
  82408. /**
  82409. * Returns a new normalized Vector4 from the given one.
  82410. * @param vector the vector to normalize
  82411. * @returns the vector
  82412. */
  82413. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82414. /**
  82415. * Updates the given vector "result" from the normalization of the given one.
  82416. * @param vector the vector to normalize
  82417. * @param result the vector to store the result in
  82418. */
  82419. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82420. /**
  82421. * Returns a vector with the minimum values from the left and right vectors
  82422. * @param left left vector to minimize
  82423. * @param right right vector to minimize
  82424. * @returns a new vector with the minimum of the left and right vector values
  82425. */
  82426. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82427. /**
  82428. * Returns a vector with the maximum values from the left and right vectors
  82429. * @param left left vector to maximize
  82430. * @param right right vector to maximize
  82431. * @returns a new vector with the maximum of the left and right vector values
  82432. */
  82433. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82434. /**
  82435. * Returns the distance (float) between the vectors "value1" and "value2".
  82436. * @param value1 value to calulate the distance between
  82437. * @param value2 value to calulate the distance between
  82438. * @return the distance between the two vectors
  82439. */
  82440. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82441. /**
  82442. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82443. * @param value1 value to calulate the distance between
  82444. * @param value2 value to calulate the distance between
  82445. * @return the distance between the two vectors squared
  82446. */
  82447. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82448. /**
  82449. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82450. * @param value1 value to calulate the center between
  82451. * @param value2 value to calulate the center between
  82452. * @return the center between the two vectors
  82453. */
  82454. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82455. /**
  82456. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82457. * This methods computes transformed normalized direction vectors only.
  82458. * @param vector the vector to transform
  82459. * @param transformation the transformation matrix to apply
  82460. * @returns the new vector
  82461. */
  82462. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82463. /**
  82464. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82465. * This methods computes transformed normalized direction vectors only.
  82466. * @param vector the vector to transform
  82467. * @param transformation the transformation matrix to apply
  82468. * @param result the vector to store the result in
  82469. */
  82470. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82471. /**
  82472. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82473. * This methods computes transformed normalized direction vectors only.
  82474. * @param x value to transform
  82475. * @param y value to transform
  82476. * @param z value to transform
  82477. * @param w value to transform
  82478. * @param transformation the transformation matrix to apply
  82479. * @param result the vector to store the results in
  82480. */
  82481. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82482. /**
  82483. * Creates a new Vector4 from a Vector3
  82484. * @param source defines the source data
  82485. * @param w defines the 4th component (default is 0)
  82486. * @returns a new Vector4
  82487. */
  82488. static FromVector3(source: Vector3, w?: number): Vector4;
  82489. }
  82490. /**
  82491. * Class used to store quaternion data
  82492. * @see https://en.wikipedia.org/wiki/Quaternion
  82493. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82494. */
  82495. export class Quaternion {
  82496. /** @hidden */
  82497. _x: number;
  82498. /** @hidden */
  82499. _y: number;
  82500. /** @hidden */
  82501. _z: number;
  82502. /** @hidden */
  82503. _w: number;
  82504. /** @hidden */
  82505. _isDirty: boolean;
  82506. /** Gets or sets the x coordinate */
  82507. get x(): number;
  82508. set x(value: number);
  82509. /** Gets or sets the y coordinate */
  82510. get y(): number;
  82511. set y(value: number);
  82512. /** Gets or sets the z coordinate */
  82513. get z(): number;
  82514. set z(value: number);
  82515. /** Gets or sets the w coordinate */
  82516. get w(): number;
  82517. set w(value: number);
  82518. /**
  82519. * Creates a new Quaternion from the given floats
  82520. * @param x defines the first component (0 by default)
  82521. * @param y defines the second component (0 by default)
  82522. * @param z defines the third component (0 by default)
  82523. * @param w defines the fourth component (1.0 by default)
  82524. */
  82525. constructor(x?: number, y?: number, z?: number, w?: number);
  82526. /**
  82527. * Gets a string representation for the current quaternion
  82528. * @returns a string with the Quaternion coordinates
  82529. */
  82530. toString(): string;
  82531. /**
  82532. * Gets the class name of the quaternion
  82533. * @returns the string "Quaternion"
  82534. */
  82535. getClassName(): string;
  82536. /**
  82537. * Gets a hash code for this quaternion
  82538. * @returns the quaternion hash code
  82539. */
  82540. getHashCode(): number;
  82541. /**
  82542. * Copy the quaternion to an array
  82543. * @returns a new array populated with 4 elements from the quaternion coordinates
  82544. */
  82545. asArray(): number[];
  82546. /**
  82547. * Check if two quaternions are equals
  82548. * @param otherQuaternion defines the second operand
  82549. * @return true if the current quaternion and the given one coordinates are strictly equals
  82550. */
  82551. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82552. /**
  82553. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82554. * @param otherQuaternion defines the other quaternion
  82555. * @param epsilon defines the minimal distance to consider equality
  82556. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82557. */
  82558. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82559. /**
  82560. * Clone the current quaternion
  82561. * @returns a new quaternion copied from the current one
  82562. */
  82563. clone(): Quaternion;
  82564. /**
  82565. * Copy a quaternion to the current one
  82566. * @param other defines the other quaternion
  82567. * @returns the updated current quaternion
  82568. */
  82569. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82570. /**
  82571. * Updates the current quaternion with the given float coordinates
  82572. * @param x defines the x coordinate
  82573. * @param y defines the y coordinate
  82574. * @param z defines the z coordinate
  82575. * @param w defines the w coordinate
  82576. * @returns the updated current quaternion
  82577. */
  82578. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82579. /**
  82580. * Updates the current quaternion from the given float coordinates
  82581. * @param x defines the x coordinate
  82582. * @param y defines the y coordinate
  82583. * @param z defines the z coordinate
  82584. * @param w defines the w coordinate
  82585. * @returns the updated current quaternion
  82586. */
  82587. set(x: number, y: number, z: number, w: number): Quaternion;
  82588. /**
  82589. * Adds two quaternions
  82590. * @param other defines the second operand
  82591. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82592. */
  82593. add(other: DeepImmutable<Quaternion>): Quaternion;
  82594. /**
  82595. * Add a quaternion to the current one
  82596. * @param other defines the quaternion to add
  82597. * @returns the current quaternion
  82598. */
  82599. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82600. /**
  82601. * Subtract two quaternions
  82602. * @param other defines the second operand
  82603. * @returns a new quaternion as the subtraction result of the given one from the current one
  82604. */
  82605. subtract(other: Quaternion): Quaternion;
  82606. /**
  82607. * Multiplies the current quaternion by a scale factor
  82608. * @param value defines the scale factor
  82609. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82610. */
  82611. scale(value: number): Quaternion;
  82612. /**
  82613. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82614. * @param scale defines the scale factor
  82615. * @param result defines the Quaternion object where to store the result
  82616. * @returns the unmodified current quaternion
  82617. */
  82618. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82619. /**
  82620. * Multiplies in place the current quaternion by a scale factor
  82621. * @param value defines the scale factor
  82622. * @returns the current modified quaternion
  82623. */
  82624. scaleInPlace(value: number): Quaternion;
  82625. /**
  82626. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82627. * @param scale defines the scale factor
  82628. * @param result defines the Quaternion object where to store the result
  82629. * @returns the unmodified current quaternion
  82630. */
  82631. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82632. /**
  82633. * Multiplies two quaternions
  82634. * @param q1 defines the second operand
  82635. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82636. */
  82637. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82638. /**
  82639. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82640. * @param q1 defines the second operand
  82641. * @param result defines the target quaternion
  82642. * @returns the current quaternion
  82643. */
  82644. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82645. /**
  82646. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82647. * @param q1 defines the second operand
  82648. * @returns the currentupdated quaternion
  82649. */
  82650. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82651. /**
  82652. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82653. * @param ref defines the target quaternion
  82654. * @returns the current quaternion
  82655. */
  82656. conjugateToRef(ref: Quaternion): Quaternion;
  82657. /**
  82658. * Conjugates in place (1-q) the current quaternion
  82659. * @returns the current updated quaternion
  82660. */
  82661. conjugateInPlace(): Quaternion;
  82662. /**
  82663. * Conjugates in place (1-q) the current quaternion
  82664. * @returns a new quaternion
  82665. */
  82666. conjugate(): Quaternion;
  82667. /**
  82668. * Gets length of current quaternion
  82669. * @returns the quaternion length (float)
  82670. */
  82671. length(): number;
  82672. /**
  82673. * Normalize in place the current quaternion
  82674. * @returns the current updated quaternion
  82675. */
  82676. normalize(): Quaternion;
  82677. /**
  82678. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82679. * @param order is a reserved parameter and is ignore for now
  82680. * @returns a new Vector3 containing the Euler angles
  82681. */
  82682. toEulerAngles(order?: string): Vector3;
  82683. /**
  82684. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82685. * @param result defines the vector which will be filled with the Euler angles
  82686. * @param order is a reserved parameter and is ignore for now
  82687. * @returns the current unchanged quaternion
  82688. */
  82689. toEulerAnglesToRef(result: Vector3): Quaternion;
  82690. /**
  82691. * Updates the given rotation matrix with the current quaternion values
  82692. * @param result defines the target matrix
  82693. * @returns the current unchanged quaternion
  82694. */
  82695. toRotationMatrix(result: Matrix): Quaternion;
  82696. /**
  82697. * Updates the current quaternion from the given rotation matrix values
  82698. * @param matrix defines the source matrix
  82699. * @returns the current updated quaternion
  82700. */
  82701. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82702. /**
  82703. * Creates a new quaternion from a rotation matrix
  82704. * @param matrix defines the source matrix
  82705. * @returns a new quaternion created from the given rotation matrix values
  82706. */
  82707. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82708. /**
  82709. * Updates the given quaternion with the given rotation matrix values
  82710. * @param matrix defines the source matrix
  82711. * @param result defines the target quaternion
  82712. */
  82713. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82714. /**
  82715. * Returns the dot product (float) between the quaternions "left" and "right"
  82716. * @param left defines the left operand
  82717. * @param right defines the right operand
  82718. * @returns the dot product
  82719. */
  82720. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82721. /**
  82722. * Checks if the two quaternions are close to each other
  82723. * @param quat0 defines the first quaternion to check
  82724. * @param quat1 defines the second quaternion to check
  82725. * @returns true if the two quaternions are close to each other
  82726. */
  82727. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82728. /**
  82729. * Creates an empty quaternion
  82730. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82731. */
  82732. static Zero(): Quaternion;
  82733. /**
  82734. * Inverse a given quaternion
  82735. * @param q defines the source quaternion
  82736. * @returns a new quaternion as the inverted current quaternion
  82737. */
  82738. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82739. /**
  82740. * Inverse a given quaternion
  82741. * @param q defines the source quaternion
  82742. * @param result the quaternion the result will be stored in
  82743. * @returns the result quaternion
  82744. */
  82745. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82746. /**
  82747. * Creates an identity quaternion
  82748. * @returns the identity quaternion
  82749. */
  82750. static Identity(): Quaternion;
  82751. /**
  82752. * Gets a boolean indicating if the given quaternion is identity
  82753. * @param quaternion defines the quaternion to check
  82754. * @returns true if the quaternion is identity
  82755. */
  82756. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82757. /**
  82758. * Creates a quaternion from a rotation around an axis
  82759. * @param axis defines the axis to use
  82760. * @param angle defines the angle to use
  82761. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82762. */
  82763. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82764. /**
  82765. * Creates a rotation around an axis and stores it into the given quaternion
  82766. * @param axis defines the axis to use
  82767. * @param angle defines the angle to use
  82768. * @param result defines the target quaternion
  82769. * @returns the target quaternion
  82770. */
  82771. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82772. /**
  82773. * Creates a new quaternion from data stored into an array
  82774. * @param array defines the data source
  82775. * @param offset defines the offset in the source array where the data starts
  82776. * @returns a new quaternion
  82777. */
  82778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82779. /**
  82780. * Updates the given quaternion "result" from the starting index of the given array.
  82781. * @param array the array to pull values from
  82782. * @param offset the offset into the array to start at
  82783. * @param result the quaternion to store the result in
  82784. */
  82785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82786. /**
  82787. * Create a quaternion from Euler rotation angles
  82788. * @param x Pitch
  82789. * @param y Yaw
  82790. * @param z Roll
  82791. * @returns the new Quaternion
  82792. */
  82793. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82794. /**
  82795. * Updates a quaternion from Euler rotation angles
  82796. * @param x Pitch
  82797. * @param y Yaw
  82798. * @param z Roll
  82799. * @param result the quaternion to store the result
  82800. * @returns the updated quaternion
  82801. */
  82802. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82803. /**
  82804. * Create a quaternion from Euler rotation vector
  82805. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82806. * @returns the new Quaternion
  82807. */
  82808. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82809. /**
  82810. * Updates a quaternion from Euler rotation vector
  82811. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82812. * @param result the quaternion to store the result
  82813. * @returns the updated quaternion
  82814. */
  82815. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82816. /**
  82817. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82818. * @param yaw defines the rotation around Y axis
  82819. * @param pitch defines the rotation around X axis
  82820. * @param roll defines the rotation around Z axis
  82821. * @returns the new quaternion
  82822. */
  82823. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82824. /**
  82825. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82826. * @param yaw defines the rotation around Y axis
  82827. * @param pitch defines the rotation around X axis
  82828. * @param roll defines the rotation around Z axis
  82829. * @param result defines the target quaternion
  82830. */
  82831. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82832. /**
  82833. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82834. * @param alpha defines the rotation around first axis
  82835. * @param beta defines the rotation around second axis
  82836. * @param gamma defines the rotation around third axis
  82837. * @returns the new quaternion
  82838. */
  82839. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82840. /**
  82841. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82842. * @param alpha defines the rotation around first axis
  82843. * @param beta defines the rotation around second axis
  82844. * @param gamma defines the rotation around third axis
  82845. * @param result defines the target quaternion
  82846. */
  82847. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82848. /**
  82849. * 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)
  82850. * @param axis1 defines the first axis
  82851. * @param axis2 defines the second axis
  82852. * @param axis3 defines the third axis
  82853. * @returns the new quaternion
  82854. */
  82855. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82856. /**
  82857. * 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
  82858. * @param axis1 defines the first axis
  82859. * @param axis2 defines the second axis
  82860. * @param axis3 defines the third axis
  82861. * @param ref defines the target quaternion
  82862. */
  82863. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82864. /**
  82865. * Interpolates between two quaternions
  82866. * @param left defines first quaternion
  82867. * @param right defines second quaternion
  82868. * @param amount defines the gradient to use
  82869. * @returns the new interpolated quaternion
  82870. */
  82871. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82872. /**
  82873. * Interpolates between two quaternions and stores it into a target quaternion
  82874. * @param left defines first quaternion
  82875. * @param right defines second quaternion
  82876. * @param amount defines the gradient to use
  82877. * @param result defines the target quaternion
  82878. */
  82879. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82880. /**
  82881. * Interpolate between two quaternions using Hermite interpolation
  82882. * @param value1 defines first quaternion
  82883. * @param tangent1 defines the incoming tangent
  82884. * @param value2 defines second quaternion
  82885. * @param tangent2 defines the outgoing tangent
  82886. * @param amount defines the target quaternion
  82887. * @returns the new interpolated quaternion
  82888. */
  82889. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82890. }
  82891. /**
  82892. * Class used to store matrix data (4x4)
  82893. */
  82894. export class Matrix {
  82895. /**
  82896. * Gets the precision of matrix computations
  82897. */
  82898. static get Use64Bits(): boolean;
  82899. private static _updateFlagSeed;
  82900. private static _identityReadOnly;
  82901. private _isIdentity;
  82902. private _isIdentityDirty;
  82903. private _isIdentity3x2;
  82904. private _isIdentity3x2Dirty;
  82905. /**
  82906. * Gets the update flag of the matrix which is an unique number for the matrix.
  82907. * It will be incremented every time the matrix data change.
  82908. * You can use it to speed the comparison between two versions of the same matrix.
  82909. */
  82910. updateFlag: number;
  82911. private readonly _m;
  82912. /**
  82913. * Gets the internal data of the matrix
  82914. */
  82915. get m(): DeepImmutable<Float32Array | Array<number>>;
  82916. /** @hidden */
  82917. _markAsUpdated(): void;
  82918. /** @hidden */
  82919. private _updateIdentityStatus;
  82920. /**
  82921. * Creates an empty matrix (filled with zeros)
  82922. */
  82923. constructor();
  82924. /**
  82925. * Check if the current matrix is identity
  82926. * @returns true is the matrix is the identity matrix
  82927. */
  82928. isIdentity(): boolean;
  82929. /**
  82930. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82931. * @returns true is the matrix is the identity matrix
  82932. */
  82933. isIdentityAs3x2(): boolean;
  82934. /**
  82935. * Gets the determinant of the matrix
  82936. * @returns the matrix determinant
  82937. */
  82938. determinant(): number;
  82939. /**
  82940. * Returns the matrix as a Float32Array or Array<number>
  82941. * @returns the matrix underlying array
  82942. */
  82943. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82944. /**
  82945. * Returns the matrix as a Float32Array or Array<number>
  82946. * @returns the matrix underlying array.
  82947. */
  82948. asArray(): DeepImmutable<Float32Array | Array<number>>;
  82949. /**
  82950. * Inverts the current matrix in place
  82951. * @returns the current inverted matrix
  82952. */
  82953. invert(): Matrix;
  82954. /**
  82955. * Sets all the matrix elements to zero
  82956. * @returns the current matrix
  82957. */
  82958. reset(): Matrix;
  82959. /**
  82960. * Adds the current matrix with a second one
  82961. * @param other defines the matrix to add
  82962. * @returns a new matrix as the addition of the current matrix and the given one
  82963. */
  82964. add(other: DeepImmutable<Matrix>): Matrix;
  82965. /**
  82966. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82967. * @param other defines the matrix to add
  82968. * @param result defines the target matrix
  82969. * @returns the current matrix
  82970. */
  82971. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82972. /**
  82973. * Adds in place the given matrix to the current matrix
  82974. * @param other defines the second operand
  82975. * @returns the current updated matrix
  82976. */
  82977. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82978. /**
  82979. * Sets the given matrix to the current inverted Matrix
  82980. * @param other defines the target matrix
  82981. * @returns the unmodified current matrix
  82982. */
  82983. invertToRef(other: Matrix): Matrix;
  82984. /**
  82985. * add a value at the specified position in the current Matrix
  82986. * @param index the index of the value within the matrix. between 0 and 15.
  82987. * @param value the value to be added
  82988. * @returns the current updated matrix
  82989. */
  82990. addAtIndex(index: number, value: number): Matrix;
  82991. /**
  82992. * mutiply the specified position in the current Matrix by a value
  82993. * @param index the index of the value within the matrix. between 0 and 15.
  82994. * @param value the value to be added
  82995. * @returns the current updated matrix
  82996. */
  82997. multiplyAtIndex(index: number, value: number): Matrix;
  82998. /**
  82999. * Inserts the translation vector (using 3 floats) in the current matrix
  83000. * @param x defines the 1st component of the translation
  83001. * @param y defines the 2nd component of the translation
  83002. * @param z defines the 3rd component of the translation
  83003. * @returns the current updated matrix
  83004. */
  83005. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83006. /**
  83007. * Adds the translation vector (using 3 floats) in the current matrix
  83008. * @param x defines the 1st component of the translation
  83009. * @param y defines the 2nd component of the translation
  83010. * @param z defines the 3rd component of the translation
  83011. * @returns the current updated matrix
  83012. */
  83013. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83014. /**
  83015. * Inserts the translation vector in the current matrix
  83016. * @param vector3 defines the translation to insert
  83017. * @returns the current updated matrix
  83018. */
  83019. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83020. /**
  83021. * Gets the translation value of the current matrix
  83022. * @returns a new Vector3 as the extracted translation from the matrix
  83023. */
  83024. getTranslation(): Vector3;
  83025. /**
  83026. * Fill a Vector3 with the extracted translation from the matrix
  83027. * @param result defines the Vector3 where to store the translation
  83028. * @returns the current matrix
  83029. */
  83030. getTranslationToRef(result: Vector3): Matrix;
  83031. /**
  83032. * Remove rotation and scaling part from the matrix
  83033. * @returns the updated matrix
  83034. */
  83035. removeRotationAndScaling(): Matrix;
  83036. /**
  83037. * Multiply two matrices
  83038. * @param other defines the second operand
  83039. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83040. */
  83041. multiply(other: DeepImmutable<Matrix>): Matrix;
  83042. /**
  83043. * Copy the current matrix from the given one
  83044. * @param other defines the source matrix
  83045. * @returns the current updated matrix
  83046. */
  83047. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83048. /**
  83049. * Populates the given array from the starting index with the current matrix values
  83050. * @param array defines the target array
  83051. * @param offset defines the offset in the target array where to start storing values
  83052. * @returns the current matrix
  83053. */
  83054. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83055. /**
  83056. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83057. * @param other defines the second operand
  83058. * @param result defines the matrix where to store the multiplication
  83059. * @returns the current matrix
  83060. */
  83061. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83062. /**
  83063. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83064. * @param other defines the second operand
  83065. * @param result defines the array where to store the multiplication
  83066. * @param offset defines the offset in the target array where to start storing values
  83067. * @returns the current matrix
  83068. */
  83069. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83070. /**
  83071. * Check equality between this matrix and a second one
  83072. * @param value defines the second matrix to compare
  83073. * @returns true is the current matrix and the given one values are strictly equal
  83074. */
  83075. equals(value: DeepImmutable<Matrix>): boolean;
  83076. /**
  83077. * Clone the current matrix
  83078. * @returns a new matrix from the current matrix
  83079. */
  83080. clone(): Matrix;
  83081. /**
  83082. * Returns the name of the current matrix class
  83083. * @returns the string "Matrix"
  83084. */
  83085. getClassName(): string;
  83086. /**
  83087. * Gets the hash code of the current matrix
  83088. * @returns the hash code
  83089. */
  83090. getHashCode(): number;
  83091. /**
  83092. * Decomposes the current Matrix into a translation, rotation and scaling components
  83093. * @param scale defines the scale vector3 given as a reference to update
  83094. * @param rotation defines the rotation quaternion given as a reference to update
  83095. * @param translation defines the translation vector3 given as a reference to update
  83096. * @returns true if operation was successful
  83097. */
  83098. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83099. /**
  83100. * Gets specific row of the matrix
  83101. * @param index defines the number of the row to get
  83102. * @returns the index-th row of the current matrix as a new Vector4
  83103. */
  83104. getRow(index: number): Nullable<Vector4>;
  83105. /**
  83106. * Sets the index-th row of the current matrix to the vector4 values
  83107. * @param index defines the number of the row to set
  83108. * @param row defines the target vector4
  83109. * @returns the updated current matrix
  83110. */
  83111. setRow(index: number, row: Vector4): Matrix;
  83112. /**
  83113. * Compute the transpose of the matrix
  83114. * @returns the new transposed matrix
  83115. */
  83116. transpose(): Matrix;
  83117. /**
  83118. * Compute the transpose of the matrix and store it in a given matrix
  83119. * @param result defines the target matrix
  83120. * @returns the current matrix
  83121. */
  83122. transposeToRef(result: Matrix): Matrix;
  83123. /**
  83124. * Sets the index-th row of the current matrix with the given 4 x float values
  83125. * @param index defines the row index
  83126. * @param x defines the x component to set
  83127. * @param y defines the y component to set
  83128. * @param z defines the z component to set
  83129. * @param w defines the w component to set
  83130. * @returns the updated current matrix
  83131. */
  83132. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83133. /**
  83134. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83135. * @param scale defines the scale factor
  83136. * @returns a new matrix
  83137. */
  83138. scale(scale: number): Matrix;
  83139. /**
  83140. * Scale the current matrix values by a factor to a given result matrix
  83141. * @param scale defines the scale factor
  83142. * @param result defines the matrix to store the result
  83143. * @returns the current matrix
  83144. */
  83145. scaleToRef(scale: number, result: Matrix): Matrix;
  83146. /**
  83147. * Scale the current matrix values by a factor and add the result to a given matrix
  83148. * @param scale defines the scale factor
  83149. * @param result defines the Matrix to store the result
  83150. * @returns the current matrix
  83151. */
  83152. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83153. /**
  83154. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83155. * @param ref matrix to store the result
  83156. */
  83157. toNormalMatrix(ref: Matrix): void;
  83158. /**
  83159. * Gets only rotation part of the current matrix
  83160. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83161. */
  83162. getRotationMatrix(): Matrix;
  83163. /**
  83164. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83165. * @param result defines the target matrix to store data to
  83166. * @returns the current matrix
  83167. */
  83168. getRotationMatrixToRef(result: Matrix): Matrix;
  83169. /**
  83170. * Toggles model matrix from being right handed to left handed in place and vice versa
  83171. */
  83172. toggleModelMatrixHandInPlace(): void;
  83173. /**
  83174. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83175. */
  83176. toggleProjectionMatrixHandInPlace(): void;
  83177. /**
  83178. * Creates a matrix from an array
  83179. * @param array defines the source array
  83180. * @param offset defines an offset in the source array
  83181. * @returns a new Matrix set from the starting index of the given array
  83182. */
  83183. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83184. /**
  83185. * Copy the content of an array into a given matrix
  83186. * @param array defines the source array
  83187. * @param offset defines an offset in the source array
  83188. * @param result defines the target matrix
  83189. */
  83190. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83191. /**
  83192. * Stores an array into a matrix after having multiplied each component by a given factor
  83193. * @param array defines the source array
  83194. * @param offset defines the offset in the source array
  83195. * @param scale defines the scaling factor
  83196. * @param result defines the target matrix
  83197. */
  83198. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83199. /**
  83200. * Gets an identity matrix that must not be updated
  83201. */
  83202. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83203. /**
  83204. * Stores a list of values (16) inside a given matrix
  83205. * @param initialM11 defines 1st value of 1st row
  83206. * @param initialM12 defines 2nd value of 1st row
  83207. * @param initialM13 defines 3rd value of 1st row
  83208. * @param initialM14 defines 4th value of 1st row
  83209. * @param initialM21 defines 1st value of 2nd row
  83210. * @param initialM22 defines 2nd value of 2nd row
  83211. * @param initialM23 defines 3rd value of 2nd row
  83212. * @param initialM24 defines 4th value of 2nd row
  83213. * @param initialM31 defines 1st value of 3rd row
  83214. * @param initialM32 defines 2nd value of 3rd row
  83215. * @param initialM33 defines 3rd value of 3rd row
  83216. * @param initialM34 defines 4th value of 3rd row
  83217. * @param initialM41 defines 1st value of 4th row
  83218. * @param initialM42 defines 2nd value of 4th row
  83219. * @param initialM43 defines 3rd value of 4th row
  83220. * @param initialM44 defines 4th value of 4th row
  83221. * @param result defines the target matrix
  83222. */
  83223. 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;
  83224. /**
  83225. * Creates new matrix from a list of values (16)
  83226. * @param initialM11 defines 1st value of 1st row
  83227. * @param initialM12 defines 2nd value of 1st row
  83228. * @param initialM13 defines 3rd value of 1st row
  83229. * @param initialM14 defines 4th value of 1st row
  83230. * @param initialM21 defines 1st value of 2nd row
  83231. * @param initialM22 defines 2nd value of 2nd row
  83232. * @param initialM23 defines 3rd value of 2nd row
  83233. * @param initialM24 defines 4th value of 2nd row
  83234. * @param initialM31 defines 1st value of 3rd row
  83235. * @param initialM32 defines 2nd value of 3rd row
  83236. * @param initialM33 defines 3rd value of 3rd row
  83237. * @param initialM34 defines 4th value of 3rd row
  83238. * @param initialM41 defines 1st value of 4th row
  83239. * @param initialM42 defines 2nd value of 4th row
  83240. * @param initialM43 defines 3rd value of 4th row
  83241. * @param initialM44 defines 4th value of 4th row
  83242. * @returns the new matrix
  83243. */
  83244. 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;
  83245. /**
  83246. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83247. * @param scale defines the scale vector3
  83248. * @param rotation defines the rotation quaternion
  83249. * @param translation defines the translation vector3
  83250. * @returns a new matrix
  83251. */
  83252. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83253. /**
  83254. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83255. * @param scale defines the scale vector3
  83256. * @param rotation defines the rotation quaternion
  83257. * @param translation defines the translation vector3
  83258. * @param result defines the target matrix
  83259. */
  83260. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83261. /**
  83262. * Creates a new identity matrix
  83263. * @returns a new identity matrix
  83264. */
  83265. static Identity(): Matrix;
  83266. /**
  83267. * Creates a new identity matrix and stores the result in a given matrix
  83268. * @param result defines the target matrix
  83269. */
  83270. static IdentityToRef(result: Matrix): void;
  83271. /**
  83272. * Creates a new zero matrix
  83273. * @returns a new zero matrix
  83274. */
  83275. static Zero(): Matrix;
  83276. /**
  83277. * Creates a new rotation matrix for "angle" radians around the X axis
  83278. * @param angle defines the angle (in radians) to use
  83279. * @return the new matrix
  83280. */
  83281. static RotationX(angle: number): Matrix;
  83282. /**
  83283. * Creates a new matrix as the invert of a given matrix
  83284. * @param source defines the source matrix
  83285. * @returns the new matrix
  83286. */
  83287. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83288. /**
  83289. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83290. * @param angle defines the angle (in radians) to use
  83291. * @param result defines the target matrix
  83292. */
  83293. static RotationXToRef(angle: number, result: Matrix): void;
  83294. /**
  83295. * Creates a new rotation matrix for "angle" radians around the Y axis
  83296. * @param angle defines the angle (in radians) to use
  83297. * @return the new matrix
  83298. */
  83299. static RotationY(angle: number): Matrix;
  83300. /**
  83301. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83302. * @param angle defines the angle (in radians) to use
  83303. * @param result defines the target matrix
  83304. */
  83305. static RotationYToRef(angle: number, result: Matrix): void;
  83306. /**
  83307. * Creates a new rotation matrix for "angle" radians around the Z axis
  83308. * @param angle defines the angle (in radians) to use
  83309. * @return the new matrix
  83310. */
  83311. static RotationZ(angle: number): Matrix;
  83312. /**
  83313. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83314. * @param angle defines the angle (in radians) to use
  83315. * @param result defines the target matrix
  83316. */
  83317. static RotationZToRef(angle: number, result: Matrix): void;
  83318. /**
  83319. * Creates a new rotation matrix for "angle" radians around the given axis
  83320. * @param axis defines the axis to use
  83321. * @param angle defines the angle (in radians) to use
  83322. * @return the new matrix
  83323. */
  83324. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83325. /**
  83326. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83327. * @param axis defines the axis to use
  83328. * @param angle defines the angle (in radians) to use
  83329. * @param result defines the target matrix
  83330. */
  83331. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83332. /**
  83333. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83334. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83335. * @param from defines the vector to align
  83336. * @param to defines the vector to align to
  83337. * @param result defines the target matrix
  83338. */
  83339. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83340. /**
  83341. * Creates a rotation matrix
  83342. * @param yaw defines the yaw angle in radians (Y axis)
  83343. * @param pitch defines the pitch angle in radians (X axis)
  83344. * @param roll defines the roll angle in radians (Z axis)
  83345. * @returns the new rotation matrix
  83346. */
  83347. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83348. /**
  83349. * Creates a rotation matrix and stores it in a given matrix
  83350. * @param yaw defines the yaw angle in radians (Y axis)
  83351. * @param pitch defines the pitch angle in radians (X axis)
  83352. * @param roll defines the roll angle in radians (Z axis)
  83353. * @param result defines the target matrix
  83354. */
  83355. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83356. /**
  83357. * Creates a scaling matrix
  83358. * @param x defines the scale factor on X axis
  83359. * @param y defines the scale factor on Y axis
  83360. * @param z defines the scale factor on Z axis
  83361. * @returns the new matrix
  83362. */
  83363. static Scaling(x: number, y: number, z: number): Matrix;
  83364. /**
  83365. * Creates a scaling matrix and stores it in a given matrix
  83366. * @param x defines the scale factor on X axis
  83367. * @param y defines the scale factor on Y axis
  83368. * @param z defines the scale factor on Z axis
  83369. * @param result defines the target matrix
  83370. */
  83371. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83372. /**
  83373. * Creates a translation matrix
  83374. * @param x defines the translation on X axis
  83375. * @param y defines the translation on Y axis
  83376. * @param z defines the translationon Z axis
  83377. * @returns the new matrix
  83378. */
  83379. static Translation(x: number, y: number, z: number): Matrix;
  83380. /**
  83381. * Creates a translation matrix and stores it in a given matrix
  83382. * @param x defines the translation on X axis
  83383. * @param y defines the translation on Y axis
  83384. * @param z defines the translationon Z axis
  83385. * @param result defines the target matrix
  83386. */
  83387. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83388. /**
  83389. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83390. * @param startValue defines the start value
  83391. * @param endValue defines the end value
  83392. * @param gradient defines the gradient factor
  83393. * @returns the new matrix
  83394. */
  83395. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83396. /**
  83397. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83398. * @param startValue defines the start value
  83399. * @param endValue defines the end value
  83400. * @param gradient defines the gradient factor
  83401. * @param result defines the Matrix object where to store data
  83402. */
  83403. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83404. /**
  83405. * Builds a new matrix whose values are computed by:
  83406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83409. * @param startValue defines the first matrix
  83410. * @param endValue defines the second matrix
  83411. * @param gradient defines the gradient between the two matrices
  83412. * @returns the new matrix
  83413. */
  83414. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83415. /**
  83416. * Update a matrix to values which are computed by:
  83417. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83418. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83419. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83420. * @param startValue defines the first matrix
  83421. * @param endValue defines the second matrix
  83422. * @param gradient defines the gradient between the two matrices
  83423. * @param result defines the target matrix
  83424. */
  83425. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83426. /**
  83427. * 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"
  83428. * This function works in left handed mode
  83429. * @param eye defines the final position of the entity
  83430. * @param target defines where the entity should look at
  83431. * @param up defines the up vector for the entity
  83432. * @returns the new matrix
  83433. */
  83434. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83435. /**
  83436. * 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".
  83437. * This function works in left handed mode
  83438. * @param eye defines the final position of the entity
  83439. * @param target defines where the entity should look at
  83440. * @param up defines the up vector for the entity
  83441. * @param result defines the target matrix
  83442. */
  83443. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83444. /**
  83445. * 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"
  83446. * This function works in right handed mode
  83447. * @param eye defines the final position of the entity
  83448. * @param target defines where the entity should look at
  83449. * @param up defines the up vector for the entity
  83450. * @returns the new matrix
  83451. */
  83452. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83453. /**
  83454. * 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".
  83455. * This function works in right handed mode
  83456. * @param eye defines the final position of the entity
  83457. * @param target defines where the entity should look at
  83458. * @param up defines the up vector for the entity
  83459. * @param result defines the target matrix
  83460. */
  83461. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83462. /**
  83463. * Create a left-handed orthographic projection matrix
  83464. * @param width defines the viewport width
  83465. * @param height defines the viewport height
  83466. * @param znear defines the near clip plane
  83467. * @param zfar defines the far clip plane
  83468. * @returns a new matrix as a left-handed orthographic projection matrix
  83469. */
  83470. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83471. /**
  83472. * Store a left-handed orthographic projection to a given matrix
  83473. * @param width defines the viewport width
  83474. * @param height defines the viewport height
  83475. * @param znear defines the near clip plane
  83476. * @param zfar defines the far clip plane
  83477. * @param result defines the target matrix
  83478. */
  83479. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83480. /**
  83481. * Create a left-handed orthographic projection matrix
  83482. * @param left defines the viewport left coordinate
  83483. * @param right defines the viewport right coordinate
  83484. * @param bottom defines the viewport bottom coordinate
  83485. * @param top defines the viewport top coordinate
  83486. * @param znear defines the near clip plane
  83487. * @param zfar defines the far clip plane
  83488. * @returns a new matrix as a left-handed orthographic projection matrix
  83489. */
  83490. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83491. /**
  83492. * Stores a left-handed orthographic projection into a given matrix
  83493. * @param left defines the viewport left coordinate
  83494. * @param right defines the viewport right coordinate
  83495. * @param bottom defines the viewport bottom coordinate
  83496. * @param top defines the viewport top coordinate
  83497. * @param znear defines the near clip plane
  83498. * @param zfar defines the far clip plane
  83499. * @param result defines the target matrix
  83500. */
  83501. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83502. /**
  83503. * Creates a right-handed orthographic projection matrix
  83504. * @param left defines the viewport left coordinate
  83505. * @param right defines the viewport right coordinate
  83506. * @param bottom defines the viewport bottom coordinate
  83507. * @param top defines the viewport top coordinate
  83508. * @param znear defines the near clip plane
  83509. * @param zfar defines the far clip plane
  83510. * @returns a new matrix as a right-handed orthographic projection matrix
  83511. */
  83512. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83513. /**
  83514. * Stores a right-handed orthographic projection into a given matrix
  83515. * @param left defines the viewport left coordinate
  83516. * @param right defines the viewport right coordinate
  83517. * @param bottom defines the viewport bottom coordinate
  83518. * @param top defines the viewport top coordinate
  83519. * @param znear defines the near clip plane
  83520. * @param zfar defines the far clip plane
  83521. * @param result defines the target matrix
  83522. */
  83523. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83524. /**
  83525. * Creates a left-handed perspective projection matrix
  83526. * @param width defines the viewport width
  83527. * @param height defines the viewport height
  83528. * @param znear defines the near clip plane
  83529. * @param zfar defines the far clip plane
  83530. * @returns a new matrix as a left-handed perspective projection matrix
  83531. */
  83532. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83533. /**
  83534. * Creates a left-handed perspective projection matrix
  83535. * @param fov defines the horizontal field of view
  83536. * @param aspect defines the aspect ratio
  83537. * @param znear defines the near clip plane
  83538. * @param zfar defines the far clip plane
  83539. * @returns a new matrix as a left-handed perspective projection matrix
  83540. */
  83541. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83542. /**
  83543. * Stores a left-handed perspective projection into a given matrix
  83544. * @param fov defines the horizontal field of view
  83545. * @param aspect defines the aspect ratio
  83546. * @param znear defines the near clip plane
  83547. * @param zfar defines the far clip plane
  83548. * @param result defines the target matrix
  83549. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83550. */
  83551. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83552. /**
  83553. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83554. * @param fov defines the horizontal field of view
  83555. * @param aspect defines the aspect ratio
  83556. * @param znear defines the near clip plane
  83557. * @param zfar not used as infinity is used as far clip
  83558. * @param result defines the target matrix
  83559. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83560. */
  83561. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83562. /**
  83563. * Creates a right-handed perspective projection matrix
  83564. * @param fov defines the horizontal field of view
  83565. * @param aspect defines the aspect ratio
  83566. * @param znear defines the near clip plane
  83567. * @param zfar defines the far clip plane
  83568. * @returns a new matrix as a right-handed perspective projection matrix
  83569. */
  83570. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83571. /**
  83572. * Stores a right-handed perspective projection into a given matrix
  83573. * @param fov defines the horizontal field of view
  83574. * @param aspect defines the aspect ratio
  83575. * @param znear defines the near clip plane
  83576. * @param zfar defines the far clip plane
  83577. * @param result defines the target matrix
  83578. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83579. */
  83580. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83581. /**
  83582. * Stores a right-handed perspective projection into a given matrix
  83583. * @param fov defines the horizontal field of view
  83584. * @param aspect defines the aspect ratio
  83585. * @param znear defines the near clip plane
  83586. * @param zfar not used as infinity is used as far clip
  83587. * @param result defines the target matrix
  83588. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83589. */
  83590. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83591. /**
  83592. * Stores a perspective projection for WebVR info a given matrix
  83593. * @param fov defines the field of view
  83594. * @param znear defines the near clip plane
  83595. * @param zfar defines the far clip plane
  83596. * @param result defines the target matrix
  83597. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83598. */
  83599. static PerspectiveFovWebVRToRef(fov: {
  83600. upDegrees: number;
  83601. downDegrees: number;
  83602. leftDegrees: number;
  83603. rightDegrees: number;
  83604. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83605. /**
  83606. * Computes a complete transformation matrix
  83607. * @param viewport defines the viewport to use
  83608. * @param world defines the world matrix
  83609. * @param view defines the view matrix
  83610. * @param projection defines the projection matrix
  83611. * @param zmin defines the near clip plane
  83612. * @param zmax defines the far clip plane
  83613. * @returns the transformation matrix
  83614. */
  83615. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83616. /**
  83617. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83618. * @param matrix defines the matrix to use
  83619. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83620. */
  83621. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83622. /**
  83623. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83624. * @param matrix defines the matrix to use
  83625. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83626. */
  83627. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83628. /**
  83629. * Compute the transpose of a given matrix
  83630. * @param matrix defines the matrix to transpose
  83631. * @returns the new matrix
  83632. */
  83633. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83634. /**
  83635. * Compute the transpose of a matrix and store it in a target matrix
  83636. * @param matrix defines the matrix to transpose
  83637. * @param result defines the target matrix
  83638. */
  83639. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83640. /**
  83641. * Computes a reflection matrix from a plane
  83642. * @param plane defines the reflection plane
  83643. * @returns a new matrix
  83644. */
  83645. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83646. /**
  83647. * Computes a reflection matrix from a plane
  83648. * @param plane defines the reflection plane
  83649. * @param result defines the target matrix
  83650. */
  83651. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83652. /**
  83653. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83654. * @param xaxis defines the value of the 1st axis
  83655. * @param yaxis defines the value of the 2nd axis
  83656. * @param zaxis defines the value of the 3rd axis
  83657. * @param result defines the target matrix
  83658. */
  83659. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83660. /**
  83661. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83662. * @param quat defines the quaternion to use
  83663. * @param result defines the target matrix
  83664. */
  83665. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83666. }
  83667. /**
  83668. * @hidden
  83669. */
  83670. export class TmpVectors {
  83671. static Vector2: Vector2[];
  83672. static Vector3: Vector3[];
  83673. static Vector4: Vector4[];
  83674. static Quaternion: Quaternion[];
  83675. static Matrix: Matrix[];
  83676. }
  83677. }
  83678. declare module BABYLON {
  83679. /**
  83680. * Defines potential orientation for back face culling
  83681. */
  83682. export enum Orientation {
  83683. /**
  83684. * Clockwise
  83685. */
  83686. CW = 0,
  83687. /** Counter clockwise */
  83688. CCW = 1
  83689. }
  83690. /** Class used to represent a Bezier curve */
  83691. export class BezierCurve {
  83692. /**
  83693. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83694. * @param t defines the time
  83695. * @param x1 defines the left coordinate on X axis
  83696. * @param y1 defines the left coordinate on Y axis
  83697. * @param x2 defines the right coordinate on X axis
  83698. * @param y2 defines the right coordinate on Y axis
  83699. * @returns the interpolated value
  83700. */
  83701. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83702. }
  83703. /**
  83704. * Defines angle representation
  83705. */
  83706. export class Angle {
  83707. private _radians;
  83708. /**
  83709. * Creates an Angle object of "radians" radians (float).
  83710. * @param radians the angle in radians
  83711. */
  83712. constructor(radians: number);
  83713. /**
  83714. * Get value in degrees
  83715. * @returns the Angle value in degrees (float)
  83716. */
  83717. degrees(): number;
  83718. /**
  83719. * Get value in radians
  83720. * @returns the Angle value in radians (float)
  83721. */
  83722. radians(): number;
  83723. /**
  83724. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83725. * @param a defines first point as the origin
  83726. * @param b defines point
  83727. * @returns a new Angle
  83728. */
  83729. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83730. /**
  83731. * Gets a new Angle object from the given float in radians
  83732. * @param radians defines the angle value in radians
  83733. * @returns a new Angle
  83734. */
  83735. static FromRadians(radians: number): Angle;
  83736. /**
  83737. * Gets a new Angle object from the given float in degrees
  83738. * @param degrees defines the angle value in degrees
  83739. * @returns a new Angle
  83740. */
  83741. static FromDegrees(degrees: number): Angle;
  83742. }
  83743. /**
  83744. * This represents an arc in a 2d space.
  83745. */
  83746. export class Arc2 {
  83747. /** Defines the start point of the arc */
  83748. startPoint: Vector2;
  83749. /** Defines the mid point of the arc */
  83750. midPoint: Vector2;
  83751. /** Defines the end point of the arc */
  83752. endPoint: Vector2;
  83753. /**
  83754. * Defines the center point of the arc.
  83755. */
  83756. centerPoint: Vector2;
  83757. /**
  83758. * Defines the radius of the arc.
  83759. */
  83760. radius: number;
  83761. /**
  83762. * Defines the angle of the arc (from mid point to end point).
  83763. */
  83764. angle: Angle;
  83765. /**
  83766. * Defines the start angle of the arc (from start point to middle point).
  83767. */
  83768. startAngle: Angle;
  83769. /**
  83770. * Defines the orientation of the arc (clock wise/counter clock wise).
  83771. */
  83772. orientation: Orientation;
  83773. /**
  83774. * Creates an Arc object from the three given points : start, middle and end.
  83775. * @param startPoint Defines the start point of the arc
  83776. * @param midPoint Defines the midlle point of the arc
  83777. * @param endPoint Defines the end point of the arc
  83778. */
  83779. constructor(
  83780. /** Defines the start point of the arc */
  83781. startPoint: Vector2,
  83782. /** Defines the mid point of the arc */
  83783. midPoint: Vector2,
  83784. /** Defines the end point of the arc */
  83785. endPoint: Vector2);
  83786. }
  83787. /**
  83788. * Represents a 2D path made up of multiple 2D points
  83789. */
  83790. export class Path2 {
  83791. private _points;
  83792. private _length;
  83793. /**
  83794. * If the path start and end point are the same
  83795. */
  83796. closed: boolean;
  83797. /**
  83798. * Creates a Path2 object from the starting 2D coordinates x and y.
  83799. * @param x the starting points x value
  83800. * @param y the starting points y value
  83801. */
  83802. constructor(x: number, y: number);
  83803. /**
  83804. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83805. * @param x the added points x value
  83806. * @param y the added points y value
  83807. * @returns the updated Path2.
  83808. */
  83809. addLineTo(x: number, y: number): Path2;
  83810. /**
  83811. * 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.
  83812. * @param midX middle point x value
  83813. * @param midY middle point y value
  83814. * @param endX end point x value
  83815. * @param endY end point y value
  83816. * @param numberOfSegments (default: 36)
  83817. * @returns the updated Path2.
  83818. */
  83819. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83820. /**
  83821. * Closes the Path2.
  83822. * @returns the Path2.
  83823. */
  83824. close(): Path2;
  83825. /**
  83826. * Gets the sum of the distance between each sequential point in the path
  83827. * @returns the Path2 total length (float).
  83828. */
  83829. length(): number;
  83830. /**
  83831. * Gets the points which construct the path
  83832. * @returns the Path2 internal array of points.
  83833. */
  83834. getPoints(): Vector2[];
  83835. /**
  83836. * Retreives the point at the distance aways from the starting point
  83837. * @param normalizedLengthPosition the length along the path to retreive the point from
  83838. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83839. */
  83840. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83841. /**
  83842. * Creates a new path starting from an x and y position
  83843. * @param x starting x value
  83844. * @param y starting y value
  83845. * @returns a new Path2 starting at the coordinates (x, y).
  83846. */
  83847. static StartingAt(x: number, y: number): Path2;
  83848. }
  83849. /**
  83850. * Represents a 3D path made up of multiple 3D points
  83851. */
  83852. export class Path3D {
  83853. /**
  83854. * an array of Vector3, the curve axis of the Path3D
  83855. */
  83856. path: Vector3[];
  83857. private _curve;
  83858. private _distances;
  83859. private _tangents;
  83860. private _normals;
  83861. private _binormals;
  83862. private _raw;
  83863. private _alignTangentsWithPath;
  83864. private readonly _pointAtData;
  83865. /**
  83866. * new Path3D(path, normal, raw)
  83867. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83868. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83869. * @param path an array of Vector3, the curve axis of the Path3D
  83870. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83871. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83872. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83873. */
  83874. constructor(
  83875. /**
  83876. * an array of Vector3, the curve axis of the Path3D
  83877. */
  83878. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83879. /**
  83880. * Returns the Path3D array of successive Vector3 designing its curve.
  83881. * @returns the Path3D array of successive Vector3 designing its curve.
  83882. */
  83883. getCurve(): Vector3[];
  83884. /**
  83885. * Returns the Path3D array of successive Vector3 designing its curve.
  83886. * @returns the Path3D array of successive Vector3 designing its curve.
  83887. */
  83888. getPoints(): Vector3[];
  83889. /**
  83890. * @returns the computed length (float) of the path.
  83891. */
  83892. length(): number;
  83893. /**
  83894. * Returns an array populated with tangent vectors on each Path3D curve point.
  83895. * @returns an array populated with tangent vectors on each Path3D curve point.
  83896. */
  83897. getTangents(): Vector3[];
  83898. /**
  83899. * Returns an array populated with normal vectors on each Path3D curve point.
  83900. * @returns an array populated with normal vectors on each Path3D curve point.
  83901. */
  83902. getNormals(): Vector3[];
  83903. /**
  83904. * Returns an array populated with binormal vectors on each Path3D curve point.
  83905. * @returns an array populated with binormal vectors on each Path3D curve point.
  83906. */
  83907. getBinormals(): Vector3[];
  83908. /**
  83909. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83910. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83911. */
  83912. getDistances(): number[];
  83913. /**
  83914. * Returns an interpolated point along this path
  83915. * @param position the position of the point along this path, from 0.0 to 1.0
  83916. * @returns a new Vector3 as the point
  83917. */
  83918. getPointAt(position: number): Vector3;
  83919. /**
  83920. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83921. * @param position the position of the point along this path, from 0.0 to 1.0
  83922. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83923. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83924. */
  83925. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83926. /**
  83927. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83928. * @param position the position of the point along this path, from 0.0 to 1.0
  83929. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83930. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83931. */
  83932. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83933. /**
  83934. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83935. * @param position the position of the point along this path, from 0.0 to 1.0
  83936. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83937. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83938. */
  83939. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83940. /**
  83941. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83942. * @param position the position of the point along this path, from 0.0 to 1.0
  83943. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83944. */
  83945. getDistanceAt(position: number): number;
  83946. /**
  83947. * Returns the array index of the previous point of an interpolated point along this path
  83948. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83949. * @returns the array index
  83950. */
  83951. getPreviousPointIndexAt(position: number): number;
  83952. /**
  83953. * 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)
  83954. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83955. * @returns the sub position
  83956. */
  83957. getSubPositionAt(position: number): number;
  83958. /**
  83959. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83960. * @param target the vector of which to get the closest position to
  83961. * @returns the position of the closest virtual point on this path to the target vector
  83962. */
  83963. getClosestPositionTo(target: Vector3): number;
  83964. /**
  83965. * Returns a sub path (slice) of this path
  83966. * @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
  83967. * @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
  83968. * @returns a sub path (slice) of this path
  83969. */
  83970. slice(start?: number, end?: number): Path3D;
  83971. /**
  83972. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83973. * @param path path which all values are copied into the curves points
  83974. * @param firstNormal which should be projected onto the curve
  83975. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83976. * @returns the same object updated.
  83977. */
  83978. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83979. private _compute;
  83980. private _getFirstNonNullVector;
  83981. private _getLastNonNullVector;
  83982. private _normalVector;
  83983. /**
  83984. * Updates the point at data for an interpolated point along this curve
  83985. * @param position the position of the point along this curve, from 0.0 to 1.0
  83986. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83987. * @returns the (updated) point at data
  83988. */
  83989. private _updatePointAtData;
  83990. /**
  83991. * Updates the point at data from the specified parameters
  83992. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83993. * @param point the interpolated point
  83994. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83995. */
  83996. private _setPointAtData;
  83997. /**
  83998. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83999. */
  84000. private _updateInterpolationMatrix;
  84001. }
  84002. /**
  84003. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84004. * A Curve3 is designed from a series of successive Vector3.
  84005. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84006. */
  84007. export class Curve3 {
  84008. private _points;
  84009. private _length;
  84010. /**
  84011. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84012. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84013. * @param v1 (Vector3) the control point
  84014. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84015. * @param nbPoints (integer) the wanted number of points in the curve
  84016. * @returns the created Curve3
  84017. */
  84018. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84019. /**
  84020. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84021. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84022. * @param v1 (Vector3) the first control point
  84023. * @param v2 (Vector3) the second control point
  84024. * @param v3 (Vector3) the end point of the Cubic Bezier
  84025. * @param nbPoints (integer) the wanted number of points in the curve
  84026. * @returns the created Curve3
  84027. */
  84028. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84029. /**
  84030. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84031. * @param p1 (Vector3) the origin point of the Hermite Spline
  84032. * @param t1 (Vector3) the tangent vector at the origin point
  84033. * @param p2 (Vector3) the end point of the Hermite Spline
  84034. * @param t2 (Vector3) the tangent vector at the end point
  84035. * @param nbPoints (integer) the wanted number of points in the curve
  84036. * @returns the created Curve3
  84037. */
  84038. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84039. /**
  84040. * Returns a Curve3 object along a CatmullRom Spline curve :
  84041. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84042. * @param nbPoints (integer) the wanted number of points between each curve control points
  84043. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84044. * @returns the created Curve3
  84045. */
  84046. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84047. /**
  84048. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84049. * A Curve3 is designed from a series of successive Vector3.
  84050. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84051. * @param points points which make up the curve
  84052. */
  84053. constructor(points: Vector3[]);
  84054. /**
  84055. * @returns the Curve3 stored array of successive Vector3
  84056. */
  84057. getPoints(): Vector3[];
  84058. /**
  84059. * @returns the computed length (float) of the curve.
  84060. */
  84061. length(): number;
  84062. /**
  84063. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84064. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84065. * curveA and curveB keep unchanged.
  84066. * @param curve the curve to continue from this curve
  84067. * @returns the newly constructed curve
  84068. */
  84069. continue(curve: DeepImmutable<Curve3>): Curve3;
  84070. private _computeLength;
  84071. }
  84072. }
  84073. declare module BABYLON {
  84074. /**
  84075. * This represents the main contract an easing function should follow.
  84076. * Easing functions are used throughout the animation system.
  84077. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84078. */
  84079. export interface IEasingFunction {
  84080. /**
  84081. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84082. * of the easing function.
  84083. * The link below provides some of the most common examples of easing functions.
  84084. * @see https://easings.net/
  84085. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84086. * @returns the corresponding value on the curve defined by the easing function
  84087. */
  84088. ease(gradient: number): number;
  84089. }
  84090. /**
  84091. * Base class used for every default easing function.
  84092. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84093. */
  84094. export class EasingFunction implements IEasingFunction {
  84095. /**
  84096. * Interpolation follows the mathematical formula associated with the easing function.
  84097. */
  84098. static readonly EASINGMODE_EASEIN: number;
  84099. /**
  84100. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84101. */
  84102. static readonly EASINGMODE_EASEOUT: number;
  84103. /**
  84104. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84105. */
  84106. static readonly EASINGMODE_EASEINOUT: number;
  84107. private _easingMode;
  84108. /**
  84109. * Sets the easing mode of the current function.
  84110. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84111. */
  84112. setEasingMode(easingMode: number): void;
  84113. /**
  84114. * Gets the current easing mode.
  84115. * @returns the easing mode
  84116. */
  84117. getEasingMode(): number;
  84118. /**
  84119. * @hidden
  84120. */
  84121. easeInCore(gradient: number): number;
  84122. /**
  84123. * Given an input gradient between 0 and 1, this returns the corresponding value
  84124. * of the easing function.
  84125. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84126. * @returns the corresponding value on the curve defined by the easing function
  84127. */
  84128. ease(gradient: number): number;
  84129. }
  84130. /**
  84131. * Easing function with a circle shape (see link below).
  84132. * @see https://easings.net/#easeInCirc
  84133. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84134. */
  84135. export class CircleEase extends EasingFunction implements IEasingFunction {
  84136. /** @hidden */
  84137. easeInCore(gradient: number): number;
  84138. }
  84139. /**
  84140. * Easing function with a ease back shape (see link below).
  84141. * @see https://easings.net/#easeInBack
  84142. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84143. */
  84144. export class BackEase extends EasingFunction implements IEasingFunction {
  84145. /** Defines the amplitude of the function */
  84146. amplitude: number;
  84147. /**
  84148. * Instantiates a back ease easing
  84149. * @see https://easings.net/#easeInBack
  84150. * @param amplitude Defines the amplitude of the function
  84151. */
  84152. constructor(
  84153. /** Defines the amplitude of the function */
  84154. amplitude?: number);
  84155. /** @hidden */
  84156. easeInCore(gradient: number): number;
  84157. }
  84158. /**
  84159. * Easing function with a bouncing shape (see link below).
  84160. * @see https://easings.net/#easeInBounce
  84161. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84162. */
  84163. export class BounceEase extends EasingFunction implements IEasingFunction {
  84164. /** Defines the number of bounces */
  84165. bounces: number;
  84166. /** Defines the amplitude of the bounce */
  84167. bounciness: number;
  84168. /**
  84169. * Instantiates a bounce easing
  84170. * @see https://easings.net/#easeInBounce
  84171. * @param bounces Defines the number of bounces
  84172. * @param bounciness Defines the amplitude of the bounce
  84173. */
  84174. constructor(
  84175. /** Defines the number of bounces */
  84176. bounces?: number,
  84177. /** Defines the amplitude of the bounce */
  84178. bounciness?: number);
  84179. /** @hidden */
  84180. easeInCore(gradient: number): number;
  84181. }
  84182. /**
  84183. * Easing function with a power of 3 shape (see link below).
  84184. * @see https://easings.net/#easeInCubic
  84185. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84186. */
  84187. export class CubicEase extends EasingFunction implements IEasingFunction {
  84188. /** @hidden */
  84189. easeInCore(gradient: number): number;
  84190. }
  84191. /**
  84192. * Easing function with an elastic shape (see link below).
  84193. * @see https://easings.net/#easeInElastic
  84194. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84195. */
  84196. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84197. /** Defines the number of oscillations*/
  84198. oscillations: number;
  84199. /** Defines the amplitude of the oscillations*/
  84200. springiness: number;
  84201. /**
  84202. * Instantiates an elastic easing function
  84203. * @see https://easings.net/#easeInElastic
  84204. * @param oscillations Defines the number of oscillations
  84205. * @param springiness Defines the amplitude of the oscillations
  84206. */
  84207. constructor(
  84208. /** Defines the number of oscillations*/
  84209. oscillations?: number,
  84210. /** Defines the amplitude of the oscillations*/
  84211. springiness?: number);
  84212. /** @hidden */
  84213. easeInCore(gradient: number): number;
  84214. }
  84215. /**
  84216. * Easing function with an exponential shape (see link below).
  84217. * @see https://easings.net/#easeInExpo
  84218. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84219. */
  84220. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84221. /** Defines the exponent of the function */
  84222. exponent: number;
  84223. /**
  84224. * Instantiates an exponential easing function
  84225. * @see https://easings.net/#easeInExpo
  84226. * @param exponent Defines the exponent of the function
  84227. */
  84228. constructor(
  84229. /** Defines the exponent of the function */
  84230. exponent?: number);
  84231. /** @hidden */
  84232. easeInCore(gradient: number): number;
  84233. }
  84234. /**
  84235. * Easing function with a power shape (see link below).
  84236. * @see https://easings.net/#easeInQuad
  84237. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84238. */
  84239. export class PowerEase extends EasingFunction implements IEasingFunction {
  84240. /** Defines the power of the function */
  84241. power: number;
  84242. /**
  84243. * Instantiates an power base easing function
  84244. * @see https://easings.net/#easeInQuad
  84245. * @param power Defines the power of the function
  84246. */
  84247. constructor(
  84248. /** Defines the power of the function */
  84249. power?: number);
  84250. /** @hidden */
  84251. easeInCore(gradient: number): number;
  84252. }
  84253. /**
  84254. * Easing function with a power of 2 shape (see link below).
  84255. * @see https://easings.net/#easeInQuad
  84256. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84257. */
  84258. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84259. /** @hidden */
  84260. easeInCore(gradient: number): number;
  84261. }
  84262. /**
  84263. * Easing function with a power of 4 shape (see link below).
  84264. * @see https://easings.net/#easeInQuart
  84265. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84266. */
  84267. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84268. /** @hidden */
  84269. easeInCore(gradient: number): number;
  84270. }
  84271. /**
  84272. * Easing function with a power of 5 shape (see link below).
  84273. * @see https://easings.net/#easeInQuint
  84274. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84275. */
  84276. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84277. /** @hidden */
  84278. easeInCore(gradient: number): number;
  84279. }
  84280. /**
  84281. * Easing function with a sin shape (see link below).
  84282. * @see https://easings.net/#easeInSine
  84283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84284. */
  84285. export class SineEase extends EasingFunction implements IEasingFunction {
  84286. /** @hidden */
  84287. easeInCore(gradient: number): number;
  84288. }
  84289. /**
  84290. * Easing function with a bezier shape (see link below).
  84291. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84292. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84293. */
  84294. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84295. /** Defines the x component of the start tangent in the bezier curve */
  84296. x1: number;
  84297. /** Defines the y component of the start tangent in the bezier curve */
  84298. y1: number;
  84299. /** Defines the x component of the end tangent in the bezier curve */
  84300. x2: number;
  84301. /** Defines the y component of the end tangent in the bezier curve */
  84302. y2: number;
  84303. /**
  84304. * Instantiates a bezier function
  84305. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84306. * @param x1 Defines the x component of the start tangent in the bezier curve
  84307. * @param y1 Defines the y component of the start tangent in the bezier curve
  84308. * @param x2 Defines the x component of the end tangent in the bezier curve
  84309. * @param y2 Defines the y component of the end tangent in the bezier curve
  84310. */
  84311. constructor(
  84312. /** Defines the x component of the start tangent in the bezier curve */
  84313. x1?: number,
  84314. /** Defines the y component of the start tangent in the bezier curve */
  84315. y1?: number,
  84316. /** Defines the x component of the end tangent in the bezier curve */
  84317. x2?: number,
  84318. /** Defines the y component of the end tangent in the bezier curve */
  84319. y2?: number);
  84320. /** @hidden */
  84321. easeInCore(gradient: number): number;
  84322. }
  84323. }
  84324. declare module BABYLON {
  84325. /**
  84326. * Class used to hold a RBG color
  84327. */
  84328. export class Color3 {
  84329. /**
  84330. * Defines the red component (between 0 and 1, default is 0)
  84331. */
  84332. r: number;
  84333. /**
  84334. * Defines the green component (between 0 and 1, default is 0)
  84335. */
  84336. g: number;
  84337. /**
  84338. * Defines the blue component (between 0 and 1, default is 0)
  84339. */
  84340. b: number;
  84341. /**
  84342. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84343. * @param r defines the red component (between 0 and 1, default is 0)
  84344. * @param g defines the green component (between 0 and 1, default is 0)
  84345. * @param b defines the blue component (between 0 and 1, default is 0)
  84346. */
  84347. constructor(
  84348. /**
  84349. * Defines the red component (between 0 and 1, default is 0)
  84350. */
  84351. r?: number,
  84352. /**
  84353. * Defines the green component (between 0 and 1, default is 0)
  84354. */
  84355. g?: number,
  84356. /**
  84357. * Defines the blue component (between 0 and 1, default is 0)
  84358. */
  84359. b?: number);
  84360. /**
  84361. * Creates a string with the Color3 current values
  84362. * @returns the string representation of the Color3 object
  84363. */
  84364. toString(): string;
  84365. /**
  84366. * Returns the string "Color3"
  84367. * @returns "Color3"
  84368. */
  84369. getClassName(): string;
  84370. /**
  84371. * Compute the Color3 hash code
  84372. * @returns an unique number that can be used to hash Color3 objects
  84373. */
  84374. getHashCode(): number;
  84375. /**
  84376. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84377. * @param array defines the array where to store the r,g,b components
  84378. * @param index defines an optional index in the target array to define where to start storing values
  84379. * @returns the current Color3 object
  84380. */
  84381. toArray(array: FloatArray, index?: number): Color3;
  84382. /**
  84383. * Update the current color with values stored in an array from the starting index of the given array
  84384. * @param array defines the source array
  84385. * @param offset defines an offset in the source array
  84386. * @returns the current Color3 object
  84387. */
  84388. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84389. /**
  84390. * Returns a new Color4 object from the current Color3 and the given alpha
  84391. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84392. * @returns a new Color4 object
  84393. */
  84394. toColor4(alpha?: number): Color4;
  84395. /**
  84396. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84397. * @returns the new array
  84398. */
  84399. asArray(): number[];
  84400. /**
  84401. * Returns the luminance value
  84402. * @returns a float value
  84403. */
  84404. toLuminance(): number;
  84405. /**
  84406. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84407. * @param otherColor defines the second operand
  84408. * @returns the new Color3 object
  84409. */
  84410. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84411. /**
  84412. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84413. * @param otherColor defines the second operand
  84414. * @param result defines the Color3 object where to store the result
  84415. * @returns the current Color3
  84416. */
  84417. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84418. /**
  84419. * Determines equality between Color3 objects
  84420. * @param otherColor defines the second operand
  84421. * @returns true if the rgb values are equal to the given ones
  84422. */
  84423. equals(otherColor: DeepImmutable<Color3>): boolean;
  84424. /**
  84425. * Determines equality between the current Color3 object and a set of r,b,g values
  84426. * @param r defines the red component to check
  84427. * @param g defines the green component to check
  84428. * @param b defines the blue component to check
  84429. * @returns true if the rgb values are equal to the given ones
  84430. */
  84431. equalsFloats(r: number, g: number, b: number): boolean;
  84432. /**
  84433. * Multiplies in place each rgb value by scale
  84434. * @param scale defines the scaling factor
  84435. * @returns the updated Color3
  84436. */
  84437. scale(scale: number): Color3;
  84438. /**
  84439. * Multiplies the rgb values by scale and stores the result into "result"
  84440. * @param scale defines the scaling factor
  84441. * @param result defines the Color3 object where to store the result
  84442. * @returns the unmodified current Color3
  84443. */
  84444. scaleToRef(scale: number, result: Color3): Color3;
  84445. /**
  84446. * Scale the current Color3 values by a factor and add the result to a given Color3
  84447. * @param scale defines the scale factor
  84448. * @param result defines color to store the result into
  84449. * @returns the unmodified current Color3
  84450. */
  84451. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84452. /**
  84453. * Clamps the rgb values by the min and max values and stores the result into "result"
  84454. * @param min defines minimum clamping value (default is 0)
  84455. * @param max defines maximum clamping value (default is 1)
  84456. * @param result defines color to store the result into
  84457. * @returns the original Color3
  84458. */
  84459. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84460. /**
  84461. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84462. * @param otherColor defines the second operand
  84463. * @returns the new Color3
  84464. */
  84465. add(otherColor: DeepImmutable<Color3>): Color3;
  84466. /**
  84467. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84468. * @param otherColor defines the second operand
  84469. * @param result defines Color3 object to store the result into
  84470. * @returns the unmodified current Color3
  84471. */
  84472. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84473. /**
  84474. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84475. * @param otherColor defines the second operand
  84476. * @returns the new Color3
  84477. */
  84478. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84479. /**
  84480. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84481. * @param otherColor defines the second operand
  84482. * @param result defines Color3 object to store the result into
  84483. * @returns the unmodified current Color3
  84484. */
  84485. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84486. /**
  84487. * Copy the current object
  84488. * @returns a new Color3 copied the current one
  84489. */
  84490. clone(): Color3;
  84491. /**
  84492. * Copies the rgb values from the source in the current Color3
  84493. * @param source defines the source Color3 object
  84494. * @returns the updated Color3 object
  84495. */
  84496. copyFrom(source: DeepImmutable<Color3>): Color3;
  84497. /**
  84498. * Updates the Color3 rgb values from the given floats
  84499. * @param r defines the red component to read from
  84500. * @param g defines the green component to read from
  84501. * @param b defines the blue component to read from
  84502. * @returns the current Color3 object
  84503. */
  84504. copyFromFloats(r: number, g: number, b: number): Color3;
  84505. /**
  84506. * Updates the Color3 rgb values from the given floats
  84507. * @param r defines the red component to read from
  84508. * @param g defines the green component to read from
  84509. * @param b defines the blue component to read from
  84510. * @returns the current Color3 object
  84511. */
  84512. set(r: number, g: number, b: number): Color3;
  84513. /**
  84514. * Compute the Color3 hexadecimal code as a string
  84515. * @returns a string containing the hexadecimal representation of the Color3 object
  84516. */
  84517. toHexString(): string;
  84518. /**
  84519. * Computes a new Color3 converted from the current one to linear space
  84520. * @returns a new Color3 object
  84521. */
  84522. toLinearSpace(): Color3;
  84523. /**
  84524. * Converts current color in rgb space to HSV values
  84525. * @returns a new color3 representing the HSV values
  84526. */
  84527. toHSV(): Color3;
  84528. /**
  84529. * Converts current color in rgb space to HSV values
  84530. * @param result defines the Color3 where to store the HSV values
  84531. */
  84532. toHSVToRef(result: Color3): void;
  84533. /**
  84534. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84535. * @param convertedColor defines the Color3 object where to store the linear space version
  84536. * @returns the unmodified Color3
  84537. */
  84538. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84539. /**
  84540. * Computes a new Color3 converted from the current one to gamma space
  84541. * @returns a new Color3 object
  84542. */
  84543. toGammaSpace(): Color3;
  84544. /**
  84545. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84546. * @param convertedColor defines the Color3 object where to store the gamma space version
  84547. * @returns the unmodified Color3
  84548. */
  84549. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84550. private static _BlackReadOnly;
  84551. /**
  84552. * Convert Hue, saturation and value to a Color3 (RGB)
  84553. * @param hue defines the hue
  84554. * @param saturation defines the saturation
  84555. * @param value defines the value
  84556. * @param result defines the Color3 where to store the RGB values
  84557. */
  84558. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84559. /**
  84560. * Creates a new Color3 from the string containing valid hexadecimal values
  84561. * @param hex defines a string containing valid hexadecimal values
  84562. * @returns a new Color3 object
  84563. */
  84564. static FromHexString(hex: string): Color3;
  84565. /**
  84566. * Creates a new Color3 from the starting index of the given array
  84567. * @param array defines the source array
  84568. * @param offset defines an offset in the source array
  84569. * @returns a new Color3 object
  84570. */
  84571. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84572. /**
  84573. * Creates a new Color3 from the starting index element of the given array
  84574. * @param array defines the source array to read from
  84575. * @param offset defines the offset in the source array
  84576. * @param result defines the target Color3 object
  84577. */
  84578. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  84579. /**
  84580. * Creates a new Color3 from integer values (< 256)
  84581. * @param r defines the red component to read from (value between 0 and 255)
  84582. * @param g defines the green component to read from (value between 0 and 255)
  84583. * @param b defines the blue component to read from (value between 0 and 255)
  84584. * @returns a new Color3 object
  84585. */
  84586. static FromInts(r: number, g: number, b: number): Color3;
  84587. /**
  84588. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84589. * @param start defines the start Color3 value
  84590. * @param end defines the end Color3 value
  84591. * @param amount defines the gradient value between start and end
  84592. * @returns a new Color3 object
  84593. */
  84594. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84595. /**
  84596. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84597. * @param left defines the start value
  84598. * @param right defines the end value
  84599. * @param amount defines the gradient factor
  84600. * @param result defines the Color3 object where to store the result
  84601. */
  84602. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84603. /**
  84604. * Returns a Color3 value containing a red color
  84605. * @returns a new Color3 object
  84606. */
  84607. static Red(): Color3;
  84608. /**
  84609. * Returns a Color3 value containing a green color
  84610. * @returns a new Color3 object
  84611. */
  84612. static Green(): Color3;
  84613. /**
  84614. * Returns a Color3 value containing a blue color
  84615. * @returns a new Color3 object
  84616. */
  84617. static Blue(): Color3;
  84618. /**
  84619. * Returns a Color3 value containing a black color
  84620. * @returns a new Color3 object
  84621. */
  84622. static Black(): Color3;
  84623. /**
  84624. * Gets a Color3 value containing a black color that must not be updated
  84625. */
  84626. static get BlackReadOnly(): DeepImmutable<Color3>;
  84627. /**
  84628. * Returns a Color3 value containing a white color
  84629. * @returns a new Color3 object
  84630. */
  84631. static White(): Color3;
  84632. /**
  84633. * Returns a Color3 value containing a purple color
  84634. * @returns a new Color3 object
  84635. */
  84636. static Purple(): Color3;
  84637. /**
  84638. * Returns a Color3 value containing a magenta color
  84639. * @returns a new Color3 object
  84640. */
  84641. static Magenta(): Color3;
  84642. /**
  84643. * Returns a Color3 value containing a yellow color
  84644. * @returns a new Color3 object
  84645. */
  84646. static Yellow(): Color3;
  84647. /**
  84648. * Returns a Color3 value containing a gray color
  84649. * @returns a new Color3 object
  84650. */
  84651. static Gray(): Color3;
  84652. /**
  84653. * Returns a Color3 value containing a teal color
  84654. * @returns a new Color3 object
  84655. */
  84656. static Teal(): Color3;
  84657. /**
  84658. * Returns a Color3 value containing a random color
  84659. * @returns a new Color3 object
  84660. */
  84661. static Random(): Color3;
  84662. }
  84663. /**
  84664. * Class used to hold a RBGA color
  84665. */
  84666. export class Color4 {
  84667. /**
  84668. * Defines the red component (between 0 and 1, default is 0)
  84669. */
  84670. r: number;
  84671. /**
  84672. * Defines the green component (between 0 and 1, default is 0)
  84673. */
  84674. g: number;
  84675. /**
  84676. * Defines the blue component (between 0 and 1, default is 0)
  84677. */
  84678. b: number;
  84679. /**
  84680. * Defines the alpha component (between 0 and 1, default is 1)
  84681. */
  84682. a: number;
  84683. /**
  84684. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84685. * @param r defines the red component (between 0 and 1, default is 0)
  84686. * @param g defines the green component (between 0 and 1, default is 0)
  84687. * @param b defines the blue component (between 0 and 1, default is 0)
  84688. * @param a defines the alpha component (between 0 and 1, default is 1)
  84689. */
  84690. constructor(
  84691. /**
  84692. * Defines the red component (between 0 and 1, default is 0)
  84693. */
  84694. r?: number,
  84695. /**
  84696. * Defines the green component (between 0 and 1, default is 0)
  84697. */
  84698. g?: number,
  84699. /**
  84700. * Defines the blue component (between 0 and 1, default is 0)
  84701. */
  84702. b?: number,
  84703. /**
  84704. * Defines the alpha component (between 0 and 1, default is 1)
  84705. */
  84706. a?: number);
  84707. /**
  84708. * Adds in place the given Color4 values to the current Color4 object
  84709. * @param right defines the second operand
  84710. * @returns the current updated Color4 object
  84711. */
  84712. addInPlace(right: DeepImmutable<Color4>): Color4;
  84713. /**
  84714. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84715. * @returns the new array
  84716. */
  84717. asArray(): number[];
  84718. /**
  84719. * Stores from the starting index in the given array the Color4 successive values
  84720. * @param array defines the array where to store the r,g,b components
  84721. * @param index defines an optional index in the target array to define where to start storing values
  84722. * @returns the current Color4 object
  84723. */
  84724. toArray(array: number[], index?: number): Color4;
  84725. /**
  84726. * Update the current color with values stored in an array from the starting index of the given array
  84727. * @param array defines the source array
  84728. * @param offset defines an offset in the source array
  84729. * @returns the current Color4 object
  84730. */
  84731. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84732. /**
  84733. * Determines equality between Color4 objects
  84734. * @param otherColor defines the second operand
  84735. * @returns true if the rgba values are equal to the given ones
  84736. */
  84737. equals(otherColor: DeepImmutable<Color4>): boolean;
  84738. /**
  84739. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84740. * @param right defines the second operand
  84741. * @returns a new Color4 object
  84742. */
  84743. add(right: DeepImmutable<Color4>): Color4;
  84744. /**
  84745. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84746. * @param right defines the second operand
  84747. * @returns a new Color4 object
  84748. */
  84749. subtract(right: DeepImmutable<Color4>): Color4;
  84750. /**
  84751. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84752. * @param right defines the second operand
  84753. * @param result defines the Color4 object where to store the result
  84754. * @returns the current Color4 object
  84755. */
  84756. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84757. /**
  84758. * Creates a new Color4 with the current Color4 values multiplied by scale
  84759. * @param scale defines the scaling factor to apply
  84760. * @returns a new Color4 object
  84761. */
  84762. scale(scale: number): Color4;
  84763. /**
  84764. * Multiplies the current Color4 values by scale and stores the result in "result"
  84765. * @param scale defines the scaling factor to apply
  84766. * @param result defines the Color4 object where to store the result
  84767. * @returns the current unmodified Color4
  84768. */
  84769. scaleToRef(scale: number, result: Color4): Color4;
  84770. /**
  84771. * Scale the current Color4 values by a factor and add the result to a given Color4
  84772. * @param scale defines the scale factor
  84773. * @param result defines the Color4 object where to store the result
  84774. * @returns the unmodified current Color4
  84775. */
  84776. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84777. /**
  84778. * Clamps the rgb values by the min and max values and stores the result into "result"
  84779. * @param min defines minimum clamping value (default is 0)
  84780. * @param max defines maximum clamping value (default is 1)
  84781. * @param result defines color to store the result into.
  84782. * @returns the cuurent Color4
  84783. */
  84784. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84785. /**
  84786. * Multipy an Color4 value by another and return a new Color4 object
  84787. * @param color defines the Color4 value to multiply by
  84788. * @returns a new Color4 object
  84789. */
  84790. multiply(color: Color4): Color4;
  84791. /**
  84792. * Multipy a Color4 value by another and push the result in a reference value
  84793. * @param color defines the Color4 value to multiply by
  84794. * @param result defines the Color4 to fill the result in
  84795. * @returns the result Color4
  84796. */
  84797. multiplyToRef(color: Color4, result: Color4): Color4;
  84798. /**
  84799. * Creates a string with the Color4 current values
  84800. * @returns the string representation of the Color4 object
  84801. */
  84802. toString(): string;
  84803. /**
  84804. * Returns the string "Color4"
  84805. * @returns "Color4"
  84806. */
  84807. getClassName(): string;
  84808. /**
  84809. * Compute the Color4 hash code
  84810. * @returns an unique number that can be used to hash Color4 objects
  84811. */
  84812. getHashCode(): number;
  84813. /**
  84814. * Creates a new Color4 copied from the current one
  84815. * @returns a new Color4 object
  84816. */
  84817. clone(): Color4;
  84818. /**
  84819. * Copies the given Color4 values into the current one
  84820. * @param source defines the source Color4 object
  84821. * @returns the current updated Color4 object
  84822. */
  84823. copyFrom(source: Color4): Color4;
  84824. /**
  84825. * Copies the given float values into the current one
  84826. * @param r defines the red component to read from
  84827. * @param g defines the green component to read from
  84828. * @param b defines the blue component to read from
  84829. * @param a defines the alpha component to read from
  84830. * @returns the current updated Color4 object
  84831. */
  84832. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84833. /**
  84834. * Copies the given float values into the current one
  84835. * @param r defines the red component to read from
  84836. * @param g defines the green component to read from
  84837. * @param b defines the blue component to read from
  84838. * @param a defines the alpha component to read from
  84839. * @returns the current updated Color4 object
  84840. */
  84841. set(r: number, g: number, b: number, a: number): Color4;
  84842. /**
  84843. * Compute the Color4 hexadecimal code as a string
  84844. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84845. * @returns a string containing the hexadecimal representation of the Color4 object
  84846. */
  84847. toHexString(returnAsColor3?: boolean): string;
  84848. /**
  84849. * Computes a new Color4 converted from the current one to linear space
  84850. * @returns a new Color4 object
  84851. */
  84852. toLinearSpace(): Color4;
  84853. /**
  84854. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84855. * @param convertedColor defines the Color4 object where to store the linear space version
  84856. * @returns the unmodified Color4
  84857. */
  84858. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84859. /**
  84860. * Computes a new Color4 converted from the current one to gamma space
  84861. * @returns a new Color4 object
  84862. */
  84863. toGammaSpace(): Color4;
  84864. /**
  84865. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84866. * @param convertedColor defines the Color4 object where to store the gamma space version
  84867. * @returns the unmodified Color4
  84868. */
  84869. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84870. /**
  84871. * Creates a new Color4 from the string containing valid hexadecimal values
  84872. * @param hex defines a string containing valid hexadecimal values
  84873. * @returns a new Color4 object
  84874. */
  84875. static FromHexString(hex: string): Color4;
  84876. /**
  84877. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84878. * @param left defines the start value
  84879. * @param right defines the end value
  84880. * @param amount defines the gradient factor
  84881. * @returns a new Color4 object
  84882. */
  84883. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84884. /**
  84885. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84886. * @param left defines the start value
  84887. * @param right defines the end value
  84888. * @param amount defines the gradient factor
  84889. * @param result defines the Color4 object where to store data
  84890. */
  84891. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84892. /**
  84893. * Creates a new Color4 from a Color3 and an alpha value
  84894. * @param color3 defines the source Color3 to read from
  84895. * @param alpha defines the alpha component (1.0 by default)
  84896. * @returns a new Color4 object
  84897. */
  84898. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84899. /**
  84900. * Creates a new Color4 from the starting index element of the given array
  84901. * @param array defines the source array to read from
  84902. * @param offset defines the offset in the source array
  84903. * @returns a new Color4 object
  84904. */
  84905. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84906. /**
  84907. * Creates a new Color4 from the starting index element of the given array
  84908. * @param array defines the source array to read from
  84909. * @param offset defines the offset in the source array
  84910. * @param result defines the target Color4 object
  84911. */
  84912. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  84913. /**
  84914. * Creates a new Color3 from integer values (< 256)
  84915. * @param r defines the red component to read from (value between 0 and 255)
  84916. * @param g defines the green component to read from (value between 0 and 255)
  84917. * @param b defines the blue component to read from (value between 0 and 255)
  84918. * @param a defines the alpha component to read from (value between 0 and 255)
  84919. * @returns a new Color3 object
  84920. */
  84921. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84922. /**
  84923. * Check the content of a given array and convert it to an array containing RGBA data
  84924. * If the original array was already containing count * 4 values then it is returned directly
  84925. * @param colors defines the array to check
  84926. * @param count defines the number of RGBA data to expect
  84927. * @returns an array containing count * 4 values (RGBA)
  84928. */
  84929. static CheckColors4(colors: number[], count: number): number[];
  84930. }
  84931. /**
  84932. * @hidden
  84933. */
  84934. export class TmpColors {
  84935. static Color3: Color3[];
  84936. static Color4: Color4[];
  84937. }
  84938. }
  84939. declare module BABYLON {
  84940. /**
  84941. * Defines an interface which represents an animation key frame
  84942. */
  84943. export interface IAnimationKey {
  84944. /**
  84945. * Frame of the key frame
  84946. */
  84947. frame: number;
  84948. /**
  84949. * Value at the specifies key frame
  84950. */
  84951. value: any;
  84952. /**
  84953. * The input tangent for the cubic hermite spline
  84954. */
  84955. inTangent?: any;
  84956. /**
  84957. * The output tangent for the cubic hermite spline
  84958. */
  84959. outTangent?: any;
  84960. /**
  84961. * The animation interpolation type
  84962. */
  84963. interpolation?: AnimationKeyInterpolation;
  84964. }
  84965. /**
  84966. * Enum for the animation key frame interpolation type
  84967. */
  84968. export enum AnimationKeyInterpolation {
  84969. /**
  84970. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84971. */
  84972. STEP = 1
  84973. }
  84974. }
  84975. declare module BABYLON {
  84976. /**
  84977. * Represents the range of an animation
  84978. */
  84979. export class AnimationRange {
  84980. /**The name of the animation range**/
  84981. name: string;
  84982. /**The starting frame of the animation */
  84983. from: number;
  84984. /**The ending frame of the animation*/
  84985. to: number;
  84986. /**
  84987. * Initializes the range of an animation
  84988. * @param name The name of the animation range
  84989. * @param from The starting frame of the animation
  84990. * @param to The ending frame of the animation
  84991. */
  84992. constructor(
  84993. /**The name of the animation range**/
  84994. name: string,
  84995. /**The starting frame of the animation */
  84996. from: number,
  84997. /**The ending frame of the animation*/
  84998. to: number);
  84999. /**
  85000. * Makes a copy of the animation range
  85001. * @returns A copy of the animation range
  85002. */
  85003. clone(): AnimationRange;
  85004. }
  85005. }
  85006. declare module BABYLON {
  85007. /**
  85008. * Composed of a frame, and an action function
  85009. */
  85010. export class AnimationEvent {
  85011. /** The frame for which the event is triggered **/
  85012. frame: number;
  85013. /** The event to perform when triggered **/
  85014. action: (currentFrame: number) => void;
  85015. /** Specifies if the event should be triggered only once**/
  85016. onlyOnce?: boolean | undefined;
  85017. /**
  85018. * Specifies if the animation event is done
  85019. */
  85020. isDone: boolean;
  85021. /**
  85022. * Initializes the animation event
  85023. * @param frame The frame for which the event is triggered
  85024. * @param action The event to perform when triggered
  85025. * @param onlyOnce Specifies if the event should be triggered only once
  85026. */
  85027. constructor(
  85028. /** The frame for which the event is triggered **/
  85029. frame: number,
  85030. /** The event to perform when triggered **/
  85031. action: (currentFrame: number) => void,
  85032. /** Specifies if the event should be triggered only once**/
  85033. onlyOnce?: boolean | undefined);
  85034. /** @hidden */
  85035. _clone(): AnimationEvent;
  85036. }
  85037. }
  85038. declare module BABYLON {
  85039. /**
  85040. * Interface used to define a behavior
  85041. */
  85042. export interface Behavior<T> {
  85043. /** gets or sets behavior's name */
  85044. name: string;
  85045. /**
  85046. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85047. */
  85048. init(): void;
  85049. /**
  85050. * Called when the behavior is attached to a target
  85051. * @param target defines the target where the behavior is attached to
  85052. */
  85053. attach(target: T): void;
  85054. /**
  85055. * Called when the behavior is detached from its target
  85056. */
  85057. detach(): void;
  85058. }
  85059. /**
  85060. * Interface implemented by classes supporting behaviors
  85061. */
  85062. export interface IBehaviorAware<T> {
  85063. /**
  85064. * Attach a behavior
  85065. * @param behavior defines the behavior to attach
  85066. * @returns the current host
  85067. */
  85068. addBehavior(behavior: Behavior<T>): T;
  85069. /**
  85070. * Remove a behavior from the current object
  85071. * @param behavior defines the behavior to detach
  85072. * @returns the current host
  85073. */
  85074. removeBehavior(behavior: Behavior<T>): T;
  85075. /**
  85076. * Gets a behavior using its name to search
  85077. * @param name defines the name to search
  85078. * @returns the behavior or null if not found
  85079. */
  85080. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85081. }
  85082. }
  85083. declare module BABYLON {
  85084. /**
  85085. * Defines an array and its length.
  85086. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85087. */
  85088. export interface ISmartArrayLike<T> {
  85089. /**
  85090. * The data of the array.
  85091. */
  85092. data: Array<T>;
  85093. /**
  85094. * The active length of the array.
  85095. */
  85096. length: number;
  85097. }
  85098. /**
  85099. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85100. */
  85101. export class SmartArray<T> implements ISmartArrayLike<T> {
  85102. /**
  85103. * The full set of data from the array.
  85104. */
  85105. data: Array<T>;
  85106. /**
  85107. * The active length of the array.
  85108. */
  85109. length: number;
  85110. protected _id: number;
  85111. /**
  85112. * Instantiates a Smart Array.
  85113. * @param capacity defines the default capacity of the array.
  85114. */
  85115. constructor(capacity: number);
  85116. /**
  85117. * Pushes a value at the end of the active data.
  85118. * @param value defines the object to push in the array.
  85119. */
  85120. push(value: T): void;
  85121. /**
  85122. * Iterates over the active data and apply the lambda to them.
  85123. * @param func defines the action to apply on each value.
  85124. */
  85125. forEach(func: (content: T) => void): void;
  85126. /**
  85127. * Sorts the full sets of data.
  85128. * @param compareFn defines the comparison function to apply.
  85129. */
  85130. sort(compareFn: (a: T, b: T) => number): void;
  85131. /**
  85132. * Resets the active data to an empty array.
  85133. */
  85134. reset(): void;
  85135. /**
  85136. * Releases all the data from the array as well as the array.
  85137. */
  85138. dispose(): void;
  85139. /**
  85140. * Concats the active data with a given array.
  85141. * @param array defines the data to concatenate with.
  85142. */
  85143. concat(array: any): void;
  85144. /**
  85145. * Returns the position of a value in the active data.
  85146. * @param value defines the value to find the index for
  85147. * @returns the index if found in the active data otherwise -1
  85148. */
  85149. indexOf(value: T): number;
  85150. /**
  85151. * Returns whether an element is part of the active data.
  85152. * @param value defines the value to look for
  85153. * @returns true if found in the active data otherwise false
  85154. */
  85155. contains(value: T): boolean;
  85156. private static _GlobalId;
  85157. }
  85158. /**
  85159. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85160. * The data in this array can only be present once
  85161. */
  85162. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85163. private _duplicateId;
  85164. /**
  85165. * Pushes a value at the end of the active data.
  85166. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85167. * @param value defines the object to push in the array.
  85168. */
  85169. push(value: T): void;
  85170. /**
  85171. * Pushes a value at the end of the active data.
  85172. * If the data is already present, it won t be added again
  85173. * @param value defines the object to push in the array.
  85174. * @returns true if added false if it was already present
  85175. */
  85176. pushNoDuplicate(value: T): boolean;
  85177. /**
  85178. * Resets the active data to an empty array.
  85179. */
  85180. reset(): void;
  85181. /**
  85182. * Concats the active data with a given array.
  85183. * This ensures no dupplicate will be present in the result.
  85184. * @param array defines the data to concatenate with.
  85185. */
  85186. concatWithNoDuplicate(array: any): void;
  85187. }
  85188. }
  85189. declare module BABYLON {
  85190. /**
  85191. * @ignore
  85192. * This is a list of all the different input types that are available in the application.
  85193. * Fo instance: ArcRotateCameraGamepadInput...
  85194. */
  85195. export var CameraInputTypes: {};
  85196. /**
  85197. * This is the contract to implement in order to create a new input class.
  85198. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85199. */
  85200. export interface ICameraInput<TCamera extends Camera> {
  85201. /**
  85202. * Defines the camera the input is attached to.
  85203. */
  85204. camera: Nullable<TCamera>;
  85205. /**
  85206. * Gets the class name of the current intput.
  85207. * @returns the class name
  85208. */
  85209. getClassName(): string;
  85210. /**
  85211. * Get the friendly name associated with the input class.
  85212. * @returns the input friendly name
  85213. */
  85214. getSimpleName(): string;
  85215. /**
  85216. * Attach the input controls to a specific dom element to get the input from.
  85217. * @param element Defines the element the controls should be listened from
  85218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85219. */
  85220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85221. /**
  85222. * Detach the current controls from the specified dom element.
  85223. * @param element Defines the element to stop listening the inputs from
  85224. */
  85225. detachControl(element: Nullable<HTMLElement>): void;
  85226. /**
  85227. * Update the current camera state depending on the inputs that have been used this frame.
  85228. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85229. */
  85230. checkInputs?: () => void;
  85231. }
  85232. /**
  85233. * Represents a map of input types to input instance or input index to input instance.
  85234. */
  85235. export interface CameraInputsMap<TCamera extends Camera> {
  85236. /**
  85237. * Accessor to the input by input type.
  85238. */
  85239. [name: string]: ICameraInput<TCamera>;
  85240. /**
  85241. * Accessor to the input by input index.
  85242. */
  85243. [idx: number]: ICameraInput<TCamera>;
  85244. }
  85245. /**
  85246. * This represents the input manager used within a camera.
  85247. * It helps dealing with all the different kind of input attached to a camera.
  85248. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85249. */
  85250. export class CameraInputsManager<TCamera extends Camera> {
  85251. /**
  85252. * Defines the list of inputs attahed to the camera.
  85253. */
  85254. attached: CameraInputsMap<TCamera>;
  85255. /**
  85256. * Defines the dom element the camera is collecting inputs from.
  85257. * This is null if the controls have not been attached.
  85258. */
  85259. attachedElement: Nullable<HTMLElement>;
  85260. /**
  85261. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85262. */
  85263. noPreventDefault: boolean;
  85264. /**
  85265. * Defined the camera the input manager belongs to.
  85266. */
  85267. camera: TCamera;
  85268. /**
  85269. * Update the current camera state depending on the inputs that have been used this frame.
  85270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85271. */
  85272. checkInputs: () => void;
  85273. /**
  85274. * Instantiate a new Camera Input Manager.
  85275. * @param camera Defines the camera the input manager blongs to
  85276. */
  85277. constructor(camera: TCamera);
  85278. /**
  85279. * Add an input method to a camera
  85280. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85281. * @param input camera input method
  85282. */
  85283. add(input: ICameraInput<TCamera>): void;
  85284. /**
  85285. * Remove a specific input method from a camera
  85286. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85287. * @param inputToRemove camera input method
  85288. */
  85289. remove(inputToRemove: ICameraInput<TCamera>): void;
  85290. /**
  85291. * Remove a specific input type from a camera
  85292. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85293. * @param inputType the type of the input to remove
  85294. */
  85295. removeByType(inputType: string): void;
  85296. private _addCheckInputs;
  85297. /**
  85298. * Attach the input controls to the currently attached dom element to listen the events from.
  85299. * @param input Defines the input to attach
  85300. */
  85301. attachInput(input: ICameraInput<TCamera>): void;
  85302. /**
  85303. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85304. * @param element Defines the dom element to collect the events from
  85305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85306. */
  85307. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85308. /**
  85309. * Detach the current manager inputs controls from a specific dom element.
  85310. * @param element Defines the dom element to collect the events from
  85311. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85312. */
  85313. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85314. /**
  85315. * Rebuild the dynamic inputCheck function from the current list of
  85316. * defined inputs in the manager.
  85317. */
  85318. rebuildInputCheck(): void;
  85319. /**
  85320. * Remove all attached input methods from a camera
  85321. */
  85322. clear(): void;
  85323. /**
  85324. * Serialize the current input manager attached to a camera.
  85325. * This ensures than once parsed,
  85326. * the input associated to the camera will be identical to the current ones
  85327. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85328. */
  85329. serialize(serializedCamera: any): void;
  85330. /**
  85331. * Parses an input manager serialized JSON to restore the previous list of inputs
  85332. * and states associated to a camera.
  85333. * @param parsedCamera Defines the JSON to parse
  85334. */
  85335. parse(parsedCamera: any): void;
  85336. }
  85337. }
  85338. declare module BABYLON {
  85339. /**
  85340. * Class used to store data that will be store in GPU memory
  85341. */
  85342. export class Buffer {
  85343. private _engine;
  85344. private _buffer;
  85345. /** @hidden */
  85346. _data: Nullable<DataArray>;
  85347. private _updatable;
  85348. private _instanced;
  85349. private _divisor;
  85350. /**
  85351. * Gets the byte stride.
  85352. */
  85353. readonly byteStride: number;
  85354. /**
  85355. * Constructor
  85356. * @param engine the engine
  85357. * @param data the data to use for this buffer
  85358. * @param updatable whether the data is updatable
  85359. * @param stride the stride (optional)
  85360. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85361. * @param instanced whether the buffer is instanced (optional)
  85362. * @param useBytes set to true if the stride in in bytes (optional)
  85363. * @param divisor sets an optional divisor for instances (1 by default)
  85364. */
  85365. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85366. /**
  85367. * Create a new VertexBuffer based on the current buffer
  85368. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85369. * @param offset defines offset in the buffer (0 by default)
  85370. * @param size defines the size in floats of attributes (position is 3 for instance)
  85371. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85372. * @param instanced defines if the vertex buffer contains indexed data
  85373. * @param useBytes defines if the offset and stride are in bytes *
  85374. * @param divisor sets an optional divisor for instances (1 by default)
  85375. * @returns the new vertex buffer
  85376. */
  85377. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85378. /**
  85379. * Gets a boolean indicating if the Buffer is updatable?
  85380. * @returns true if the buffer is updatable
  85381. */
  85382. isUpdatable(): boolean;
  85383. /**
  85384. * Gets current buffer's data
  85385. * @returns a DataArray or null
  85386. */
  85387. getData(): Nullable<DataArray>;
  85388. /**
  85389. * Gets underlying native buffer
  85390. * @returns underlying native buffer
  85391. */
  85392. getBuffer(): Nullable<DataBuffer>;
  85393. /**
  85394. * Gets the stride in float32 units (i.e. byte stride / 4).
  85395. * May not be an integer if the byte stride is not divisible by 4.
  85396. * @returns the stride in float32 units
  85397. * @deprecated Please use byteStride instead.
  85398. */
  85399. getStrideSize(): number;
  85400. /**
  85401. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85402. * @param data defines the data to store
  85403. */
  85404. create(data?: Nullable<DataArray>): void;
  85405. /** @hidden */
  85406. _rebuild(): void;
  85407. /**
  85408. * Update current buffer data
  85409. * @param data defines the data to store
  85410. */
  85411. update(data: DataArray): void;
  85412. /**
  85413. * Updates the data directly.
  85414. * @param data the new data
  85415. * @param offset the new offset
  85416. * @param vertexCount the vertex count (optional)
  85417. * @param useBytes set to true if the offset is in bytes
  85418. */
  85419. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85420. /**
  85421. * Release all resources
  85422. */
  85423. dispose(): void;
  85424. }
  85425. /**
  85426. * Specialized buffer used to store vertex data
  85427. */
  85428. export class VertexBuffer {
  85429. /** @hidden */
  85430. _buffer: Buffer;
  85431. private _kind;
  85432. private _size;
  85433. private _ownsBuffer;
  85434. private _instanced;
  85435. private _instanceDivisor;
  85436. /**
  85437. * The byte type.
  85438. */
  85439. static readonly BYTE: number;
  85440. /**
  85441. * The unsigned byte type.
  85442. */
  85443. static readonly UNSIGNED_BYTE: number;
  85444. /**
  85445. * The short type.
  85446. */
  85447. static readonly SHORT: number;
  85448. /**
  85449. * The unsigned short type.
  85450. */
  85451. static readonly UNSIGNED_SHORT: number;
  85452. /**
  85453. * The integer type.
  85454. */
  85455. static readonly INT: number;
  85456. /**
  85457. * The unsigned integer type.
  85458. */
  85459. static readonly UNSIGNED_INT: number;
  85460. /**
  85461. * The float type.
  85462. */
  85463. static readonly FLOAT: number;
  85464. /**
  85465. * Gets or sets the instance divisor when in instanced mode
  85466. */
  85467. get instanceDivisor(): number;
  85468. set instanceDivisor(value: number);
  85469. /**
  85470. * Gets the byte stride.
  85471. */
  85472. readonly byteStride: number;
  85473. /**
  85474. * Gets the byte offset.
  85475. */
  85476. readonly byteOffset: number;
  85477. /**
  85478. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85479. */
  85480. readonly normalized: boolean;
  85481. /**
  85482. * Gets the data type of each component in the array.
  85483. */
  85484. readonly type: number;
  85485. /**
  85486. * Constructor
  85487. * @param engine the engine
  85488. * @param data the data to use for this vertex buffer
  85489. * @param kind the vertex buffer kind
  85490. * @param updatable whether the data is updatable
  85491. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85492. * @param stride the stride (optional)
  85493. * @param instanced whether the buffer is instanced (optional)
  85494. * @param offset the offset of the data (optional)
  85495. * @param size the number of components (optional)
  85496. * @param type the type of the component (optional)
  85497. * @param normalized whether the data contains normalized data (optional)
  85498. * @param useBytes set to true if stride and offset are in bytes (optional)
  85499. * @param divisor defines the instance divisor to use (1 by default)
  85500. */
  85501. 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);
  85502. /** @hidden */
  85503. _rebuild(): void;
  85504. /**
  85505. * Returns the kind of the VertexBuffer (string)
  85506. * @returns a string
  85507. */
  85508. getKind(): string;
  85509. /**
  85510. * Gets a boolean indicating if the VertexBuffer is updatable?
  85511. * @returns true if the buffer is updatable
  85512. */
  85513. isUpdatable(): boolean;
  85514. /**
  85515. * Gets current buffer's data
  85516. * @returns a DataArray or null
  85517. */
  85518. getData(): Nullable<DataArray>;
  85519. /**
  85520. * Gets underlying native buffer
  85521. * @returns underlying native buffer
  85522. */
  85523. getBuffer(): Nullable<DataBuffer>;
  85524. /**
  85525. * Gets the stride in float32 units (i.e. byte stride / 4).
  85526. * May not be an integer if the byte stride is not divisible by 4.
  85527. * @returns the stride in float32 units
  85528. * @deprecated Please use byteStride instead.
  85529. */
  85530. getStrideSize(): number;
  85531. /**
  85532. * Returns the offset as a multiple of the type byte length.
  85533. * @returns the offset in bytes
  85534. * @deprecated Please use byteOffset instead.
  85535. */
  85536. getOffset(): number;
  85537. /**
  85538. * Returns the number of components per vertex attribute (integer)
  85539. * @returns the size in float
  85540. */
  85541. getSize(): number;
  85542. /**
  85543. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85544. * @returns true if this buffer is instanced
  85545. */
  85546. getIsInstanced(): boolean;
  85547. /**
  85548. * Returns the instancing divisor, zero for non-instanced (integer).
  85549. * @returns a number
  85550. */
  85551. getInstanceDivisor(): number;
  85552. /**
  85553. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85554. * @param data defines the data to store
  85555. */
  85556. create(data?: DataArray): void;
  85557. /**
  85558. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85559. * This function will create a new buffer if the current one is not updatable
  85560. * @param data defines the data to store
  85561. */
  85562. update(data: DataArray): void;
  85563. /**
  85564. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85565. * Returns the directly updated WebGLBuffer.
  85566. * @param data the new data
  85567. * @param offset the new offset
  85568. * @param useBytes set to true if the offset is in bytes
  85569. */
  85570. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85571. /**
  85572. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85573. */
  85574. dispose(): void;
  85575. /**
  85576. * Enumerates each value of this vertex buffer as numbers.
  85577. * @param count the number of values to enumerate
  85578. * @param callback the callback function called for each value
  85579. */
  85580. forEach(count: number, callback: (value: number, index: number) => void): void;
  85581. /**
  85582. * Positions
  85583. */
  85584. static readonly PositionKind: string;
  85585. /**
  85586. * Normals
  85587. */
  85588. static readonly NormalKind: string;
  85589. /**
  85590. * Tangents
  85591. */
  85592. static readonly TangentKind: string;
  85593. /**
  85594. * Texture coordinates
  85595. */
  85596. static readonly UVKind: string;
  85597. /**
  85598. * Texture coordinates 2
  85599. */
  85600. static readonly UV2Kind: string;
  85601. /**
  85602. * Texture coordinates 3
  85603. */
  85604. static readonly UV3Kind: string;
  85605. /**
  85606. * Texture coordinates 4
  85607. */
  85608. static readonly UV4Kind: string;
  85609. /**
  85610. * Texture coordinates 5
  85611. */
  85612. static readonly UV5Kind: string;
  85613. /**
  85614. * Texture coordinates 6
  85615. */
  85616. static readonly UV6Kind: string;
  85617. /**
  85618. * Colors
  85619. */
  85620. static readonly ColorKind: string;
  85621. /**
  85622. * Matrix indices (for bones)
  85623. */
  85624. static readonly MatricesIndicesKind: string;
  85625. /**
  85626. * Matrix weights (for bones)
  85627. */
  85628. static readonly MatricesWeightsKind: string;
  85629. /**
  85630. * Additional matrix indices (for bones)
  85631. */
  85632. static readonly MatricesIndicesExtraKind: string;
  85633. /**
  85634. * Additional matrix weights (for bones)
  85635. */
  85636. static readonly MatricesWeightsExtraKind: string;
  85637. /**
  85638. * Deduces the stride given a kind.
  85639. * @param kind The kind string to deduce
  85640. * @returns The deduced stride
  85641. */
  85642. static DeduceStride(kind: string): number;
  85643. /**
  85644. * Gets the byte length of the given type.
  85645. * @param type the type
  85646. * @returns the number of bytes
  85647. */
  85648. static GetTypeByteLength(type: number): number;
  85649. /**
  85650. * Enumerates each value of the given parameters as numbers.
  85651. * @param data the data to enumerate
  85652. * @param byteOffset the byte offset of the data
  85653. * @param byteStride the byte stride of the data
  85654. * @param componentCount the number of components per element
  85655. * @param componentType the type of the component
  85656. * @param count the number of values to enumerate
  85657. * @param normalized whether the data is normalized
  85658. * @param callback the callback function called for each value
  85659. */
  85660. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85661. private static _GetFloatValue;
  85662. }
  85663. }
  85664. declare module BABYLON {
  85665. /**
  85666. * @hidden
  85667. */
  85668. export class IntersectionInfo {
  85669. bu: Nullable<number>;
  85670. bv: Nullable<number>;
  85671. distance: number;
  85672. faceId: number;
  85673. subMeshId: number;
  85674. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85675. }
  85676. }
  85677. declare module BABYLON {
  85678. /**
  85679. * Class used to store bounding sphere information
  85680. */
  85681. export class BoundingSphere {
  85682. /**
  85683. * Gets the center of the bounding sphere in local space
  85684. */
  85685. readonly center: Vector3;
  85686. /**
  85687. * Radius of the bounding sphere in local space
  85688. */
  85689. radius: number;
  85690. /**
  85691. * Gets the center of the bounding sphere in world space
  85692. */
  85693. readonly centerWorld: Vector3;
  85694. /**
  85695. * Radius of the bounding sphere in world space
  85696. */
  85697. radiusWorld: number;
  85698. /**
  85699. * Gets the minimum vector in local space
  85700. */
  85701. readonly minimum: Vector3;
  85702. /**
  85703. * Gets the maximum vector in local space
  85704. */
  85705. readonly maximum: Vector3;
  85706. private _worldMatrix;
  85707. private static readonly TmpVector3;
  85708. /**
  85709. * Creates a new bounding sphere
  85710. * @param min defines the minimum vector (in local space)
  85711. * @param max defines the maximum vector (in local space)
  85712. * @param worldMatrix defines the new world matrix
  85713. */
  85714. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85715. /**
  85716. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85717. * @param min defines the new minimum vector (in local space)
  85718. * @param max defines the new maximum vector (in local space)
  85719. * @param worldMatrix defines the new world matrix
  85720. */
  85721. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85722. /**
  85723. * Scale the current bounding sphere by applying a scale factor
  85724. * @param factor defines the scale factor to apply
  85725. * @returns the current bounding box
  85726. */
  85727. scale(factor: number): BoundingSphere;
  85728. /**
  85729. * Gets the world matrix of the bounding box
  85730. * @returns a matrix
  85731. */
  85732. getWorldMatrix(): DeepImmutable<Matrix>;
  85733. /** @hidden */
  85734. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85735. /**
  85736. * Tests if the bounding sphere is intersecting the frustum planes
  85737. * @param frustumPlanes defines the frustum planes to test
  85738. * @returns true if there is an intersection
  85739. */
  85740. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85741. /**
  85742. * Tests if the bounding sphere center is in between the frustum planes.
  85743. * Used for optimistic fast inclusion.
  85744. * @param frustumPlanes defines the frustum planes to test
  85745. * @returns true if the sphere center is in between the frustum planes
  85746. */
  85747. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85748. /**
  85749. * Tests if a point is inside the bounding sphere
  85750. * @param point defines the point to test
  85751. * @returns true if the point is inside the bounding sphere
  85752. */
  85753. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85754. /**
  85755. * Checks if two sphere intersct
  85756. * @param sphere0 sphere 0
  85757. * @param sphere1 sphere 1
  85758. * @returns true if the speres intersect
  85759. */
  85760. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85761. }
  85762. }
  85763. declare module BABYLON {
  85764. /**
  85765. * Class used to store bounding box information
  85766. */
  85767. export class BoundingBox implements ICullable {
  85768. /**
  85769. * Gets the 8 vectors representing the bounding box in local space
  85770. */
  85771. readonly vectors: Vector3[];
  85772. /**
  85773. * Gets the center of the bounding box in local space
  85774. */
  85775. readonly center: Vector3;
  85776. /**
  85777. * Gets the center of the bounding box in world space
  85778. */
  85779. readonly centerWorld: Vector3;
  85780. /**
  85781. * Gets the extend size in local space
  85782. */
  85783. readonly extendSize: Vector3;
  85784. /**
  85785. * Gets the extend size in world space
  85786. */
  85787. readonly extendSizeWorld: Vector3;
  85788. /**
  85789. * Gets the OBB (object bounding box) directions
  85790. */
  85791. readonly directions: Vector3[];
  85792. /**
  85793. * Gets the 8 vectors representing the bounding box in world space
  85794. */
  85795. readonly vectorsWorld: Vector3[];
  85796. /**
  85797. * Gets the minimum vector in world space
  85798. */
  85799. readonly minimumWorld: Vector3;
  85800. /**
  85801. * Gets the maximum vector in world space
  85802. */
  85803. readonly maximumWorld: Vector3;
  85804. /**
  85805. * Gets the minimum vector in local space
  85806. */
  85807. readonly minimum: Vector3;
  85808. /**
  85809. * Gets the maximum vector in local space
  85810. */
  85811. readonly maximum: Vector3;
  85812. private _worldMatrix;
  85813. private static readonly TmpVector3;
  85814. /**
  85815. * @hidden
  85816. */
  85817. _tag: number;
  85818. /**
  85819. * Creates a new bounding box
  85820. * @param min defines the minimum vector (in local space)
  85821. * @param max defines the maximum vector (in local space)
  85822. * @param worldMatrix defines the new world matrix
  85823. */
  85824. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85825. /**
  85826. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85827. * @param min defines the new minimum vector (in local space)
  85828. * @param max defines the new maximum vector (in local space)
  85829. * @param worldMatrix defines the new world matrix
  85830. */
  85831. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85832. /**
  85833. * Scale the current bounding box by applying a scale factor
  85834. * @param factor defines the scale factor to apply
  85835. * @returns the current bounding box
  85836. */
  85837. scale(factor: number): BoundingBox;
  85838. /**
  85839. * Gets the world matrix of the bounding box
  85840. * @returns a matrix
  85841. */
  85842. getWorldMatrix(): DeepImmutable<Matrix>;
  85843. /** @hidden */
  85844. _update(world: DeepImmutable<Matrix>): void;
  85845. /**
  85846. * Tests if the bounding box is intersecting the frustum planes
  85847. * @param frustumPlanes defines the frustum planes to test
  85848. * @returns true if there is an intersection
  85849. */
  85850. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85851. /**
  85852. * Tests if the bounding box is entirely inside the frustum planes
  85853. * @param frustumPlanes defines the frustum planes to test
  85854. * @returns true if there is an inclusion
  85855. */
  85856. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85857. /**
  85858. * Tests if a point is inside the bounding box
  85859. * @param point defines the point to test
  85860. * @returns true if the point is inside the bounding box
  85861. */
  85862. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85863. /**
  85864. * Tests if the bounding box intersects with a bounding sphere
  85865. * @param sphere defines the sphere to test
  85866. * @returns true if there is an intersection
  85867. */
  85868. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85869. /**
  85870. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85871. * @param min defines the min vector to use
  85872. * @param max defines the max vector to use
  85873. * @returns true if there is an intersection
  85874. */
  85875. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85876. /**
  85877. * Tests if two bounding boxes are intersections
  85878. * @param box0 defines the first box to test
  85879. * @param box1 defines the second box to test
  85880. * @returns true if there is an intersection
  85881. */
  85882. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85883. /**
  85884. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85885. * @param minPoint defines the minimum vector of the bounding box
  85886. * @param maxPoint defines the maximum vector of the bounding box
  85887. * @param sphereCenter defines the sphere center
  85888. * @param sphereRadius defines the sphere radius
  85889. * @returns true if there is an intersection
  85890. */
  85891. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85892. /**
  85893. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85894. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85895. * @param frustumPlanes defines the frustum planes to test
  85896. * @return true if there is an inclusion
  85897. */
  85898. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85899. /**
  85900. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85901. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85902. * @param frustumPlanes defines the frustum planes to test
  85903. * @return true if there is an intersection
  85904. */
  85905. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85906. }
  85907. }
  85908. declare module BABYLON {
  85909. /** @hidden */
  85910. export class Collider {
  85911. /** Define if a collision was found */
  85912. collisionFound: boolean;
  85913. /**
  85914. * Define last intersection point in local space
  85915. */
  85916. intersectionPoint: Vector3;
  85917. /**
  85918. * Define last collided mesh
  85919. */
  85920. collidedMesh: Nullable<AbstractMesh>;
  85921. private _collisionPoint;
  85922. private _planeIntersectionPoint;
  85923. private _tempVector;
  85924. private _tempVector2;
  85925. private _tempVector3;
  85926. private _tempVector4;
  85927. private _edge;
  85928. private _baseToVertex;
  85929. private _destinationPoint;
  85930. private _slidePlaneNormal;
  85931. private _displacementVector;
  85932. /** @hidden */
  85933. _radius: Vector3;
  85934. /** @hidden */
  85935. _retry: number;
  85936. private _velocity;
  85937. private _basePoint;
  85938. private _epsilon;
  85939. /** @hidden */
  85940. _velocityWorldLength: number;
  85941. /** @hidden */
  85942. _basePointWorld: Vector3;
  85943. private _velocityWorld;
  85944. private _normalizedVelocity;
  85945. /** @hidden */
  85946. _initialVelocity: Vector3;
  85947. /** @hidden */
  85948. _initialPosition: Vector3;
  85949. private _nearestDistance;
  85950. private _collisionMask;
  85951. get collisionMask(): number;
  85952. set collisionMask(mask: number);
  85953. /**
  85954. * Gets the plane normal used to compute the sliding response (in local space)
  85955. */
  85956. get slidePlaneNormal(): Vector3;
  85957. /** @hidden */
  85958. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85959. /** @hidden */
  85960. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85961. /** @hidden */
  85962. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85963. /** @hidden */
  85964. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85965. /** @hidden */
  85966. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85967. /** @hidden */
  85968. _getResponse(pos: Vector3, vel: Vector3): void;
  85969. }
  85970. }
  85971. declare module BABYLON {
  85972. /**
  85973. * Interface for cullable objects
  85974. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85975. */
  85976. export interface ICullable {
  85977. /**
  85978. * Checks if the object or part of the object is in the frustum
  85979. * @param frustumPlanes Camera near/planes
  85980. * @returns true if the object is in frustum otherwise false
  85981. */
  85982. isInFrustum(frustumPlanes: Plane[]): boolean;
  85983. /**
  85984. * Checks if a cullable object (mesh...) is in the camera frustum
  85985. * Unlike isInFrustum this cheks the full bounding box
  85986. * @param frustumPlanes Camera near/planes
  85987. * @returns true if the object is in frustum otherwise false
  85988. */
  85989. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85990. }
  85991. /**
  85992. * Info for a bounding data of a mesh
  85993. */
  85994. export class BoundingInfo implements ICullable {
  85995. /**
  85996. * Bounding box for the mesh
  85997. */
  85998. readonly boundingBox: BoundingBox;
  85999. /**
  86000. * Bounding sphere for the mesh
  86001. */
  86002. readonly boundingSphere: BoundingSphere;
  86003. private _isLocked;
  86004. private static readonly TmpVector3;
  86005. /**
  86006. * Constructs bounding info
  86007. * @param minimum min vector of the bounding box/sphere
  86008. * @param maximum max vector of the bounding box/sphere
  86009. * @param worldMatrix defines the new world matrix
  86010. */
  86011. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86012. /**
  86013. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86014. * @param min defines the new minimum vector (in local space)
  86015. * @param max defines the new maximum vector (in local space)
  86016. * @param worldMatrix defines the new world matrix
  86017. */
  86018. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86019. /**
  86020. * min vector of the bounding box/sphere
  86021. */
  86022. get minimum(): Vector3;
  86023. /**
  86024. * max vector of the bounding box/sphere
  86025. */
  86026. get maximum(): Vector3;
  86027. /**
  86028. * If the info is locked and won't be updated to avoid perf overhead
  86029. */
  86030. get isLocked(): boolean;
  86031. set isLocked(value: boolean);
  86032. /**
  86033. * Updates the bounding sphere and box
  86034. * @param world world matrix to be used to update
  86035. */
  86036. update(world: DeepImmutable<Matrix>): void;
  86037. /**
  86038. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86039. * @param center New center of the bounding info
  86040. * @param extend New extend of the bounding info
  86041. * @returns the current bounding info
  86042. */
  86043. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86044. /**
  86045. * Scale the current bounding info by applying a scale factor
  86046. * @param factor defines the scale factor to apply
  86047. * @returns the current bounding info
  86048. */
  86049. scale(factor: number): BoundingInfo;
  86050. /**
  86051. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86052. * @param frustumPlanes defines the frustum to test
  86053. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86054. * @returns true if the bounding info is in the frustum planes
  86055. */
  86056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86057. /**
  86058. * Gets the world distance between the min and max points of the bounding box
  86059. */
  86060. get diagonalLength(): number;
  86061. /**
  86062. * Checks if a cullable object (mesh...) is in the camera frustum
  86063. * Unlike isInFrustum this cheks the full bounding box
  86064. * @param frustumPlanes Camera near/planes
  86065. * @returns true if the object is in frustum otherwise false
  86066. */
  86067. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86068. /** @hidden */
  86069. _checkCollision(collider: Collider): boolean;
  86070. /**
  86071. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86072. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86073. * @param point the point to check intersection with
  86074. * @returns if the point intersects
  86075. */
  86076. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86077. /**
  86078. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86079. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86080. * @param boundingInfo the bounding info to check intersection with
  86081. * @param precise if the intersection should be done using OBB
  86082. * @returns if the bounding info intersects
  86083. */
  86084. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86085. }
  86086. }
  86087. declare module BABYLON {
  86088. /**
  86089. * Extracts minimum and maximum values from a list of indexed positions
  86090. * @param positions defines the positions to use
  86091. * @param indices defines the indices to the positions
  86092. * @param indexStart defines the start index
  86093. * @param indexCount defines the end index
  86094. * @param bias defines bias value to add to the result
  86095. * @return minimum and maximum values
  86096. */
  86097. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86098. minimum: Vector3;
  86099. maximum: Vector3;
  86100. };
  86101. /**
  86102. * Extracts minimum and maximum values from a list of positions
  86103. * @param positions defines the positions to use
  86104. * @param start defines the start index in the positions array
  86105. * @param count defines the number of positions to handle
  86106. * @param bias defines bias value to add to the result
  86107. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86108. * @return minimum and maximum values
  86109. */
  86110. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86111. minimum: Vector3;
  86112. maximum: Vector3;
  86113. };
  86114. }
  86115. declare module BABYLON {
  86116. /** @hidden */
  86117. export class WebGLDataBuffer extends DataBuffer {
  86118. private _buffer;
  86119. constructor(resource: WebGLBuffer);
  86120. get underlyingResource(): any;
  86121. }
  86122. }
  86123. declare module BABYLON {
  86124. /** @hidden */
  86125. export class WebGLPipelineContext implements IPipelineContext {
  86126. engine: ThinEngine;
  86127. program: Nullable<WebGLProgram>;
  86128. context?: WebGLRenderingContext;
  86129. vertexShader?: WebGLShader;
  86130. fragmentShader?: WebGLShader;
  86131. isParallelCompiled: boolean;
  86132. onCompiled?: () => void;
  86133. transformFeedback?: WebGLTransformFeedback | null;
  86134. vertexCompilationError: Nullable<string>;
  86135. fragmentCompilationError: Nullable<string>;
  86136. programLinkError: Nullable<string>;
  86137. programValidationError: Nullable<string>;
  86138. get isAsync(): boolean;
  86139. get isReady(): boolean;
  86140. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86141. _getVertexShaderCode(): string | null;
  86142. _getFragmentShaderCode(): string | null;
  86143. }
  86144. }
  86145. declare module BABYLON {
  86146. interface ThinEngine {
  86147. /**
  86148. * Create an uniform buffer
  86149. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86150. * @param elements defines the content of the uniform buffer
  86151. * @returns the webGL uniform buffer
  86152. */
  86153. createUniformBuffer(elements: FloatArray): DataBuffer;
  86154. /**
  86155. * Create a dynamic uniform buffer
  86156. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86157. * @param elements defines the content of the uniform buffer
  86158. * @returns the webGL uniform buffer
  86159. */
  86160. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86161. /**
  86162. * Update an existing uniform buffer
  86163. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86164. * @param uniformBuffer defines the target uniform buffer
  86165. * @param elements defines the content to update
  86166. * @param offset defines the offset in the uniform buffer where update should start
  86167. * @param count defines the size of the data to update
  86168. */
  86169. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86170. /**
  86171. * Bind an uniform buffer to the current webGL context
  86172. * @param buffer defines the buffer to bind
  86173. */
  86174. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86175. /**
  86176. * Bind a buffer to the current webGL context at a given location
  86177. * @param buffer defines the buffer to bind
  86178. * @param location defines the index where to bind the buffer
  86179. */
  86180. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86181. /**
  86182. * Bind a specific block at a given index in a specific shader program
  86183. * @param pipelineContext defines the pipeline context to use
  86184. * @param blockName defines the block name
  86185. * @param index defines the index where to bind the block
  86186. */
  86187. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86188. }
  86189. }
  86190. declare module BABYLON {
  86191. /**
  86192. * Uniform buffer objects.
  86193. *
  86194. * Handles blocks of uniform on the GPU.
  86195. *
  86196. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86197. *
  86198. * For more information, please refer to :
  86199. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86200. */
  86201. export class UniformBuffer {
  86202. private _engine;
  86203. private _buffer;
  86204. private _data;
  86205. private _bufferData;
  86206. private _dynamic?;
  86207. private _uniformLocations;
  86208. private _uniformSizes;
  86209. private _uniformLocationPointer;
  86210. private _needSync;
  86211. private _noUBO;
  86212. private _currentEffect;
  86213. /** @hidden */
  86214. _alreadyBound: boolean;
  86215. private static _MAX_UNIFORM_SIZE;
  86216. private static _tempBuffer;
  86217. /**
  86218. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86219. * This is dynamic to allow compat with webgl 1 and 2.
  86220. * You will need to pass the name of the uniform as well as the value.
  86221. */
  86222. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86223. /**
  86224. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86225. * This is dynamic to allow compat with webgl 1 and 2.
  86226. * You will need to pass the name of the uniform as well as the value.
  86227. */
  86228. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86229. /**
  86230. * Lambda to Update a single float in a uniform buffer.
  86231. * This is dynamic to allow compat with webgl 1 and 2.
  86232. * You will need to pass the name of the uniform as well as the value.
  86233. */
  86234. updateFloat: (name: string, x: number) => void;
  86235. /**
  86236. * Lambda to Update a vec2 of float in a uniform buffer.
  86237. * This is dynamic to allow compat with webgl 1 and 2.
  86238. * You will need to pass the name of the uniform as well as the value.
  86239. */
  86240. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86241. /**
  86242. * Lambda to Update a vec3 of float in a uniform buffer.
  86243. * This is dynamic to allow compat with webgl 1 and 2.
  86244. * You will need to pass the name of the uniform as well as the value.
  86245. */
  86246. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86247. /**
  86248. * Lambda to Update a vec4 of float in a uniform buffer.
  86249. * This is dynamic to allow compat with webgl 1 and 2.
  86250. * You will need to pass the name of the uniform as well as the value.
  86251. */
  86252. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86253. /**
  86254. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86255. * This is dynamic to allow compat with webgl 1 and 2.
  86256. * You will need to pass the name of the uniform as well as the value.
  86257. */
  86258. updateMatrix: (name: string, mat: Matrix) => void;
  86259. /**
  86260. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86261. * This is dynamic to allow compat with webgl 1 and 2.
  86262. * You will need to pass the name of the uniform as well as the value.
  86263. */
  86264. updateVector3: (name: string, vector: Vector3) => void;
  86265. /**
  86266. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86267. * This is dynamic to allow compat with webgl 1 and 2.
  86268. * You will need to pass the name of the uniform as well as the value.
  86269. */
  86270. updateVector4: (name: string, vector: Vector4) => void;
  86271. /**
  86272. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86273. * This is dynamic to allow compat with webgl 1 and 2.
  86274. * You will need to pass the name of the uniform as well as the value.
  86275. */
  86276. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86277. /**
  86278. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86279. * This is dynamic to allow compat with webgl 1 and 2.
  86280. * You will need to pass the name of the uniform as well as the value.
  86281. */
  86282. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86283. /**
  86284. * Instantiates a new Uniform buffer objects.
  86285. *
  86286. * Handles blocks of uniform on the GPU.
  86287. *
  86288. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86289. *
  86290. * For more information, please refer to :
  86291. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86292. * @param engine Define the engine the buffer is associated with
  86293. * @param data Define the data contained in the buffer
  86294. * @param dynamic Define if the buffer is updatable
  86295. */
  86296. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86297. /**
  86298. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86299. * or just falling back on setUniformXXX calls.
  86300. */
  86301. get useUbo(): boolean;
  86302. /**
  86303. * Indicates if the WebGL underlying uniform buffer is in sync
  86304. * with the javascript cache data.
  86305. */
  86306. get isSync(): boolean;
  86307. /**
  86308. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86309. * Also, a dynamic UniformBuffer will disable cache verification and always
  86310. * update the underlying WebGL uniform buffer to the GPU.
  86311. * @returns if Dynamic, otherwise false
  86312. */
  86313. isDynamic(): boolean;
  86314. /**
  86315. * The data cache on JS side.
  86316. * @returns the underlying data as a float array
  86317. */
  86318. getData(): Float32Array;
  86319. /**
  86320. * The underlying WebGL Uniform buffer.
  86321. * @returns the webgl buffer
  86322. */
  86323. getBuffer(): Nullable<DataBuffer>;
  86324. /**
  86325. * std140 layout specifies how to align data within an UBO structure.
  86326. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86327. * for specs.
  86328. */
  86329. private _fillAlignment;
  86330. /**
  86331. * Adds an uniform in the buffer.
  86332. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86333. * for the layout to be correct !
  86334. * @param name Name of the uniform, as used in the uniform block in the shader.
  86335. * @param size Data size, or data directly.
  86336. */
  86337. addUniform(name: string, size: number | number[]): void;
  86338. /**
  86339. * Adds a Matrix 4x4 to the uniform buffer.
  86340. * @param name Name of the uniform, as used in the uniform block in the shader.
  86341. * @param mat A 4x4 matrix.
  86342. */
  86343. addMatrix(name: string, mat: Matrix): void;
  86344. /**
  86345. * Adds a vec2 to the uniform buffer.
  86346. * @param name Name of the uniform, as used in the uniform block in the shader.
  86347. * @param x Define the x component value of the vec2
  86348. * @param y Define the y component value of the vec2
  86349. */
  86350. addFloat2(name: string, x: number, y: number): void;
  86351. /**
  86352. * Adds a vec3 to the uniform buffer.
  86353. * @param name Name of the uniform, as used in the uniform block in the shader.
  86354. * @param x Define the x component value of the vec3
  86355. * @param y Define the y component value of the vec3
  86356. * @param z Define the z component value of the vec3
  86357. */
  86358. addFloat3(name: string, x: number, y: number, z: number): void;
  86359. /**
  86360. * Adds a vec3 to the uniform buffer.
  86361. * @param name Name of the uniform, as used in the uniform block in the shader.
  86362. * @param color Define the vec3 from a Color
  86363. */
  86364. addColor3(name: string, color: Color3): void;
  86365. /**
  86366. * Adds a vec4 to the uniform buffer.
  86367. * @param name Name of the uniform, as used in the uniform block in the shader.
  86368. * @param color Define the rgb components from a Color
  86369. * @param alpha Define the a component of the vec4
  86370. */
  86371. addColor4(name: string, color: Color3, alpha: number): void;
  86372. /**
  86373. * Adds a vec3 to the uniform buffer.
  86374. * @param name Name of the uniform, as used in the uniform block in the shader.
  86375. * @param vector Define the vec3 components from a Vector
  86376. */
  86377. addVector3(name: string, vector: Vector3): void;
  86378. /**
  86379. * Adds a Matrix 3x3 to the uniform buffer.
  86380. * @param name Name of the uniform, as used in the uniform block in the shader.
  86381. */
  86382. addMatrix3x3(name: string): void;
  86383. /**
  86384. * Adds a Matrix 2x2 to the uniform buffer.
  86385. * @param name Name of the uniform, as used in the uniform block in the shader.
  86386. */
  86387. addMatrix2x2(name: string): void;
  86388. /**
  86389. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86390. */
  86391. create(): void;
  86392. /** @hidden */
  86393. _rebuild(): void;
  86394. /**
  86395. * Updates the WebGL Uniform Buffer on the GPU.
  86396. * If the `dynamic` flag is set to true, no cache comparison is done.
  86397. * Otherwise, the buffer will be updated only if the cache differs.
  86398. */
  86399. update(): void;
  86400. /**
  86401. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86402. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86403. * @param data Define the flattened data
  86404. * @param size Define the size of the data.
  86405. */
  86406. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86407. private _valueCache;
  86408. private _cacheMatrix;
  86409. private _updateMatrix3x3ForUniform;
  86410. private _updateMatrix3x3ForEffect;
  86411. private _updateMatrix2x2ForEffect;
  86412. private _updateMatrix2x2ForUniform;
  86413. private _updateFloatForEffect;
  86414. private _updateFloatForUniform;
  86415. private _updateFloat2ForEffect;
  86416. private _updateFloat2ForUniform;
  86417. private _updateFloat3ForEffect;
  86418. private _updateFloat3ForUniform;
  86419. private _updateFloat4ForEffect;
  86420. private _updateFloat4ForUniform;
  86421. private _updateMatrixForEffect;
  86422. private _updateMatrixForUniform;
  86423. private _updateVector3ForEffect;
  86424. private _updateVector3ForUniform;
  86425. private _updateVector4ForEffect;
  86426. private _updateVector4ForUniform;
  86427. private _updateColor3ForEffect;
  86428. private _updateColor3ForUniform;
  86429. private _updateColor4ForEffect;
  86430. private _updateColor4ForUniform;
  86431. /**
  86432. * Sets a sampler uniform on the effect.
  86433. * @param name Define the name of the sampler.
  86434. * @param texture Define the texture to set in the sampler
  86435. */
  86436. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86437. /**
  86438. * Directly updates the value of the uniform in the cache AND on the GPU.
  86439. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86440. * @param data Define the flattened data
  86441. */
  86442. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86443. /**
  86444. * Binds this uniform buffer to an effect.
  86445. * @param effect Define the effect to bind the buffer to
  86446. * @param name Name of the uniform block in the shader.
  86447. */
  86448. bindToEffect(effect: Effect, name: string): void;
  86449. /**
  86450. * Disposes the uniform buffer.
  86451. */
  86452. dispose(): void;
  86453. }
  86454. }
  86455. declare module BABYLON {
  86456. /**
  86457. * Enum that determines the text-wrapping mode to use.
  86458. */
  86459. export enum InspectableType {
  86460. /**
  86461. * Checkbox for booleans
  86462. */
  86463. Checkbox = 0,
  86464. /**
  86465. * Sliders for numbers
  86466. */
  86467. Slider = 1,
  86468. /**
  86469. * Vector3
  86470. */
  86471. Vector3 = 2,
  86472. /**
  86473. * Quaternions
  86474. */
  86475. Quaternion = 3,
  86476. /**
  86477. * Color3
  86478. */
  86479. Color3 = 4,
  86480. /**
  86481. * String
  86482. */
  86483. String = 5
  86484. }
  86485. /**
  86486. * Interface used to define custom inspectable properties.
  86487. * This interface is used by the inspector to display custom property grids
  86488. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86489. */
  86490. export interface IInspectable {
  86491. /**
  86492. * Gets the label to display
  86493. */
  86494. label: string;
  86495. /**
  86496. * Gets the name of the property to edit
  86497. */
  86498. propertyName: string;
  86499. /**
  86500. * Gets the type of the editor to use
  86501. */
  86502. type: InspectableType;
  86503. /**
  86504. * Gets the minimum value of the property when using in "slider" mode
  86505. */
  86506. min?: number;
  86507. /**
  86508. * Gets the maximum value of the property when using in "slider" mode
  86509. */
  86510. max?: number;
  86511. /**
  86512. * Gets the setp to use when using in "slider" mode
  86513. */
  86514. step?: number;
  86515. }
  86516. }
  86517. declare module BABYLON {
  86518. /**
  86519. * Class used to provide helper for timing
  86520. */
  86521. export class TimingTools {
  86522. /**
  86523. * Polyfill for setImmediate
  86524. * @param action defines the action to execute after the current execution block
  86525. */
  86526. static SetImmediate(action: () => void): void;
  86527. }
  86528. }
  86529. declare module BABYLON {
  86530. /**
  86531. * Class used to enable instatition of objects by class name
  86532. */
  86533. export class InstantiationTools {
  86534. /**
  86535. * Use this object to register external classes like custom textures or material
  86536. * to allow the laoders to instantiate them
  86537. */
  86538. static RegisteredExternalClasses: {
  86539. [key: string]: Object;
  86540. };
  86541. /**
  86542. * Tries to instantiate a new object from a given class name
  86543. * @param className defines the class name to instantiate
  86544. * @returns the new object or null if the system was not able to do the instantiation
  86545. */
  86546. static Instantiate(className: string): any;
  86547. }
  86548. }
  86549. declare module BABYLON {
  86550. /**
  86551. * Define options used to create a depth texture
  86552. */
  86553. export class DepthTextureCreationOptions {
  86554. /** Specifies whether or not a stencil should be allocated in the texture */
  86555. generateStencil?: boolean;
  86556. /** Specifies whether or not bilinear filtering is enable on the texture */
  86557. bilinearFiltering?: boolean;
  86558. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86559. comparisonFunction?: number;
  86560. /** Specifies if the created texture is a cube texture */
  86561. isCube?: boolean;
  86562. }
  86563. }
  86564. declare module BABYLON {
  86565. interface ThinEngine {
  86566. /**
  86567. * Creates a depth stencil cube texture.
  86568. * This is only available in WebGL 2.
  86569. * @param size The size of face edge in the cube texture.
  86570. * @param options The options defining the cube texture.
  86571. * @returns The cube texture
  86572. */
  86573. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86574. /**
  86575. * Creates a cube texture
  86576. * @param rootUrl defines the url where the files to load is located
  86577. * @param scene defines the current scene
  86578. * @param files defines the list of files to load (1 per face)
  86579. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86580. * @param onLoad defines an optional callback raised when the texture is loaded
  86581. * @param onError defines an optional callback raised if there is an issue to load the texture
  86582. * @param format defines the format of the data
  86583. * @param forcedExtension defines the extension to use to pick the right loader
  86584. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86585. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86586. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86587. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86588. * @returns the cube texture as an InternalTexture
  86589. */
  86590. 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;
  86591. /**
  86592. * Creates a cube texture
  86593. * @param rootUrl defines the url where the files to load is located
  86594. * @param scene defines the current scene
  86595. * @param files defines the list of files to load (1 per face)
  86596. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86597. * @param onLoad defines an optional callback raised when the texture is loaded
  86598. * @param onError defines an optional callback raised if there is an issue to load the texture
  86599. * @param format defines the format of the data
  86600. * @param forcedExtension defines the extension to use to pick the right loader
  86601. * @returns the cube texture as an InternalTexture
  86602. */
  86603. 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;
  86604. /**
  86605. * Creates a cube texture
  86606. * @param rootUrl defines the url where the files to load is located
  86607. * @param scene defines the current scene
  86608. * @param files defines the list of files to load (1 per face)
  86609. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86610. * @param onLoad defines an optional callback raised when the texture is loaded
  86611. * @param onError defines an optional callback raised if there is an issue to load the texture
  86612. * @param format defines the format of the data
  86613. * @param forcedExtension defines the extension to use to pick the right loader
  86614. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86615. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86616. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86617. * @returns the cube texture as an InternalTexture
  86618. */
  86619. 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;
  86620. /** @hidden */
  86621. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86622. /** @hidden */
  86623. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86624. /** @hidden */
  86625. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86626. /** @hidden */
  86627. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86628. /**
  86629. * @hidden
  86630. */
  86631. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86632. }
  86633. }
  86634. declare module BABYLON {
  86635. /**
  86636. * Class for creating a cube texture
  86637. */
  86638. export class CubeTexture extends BaseTexture {
  86639. private _delayedOnLoad;
  86640. /**
  86641. * Observable triggered once the texture has been loaded.
  86642. */
  86643. onLoadObservable: Observable<CubeTexture>;
  86644. /**
  86645. * The url of the texture
  86646. */
  86647. url: string;
  86648. /**
  86649. * Gets or sets the center of the bounding box associated with the cube texture.
  86650. * It must define where the camera used to render the texture was set
  86651. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86652. */
  86653. boundingBoxPosition: Vector3;
  86654. private _boundingBoxSize;
  86655. /**
  86656. * Gets or sets the size of the bounding box associated with the cube texture
  86657. * When defined, the cubemap will switch to local mode
  86658. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86659. * @example https://www.babylonjs-playground.com/#RNASML
  86660. */
  86661. set boundingBoxSize(value: Vector3);
  86662. /**
  86663. * Returns the bounding box size
  86664. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86665. */
  86666. get boundingBoxSize(): Vector3;
  86667. protected _rotationY: number;
  86668. /**
  86669. * Sets texture matrix rotation angle around Y axis in radians.
  86670. */
  86671. set rotationY(value: number);
  86672. /**
  86673. * Gets texture matrix rotation angle around Y axis radians.
  86674. */
  86675. get rotationY(): number;
  86676. /**
  86677. * Are mip maps generated for this texture or not.
  86678. */
  86679. get noMipmap(): boolean;
  86680. private _noMipmap;
  86681. private _files;
  86682. protected _forcedExtension: Nullable<string>;
  86683. private _extensions;
  86684. private _textureMatrix;
  86685. private _format;
  86686. private _createPolynomials;
  86687. /**
  86688. * Creates a cube texture from an array of image urls
  86689. * @param files defines an array of image urls
  86690. * @param scene defines the hosting scene
  86691. * @param noMipmap specifies if mip maps are not used
  86692. * @returns a cube texture
  86693. */
  86694. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86695. /**
  86696. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86697. * @param url defines the url of the prefiltered texture
  86698. * @param scene defines the scene the texture is attached to
  86699. * @param forcedExtension defines the extension of the file if different from the url
  86700. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86701. * @return the prefiltered texture
  86702. */
  86703. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86704. /**
  86705. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86706. * as prefiltered data.
  86707. * @param rootUrl defines the url of the texture or the root name of the six images
  86708. * @param null defines the scene or engine the texture is attached to
  86709. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86710. * @param noMipmap defines if mipmaps should be created or not
  86711. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86712. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86713. * @param onError defines a callback triggered in case of error during load
  86714. * @param format defines the internal format to use for the texture once loaded
  86715. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86716. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86717. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86718. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86719. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86720. * @return the cube texture
  86721. */
  86722. 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);
  86723. /**
  86724. * Get the current class name of the texture useful for serialization or dynamic coding.
  86725. * @returns "CubeTexture"
  86726. */
  86727. getClassName(): string;
  86728. /**
  86729. * Update the url (and optional buffer) of this texture if url was null during construction.
  86730. * @param url the url of the texture
  86731. * @param forcedExtension defines the extension to use
  86732. * @param onLoad callback called when the texture is loaded (defaults to null)
  86733. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86734. */
  86735. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86736. /**
  86737. * Delays loading of the cube texture
  86738. * @param forcedExtension defines the extension to use
  86739. */
  86740. delayLoad(forcedExtension?: string): void;
  86741. /**
  86742. * Returns the reflection texture matrix
  86743. * @returns the reflection texture matrix
  86744. */
  86745. getReflectionTextureMatrix(): Matrix;
  86746. /**
  86747. * Sets the reflection texture matrix
  86748. * @param value Reflection texture matrix
  86749. */
  86750. setReflectionTextureMatrix(value: Matrix): void;
  86751. /**
  86752. * Parses text to create a cube texture
  86753. * @param parsedTexture define the serialized text to read from
  86754. * @param scene defines the hosting scene
  86755. * @param rootUrl defines the root url of the cube texture
  86756. * @returns a cube texture
  86757. */
  86758. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86759. /**
  86760. * Makes a clone, or deep copy, of the cube texture
  86761. * @returns a new cube texture
  86762. */
  86763. clone(): CubeTexture;
  86764. }
  86765. }
  86766. declare module BABYLON {
  86767. /**
  86768. * Manages the defines for the Material
  86769. */
  86770. export class MaterialDefines {
  86771. /** @hidden */
  86772. protected _keys: string[];
  86773. private _isDirty;
  86774. /** @hidden */
  86775. _renderId: number;
  86776. /** @hidden */
  86777. _areLightsDirty: boolean;
  86778. /** @hidden */
  86779. _areLightsDisposed: boolean;
  86780. /** @hidden */
  86781. _areAttributesDirty: boolean;
  86782. /** @hidden */
  86783. _areTexturesDirty: boolean;
  86784. /** @hidden */
  86785. _areFresnelDirty: boolean;
  86786. /** @hidden */
  86787. _areMiscDirty: boolean;
  86788. /** @hidden */
  86789. _areImageProcessingDirty: boolean;
  86790. /** @hidden */
  86791. _normals: boolean;
  86792. /** @hidden */
  86793. _uvs: boolean;
  86794. /** @hidden */
  86795. _needNormals: boolean;
  86796. /** @hidden */
  86797. _needUVs: boolean;
  86798. [id: string]: any;
  86799. /**
  86800. * Specifies if the material needs to be re-calculated
  86801. */
  86802. get isDirty(): boolean;
  86803. /**
  86804. * Marks the material to indicate that it has been re-calculated
  86805. */
  86806. markAsProcessed(): void;
  86807. /**
  86808. * Marks the material to indicate that it needs to be re-calculated
  86809. */
  86810. markAsUnprocessed(): void;
  86811. /**
  86812. * Marks the material to indicate all of its defines need to be re-calculated
  86813. */
  86814. markAllAsDirty(): void;
  86815. /**
  86816. * Marks the material to indicate that image processing needs to be re-calculated
  86817. */
  86818. markAsImageProcessingDirty(): void;
  86819. /**
  86820. * Marks the material to indicate the lights need to be re-calculated
  86821. * @param disposed Defines whether the light is dirty due to dispose or not
  86822. */
  86823. markAsLightDirty(disposed?: boolean): void;
  86824. /**
  86825. * Marks the attribute state as changed
  86826. */
  86827. markAsAttributesDirty(): void;
  86828. /**
  86829. * Marks the texture state as changed
  86830. */
  86831. markAsTexturesDirty(): void;
  86832. /**
  86833. * Marks the fresnel state as changed
  86834. */
  86835. markAsFresnelDirty(): void;
  86836. /**
  86837. * Marks the misc state as changed
  86838. */
  86839. markAsMiscDirty(): void;
  86840. /**
  86841. * Rebuilds the material defines
  86842. */
  86843. rebuild(): void;
  86844. /**
  86845. * Specifies if two material defines are equal
  86846. * @param other - A material define instance to compare to
  86847. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86848. */
  86849. isEqual(other: MaterialDefines): boolean;
  86850. /**
  86851. * Clones this instance's defines to another instance
  86852. * @param other - material defines to clone values to
  86853. */
  86854. cloneTo(other: MaterialDefines): void;
  86855. /**
  86856. * Resets the material define values
  86857. */
  86858. reset(): void;
  86859. /**
  86860. * Converts the material define values to a string
  86861. * @returns - String of material define information
  86862. */
  86863. toString(): string;
  86864. }
  86865. }
  86866. declare module BABYLON {
  86867. /**
  86868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86870. * 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;
  86871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86872. */
  86873. export class ColorCurves {
  86874. private _dirty;
  86875. private _tempColor;
  86876. private _globalCurve;
  86877. private _highlightsCurve;
  86878. private _midtonesCurve;
  86879. private _shadowsCurve;
  86880. private _positiveCurve;
  86881. private _negativeCurve;
  86882. private _globalHue;
  86883. private _globalDensity;
  86884. private _globalSaturation;
  86885. private _globalExposure;
  86886. /**
  86887. * Gets the global Hue value.
  86888. * 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).
  86889. */
  86890. get globalHue(): number;
  86891. /**
  86892. * Sets the global Hue value.
  86893. * 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).
  86894. */
  86895. set globalHue(value: number);
  86896. /**
  86897. * Gets the global Density value.
  86898. * 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.
  86899. * Values less than zero provide a filter of opposite hue.
  86900. */
  86901. get globalDensity(): number;
  86902. /**
  86903. * Sets the global Density value.
  86904. * 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.
  86905. * Values less than zero provide a filter of opposite hue.
  86906. */
  86907. set globalDensity(value: number);
  86908. /**
  86909. * Gets the global Saturation value.
  86910. * 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.
  86911. */
  86912. get globalSaturation(): number;
  86913. /**
  86914. * Sets the global Saturation value.
  86915. * 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.
  86916. */
  86917. set globalSaturation(value: number);
  86918. /**
  86919. * Gets the global Exposure value.
  86920. * 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.
  86921. */
  86922. get globalExposure(): number;
  86923. /**
  86924. * Sets the global Exposure value.
  86925. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  86926. */
  86927. set globalExposure(value: number);
  86928. private _highlightsHue;
  86929. private _highlightsDensity;
  86930. private _highlightsSaturation;
  86931. private _highlightsExposure;
  86932. /**
  86933. * Gets the highlights Hue value.
  86934. * 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).
  86935. */
  86936. get highlightsHue(): number;
  86937. /**
  86938. * Sets the highlights Hue value.
  86939. * 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).
  86940. */
  86941. set highlightsHue(value: number);
  86942. /**
  86943. * Gets the highlights Density value.
  86944. * 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.
  86945. * Values less than zero provide a filter of opposite hue.
  86946. */
  86947. get highlightsDensity(): number;
  86948. /**
  86949. * Sets the highlights Density value.
  86950. * 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.
  86951. * Values less than zero provide a filter of opposite hue.
  86952. */
  86953. set highlightsDensity(value: number);
  86954. /**
  86955. * Gets the highlights Saturation value.
  86956. * 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.
  86957. */
  86958. get highlightsSaturation(): number;
  86959. /**
  86960. * Sets the highlights Saturation value.
  86961. * 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.
  86962. */
  86963. set highlightsSaturation(value: number);
  86964. /**
  86965. * Gets the highlights Exposure value.
  86966. * 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.
  86967. */
  86968. get highlightsExposure(): number;
  86969. /**
  86970. * Sets the highlights Exposure value.
  86971. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  86972. */
  86973. set highlightsExposure(value: number);
  86974. private _midtonesHue;
  86975. private _midtonesDensity;
  86976. private _midtonesSaturation;
  86977. private _midtonesExposure;
  86978. /**
  86979. * Gets the midtones Hue value.
  86980. * 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).
  86981. */
  86982. get midtonesHue(): number;
  86983. /**
  86984. * Sets the midtones Hue value.
  86985. * 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).
  86986. */
  86987. set midtonesHue(value: number);
  86988. /**
  86989. * Gets the midtones Density value.
  86990. * 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.
  86991. * Values less than zero provide a filter of opposite hue.
  86992. */
  86993. get midtonesDensity(): number;
  86994. /**
  86995. * Sets the midtones Density value.
  86996. * 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.
  86997. * Values less than zero provide a filter of opposite hue.
  86998. */
  86999. set midtonesDensity(value: number);
  87000. /**
  87001. * Gets the midtones Saturation value.
  87002. * 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.
  87003. */
  87004. get midtonesSaturation(): number;
  87005. /**
  87006. * Sets the midtones Saturation value.
  87007. * 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.
  87008. */
  87009. set midtonesSaturation(value: number);
  87010. /**
  87011. * Gets the midtones Exposure value.
  87012. * 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.
  87013. */
  87014. get midtonesExposure(): number;
  87015. /**
  87016. * Sets the midtones Exposure value.
  87017. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  87018. */
  87019. set midtonesExposure(value: number);
  87020. private _shadowsHue;
  87021. private _shadowsDensity;
  87022. private _shadowsSaturation;
  87023. private _shadowsExposure;
  87024. /**
  87025. * Gets the shadows Hue value.
  87026. * 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).
  87027. */
  87028. get shadowsHue(): number;
  87029. /**
  87030. * Sets the shadows Hue value.
  87031. * 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).
  87032. */
  87033. set shadowsHue(value: number);
  87034. /**
  87035. * Gets the shadows Density value.
  87036. * 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.
  87037. * Values less than zero provide a filter of opposite hue.
  87038. */
  87039. get shadowsDensity(): number;
  87040. /**
  87041. * Sets the shadows Density value.
  87042. * 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.
  87043. * Values less than zero provide a filter of opposite hue.
  87044. */
  87045. set shadowsDensity(value: number);
  87046. /**
  87047. * Gets the shadows Saturation value.
  87048. * 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.
  87049. */
  87050. get shadowsSaturation(): number;
  87051. /**
  87052. * Sets the shadows Saturation value.
  87053. * 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.
  87054. */
  87055. set shadowsSaturation(value: number);
  87056. /**
  87057. * Gets the shadows Exposure value.
  87058. * 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.
  87059. */
  87060. get shadowsExposure(): number;
  87061. /**
  87062. * Sets the shadows Exposure value.
  87063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  87064. */
  87065. set shadowsExposure(value: number);
  87066. /**
  87067. * Returns the class name
  87068. * @returns The class name
  87069. */
  87070. getClassName(): string;
  87071. /**
  87072. * Binds the color curves to the shader.
  87073. * @param colorCurves The color curve to bind
  87074. * @param effect The effect to bind to
  87075. * @param positiveUniform The positive uniform shader parameter
  87076. * @param neutralUniform The neutral uniform shader parameter
  87077. * @param negativeUniform The negative uniform shader parameter
  87078. */
  87079. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87080. /**
  87081. * Prepare the list of uniforms associated with the ColorCurves effects.
  87082. * @param uniformsList The list of uniforms used in the effect
  87083. */
  87084. static PrepareUniforms(uniformsList: string[]): void;
  87085. /**
  87086. * Returns color grading data based on a hue, density, saturation and exposure value.
  87087. * @param filterHue The hue of the color filter.
  87088. * @param filterDensity The density of the color filter.
  87089. * @param saturation The saturation.
  87090. * @param exposure The exposure.
  87091. * @param result The result data container.
  87092. */
  87093. private getColorGradingDataToRef;
  87094. /**
  87095. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87096. * @param value The input slider value in range [-100,100].
  87097. * @returns Adjusted value.
  87098. */
  87099. private static applyColorGradingSliderNonlinear;
  87100. /**
  87101. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87102. * @param hue The hue (H) input.
  87103. * @param saturation The saturation (S) input.
  87104. * @param brightness The brightness (B) input.
  87105. * @result An RGBA color represented as Vector4.
  87106. */
  87107. private static fromHSBToRef;
  87108. /**
  87109. * Returns a value clamped between min and max
  87110. * @param value The value to clamp
  87111. * @param min The minimum of value
  87112. * @param max The maximum of value
  87113. * @returns The clamped value.
  87114. */
  87115. private static clamp;
  87116. /**
  87117. * Clones the current color curve instance.
  87118. * @return The cloned curves
  87119. */
  87120. clone(): ColorCurves;
  87121. /**
  87122. * Serializes the current color curve instance to a json representation.
  87123. * @return a JSON representation
  87124. */
  87125. serialize(): any;
  87126. /**
  87127. * Parses the color curve from a json representation.
  87128. * @param source the JSON source to parse
  87129. * @return The parsed curves
  87130. */
  87131. static Parse(source: any): ColorCurves;
  87132. }
  87133. }
  87134. declare module BABYLON {
  87135. /**
  87136. * Interface to follow in your material defines to integrate easily the
  87137. * Image proccessing functions.
  87138. * @hidden
  87139. */
  87140. export interface IImageProcessingConfigurationDefines {
  87141. IMAGEPROCESSING: boolean;
  87142. VIGNETTE: boolean;
  87143. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87144. VIGNETTEBLENDMODEOPAQUE: boolean;
  87145. TONEMAPPING: boolean;
  87146. TONEMAPPING_ACES: boolean;
  87147. CONTRAST: boolean;
  87148. EXPOSURE: boolean;
  87149. COLORCURVES: boolean;
  87150. COLORGRADING: boolean;
  87151. COLORGRADING3D: boolean;
  87152. SAMPLER3DGREENDEPTH: boolean;
  87153. SAMPLER3DBGRMAP: boolean;
  87154. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87155. }
  87156. /**
  87157. * @hidden
  87158. */
  87159. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87160. IMAGEPROCESSING: boolean;
  87161. VIGNETTE: boolean;
  87162. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87163. VIGNETTEBLENDMODEOPAQUE: boolean;
  87164. TONEMAPPING: boolean;
  87165. TONEMAPPING_ACES: boolean;
  87166. CONTRAST: boolean;
  87167. COLORCURVES: boolean;
  87168. COLORGRADING: boolean;
  87169. COLORGRADING3D: boolean;
  87170. SAMPLER3DGREENDEPTH: boolean;
  87171. SAMPLER3DBGRMAP: boolean;
  87172. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87173. EXPOSURE: boolean;
  87174. constructor();
  87175. }
  87176. /**
  87177. * This groups together the common properties used for image processing either in direct forward pass
  87178. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87179. * or not.
  87180. */
  87181. export class ImageProcessingConfiguration {
  87182. /**
  87183. * Default tone mapping applied in BabylonJS.
  87184. */
  87185. static readonly TONEMAPPING_STANDARD: number;
  87186. /**
  87187. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87188. * to other engines rendering to increase portability.
  87189. */
  87190. static readonly TONEMAPPING_ACES: number;
  87191. /**
  87192. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87193. */
  87194. colorCurves: Nullable<ColorCurves>;
  87195. private _colorCurvesEnabled;
  87196. /**
  87197. * Gets wether the color curves effect is enabled.
  87198. */
  87199. get colorCurvesEnabled(): boolean;
  87200. /**
  87201. * Sets wether the color curves effect is enabled.
  87202. */
  87203. set colorCurvesEnabled(value: boolean);
  87204. private _colorGradingTexture;
  87205. /**
  87206. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87207. */
  87208. get colorGradingTexture(): Nullable<BaseTexture>;
  87209. /**
  87210. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87211. */
  87212. set colorGradingTexture(value: Nullable<BaseTexture>);
  87213. private _colorGradingEnabled;
  87214. /**
  87215. * Gets wether the color grading effect is enabled.
  87216. */
  87217. get colorGradingEnabled(): boolean;
  87218. /**
  87219. * Sets wether the color grading effect is enabled.
  87220. */
  87221. set colorGradingEnabled(value: boolean);
  87222. private _colorGradingWithGreenDepth;
  87223. /**
  87224. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87225. */
  87226. get colorGradingWithGreenDepth(): boolean;
  87227. /**
  87228. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87229. */
  87230. set colorGradingWithGreenDepth(value: boolean);
  87231. private _colorGradingBGR;
  87232. /**
  87233. * Gets wether the color grading texture contains BGR values.
  87234. */
  87235. get colorGradingBGR(): boolean;
  87236. /**
  87237. * Sets wether the color grading texture contains BGR values.
  87238. */
  87239. set colorGradingBGR(value: boolean);
  87240. /** @hidden */
  87241. _exposure: number;
  87242. /**
  87243. * Gets the Exposure used in the effect.
  87244. */
  87245. get exposure(): number;
  87246. /**
  87247. * Sets the Exposure used in the effect.
  87248. */
  87249. set exposure(value: number);
  87250. private _toneMappingEnabled;
  87251. /**
  87252. * Gets wether the tone mapping effect is enabled.
  87253. */
  87254. get toneMappingEnabled(): boolean;
  87255. /**
  87256. * Sets wether the tone mapping effect is enabled.
  87257. */
  87258. set toneMappingEnabled(value: boolean);
  87259. private _toneMappingType;
  87260. /**
  87261. * Gets the type of tone mapping effect.
  87262. */
  87263. get toneMappingType(): number;
  87264. /**
  87265. * Sets the type of tone mapping effect used in BabylonJS.
  87266. */
  87267. set toneMappingType(value: number);
  87268. protected _contrast: number;
  87269. /**
  87270. * Gets the contrast used in the effect.
  87271. */
  87272. get contrast(): number;
  87273. /**
  87274. * Sets the contrast used in the effect.
  87275. */
  87276. set contrast(value: number);
  87277. /**
  87278. * Vignette stretch size.
  87279. */
  87280. vignetteStretch: number;
  87281. /**
  87282. * Vignette centre X Offset.
  87283. */
  87284. vignetteCentreX: number;
  87285. /**
  87286. * Vignette centre Y Offset.
  87287. */
  87288. vignetteCentreY: number;
  87289. /**
  87290. * Vignette weight or intensity of the vignette effect.
  87291. */
  87292. vignetteWeight: number;
  87293. /**
  87294. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87295. * if vignetteEnabled is set to true.
  87296. */
  87297. vignetteColor: Color4;
  87298. /**
  87299. * Camera field of view used by the Vignette effect.
  87300. */
  87301. vignetteCameraFov: number;
  87302. private _vignetteBlendMode;
  87303. /**
  87304. * Gets the vignette blend mode allowing different kind of effect.
  87305. */
  87306. get vignetteBlendMode(): number;
  87307. /**
  87308. * Sets the vignette blend mode allowing different kind of effect.
  87309. */
  87310. set vignetteBlendMode(value: number);
  87311. private _vignetteEnabled;
  87312. /**
  87313. * Gets wether the vignette effect is enabled.
  87314. */
  87315. get vignetteEnabled(): boolean;
  87316. /**
  87317. * Sets wether the vignette effect is enabled.
  87318. */
  87319. set vignetteEnabled(value: boolean);
  87320. private _applyByPostProcess;
  87321. /**
  87322. * Gets wether the image processing is applied through a post process or not.
  87323. */
  87324. get applyByPostProcess(): boolean;
  87325. /**
  87326. * Sets wether the image processing is applied through a post process or not.
  87327. */
  87328. set applyByPostProcess(value: boolean);
  87329. private _isEnabled;
  87330. /**
  87331. * Gets wether the image processing is enabled or not.
  87332. */
  87333. get isEnabled(): boolean;
  87334. /**
  87335. * Sets wether the image processing is enabled or not.
  87336. */
  87337. set isEnabled(value: boolean);
  87338. /**
  87339. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87340. */
  87341. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87342. /**
  87343. * Method called each time the image processing information changes requires to recompile the effect.
  87344. */
  87345. protected _updateParameters(): void;
  87346. /**
  87347. * Gets the current class name.
  87348. * @return "ImageProcessingConfiguration"
  87349. */
  87350. getClassName(): string;
  87351. /**
  87352. * Prepare the list of uniforms associated with the Image Processing effects.
  87353. * @param uniforms The list of uniforms used in the effect
  87354. * @param defines the list of defines currently in use
  87355. */
  87356. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87357. /**
  87358. * Prepare the list of samplers associated with the Image Processing effects.
  87359. * @param samplersList The list of uniforms used in the effect
  87360. * @param defines the list of defines currently in use
  87361. */
  87362. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87363. /**
  87364. * Prepare the list of defines associated to the shader.
  87365. * @param defines the list of defines to complete
  87366. * @param forPostProcess Define if we are currently in post process mode or not
  87367. */
  87368. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87369. /**
  87370. * Returns true if all the image processing information are ready.
  87371. * @returns True if ready, otherwise, false
  87372. */
  87373. isReady(): boolean;
  87374. /**
  87375. * Binds the image processing to the shader.
  87376. * @param effect The effect to bind to
  87377. * @param overrideAspectRatio Override the aspect ratio of the effect
  87378. */
  87379. bind(effect: Effect, overrideAspectRatio?: number): void;
  87380. /**
  87381. * Clones the current image processing instance.
  87382. * @return The cloned image processing
  87383. */
  87384. clone(): ImageProcessingConfiguration;
  87385. /**
  87386. * Serializes the current image processing instance to a json representation.
  87387. * @return a JSON representation
  87388. */
  87389. serialize(): any;
  87390. /**
  87391. * Parses the image processing from a json representation.
  87392. * @param source the JSON source to parse
  87393. * @return The parsed image processing
  87394. */
  87395. static Parse(source: any): ImageProcessingConfiguration;
  87396. private static _VIGNETTEMODE_MULTIPLY;
  87397. private static _VIGNETTEMODE_OPAQUE;
  87398. /**
  87399. * Used to apply the vignette as a mix with the pixel color.
  87400. */
  87401. static get VIGNETTEMODE_MULTIPLY(): number;
  87402. /**
  87403. * Used to apply the vignette as a replacement of the pixel color.
  87404. */
  87405. static get VIGNETTEMODE_OPAQUE(): number;
  87406. }
  87407. }
  87408. declare module BABYLON {
  87409. /** @hidden */
  87410. export var postprocessVertexShader: {
  87411. name: string;
  87412. shader: string;
  87413. };
  87414. }
  87415. declare module BABYLON {
  87416. interface ThinEngine {
  87417. /**
  87418. * Creates a new render target texture
  87419. * @param size defines the size of the texture
  87420. * @param options defines the options used to create the texture
  87421. * @returns a new render target texture stored in an InternalTexture
  87422. */
  87423. createRenderTargetTexture(size: number | {
  87424. width: number;
  87425. height: number;
  87426. layers?: number;
  87427. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87428. /**
  87429. * Creates a depth stencil texture.
  87430. * This is only available in WebGL 2 or with the depth texture extension available.
  87431. * @param size The size of face edge in the texture.
  87432. * @param options The options defining the texture.
  87433. * @returns The texture
  87434. */
  87435. createDepthStencilTexture(size: number | {
  87436. width: number;
  87437. height: number;
  87438. layers?: number;
  87439. }, options: DepthTextureCreationOptions): InternalTexture;
  87440. /** @hidden */
  87441. _createDepthStencilTexture(size: number | {
  87442. width: number;
  87443. height: number;
  87444. layers?: number;
  87445. }, options: DepthTextureCreationOptions): InternalTexture;
  87446. }
  87447. }
  87448. declare module BABYLON {
  87449. /**
  87450. * Defines the kind of connection point for node based material
  87451. */
  87452. export enum NodeMaterialBlockConnectionPointTypes {
  87453. /** Float */
  87454. Float = 1,
  87455. /** Int */
  87456. Int = 2,
  87457. /** Vector2 */
  87458. Vector2 = 4,
  87459. /** Vector3 */
  87460. Vector3 = 8,
  87461. /** Vector4 */
  87462. Vector4 = 16,
  87463. /** Color3 */
  87464. Color3 = 32,
  87465. /** Color4 */
  87466. Color4 = 64,
  87467. /** Matrix */
  87468. Matrix = 128,
  87469. /** Custom object */
  87470. Object = 256,
  87471. /** Detect type based on connection */
  87472. AutoDetect = 1024,
  87473. /** Output type that will be defined by input type */
  87474. BasedOnInput = 2048
  87475. }
  87476. }
  87477. declare module BABYLON {
  87478. /**
  87479. * Enum used to define the target of a block
  87480. */
  87481. export enum NodeMaterialBlockTargets {
  87482. /** Vertex shader */
  87483. Vertex = 1,
  87484. /** Fragment shader */
  87485. Fragment = 2,
  87486. /** Neutral */
  87487. Neutral = 4,
  87488. /** Vertex and Fragment */
  87489. VertexAndFragment = 3
  87490. }
  87491. }
  87492. declare module BABYLON {
  87493. /**
  87494. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87495. */
  87496. export enum NodeMaterialBlockConnectionPointMode {
  87497. /** Value is an uniform */
  87498. Uniform = 0,
  87499. /** Value is a mesh attribute */
  87500. Attribute = 1,
  87501. /** Value is a varying between vertex and fragment shaders */
  87502. Varying = 2,
  87503. /** Mode is undefined */
  87504. Undefined = 3
  87505. }
  87506. }
  87507. declare module BABYLON {
  87508. /**
  87509. * Enum used to define system values e.g. values automatically provided by the system
  87510. */
  87511. export enum NodeMaterialSystemValues {
  87512. /** World */
  87513. World = 1,
  87514. /** View */
  87515. View = 2,
  87516. /** Projection */
  87517. Projection = 3,
  87518. /** ViewProjection */
  87519. ViewProjection = 4,
  87520. /** WorldView */
  87521. WorldView = 5,
  87522. /** WorldViewProjection */
  87523. WorldViewProjection = 6,
  87524. /** CameraPosition */
  87525. CameraPosition = 7,
  87526. /** Fog Color */
  87527. FogColor = 8,
  87528. /** Delta time */
  87529. DeltaTime = 9
  87530. }
  87531. }
  87532. declare module BABYLON {
  87533. /** Defines supported spaces */
  87534. export enum Space {
  87535. /** Local (object) space */
  87536. LOCAL = 0,
  87537. /** World space */
  87538. WORLD = 1,
  87539. /** Bone space */
  87540. BONE = 2
  87541. }
  87542. /** Defines the 3 main axes */
  87543. export class Axis {
  87544. /** X axis */
  87545. static X: Vector3;
  87546. /** Y axis */
  87547. static Y: Vector3;
  87548. /** Z axis */
  87549. static Z: Vector3;
  87550. }
  87551. }
  87552. declare module BABYLON {
  87553. /**
  87554. * Represents a camera frustum
  87555. */
  87556. export class Frustum {
  87557. /**
  87558. * Gets the planes representing the frustum
  87559. * @param transform matrix to be applied to the returned planes
  87560. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87561. */
  87562. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87563. /**
  87564. * Gets the near frustum plane transformed by the transform matrix
  87565. * @param transform transformation matrix to be applied to the resulting frustum plane
  87566. * @param frustumPlane the resuling frustum plane
  87567. */
  87568. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87569. /**
  87570. * Gets the far frustum plane transformed by the transform matrix
  87571. * @param transform transformation matrix to be applied to the resulting frustum plane
  87572. * @param frustumPlane the resuling frustum plane
  87573. */
  87574. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87575. /**
  87576. * Gets the left frustum plane transformed by the transform matrix
  87577. * @param transform transformation matrix to be applied to the resulting frustum plane
  87578. * @param frustumPlane the resuling frustum plane
  87579. */
  87580. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87581. /**
  87582. * Gets the right frustum plane transformed by the transform matrix
  87583. * @param transform transformation matrix to be applied to the resulting frustum plane
  87584. * @param frustumPlane the resuling frustum plane
  87585. */
  87586. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87587. /**
  87588. * Gets the top frustum plane transformed by the transform matrix
  87589. * @param transform transformation matrix to be applied to the resulting frustum plane
  87590. * @param frustumPlane the resuling frustum plane
  87591. */
  87592. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87593. /**
  87594. * Gets the bottom frustum plane transformed by the transform matrix
  87595. * @param transform transformation matrix to be applied to the resulting frustum plane
  87596. * @param frustumPlane the resuling frustum plane
  87597. */
  87598. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87599. /**
  87600. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87601. * @param transform transformation matrix to be applied to the resulting frustum planes
  87602. * @param frustumPlanes the resuling frustum planes
  87603. */
  87604. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87605. }
  87606. }
  87607. declare module BABYLON {
  87608. /**
  87609. * Interface for the size containing width and height
  87610. */
  87611. export interface ISize {
  87612. /**
  87613. * Width
  87614. */
  87615. width: number;
  87616. /**
  87617. * Heighht
  87618. */
  87619. height: number;
  87620. }
  87621. /**
  87622. * Size containing widht and height
  87623. */
  87624. export class Size implements ISize {
  87625. /**
  87626. * Width
  87627. */
  87628. width: number;
  87629. /**
  87630. * Height
  87631. */
  87632. height: number;
  87633. /**
  87634. * Creates a Size object from the given width and height (floats).
  87635. * @param width width of the new size
  87636. * @param height height of the new size
  87637. */
  87638. constructor(width: number, height: number);
  87639. /**
  87640. * Returns a string with the Size width and height
  87641. * @returns a string with the Size width and height
  87642. */
  87643. toString(): string;
  87644. /**
  87645. * "Size"
  87646. * @returns the string "Size"
  87647. */
  87648. getClassName(): string;
  87649. /**
  87650. * Returns the Size hash code.
  87651. * @returns a hash code for a unique width and height
  87652. */
  87653. getHashCode(): number;
  87654. /**
  87655. * Updates the current size from the given one.
  87656. * @param src the given size
  87657. */
  87658. copyFrom(src: Size): void;
  87659. /**
  87660. * Updates in place the current Size from the given floats.
  87661. * @param width width of the new size
  87662. * @param height height of the new size
  87663. * @returns the updated Size.
  87664. */
  87665. copyFromFloats(width: number, height: number): Size;
  87666. /**
  87667. * Updates in place the current Size from the given floats.
  87668. * @param width width to set
  87669. * @param height height to set
  87670. * @returns the updated Size.
  87671. */
  87672. set(width: number, height: number): Size;
  87673. /**
  87674. * Multiplies the width and height by numbers
  87675. * @param w factor to multiple the width by
  87676. * @param h factor to multiple the height by
  87677. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87678. */
  87679. multiplyByFloats(w: number, h: number): Size;
  87680. /**
  87681. * Clones the size
  87682. * @returns a new Size copied from the given one.
  87683. */
  87684. clone(): Size;
  87685. /**
  87686. * True if the current Size and the given one width and height are strictly equal.
  87687. * @param other the other size to compare against
  87688. * @returns True if the current Size and the given one width and height are strictly equal.
  87689. */
  87690. equals(other: Size): boolean;
  87691. /**
  87692. * The surface of the Size : width * height (float).
  87693. */
  87694. get surface(): number;
  87695. /**
  87696. * Create a new size of zero
  87697. * @returns a new Size set to (0.0, 0.0)
  87698. */
  87699. static Zero(): Size;
  87700. /**
  87701. * Sums the width and height of two sizes
  87702. * @param otherSize size to add to this size
  87703. * @returns a new Size set as the addition result of the current Size and the given one.
  87704. */
  87705. add(otherSize: Size): Size;
  87706. /**
  87707. * Subtracts the width and height of two
  87708. * @param otherSize size to subtract to this size
  87709. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87710. */
  87711. subtract(otherSize: Size): Size;
  87712. /**
  87713. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87714. * @param start starting size to lerp between
  87715. * @param end end size to lerp between
  87716. * @param amount amount to lerp between the start and end values
  87717. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87718. */
  87719. static Lerp(start: Size, end: Size, amount: number): Size;
  87720. }
  87721. }
  87722. declare module BABYLON {
  87723. /**
  87724. * Contains position and normal vectors for a vertex
  87725. */
  87726. export class PositionNormalVertex {
  87727. /** the position of the vertex (defaut: 0,0,0) */
  87728. position: Vector3;
  87729. /** the normal of the vertex (defaut: 0,1,0) */
  87730. normal: Vector3;
  87731. /**
  87732. * Creates a PositionNormalVertex
  87733. * @param position the position of the vertex (defaut: 0,0,0)
  87734. * @param normal the normal of the vertex (defaut: 0,1,0)
  87735. */
  87736. constructor(
  87737. /** the position of the vertex (defaut: 0,0,0) */
  87738. position?: Vector3,
  87739. /** the normal of the vertex (defaut: 0,1,0) */
  87740. normal?: Vector3);
  87741. /**
  87742. * Clones the PositionNormalVertex
  87743. * @returns the cloned PositionNormalVertex
  87744. */
  87745. clone(): PositionNormalVertex;
  87746. }
  87747. /**
  87748. * Contains position, normal and uv vectors for a vertex
  87749. */
  87750. export class PositionNormalTextureVertex {
  87751. /** the position of the vertex (defaut: 0,0,0) */
  87752. position: Vector3;
  87753. /** the normal of the vertex (defaut: 0,1,0) */
  87754. normal: Vector3;
  87755. /** the uv of the vertex (default: 0,0) */
  87756. uv: Vector2;
  87757. /**
  87758. * Creates a PositionNormalTextureVertex
  87759. * @param position the position of the vertex (defaut: 0,0,0)
  87760. * @param normal the normal of the vertex (defaut: 0,1,0)
  87761. * @param uv the uv of the vertex (default: 0,0)
  87762. */
  87763. constructor(
  87764. /** the position of the vertex (defaut: 0,0,0) */
  87765. position?: Vector3,
  87766. /** the normal of the vertex (defaut: 0,1,0) */
  87767. normal?: Vector3,
  87768. /** the uv of the vertex (default: 0,0) */
  87769. uv?: Vector2);
  87770. /**
  87771. * Clones the PositionNormalTextureVertex
  87772. * @returns the cloned PositionNormalTextureVertex
  87773. */
  87774. clone(): PositionNormalTextureVertex;
  87775. }
  87776. }
  87777. declare module BABYLON {
  87778. /**
  87779. * Enum defining the type of animations supported by InputBlock
  87780. */
  87781. export enum AnimatedInputBlockTypes {
  87782. /** No animation */
  87783. None = 0,
  87784. /** Time based animation. Will only work for floats */
  87785. Time = 1
  87786. }
  87787. }
  87788. declare module BABYLON {
  87789. /**
  87790. * Interface describing all the common properties and methods a shadow light needs to implement.
  87791. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87792. * as well as binding the different shadow properties to the effects.
  87793. */
  87794. export interface IShadowLight extends Light {
  87795. /**
  87796. * The light id in the scene (used in scene.findLighById for instance)
  87797. */
  87798. id: string;
  87799. /**
  87800. * The position the shdow will be casted from.
  87801. */
  87802. position: Vector3;
  87803. /**
  87804. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87805. */
  87806. direction: Vector3;
  87807. /**
  87808. * The transformed position. Position of the light in world space taking parenting in account.
  87809. */
  87810. transformedPosition: Vector3;
  87811. /**
  87812. * The transformed direction. Direction of the light in world space taking parenting in account.
  87813. */
  87814. transformedDirection: Vector3;
  87815. /**
  87816. * The friendly name of the light in the scene.
  87817. */
  87818. name: string;
  87819. /**
  87820. * Defines the shadow projection clipping minimum z value.
  87821. */
  87822. shadowMinZ: number;
  87823. /**
  87824. * Defines the shadow projection clipping maximum z value.
  87825. */
  87826. shadowMaxZ: number;
  87827. /**
  87828. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87829. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87830. */
  87831. computeTransformedInformation(): boolean;
  87832. /**
  87833. * Gets the scene the light belongs to.
  87834. * @returns The scene
  87835. */
  87836. getScene(): Scene;
  87837. /**
  87838. * Callback defining a custom Projection Matrix Builder.
  87839. * This can be used to override the default projection matrix computation.
  87840. */
  87841. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87842. /**
  87843. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87844. * @param matrix The materix to updated with the projection information
  87845. * @param viewMatrix The transform matrix of the light
  87846. * @param renderList The list of mesh to render in the map
  87847. * @returns The current light
  87848. */
  87849. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87850. /**
  87851. * Gets the current depth scale used in ESM.
  87852. * @returns The scale
  87853. */
  87854. getDepthScale(): number;
  87855. /**
  87856. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87857. * @returns true if a cube texture needs to be use
  87858. */
  87859. needCube(): boolean;
  87860. /**
  87861. * Detects if the projection matrix requires to be recomputed this frame.
  87862. * @returns true if it requires to be recomputed otherwise, false.
  87863. */
  87864. needProjectionMatrixCompute(): boolean;
  87865. /**
  87866. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87867. */
  87868. forceProjectionMatrixCompute(): void;
  87869. /**
  87870. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87871. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87872. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87873. */
  87874. getShadowDirection(faceIndex?: number): Vector3;
  87875. /**
  87876. * Gets the minZ used for shadow according to both the scene and the light.
  87877. * @param activeCamera The camera we are returning the min for
  87878. * @returns the depth min z
  87879. */
  87880. getDepthMinZ(activeCamera: Camera): number;
  87881. /**
  87882. * Gets the maxZ used for shadow according to both the scene and the light.
  87883. * @param activeCamera The camera we are returning the max for
  87884. * @returns the depth max z
  87885. */
  87886. getDepthMaxZ(activeCamera: Camera): number;
  87887. }
  87888. /**
  87889. * Base implementation IShadowLight
  87890. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87891. */
  87892. export abstract class ShadowLight extends Light implements IShadowLight {
  87893. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87894. protected _position: Vector3;
  87895. protected _setPosition(value: Vector3): void;
  87896. /**
  87897. * Sets the position the shadow will be casted from. Also use as the light position for both
  87898. * point and spot lights.
  87899. */
  87900. get position(): Vector3;
  87901. /**
  87902. * Sets the position the shadow will be casted from. Also use as the light position for both
  87903. * point and spot lights.
  87904. */
  87905. set position(value: Vector3);
  87906. protected _direction: Vector3;
  87907. protected _setDirection(value: Vector3): void;
  87908. /**
  87909. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87910. * Also use as the light direction on spot and directional lights.
  87911. */
  87912. get direction(): Vector3;
  87913. /**
  87914. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87915. * Also use as the light direction on spot and directional lights.
  87916. */
  87917. set direction(value: Vector3);
  87918. protected _shadowMinZ: number;
  87919. /**
  87920. * Gets the shadow projection clipping minimum z value.
  87921. */
  87922. get shadowMinZ(): number;
  87923. /**
  87924. * Sets the shadow projection clipping minimum z value.
  87925. */
  87926. set shadowMinZ(value: number);
  87927. protected _shadowMaxZ: number;
  87928. /**
  87929. * Sets the shadow projection clipping maximum z value.
  87930. */
  87931. get shadowMaxZ(): number;
  87932. /**
  87933. * Gets the shadow projection clipping maximum z value.
  87934. */
  87935. set shadowMaxZ(value: number);
  87936. /**
  87937. * Callback defining a custom Projection Matrix Builder.
  87938. * This can be used to override the default projection matrix computation.
  87939. */
  87940. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87941. /**
  87942. * The transformed position. Position of the light in world space taking parenting in account.
  87943. */
  87944. transformedPosition: Vector3;
  87945. /**
  87946. * The transformed direction. Direction of the light in world space taking parenting in account.
  87947. */
  87948. transformedDirection: Vector3;
  87949. private _needProjectionMatrixCompute;
  87950. /**
  87951. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87952. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87953. */
  87954. computeTransformedInformation(): boolean;
  87955. /**
  87956. * Return the depth scale used for the shadow map.
  87957. * @returns the depth scale.
  87958. */
  87959. getDepthScale(): number;
  87960. /**
  87961. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87962. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87963. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87964. */
  87965. getShadowDirection(faceIndex?: number): Vector3;
  87966. /**
  87967. * Returns the ShadowLight absolute position in the World.
  87968. * @returns the position vector in world space
  87969. */
  87970. getAbsolutePosition(): Vector3;
  87971. /**
  87972. * Sets the ShadowLight direction toward the passed target.
  87973. * @param target The point to target in local space
  87974. * @returns the updated ShadowLight direction
  87975. */
  87976. setDirectionToTarget(target: Vector3): Vector3;
  87977. /**
  87978. * Returns the light rotation in euler definition.
  87979. * @returns the x y z rotation in local space.
  87980. */
  87981. getRotation(): Vector3;
  87982. /**
  87983. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87984. * @returns true if a cube texture needs to be use
  87985. */
  87986. needCube(): boolean;
  87987. /**
  87988. * Detects if the projection matrix requires to be recomputed this frame.
  87989. * @returns true if it requires to be recomputed otherwise, false.
  87990. */
  87991. needProjectionMatrixCompute(): boolean;
  87992. /**
  87993. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87994. */
  87995. forceProjectionMatrixCompute(): void;
  87996. /** @hidden */
  87997. _initCache(): void;
  87998. /** @hidden */
  87999. _isSynchronized(): boolean;
  88000. /**
  88001. * Computes the world matrix of the node
  88002. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88003. * @returns the world matrix
  88004. */
  88005. computeWorldMatrix(force?: boolean): Matrix;
  88006. /**
  88007. * Gets the minZ used for shadow according to both the scene and the light.
  88008. * @param activeCamera The camera we are returning the min for
  88009. * @returns the depth min z
  88010. */
  88011. getDepthMinZ(activeCamera: Camera): number;
  88012. /**
  88013. * Gets the maxZ used for shadow according to both the scene and the light.
  88014. * @param activeCamera The camera we are returning the max for
  88015. * @returns the depth max z
  88016. */
  88017. getDepthMaxZ(activeCamera: Camera): number;
  88018. /**
  88019. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88020. * @param matrix The materix to updated with the projection information
  88021. * @param viewMatrix The transform matrix of the light
  88022. * @param renderList The list of mesh to render in the map
  88023. * @returns The current light
  88024. */
  88025. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88026. }
  88027. }
  88028. declare module BABYLON {
  88029. /** @hidden */
  88030. export var packingFunctions: {
  88031. name: string;
  88032. shader: string;
  88033. };
  88034. }
  88035. declare module BABYLON {
  88036. /** @hidden */
  88037. export var bayerDitherFunctions: {
  88038. name: string;
  88039. shader: string;
  88040. };
  88041. }
  88042. declare module BABYLON {
  88043. /** @hidden */
  88044. export var shadowMapFragmentDeclaration: {
  88045. name: string;
  88046. shader: string;
  88047. };
  88048. }
  88049. declare module BABYLON {
  88050. /** @hidden */
  88051. export var clipPlaneFragmentDeclaration: {
  88052. name: string;
  88053. shader: string;
  88054. };
  88055. }
  88056. declare module BABYLON {
  88057. /** @hidden */
  88058. export var clipPlaneFragment: {
  88059. name: string;
  88060. shader: string;
  88061. };
  88062. }
  88063. declare module BABYLON {
  88064. /** @hidden */
  88065. export var shadowMapFragment: {
  88066. name: string;
  88067. shader: string;
  88068. };
  88069. }
  88070. declare module BABYLON {
  88071. /** @hidden */
  88072. export var shadowMapPixelShader: {
  88073. name: string;
  88074. shader: string;
  88075. };
  88076. }
  88077. declare module BABYLON {
  88078. /** @hidden */
  88079. export var bonesDeclaration: {
  88080. name: string;
  88081. shader: string;
  88082. };
  88083. }
  88084. declare module BABYLON {
  88085. /** @hidden */
  88086. export var morphTargetsVertexGlobalDeclaration: {
  88087. name: string;
  88088. shader: string;
  88089. };
  88090. }
  88091. declare module BABYLON {
  88092. /** @hidden */
  88093. export var morphTargetsVertexDeclaration: {
  88094. name: string;
  88095. shader: string;
  88096. };
  88097. }
  88098. declare module BABYLON {
  88099. /** @hidden */
  88100. export var instancesDeclaration: {
  88101. name: string;
  88102. shader: string;
  88103. };
  88104. }
  88105. declare module BABYLON {
  88106. /** @hidden */
  88107. export var helperFunctions: {
  88108. name: string;
  88109. shader: string;
  88110. };
  88111. }
  88112. declare module BABYLON {
  88113. /** @hidden */
  88114. export var shadowMapVertexDeclaration: {
  88115. name: string;
  88116. shader: string;
  88117. };
  88118. }
  88119. declare module BABYLON {
  88120. /** @hidden */
  88121. export var clipPlaneVertexDeclaration: {
  88122. name: string;
  88123. shader: string;
  88124. };
  88125. }
  88126. declare module BABYLON {
  88127. /** @hidden */
  88128. export var morphTargetsVertex: {
  88129. name: string;
  88130. shader: string;
  88131. };
  88132. }
  88133. declare module BABYLON {
  88134. /** @hidden */
  88135. export var instancesVertex: {
  88136. name: string;
  88137. shader: string;
  88138. };
  88139. }
  88140. declare module BABYLON {
  88141. /** @hidden */
  88142. export var bonesVertex: {
  88143. name: string;
  88144. shader: string;
  88145. };
  88146. }
  88147. declare module BABYLON {
  88148. /** @hidden */
  88149. export var shadowMapVertexNormalBias: {
  88150. name: string;
  88151. shader: string;
  88152. };
  88153. }
  88154. declare module BABYLON {
  88155. /** @hidden */
  88156. export var shadowMapVertexMetric: {
  88157. name: string;
  88158. shader: string;
  88159. };
  88160. }
  88161. declare module BABYLON {
  88162. /** @hidden */
  88163. export var clipPlaneVertex: {
  88164. name: string;
  88165. shader: string;
  88166. };
  88167. }
  88168. declare module BABYLON {
  88169. /** @hidden */
  88170. export var shadowMapVertexShader: {
  88171. name: string;
  88172. shader: string;
  88173. };
  88174. }
  88175. declare module BABYLON {
  88176. /** @hidden */
  88177. export var depthBoxBlurPixelShader: {
  88178. name: string;
  88179. shader: string;
  88180. };
  88181. }
  88182. declare module BABYLON {
  88183. /** @hidden */
  88184. export var shadowMapFragmentSoftTransparentShadow: {
  88185. name: string;
  88186. shader: string;
  88187. };
  88188. }
  88189. declare module BABYLON {
  88190. /**
  88191. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88192. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88193. */
  88194. export class EffectFallbacks implements IEffectFallbacks {
  88195. private _defines;
  88196. private _currentRank;
  88197. private _maxRank;
  88198. private _mesh;
  88199. /**
  88200. * Removes the fallback from the bound mesh.
  88201. */
  88202. unBindMesh(): void;
  88203. /**
  88204. * Adds a fallback on the specified property.
  88205. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88206. * @param define The name of the define in the shader
  88207. */
  88208. addFallback(rank: number, define: string): void;
  88209. /**
  88210. * Sets the mesh to use CPU skinning when needing to fallback.
  88211. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88212. * @param mesh The mesh to use the fallbacks.
  88213. */
  88214. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88215. /**
  88216. * Checks to see if more fallbacks are still availible.
  88217. */
  88218. get hasMoreFallbacks(): boolean;
  88219. /**
  88220. * Removes the defines that should be removed when falling back.
  88221. * @param currentDefines defines the current define statements for the shader.
  88222. * @param effect defines the current effect we try to compile
  88223. * @returns The resulting defines with defines of the current rank removed.
  88224. */
  88225. reduce(currentDefines: string, effect: Effect): string;
  88226. }
  88227. }
  88228. declare module BABYLON {
  88229. /**
  88230. * Interface used to define Action
  88231. */
  88232. export interface IAction {
  88233. /**
  88234. * Trigger for the action
  88235. */
  88236. trigger: number;
  88237. /** Options of the trigger */
  88238. triggerOptions: any;
  88239. /**
  88240. * Gets the trigger parameters
  88241. * @returns the trigger parameters
  88242. */
  88243. getTriggerParameter(): any;
  88244. /**
  88245. * Internal only - executes current action event
  88246. * @hidden
  88247. */
  88248. _executeCurrent(evt?: ActionEvent): void;
  88249. /**
  88250. * Serialize placeholder for child classes
  88251. * @param parent of child
  88252. * @returns the serialized object
  88253. */
  88254. serialize(parent: any): any;
  88255. /**
  88256. * Internal only
  88257. * @hidden
  88258. */
  88259. _prepare(): void;
  88260. /**
  88261. * Internal only - manager for action
  88262. * @hidden
  88263. */
  88264. _actionManager: AbstractActionManager;
  88265. /**
  88266. * Adds action to chain of actions, may be a DoNothingAction
  88267. * @param action defines the next action to execute
  88268. * @returns The action passed in
  88269. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88270. */
  88271. then(action: IAction): IAction;
  88272. }
  88273. /**
  88274. * The action to be carried out following a trigger
  88275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88276. */
  88277. export class Action implements IAction {
  88278. /** the trigger, with or without parameters, for the action */
  88279. triggerOptions: any;
  88280. /**
  88281. * Trigger for the action
  88282. */
  88283. trigger: number;
  88284. /**
  88285. * Internal only - manager for action
  88286. * @hidden
  88287. */
  88288. _actionManager: ActionManager;
  88289. private _nextActiveAction;
  88290. private _child;
  88291. private _condition?;
  88292. private _triggerParameter;
  88293. /**
  88294. * An event triggered prior to action being executed.
  88295. */
  88296. onBeforeExecuteObservable: Observable<Action>;
  88297. /**
  88298. * Creates a new Action
  88299. * @param triggerOptions the trigger, with or without parameters, for the action
  88300. * @param condition an optional determinant of action
  88301. */
  88302. constructor(
  88303. /** the trigger, with or without parameters, for the action */
  88304. triggerOptions: any, condition?: Condition);
  88305. /**
  88306. * Internal only
  88307. * @hidden
  88308. */
  88309. _prepare(): void;
  88310. /**
  88311. * Gets the trigger parameters
  88312. * @returns the trigger parameters
  88313. */
  88314. getTriggerParameter(): any;
  88315. /**
  88316. * Internal only - executes current action event
  88317. * @hidden
  88318. */
  88319. _executeCurrent(evt?: ActionEvent): void;
  88320. /**
  88321. * Execute placeholder for child classes
  88322. * @param evt optional action event
  88323. */
  88324. execute(evt?: ActionEvent): void;
  88325. /**
  88326. * Skips to next active action
  88327. */
  88328. skipToNextActiveAction(): void;
  88329. /**
  88330. * Adds action to chain of actions, may be a DoNothingAction
  88331. * @param action defines the next action to execute
  88332. * @returns The action passed in
  88333. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88334. */
  88335. then(action: Action): Action;
  88336. /**
  88337. * Internal only
  88338. * @hidden
  88339. */
  88340. _getProperty(propertyPath: string): string;
  88341. /**
  88342. * Internal only
  88343. * @hidden
  88344. */
  88345. _getEffectiveTarget(target: any, propertyPath: string): any;
  88346. /**
  88347. * Serialize placeholder for child classes
  88348. * @param parent of child
  88349. * @returns the serialized object
  88350. */
  88351. serialize(parent: any): any;
  88352. /**
  88353. * Internal only called by serialize
  88354. * @hidden
  88355. */
  88356. protected _serialize(serializedAction: any, parent?: any): any;
  88357. /**
  88358. * Internal only
  88359. * @hidden
  88360. */
  88361. static _SerializeValueAsString: (value: any) => string;
  88362. /**
  88363. * Internal only
  88364. * @hidden
  88365. */
  88366. static _GetTargetProperty: (target: Scene | Node) => {
  88367. name: string;
  88368. targetType: string;
  88369. value: string;
  88370. };
  88371. }
  88372. }
  88373. declare module BABYLON {
  88374. /**
  88375. * A Condition applied to an Action
  88376. */
  88377. export class Condition {
  88378. /**
  88379. * Internal only - manager for action
  88380. * @hidden
  88381. */
  88382. _actionManager: ActionManager;
  88383. /**
  88384. * Internal only
  88385. * @hidden
  88386. */
  88387. _evaluationId: number;
  88388. /**
  88389. * Internal only
  88390. * @hidden
  88391. */
  88392. _currentResult: boolean;
  88393. /**
  88394. * Creates a new Condition
  88395. * @param actionManager the manager of the action the condition is applied to
  88396. */
  88397. constructor(actionManager: ActionManager);
  88398. /**
  88399. * Check if the current condition is valid
  88400. * @returns a boolean
  88401. */
  88402. isValid(): boolean;
  88403. /**
  88404. * Internal only
  88405. * @hidden
  88406. */
  88407. _getProperty(propertyPath: string): string;
  88408. /**
  88409. * Internal only
  88410. * @hidden
  88411. */
  88412. _getEffectiveTarget(target: any, propertyPath: string): any;
  88413. /**
  88414. * Serialize placeholder for child classes
  88415. * @returns the serialized object
  88416. */
  88417. serialize(): any;
  88418. /**
  88419. * Internal only
  88420. * @hidden
  88421. */
  88422. protected _serialize(serializedCondition: any): any;
  88423. }
  88424. /**
  88425. * Defines specific conditional operators as extensions of Condition
  88426. */
  88427. export class ValueCondition extends Condition {
  88428. /** path to specify the property of the target the conditional operator uses */
  88429. propertyPath: string;
  88430. /** the value compared by the conditional operator against the current value of the property */
  88431. value: any;
  88432. /** the conditional operator, default ValueCondition.IsEqual */
  88433. operator: number;
  88434. /**
  88435. * Internal only
  88436. * @hidden
  88437. */
  88438. private static _IsEqual;
  88439. /**
  88440. * Internal only
  88441. * @hidden
  88442. */
  88443. private static _IsDifferent;
  88444. /**
  88445. * Internal only
  88446. * @hidden
  88447. */
  88448. private static _IsGreater;
  88449. /**
  88450. * Internal only
  88451. * @hidden
  88452. */
  88453. private static _IsLesser;
  88454. /**
  88455. * returns the number for IsEqual
  88456. */
  88457. static get IsEqual(): number;
  88458. /**
  88459. * Returns the number for IsDifferent
  88460. */
  88461. static get IsDifferent(): number;
  88462. /**
  88463. * Returns the number for IsGreater
  88464. */
  88465. static get IsGreater(): number;
  88466. /**
  88467. * Returns the number for IsLesser
  88468. */
  88469. static get IsLesser(): number;
  88470. /**
  88471. * Internal only The action manager for the condition
  88472. * @hidden
  88473. */
  88474. _actionManager: ActionManager;
  88475. /**
  88476. * Internal only
  88477. * @hidden
  88478. */
  88479. private _target;
  88480. /**
  88481. * Internal only
  88482. * @hidden
  88483. */
  88484. private _effectiveTarget;
  88485. /**
  88486. * Internal only
  88487. * @hidden
  88488. */
  88489. private _property;
  88490. /**
  88491. * Creates a new ValueCondition
  88492. * @param actionManager manager for the action the condition applies to
  88493. * @param target for the action
  88494. * @param propertyPath path to specify the property of the target the conditional operator uses
  88495. * @param value the value compared by the conditional operator against the current value of the property
  88496. * @param operator the conditional operator, default ValueCondition.IsEqual
  88497. */
  88498. constructor(actionManager: ActionManager, target: any,
  88499. /** path to specify the property of the target the conditional operator uses */
  88500. propertyPath: string,
  88501. /** the value compared by the conditional operator against the current value of the property */
  88502. value: any,
  88503. /** the conditional operator, default ValueCondition.IsEqual */
  88504. operator?: number);
  88505. /**
  88506. * Compares the given value with the property value for the specified conditional operator
  88507. * @returns the result of the comparison
  88508. */
  88509. isValid(): boolean;
  88510. /**
  88511. * Serialize the ValueCondition into a JSON compatible object
  88512. * @returns serialization object
  88513. */
  88514. serialize(): any;
  88515. /**
  88516. * Gets the name of the conditional operator for the ValueCondition
  88517. * @param operator the conditional operator
  88518. * @returns the name
  88519. */
  88520. static GetOperatorName(operator: number): string;
  88521. }
  88522. /**
  88523. * Defines a predicate condition as an extension of Condition
  88524. */
  88525. export class PredicateCondition extends Condition {
  88526. /** defines the predicate function used to validate the condition */
  88527. predicate: () => boolean;
  88528. /**
  88529. * Internal only - manager for action
  88530. * @hidden
  88531. */
  88532. _actionManager: ActionManager;
  88533. /**
  88534. * Creates a new PredicateCondition
  88535. * @param actionManager manager for the action the condition applies to
  88536. * @param predicate defines the predicate function used to validate the condition
  88537. */
  88538. constructor(actionManager: ActionManager,
  88539. /** defines the predicate function used to validate the condition */
  88540. predicate: () => boolean);
  88541. /**
  88542. * @returns the validity of the predicate condition
  88543. */
  88544. isValid(): boolean;
  88545. }
  88546. /**
  88547. * Defines a state condition as an extension of Condition
  88548. */
  88549. export class StateCondition extends Condition {
  88550. /** Value to compare with target state */
  88551. value: string;
  88552. /**
  88553. * Internal only - manager for action
  88554. * @hidden
  88555. */
  88556. _actionManager: ActionManager;
  88557. /**
  88558. * Internal only
  88559. * @hidden
  88560. */
  88561. private _target;
  88562. /**
  88563. * Creates a new StateCondition
  88564. * @param actionManager manager for the action the condition applies to
  88565. * @param target of the condition
  88566. * @param value to compare with target state
  88567. */
  88568. constructor(actionManager: ActionManager, target: any,
  88569. /** Value to compare with target state */
  88570. value: string);
  88571. /**
  88572. * Gets a boolean indicating if the current condition is met
  88573. * @returns the validity of the state
  88574. */
  88575. isValid(): boolean;
  88576. /**
  88577. * Serialize the StateCondition into a JSON compatible object
  88578. * @returns serialization object
  88579. */
  88580. serialize(): any;
  88581. }
  88582. }
  88583. declare module BABYLON {
  88584. /**
  88585. * This defines an action responsible to toggle a boolean once triggered.
  88586. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88587. */
  88588. export class SwitchBooleanAction extends Action {
  88589. /**
  88590. * The path to the boolean property in the target object
  88591. */
  88592. propertyPath: string;
  88593. private _target;
  88594. private _effectiveTarget;
  88595. private _property;
  88596. /**
  88597. * Instantiate the action
  88598. * @param triggerOptions defines the trigger options
  88599. * @param target defines the object containing the boolean
  88600. * @param propertyPath defines the path to the boolean property in the target object
  88601. * @param condition defines the trigger related conditions
  88602. */
  88603. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88604. /** @hidden */
  88605. _prepare(): void;
  88606. /**
  88607. * Execute the action toggle the boolean value.
  88608. */
  88609. execute(): void;
  88610. /**
  88611. * Serializes the actions and its related information.
  88612. * @param parent defines the object to serialize in
  88613. * @returns the serialized object
  88614. */
  88615. serialize(parent: any): any;
  88616. }
  88617. /**
  88618. * This defines an action responsible to set a the state field of the target
  88619. * to a desired value once triggered.
  88620. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88621. */
  88622. export class SetStateAction extends Action {
  88623. /**
  88624. * The value to store in the state field.
  88625. */
  88626. value: string;
  88627. private _target;
  88628. /**
  88629. * Instantiate the action
  88630. * @param triggerOptions defines the trigger options
  88631. * @param target defines the object containing the state property
  88632. * @param value defines the value to store in the state field
  88633. * @param condition defines the trigger related conditions
  88634. */
  88635. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88636. /**
  88637. * Execute the action and store the value on the target state property.
  88638. */
  88639. execute(): void;
  88640. /**
  88641. * Serializes the actions and its related information.
  88642. * @param parent defines the object to serialize in
  88643. * @returns the serialized object
  88644. */
  88645. serialize(parent: any): any;
  88646. }
  88647. /**
  88648. * This defines an action responsible to set a property of the target
  88649. * to a desired value once triggered.
  88650. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88651. */
  88652. export class SetValueAction extends Action {
  88653. /**
  88654. * The path of the property to set in the target.
  88655. */
  88656. propertyPath: string;
  88657. /**
  88658. * The value to set in the property
  88659. */
  88660. value: any;
  88661. private _target;
  88662. private _effectiveTarget;
  88663. private _property;
  88664. /**
  88665. * Instantiate the action
  88666. * @param triggerOptions defines the trigger options
  88667. * @param target defines the object containing the property
  88668. * @param propertyPath defines the path of the property to set in the target
  88669. * @param value defines the value to set in the property
  88670. * @param condition defines the trigger related conditions
  88671. */
  88672. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88673. /** @hidden */
  88674. _prepare(): void;
  88675. /**
  88676. * Execute the action and set the targetted property to the desired value.
  88677. */
  88678. execute(): void;
  88679. /**
  88680. * Serializes the actions and its related information.
  88681. * @param parent defines the object to serialize in
  88682. * @returns the serialized object
  88683. */
  88684. serialize(parent: any): any;
  88685. }
  88686. /**
  88687. * This defines an action responsible to increment the target value
  88688. * to a desired value once triggered.
  88689. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88690. */
  88691. export class IncrementValueAction extends Action {
  88692. /**
  88693. * The path of the property to increment in the target.
  88694. */
  88695. propertyPath: string;
  88696. /**
  88697. * The value we should increment the property by.
  88698. */
  88699. value: any;
  88700. private _target;
  88701. private _effectiveTarget;
  88702. private _property;
  88703. /**
  88704. * Instantiate the action
  88705. * @param triggerOptions defines the trigger options
  88706. * @param target defines the object containing the property
  88707. * @param propertyPath defines the path of the property to increment in the target
  88708. * @param value defines the value value we should increment the property by
  88709. * @param condition defines the trigger related conditions
  88710. */
  88711. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88712. /** @hidden */
  88713. _prepare(): void;
  88714. /**
  88715. * Execute the action and increment the target of the value amount.
  88716. */
  88717. execute(): void;
  88718. /**
  88719. * Serializes the actions and its related information.
  88720. * @param parent defines the object to serialize in
  88721. * @returns the serialized object
  88722. */
  88723. serialize(parent: any): any;
  88724. }
  88725. /**
  88726. * This defines an action responsible to start an animation once triggered.
  88727. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88728. */
  88729. export class PlayAnimationAction extends Action {
  88730. /**
  88731. * Where the animation should start (animation frame)
  88732. */
  88733. from: number;
  88734. /**
  88735. * Where the animation should stop (animation frame)
  88736. */
  88737. to: number;
  88738. /**
  88739. * Define if the animation should loop or stop after the first play.
  88740. */
  88741. loop?: boolean;
  88742. private _target;
  88743. /**
  88744. * Instantiate the action
  88745. * @param triggerOptions defines the trigger options
  88746. * @param target defines the target animation or animation name
  88747. * @param from defines from where the animation should start (animation frame)
  88748. * @param end defines where the animation should stop (animation frame)
  88749. * @param loop defines if the animation should loop or stop after the first play
  88750. * @param condition defines the trigger related conditions
  88751. */
  88752. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88753. /** @hidden */
  88754. _prepare(): void;
  88755. /**
  88756. * Execute the action and play the animation.
  88757. */
  88758. execute(): void;
  88759. /**
  88760. * Serializes the actions and its related information.
  88761. * @param parent defines the object to serialize in
  88762. * @returns the serialized object
  88763. */
  88764. serialize(parent: any): any;
  88765. }
  88766. /**
  88767. * This defines an action responsible to stop an animation once triggered.
  88768. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88769. */
  88770. export class StopAnimationAction extends Action {
  88771. private _target;
  88772. /**
  88773. * Instantiate the action
  88774. * @param triggerOptions defines the trigger options
  88775. * @param target defines the target animation or animation name
  88776. * @param condition defines the trigger related conditions
  88777. */
  88778. constructor(triggerOptions: any, target: any, condition?: Condition);
  88779. /** @hidden */
  88780. _prepare(): void;
  88781. /**
  88782. * Execute the action and stop the animation.
  88783. */
  88784. execute(): void;
  88785. /**
  88786. * Serializes the actions and its related information.
  88787. * @param parent defines the object to serialize in
  88788. * @returns the serialized object
  88789. */
  88790. serialize(parent: any): any;
  88791. }
  88792. /**
  88793. * This defines an action responsible that does nothing once triggered.
  88794. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88795. */
  88796. export class DoNothingAction extends Action {
  88797. /**
  88798. * Instantiate the action
  88799. * @param triggerOptions defines the trigger options
  88800. * @param condition defines the trigger related conditions
  88801. */
  88802. constructor(triggerOptions?: any, condition?: Condition);
  88803. /**
  88804. * Execute the action and do nothing.
  88805. */
  88806. execute(): void;
  88807. /**
  88808. * Serializes the actions and its related information.
  88809. * @param parent defines the object to serialize in
  88810. * @returns the serialized object
  88811. */
  88812. serialize(parent: any): any;
  88813. }
  88814. /**
  88815. * This defines an action responsible to trigger several actions once triggered.
  88816. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88817. */
  88818. export class CombineAction extends Action {
  88819. /**
  88820. * The list of aggregated animations to run.
  88821. */
  88822. children: Action[];
  88823. /**
  88824. * Instantiate the action
  88825. * @param triggerOptions defines the trigger options
  88826. * @param children defines the list of aggregated animations to run
  88827. * @param condition defines the trigger related conditions
  88828. */
  88829. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88830. /** @hidden */
  88831. _prepare(): void;
  88832. /**
  88833. * Execute the action and executes all the aggregated actions.
  88834. */
  88835. execute(evt: ActionEvent): void;
  88836. /**
  88837. * Serializes the actions and its related information.
  88838. * @param parent defines the object to serialize in
  88839. * @returns the serialized object
  88840. */
  88841. serialize(parent: any): any;
  88842. }
  88843. /**
  88844. * This defines an action responsible to run code (external event) once triggered.
  88845. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88846. */
  88847. export class ExecuteCodeAction extends Action {
  88848. /**
  88849. * The callback function to run.
  88850. */
  88851. func: (evt: ActionEvent) => void;
  88852. /**
  88853. * Instantiate the action
  88854. * @param triggerOptions defines the trigger options
  88855. * @param func defines the callback function to run
  88856. * @param condition defines the trigger related conditions
  88857. */
  88858. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88859. /**
  88860. * Execute the action and run the attached code.
  88861. */
  88862. execute(evt: ActionEvent): void;
  88863. }
  88864. /**
  88865. * This defines an action responsible to set the parent property of the target once triggered.
  88866. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88867. */
  88868. export class SetParentAction extends Action {
  88869. private _parent;
  88870. private _target;
  88871. /**
  88872. * Instantiate the action
  88873. * @param triggerOptions defines the trigger options
  88874. * @param target defines the target containing the parent property
  88875. * @param parent defines from where the animation should start (animation frame)
  88876. * @param condition defines the trigger related conditions
  88877. */
  88878. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88879. /** @hidden */
  88880. _prepare(): void;
  88881. /**
  88882. * Execute the action and set the parent property.
  88883. */
  88884. execute(): void;
  88885. /**
  88886. * Serializes the actions and its related information.
  88887. * @param parent defines the object to serialize in
  88888. * @returns the serialized object
  88889. */
  88890. serialize(parent: any): any;
  88891. }
  88892. }
  88893. declare module BABYLON {
  88894. /**
  88895. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88896. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88897. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88898. */
  88899. export class ActionManager extends AbstractActionManager {
  88900. /**
  88901. * Nothing
  88902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88903. */
  88904. static readonly NothingTrigger: number;
  88905. /**
  88906. * On pick
  88907. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88908. */
  88909. static readonly OnPickTrigger: number;
  88910. /**
  88911. * On left pick
  88912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88913. */
  88914. static readonly OnLeftPickTrigger: number;
  88915. /**
  88916. * On right pick
  88917. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88918. */
  88919. static readonly OnRightPickTrigger: number;
  88920. /**
  88921. * On center pick
  88922. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88923. */
  88924. static readonly OnCenterPickTrigger: number;
  88925. /**
  88926. * On pick down
  88927. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88928. */
  88929. static readonly OnPickDownTrigger: number;
  88930. /**
  88931. * On double pick
  88932. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88933. */
  88934. static readonly OnDoublePickTrigger: number;
  88935. /**
  88936. * On pick up
  88937. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88938. */
  88939. static readonly OnPickUpTrigger: number;
  88940. /**
  88941. * On pick out.
  88942. * This trigger will only be raised if you also declared a OnPickDown
  88943. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88944. */
  88945. static readonly OnPickOutTrigger: number;
  88946. /**
  88947. * On long press
  88948. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88949. */
  88950. static readonly OnLongPressTrigger: number;
  88951. /**
  88952. * On pointer over
  88953. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88954. */
  88955. static readonly OnPointerOverTrigger: number;
  88956. /**
  88957. * On pointer out
  88958. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88959. */
  88960. static readonly OnPointerOutTrigger: number;
  88961. /**
  88962. * On every frame
  88963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88964. */
  88965. static readonly OnEveryFrameTrigger: number;
  88966. /**
  88967. * On intersection enter
  88968. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88969. */
  88970. static readonly OnIntersectionEnterTrigger: number;
  88971. /**
  88972. * On intersection exit
  88973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88974. */
  88975. static readonly OnIntersectionExitTrigger: number;
  88976. /**
  88977. * On key down
  88978. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88979. */
  88980. static readonly OnKeyDownTrigger: number;
  88981. /**
  88982. * On key up
  88983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88984. */
  88985. static readonly OnKeyUpTrigger: number;
  88986. private _scene;
  88987. /**
  88988. * Creates a new action manager
  88989. * @param scene defines the hosting scene
  88990. */
  88991. constructor(scene: Scene);
  88992. /**
  88993. * Releases all associated resources
  88994. */
  88995. dispose(): void;
  88996. /**
  88997. * Gets hosting scene
  88998. * @returns the hosting scene
  88999. */
  89000. getScene(): Scene;
  89001. /**
  89002. * Does this action manager handles actions of any of the given triggers
  89003. * @param triggers defines the triggers to be tested
  89004. * @return a boolean indicating whether one (or more) of the triggers is handled
  89005. */
  89006. hasSpecificTriggers(triggers: number[]): boolean;
  89007. /**
  89008. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89009. * speed.
  89010. * @param triggerA defines the trigger to be tested
  89011. * @param triggerB defines the trigger to be tested
  89012. * @return a boolean indicating whether one (or more) of the triggers is handled
  89013. */
  89014. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89015. /**
  89016. * Does this action manager handles actions of a given trigger
  89017. * @param trigger defines the trigger to be tested
  89018. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89019. * @return whether the trigger is handled
  89020. */
  89021. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89022. /**
  89023. * Does this action manager has pointer triggers
  89024. */
  89025. get hasPointerTriggers(): boolean;
  89026. /**
  89027. * Does this action manager has pick triggers
  89028. */
  89029. get hasPickTriggers(): boolean;
  89030. /**
  89031. * Registers an action to this action manager
  89032. * @param action defines the action to be registered
  89033. * @return the action amended (prepared) after registration
  89034. */
  89035. registerAction(action: IAction): Nullable<IAction>;
  89036. /**
  89037. * Unregisters an action to this action manager
  89038. * @param action defines the action to be unregistered
  89039. * @return a boolean indicating whether the action has been unregistered
  89040. */
  89041. unregisterAction(action: IAction): Boolean;
  89042. /**
  89043. * Process a specific trigger
  89044. * @param trigger defines the trigger to process
  89045. * @param evt defines the event details to be processed
  89046. */
  89047. processTrigger(trigger: number, evt?: IActionEvent): void;
  89048. /** @hidden */
  89049. _getEffectiveTarget(target: any, propertyPath: string): any;
  89050. /** @hidden */
  89051. _getProperty(propertyPath: string): string;
  89052. /**
  89053. * Serialize this manager to a JSON object
  89054. * @param name defines the property name to store this manager
  89055. * @returns a JSON representation of this manager
  89056. */
  89057. serialize(name: string): any;
  89058. /**
  89059. * Creates a new ActionManager from a JSON data
  89060. * @param parsedActions defines the JSON data to read from
  89061. * @param object defines the hosting mesh
  89062. * @param scene defines the hosting scene
  89063. */
  89064. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89065. /**
  89066. * Get a trigger name by index
  89067. * @param trigger defines the trigger index
  89068. * @returns a trigger name
  89069. */
  89070. static GetTriggerName(trigger: number): string;
  89071. }
  89072. }
  89073. declare module BABYLON {
  89074. /**
  89075. * Class used to represent a sprite
  89076. * @see https://doc.babylonjs.com/babylon101/sprites
  89077. */
  89078. export class Sprite implements IAnimatable {
  89079. /** defines the name */
  89080. name: string;
  89081. /** Gets or sets the current world position */
  89082. position: Vector3;
  89083. /** Gets or sets the main color */
  89084. color: Color4;
  89085. /** Gets or sets the width */
  89086. width: number;
  89087. /** Gets or sets the height */
  89088. height: number;
  89089. /** Gets or sets rotation angle */
  89090. angle: number;
  89091. /** Gets or sets the cell index in the sprite sheet */
  89092. cellIndex: number;
  89093. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89094. cellRef: string;
  89095. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89096. invertU: boolean;
  89097. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89098. invertV: boolean;
  89099. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89100. disposeWhenFinishedAnimating: boolean;
  89101. /** Gets the list of attached animations */
  89102. animations: Nullable<Array<Animation>>;
  89103. /** Gets or sets a boolean indicating if the sprite can be picked */
  89104. isPickable: boolean;
  89105. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89106. useAlphaForPicking: boolean;
  89107. /** @hidden */
  89108. _xOffset: number;
  89109. /** @hidden */
  89110. _yOffset: number;
  89111. /** @hidden */
  89112. _xSize: number;
  89113. /** @hidden */
  89114. _ySize: number;
  89115. /**
  89116. * Gets or sets the associated action manager
  89117. */
  89118. actionManager: Nullable<ActionManager>;
  89119. /**
  89120. * An event triggered when the control has been disposed
  89121. */
  89122. onDisposeObservable: Observable<Sprite>;
  89123. private _animationStarted;
  89124. private _loopAnimation;
  89125. private _fromIndex;
  89126. private _toIndex;
  89127. private _delay;
  89128. private _direction;
  89129. private _manager;
  89130. private _time;
  89131. private _onAnimationEnd;
  89132. /**
  89133. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89134. */
  89135. isVisible: boolean;
  89136. /**
  89137. * Gets or sets the sprite size
  89138. */
  89139. get size(): number;
  89140. set size(value: number);
  89141. /**
  89142. * Returns a boolean indicating if the animation is started
  89143. */
  89144. get animationStarted(): boolean;
  89145. /**
  89146. * Gets or sets the unique id of the sprite
  89147. */
  89148. uniqueId: number;
  89149. /**
  89150. * Gets the manager of this sprite
  89151. */
  89152. get manager(): ISpriteManager;
  89153. /**
  89154. * Creates a new Sprite
  89155. * @param name defines the name
  89156. * @param manager defines the manager
  89157. */
  89158. constructor(
  89159. /** defines the name */
  89160. name: string, manager: ISpriteManager);
  89161. /**
  89162. * Returns the string "Sprite"
  89163. * @returns "Sprite"
  89164. */
  89165. getClassName(): string;
  89166. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89167. get fromIndex(): number;
  89168. set fromIndex(value: number);
  89169. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89170. get toIndex(): number;
  89171. set toIndex(value: number);
  89172. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89173. get loopAnimation(): boolean;
  89174. set loopAnimation(value: boolean);
  89175. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89176. get delay(): number;
  89177. set delay(value: number);
  89178. /**
  89179. * Starts an animation
  89180. * @param from defines the initial key
  89181. * @param to defines the end key
  89182. * @param loop defines if the animation must loop
  89183. * @param delay defines the start delay (in ms)
  89184. * @param onAnimationEnd defines a callback to call when animation ends
  89185. */
  89186. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89187. /** Stops current animation (if any) */
  89188. stopAnimation(): void;
  89189. /** @hidden */
  89190. _animate(deltaTime: number): void;
  89191. /** Release associated resources */
  89192. dispose(): void;
  89193. /**
  89194. * Serializes the sprite to a JSON object
  89195. * @returns the JSON object
  89196. */
  89197. serialize(): any;
  89198. /**
  89199. * Parses a JSON object to create a new sprite
  89200. * @param parsedSprite The JSON object to parse
  89201. * @param manager defines the hosting manager
  89202. * @returns the new sprite
  89203. */
  89204. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89205. }
  89206. }
  89207. declare module BABYLON {
  89208. /**
  89209. * Information about the result of picking within a scene
  89210. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89211. */
  89212. export class PickingInfo {
  89213. /** @hidden */
  89214. _pickingUnavailable: boolean;
  89215. /**
  89216. * If the pick collided with an object
  89217. */
  89218. hit: boolean;
  89219. /**
  89220. * Distance away where the pick collided
  89221. */
  89222. distance: number;
  89223. /**
  89224. * The location of pick collision
  89225. */
  89226. pickedPoint: Nullable<Vector3>;
  89227. /**
  89228. * The mesh corresponding the the pick collision
  89229. */
  89230. pickedMesh: Nullable<AbstractMesh>;
  89231. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89232. bu: number;
  89233. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89234. bv: number;
  89235. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89236. faceId: number;
  89237. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89238. subMeshFaceId: number;
  89239. /** Id of the the submesh that was picked */
  89240. subMeshId: number;
  89241. /** If a sprite was picked, this will be the sprite the pick collided with */
  89242. pickedSprite: Nullable<Sprite>;
  89243. /**
  89244. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89245. */
  89246. originMesh: Nullable<AbstractMesh>;
  89247. /**
  89248. * The ray that was used to perform the picking.
  89249. */
  89250. ray: Nullable<Ray>;
  89251. /**
  89252. * Gets the normal correspodning to the face the pick collided with
  89253. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89254. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89255. * @returns The normal correspodning to the face the pick collided with
  89256. */
  89257. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89258. /**
  89259. * Gets the texture coordinates of where the pick occured
  89260. * @returns the vector containing the coordnates of the texture
  89261. */
  89262. getTextureCoordinates(): Nullable<Vector2>;
  89263. }
  89264. }
  89265. declare module BABYLON {
  89266. /**
  89267. * Class representing a ray with position and direction
  89268. */
  89269. export class Ray {
  89270. /** origin point */
  89271. origin: Vector3;
  89272. /** direction */
  89273. direction: Vector3;
  89274. /** length of the ray */
  89275. length: number;
  89276. private static readonly TmpVector3;
  89277. private _tmpRay;
  89278. /**
  89279. * Creates a new ray
  89280. * @param origin origin point
  89281. * @param direction direction
  89282. * @param length length of the ray
  89283. */
  89284. constructor(
  89285. /** origin point */
  89286. origin: Vector3,
  89287. /** direction */
  89288. direction: Vector3,
  89289. /** length of the ray */
  89290. length?: number);
  89291. /**
  89292. * Checks if the ray intersects a box
  89293. * This does not account for the ray lenght by design to improve perfs.
  89294. * @param minimum bound of the box
  89295. * @param maximum bound of the box
  89296. * @param intersectionTreshold extra extend to be added to the box in all direction
  89297. * @returns if the box was hit
  89298. */
  89299. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89300. /**
  89301. * Checks if the ray intersects a box
  89302. * This does not account for the ray lenght by design to improve perfs.
  89303. * @param box the bounding box to check
  89304. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89305. * @returns if the box was hit
  89306. */
  89307. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89308. /**
  89309. * If the ray hits a sphere
  89310. * @param sphere the bounding sphere to check
  89311. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89312. * @returns true if it hits the sphere
  89313. */
  89314. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89315. /**
  89316. * If the ray hits a triange
  89317. * @param vertex0 triangle vertex
  89318. * @param vertex1 triangle vertex
  89319. * @param vertex2 triangle vertex
  89320. * @returns intersection information if hit
  89321. */
  89322. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89323. /**
  89324. * Checks if ray intersects a plane
  89325. * @param plane the plane to check
  89326. * @returns the distance away it was hit
  89327. */
  89328. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89329. /**
  89330. * Calculate the intercept of a ray on a given axis
  89331. * @param axis to check 'x' | 'y' | 'z'
  89332. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89333. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89334. */
  89335. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89336. /**
  89337. * Checks if ray intersects a mesh
  89338. * @param mesh the mesh to check
  89339. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89340. * @returns picking info of the intersecton
  89341. */
  89342. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89343. /**
  89344. * Checks if ray intersects a mesh
  89345. * @param meshes the meshes to check
  89346. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89347. * @param results array to store result in
  89348. * @returns Array of picking infos
  89349. */
  89350. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89351. private _comparePickingInfo;
  89352. private static smallnum;
  89353. private static rayl;
  89354. /**
  89355. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89356. * @param sega the first point of the segment to test the intersection against
  89357. * @param segb the second point of the segment to test the intersection against
  89358. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89359. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89360. */
  89361. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89362. /**
  89363. * Update the ray from viewport position
  89364. * @param x position
  89365. * @param y y position
  89366. * @param viewportWidth viewport width
  89367. * @param viewportHeight viewport height
  89368. * @param world world matrix
  89369. * @param view view matrix
  89370. * @param projection projection matrix
  89371. * @returns this ray updated
  89372. */
  89373. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89374. /**
  89375. * Creates a ray with origin and direction of 0,0,0
  89376. * @returns the new ray
  89377. */
  89378. static Zero(): Ray;
  89379. /**
  89380. * Creates a new ray from screen space and viewport
  89381. * @param x position
  89382. * @param y y position
  89383. * @param viewportWidth viewport width
  89384. * @param viewportHeight viewport height
  89385. * @param world world matrix
  89386. * @param view view matrix
  89387. * @param projection projection matrix
  89388. * @returns new ray
  89389. */
  89390. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89391. /**
  89392. * 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
  89393. * transformed to the given world matrix.
  89394. * @param origin The origin point
  89395. * @param end The end point
  89396. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89397. * @returns the new ray
  89398. */
  89399. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89400. /**
  89401. * Transforms a ray by a matrix
  89402. * @param ray ray to transform
  89403. * @param matrix matrix to apply
  89404. * @returns the resulting new ray
  89405. */
  89406. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89407. /**
  89408. * Transforms a ray by a matrix
  89409. * @param ray ray to transform
  89410. * @param matrix matrix to apply
  89411. * @param result ray to store result in
  89412. */
  89413. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89414. /**
  89415. * Unproject a ray from screen space to object space
  89416. * @param sourceX defines the screen space x coordinate to use
  89417. * @param sourceY defines the screen space y coordinate to use
  89418. * @param viewportWidth defines the current width of the viewport
  89419. * @param viewportHeight defines the current height of the viewport
  89420. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89421. * @param view defines the view matrix to use
  89422. * @param projection defines the projection matrix to use
  89423. */
  89424. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89425. }
  89426. /**
  89427. * Type used to define predicate used to select faces when a mesh intersection is detected
  89428. */
  89429. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89430. interface Scene {
  89431. /** @hidden */
  89432. _tempPickingRay: Nullable<Ray>;
  89433. /** @hidden */
  89434. _cachedRayForTransform: Ray;
  89435. /** @hidden */
  89436. _pickWithRayInverseMatrix: Matrix;
  89437. /** @hidden */
  89438. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89439. /** @hidden */
  89440. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89441. }
  89442. }
  89443. declare module BABYLON {
  89444. /**
  89445. * Groups all the scene component constants in one place to ease maintenance.
  89446. * @hidden
  89447. */
  89448. export class SceneComponentConstants {
  89449. static readonly NAME_EFFECTLAYER: string;
  89450. static readonly NAME_LAYER: string;
  89451. static readonly NAME_LENSFLARESYSTEM: string;
  89452. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89453. static readonly NAME_PARTICLESYSTEM: string;
  89454. static readonly NAME_GAMEPAD: string;
  89455. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89456. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89457. static readonly NAME_PREPASSRENDERER: string;
  89458. static readonly NAME_DEPTHRENDERER: string;
  89459. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89460. static readonly NAME_SPRITE: string;
  89461. static readonly NAME_OUTLINERENDERER: string;
  89462. static readonly NAME_PROCEDURALTEXTURE: string;
  89463. static readonly NAME_SHADOWGENERATOR: string;
  89464. static readonly NAME_OCTREE: string;
  89465. static readonly NAME_PHYSICSENGINE: string;
  89466. static readonly NAME_AUDIO: string;
  89467. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89468. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89469. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89470. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89471. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89472. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89473. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89474. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89475. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89476. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89477. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89478. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89479. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89480. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89481. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89482. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89483. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89484. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89485. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89486. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89487. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89488. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89489. static readonly STEP_AFTERRENDER_AUDIO: number;
  89490. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89491. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89492. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89493. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89494. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89495. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89496. static readonly STEP_POINTERMOVE_SPRITE: number;
  89497. static readonly STEP_POINTERDOWN_SPRITE: number;
  89498. static readonly STEP_POINTERUP_SPRITE: number;
  89499. }
  89500. /**
  89501. * This represents a scene component.
  89502. *
  89503. * This is used to decouple the dependency the scene is having on the different workloads like
  89504. * layers, post processes...
  89505. */
  89506. export interface ISceneComponent {
  89507. /**
  89508. * The name of the component. Each component must have a unique name.
  89509. */
  89510. name: string;
  89511. /**
  89512. * The scene the component belongs to.
  89513. */
  89514. scene: Scene;
  89515. /**
  89516. * Register the component to one instance of a scene.
  89517. */
  89518. register(): void;
  89519. /**
  89520. * Rebuilds the elements related to this component in case of
  89521. * context lost for instance.
  89522. */
  89523. rebuild(): void;
  89524. /**
  89525. * Disposes the component and the associated ressources.
  89526. */
  89527. dispose(): void;
  89528. }
  89529. /**
  89530. * This represents a SERIALIZABLE scene component.
  89531. *
  89532. * This extends Scene Component to add Serialization methods on top.
  89533. */
  89534. export interface ISceneSerializableComponent extends ISceneComponent {
  89535. /**
  89536. * Adds all the elements from the container to the scene
  89537. * @param container the container holding the elements
  89538. */
  89539. addFromContainer(container: AbstractScene): void;
  89540. /**
  89541. * Removes all the elements in the container from the scene
  89542. * @param container contains the elements to remove
  89543. * @param dispose if the removed element should be disposed (default: false)
  89544. */
  89545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89546. /**
  89547. * Serializes the component data to the specified json object
  89548. * @param serializationObject The object to serialize to
  89549. */
  89550. serialize(serializationObject: any): void;
  89551. }
  89552. /**
  89553. * Strong typing of a Mesh related stage step action
  89554. */
  89555. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89556. /**
  89557. * Strong typing of a Evaluate Sub Mesh related stage step action
  89558. */
  89559. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89560. /**
  89561. * Strong typing of a Active Mesh related stage step action
  89562. */
  89563. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89564. /**
  89565. * Strong typing of a Camera related stage step action
  89566. */
  89567. export type CameraStageAction = (camera: Camera) => void;
  89568. /**
  89569. * Strong typing of a Camera Frame buffer related stage step action
  89570. */
  89571. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89572. /**
  89573. * Strong typing of a Render Target related stage step action
  89574. */
  89575. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89576. /**
  89577. * Strong typing of a RenderingGroup related stage step action
  89578. */
  89579. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89580. /**
  89581. * Strong typing of a Mesh Render related stage step action
  89582. */
  89583. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89584. /**
  89585. * Strong typing of a simple stage step action
  89586. */
  89587. export type SimpleStageAction = () => void;
  89588. /**
  89589. * Strong typing of a render target action.
  89590. */
  89591. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89592. /**
  89593. * Strong typing of a pointer move action.
  89594. */
  89595. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89596. /**
  89597. * Strong typing of a pointer up/down action.
  89598. */
  89599. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89600. /**
  89601. * Representation of a stage in the scene (Basically a list of ordered steps)
  89602. * @hidden
  89603. */
  89604. export class Stage<T extends Function> extends Array<{
  89605. index: number;
  89606. component: ISceneComponent;
  89607. action: T;
  89608. }> {
  89609. /**
  89610. * Hide ctor from the rest of the world.
  89611. * @param items The items to add.
  89612. */
  89613. private constructor();
  89614. /**
  89615. * Creates a new Stage.
  89616. * @returns A new instance of a Stage
  89617. */
  89618. static Create<T extends Function>(): Stage<T>;
  89619. /**
  89620. * Registers a step in an ordered way in the targeted stage.
  89621. * @param index Defines the position to register the step in
  89622. * @param component Defines the component attached to the step
  89623. * @param action Defines the action to launch during the step
  89624. */
  89625. registerStep(index: number, component: ISceneComponent, action: T): void;
  89626. /**
  89627. * Clears all the steps from the stage.
  89628. */
  89629. clear(): void;
  89630. }
  89631. }
  89632. declare module BABYLON {
  89633. interface Scene {
  89634. /** @hidden */
  89635. _pointerOverSprite: Nullable<Sprite>;
  89636. /** @hidden */
  89637. _pickedDownSprite: Nullable<Sprite>;
  89638. /** @hidden */
  89639. _tempSpritePickingRay: Nullable<Ray>;
  89640. /**
  89641. * All of the sprite managers added to this scene
  89642. * @see https://doc.babylonjs.com/babylon101/sprites
  89643. */
  89644. spriteManagers: Array<ISpriteManager>;
  89645. /**
  89646. * An event triggered when sprites rendering is about to start
  89647. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89648. */
  89649. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89650. /**
  89651. * An event triggered when sprites rendering is done
  89652. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89653. */
  89654. onAfterSpritesRenderingObservable: Observable<Scene>;
  89655. /** @hidden */
  89656. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89657. /** Launch a ray to try to pick a sprite in the scene
  89658. * @param x position on screen
  89659. * @param y position on screen
  89660. * @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
  89661. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89662. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89663. * @returns a PickingInfo
  89664. */
  89665. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89666. /** Use the given ray to pick a sprite in the scene
  89667. * @param ray The ray (in world space) to use to pick meshes
  89668. * @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
  89669. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89670. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89671. * @returns a PickingInfo
  89672. */
  89673. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89674. /** @hidden */
  89675. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89676. /** Launch a ray to try to pick sprites in the scene
  89677. * @param x position on screen
  89678. * @param y position on screen
  89679. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  89680. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89681. * @returns a PickingInfo array
  89682. */
  89683. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89684. /** Use the given ray to pick sprites in the scene
  89685. * @param ray The ray (in world space) to use to pick meshes
  89686. * @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
  89687. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89688. * @returns a PickingInfo array
  89689. */
  89690. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89691. /**
  89692. * Force the sprite under the pointer
  89693. * @param sprite defines the sprite to use
  89694. */
  89695. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89696. /**
  89697. * Gets the sprite under the pointer
  89698. * @returns a Sprite or null if no sprite is under the pointer
  89699. */
  89700. getPointerOverSprite(): Nullable<Sprite>;
  89701. }
  89702. /**
  89703. * Defines the sprite scene component responsible to manage sprites
  89704. * in a given scene.
  89705. */
  89706. export class SpriteSceneComponent implements ISceneComponent {
  89707. /**
  89708. * The component name helpfull to identify the component in the list of scene components.
  89709. */
  89710. readonly name: string;
  89711. /**
  89712. * The scene the component belongs to.
  89713. */
  89714. scene: Scene;
  89715. /** @hidden */
  89716. private _spritePredicate;
  89717. /**
  89718. * Creates a new instance of the component for the given scene
  89719. * @param scene Defines the scene to register the component in
  89720. */
  89721. constructor(scene: Scene);
  89722. /**
  89723. * Registers the component in a given scene
  89724. */
  89725. register(): void;
  89726. /**
  89727. * Rebuilds the elements related to this component in case of
  89728. * context lost for instance.
  89729. */
  89730. rebuild(): void;
  89731. /**
  89732. * Disposes the component and the associated ressources.
  89733. */
  89734. dispose(): void;
  89735. private _pickSpriteButKeepRay;
  89736. private _pointerMove;
  89737. private _pointerDown;
  89738. private _pointerUp;
  89739. }
  89740. }
  89741. declare module BABYLON {
  89742. /** @hidden */
  89743. export var fogFragmentDeclaration: {
  89744. name: string;
  89745. shader: string;
  89746. };
  89747. }
  89748. declare module BABYLON {
  89749. /** @hidden */
  89750. export var fogFragment: {
  89751. name: string;
  89752. shader: string;
  89753. };
  89754. }
  89755. declare module BABYLON {
  89756. /** @hidden */
  89757. export var spritesPixelShader: {
  89758. name: string;
  89759. shader: string;
  89760. };
  89761. }
  89762. declare module BABYLON {
  89763. /** @hidden */
  89764. export var fogVertexDeclaration: {
  89765. name: string;
  89766. shader: string;
  89767. };
  89768. }
  89769. declare module BABYLON {
  89770. /** @hidden */
  89771. export var spritesVertexShader: {
  89772. name: string;
  89773. shader: string;
  89774. };
  89775. }
  89776. declare module BABYLON {
  89777. /**
  89778. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89779. */
  89780. export interface ISpriteManager extends IDisposable {
  89781. /**
  89782. * Gets manager's name
  89783. */
  89784. name: string;
  89785. /**
  89786. * Restricts the camera to viewing objects with the same layerMask.
  89787. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89788. */
  89789. layerMask: number;
  89790. /**
  89791. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89792. */
  89793. isPickable: boolean;
  89794. /**
  89795. * Gets the hosting scene
  89796. */
  89797. scene: Scene;
  89798. /**
  89799. * Specifies the rendering group id for this mesh (0 by default)
  89800. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89801. */
  89802. renderingGroupId: number;
  89803. /**
  89804. * Defines the list of sprites managed by the manager.
  89805. */
  89806. sprites: Array<Sprite>;
  89807. /**
  89808. * Gets or sets the spritesheet texture
  89809. */
  89810. texture: Texture;
  89811. /** Defines the default width of a cell in the spritesheet */
  89812. cellWidth: number;
  89813. /** Defines the default height of a cell in the spritesheet */
  89814. cellHeight: number;
  89815. /**
  89816. * Tests the intersection of a sprite with a specific ray.
  89817. * @param ray The ray we are sending to test the collision
  89818. * @param camera The camera space we are sending rays in
  89819. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89820. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89821. * @returns picking info or null.
  89822. */
  89823. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89824. /**
  89825. * Intersects the sprites with a ray
  89826. * @param ray defines the ray to intersect with
  89827. * @param camera defines the current active camera
  89828. * @param predicate defines a predicate used to select candidate sprites
  89829. * @returns null if no hit or a PickingInfo array
  89830. */
  89831. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89832. /**
  89833. * Renders the list of sprites on screen.
  89834. */
  89835. render(): void;
  89836. }
  89837. /**
  89838. * Class used to manage multiple sprites on the same spritesheet
  89839. * @see https://doc.babylonjs.com/babylon101/sprites
  89840. */
  89841. export class SpriteManager implements ISpriteManager {
  89842. /** defines the manager's name */
  89843. name: string;
  89844. /** Define the Url to load snippets */
  89845. static SnippetUrl: string;
  89846. /** Snippet ID if the manager was created from the snippet server */
  89847. snippetId: string;
  89848. /** Gets the list of sprites */
  89849. sprites: Sprite[];
  89850. /** Gets or sets the rendering group id (0 by default) */
  89851. renderingGroupId: number;
  89852. /** Gets or sets camera layer mask */
  89853. layerMask: number;
  89854. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89855. fogEnabled: boolean;
  89856. /** Gets or sets a boolean indicating if the sprites are pickable */
  89857. isPickable: boolean;
  89858. /** Defines the default width of a cell in the spritesheet */
  89859. cellWidth: number;
  89860. /** Defines the default height of a cell in the spritesheet */
  89861. cellHeight: number;
  89862. /** Associative array from JSON sprite data file */
  89863. private _cellData;
  89864. /** Array of sprite names from JSON sprite data file */
  89865. private _spriteMap;
  89866. /** True when packed cell data from JSON file is ready*/
  89867. private _packedAndReady;
  89868. private _textureContent;
  89869. /**
  89870. * An event triggered when the manager is disposed.
  89871. */
  89872. onDisposeObservable: Observable<SpriteManager>;
  89873. private _onDisposeObserver;
  89874. /**
  89875. * Callback called when the manager is disposed
  89876. */
  89877. set onDispose(callback: () => void);
  89878. private _capacity;
  89879. private _fromPacked;
  89880. private _spriteTexture;
  89881. private _epsilon;
  89882. private _scene;
  89883. private _vertexData;
  89884. private _buffer;
  89885. private _vertexBuffers;
  89886. private _indexBuffer;
  89887. private _effectBase;
  89888. private _effectFog;
  89889. /**
  89890. * Gets or sets the unique id of the sprite
  89891. */
  89892. uniqueId: number;
  89893. /**
  89894. * Gets the array of sprites
  89895. */
  89896. get children(): Sprite[];
  89897. /**
  89898. * Gets the hosting scene
  89899. */
  89900. get scene(): Scene;
  89901. /**
  89902. * Gets the capacity of the manager
  89903. */
  89904. get capacity(): number;
  89905. /**
  89906. * Gets or sets the spritesheet texture
  89907. */
  89908. get texture(): Texture;
  89909. set texture(value: Texture);
  89910. private _blendMode;
  89911. /**
  89912. * Blend mode use to render the particle, it can be any of
  89913. * the static Constants.ALPHA_x properties provided in this class.
  89914. * Default value is Constants.ALPHA_COMBINE
  89915. */
  89916. get blendMode(): number;
  89917. set blendMode(blendMode: number);
  89918. /** Disables writing to the depth buffer when rendering the sprites.
  89919. * It can be handy to disable depth writing when using textures without alpha channel
  89920. * and setting some specific blend modes.
  89921. */
  89922. disableDepthWrite: boolean;
  89923. /**
  89924. * Creates a new sprite manager
  89925. * @param name defines the manager's name
  89926. * @param imgUrl defines the sprite sheet url
  89927. * @param capacity defines the maximum allowed number of sprites
  89928. * @param cellSize defines the size of a sprite cell
  89929. * @param scene defines the hosting scene
  89930. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89931. * @param samplingMode defines the smapling mode to use with spritesheet
  89932. * @param fromPacked set to false; do not alter
  89933. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89934. */
  89935. constructor(
  89936. /** defines the manager's name */
  89937. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89938. /**
  89939. * Returns the string "SpriteManager"
  89940. * @returns "SpriteManager"
  89941. */
  89942. getClassName(): string;
  89943. private _makePacked;
  89944. private _appendSpriteVertex;
  89945. private _checkTextureAlpha;
  89946. /**
  89947. * Intersects the sprites with a ray
  89948. * @param ray defines the ray to intersect with
  89949. * @param camera defines the current active camera
  89950. * @param predicate defines a predicate used to select candidate sprites
  89951. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89952. * @returns null if no hit or a PickingInfo
  89953. */
  89954. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89955. /**
  89956. * Intersects the sprites with a ray
  89957. * @param ray defines the ray to intersect with
  89958. * @param camera defines the current active camera
  89959. * @param predicate defines a predicate used to select candidate sprites
  89960. * @returns null if no hit or a PickingInfo array
  89961. */
  89962. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89963. /**
  89964. * Render all child sprites
  89965. */
  89966. render(): void;
  89967. /**
  89968. * Release associated resources
  89969. */
  89970. dispose(): void;
  89971. /**
  89972. * Serializes the sprite manager to a JSON object
  89973. * @param serializeTexture defines if the texture must be serialized as well
  89974. * @returns the JSON object
  89975. */
  89976. serialize(serializeTexture?: boolean): any;
  89977. /**
  89978. * Parses a JSON object to create a new sprite manager.
  89979. * @param parsedManager The JSON object to parse
  89980. * @param scene The scene to create the sprite managerin
  89981. * @param rootUrl The root url to use to load external dependencies like texture
  89982. * @returns the new sprite manager
  89983. */
  89984. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89985. /**
  89986. * Creates a sprite manager from a snippet saved in a remote file
  89987. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89988. * @param url defines the url to load from
  89989. * @param scene defines the hosting scene
  89990. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89991. * @returns a promise that will resolve to the new sprite manager
  89992. */
  89993. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89994. /**
  89995. * Creates a sprite manager from a snippet saved by the sprite editor
  89996. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  89997. * @param scene defines the hosting scene
  89998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89999. * @returns a promise that will resolve to the new sprite manager
  90000. */
  90001. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90002. }
  90003. }
  90004. declare module BABYLON {
  90005. /** Interface used by value gradients (color, factor, ...) */
  90006. export interface IValueGradient {
  90007. /**
  90008. * Gets or sets the gradient value (between 0 and 1)
  90009. */
  90010. gradient: number;
  90011. }
  90012. /** Class used to store color4 gradient */
  90013. export class ColorGradient implements IValueGradient {
  90014. /**
  90015. * Gets or sets the gradient value (between 0 and 1)
  90016. */
  90017. gradient: number;
  90018. /**
  90019. * Gets or sets first associated color
  90020. */
  90021. color1: Color4;
  90022. /**
  90023. * Gets or sets second associated color
  90024. */
  90025. color2?: Color4 | undefined;
  90026. /**
  90027. * Creates a new color4 gradient
  90028. * @param gradient gets or sets the gradient value (between 0 and 1)
  90029. * @param color1 gets or sets first associated color
  90030. * @param color2 gets or sets first second color
  90031. */
  90032. constructor(
  90033. /**
  90034. * Gets or sets the gradient value (between 0 and 1)
  90035. */
  90036. gradient: number,
  90037. /**
  90038. * Gets or sets first associated color
  90039. */
  90040. color1: Color4,
  90041. /**
  90042. * Gets or sets second associated color
  90043. */
  90044. color2?: Color4 | undefined);
  90045. /**
  90046. * Will get a color picked randomly between color1 and color2.
  90047. * If color2 is undefined then color1 will be used
  90048. * @param result defines the target Color4 to store the result in
  90049. */
  90050. getColorToRef(result: Color4): void;
  90051. }
  90052. /** Class used to store color 3 gradient */
  90053. export class Color3Gradient implements IValueGradient {
  90054. /**
  90055. * Gets or sets the gradient value (between 0 and 1)
  90056. */
  90057. gradient: number;
  90058. /**
  90059. * Gets or sets the associated color
  90060. */
  90061. color: Color3;
  90062. /**
  90063. * Creates a new color3 gradient
  90064. * @param gradient gets or sets the gradient value (between 0 and 1)
  90065. * @param color gets or sets associated color
  90066. */
  90067. constructor(
  90068. /**
  90069. * Gets or sets the gradient value (between 0 and 1)
  90070. */
  90071. gradient: number,
  90072. /**
  90073. * Gets or sets the associated color
  90074. */
  90075. color: Color3);
  90076. }
  90077. /** Class used to store factor gradient */
  90078. export class FactorGradient implements IValueGradient {
  90079. /**
  90080. * Gets or sets the gradient value (between 0 and 1)
  90081. */
  90082. gradient: number;
  90083. /**
  90084. * Gets or sets first associated factor
  90085. */
  90086. factor1: number;
  90087. /**
  90088. * Gets or sets second associated factor
  90089. */
  90090. factor2?: number | undefined;
  90091. /**
  90092. * Creates a new factor gradient
  90093. * @param gradient gets or sets the gradient value (between 0 and 1)
  90094. * @param factor1 gets or sets first associated factor
  90095. * @param factor2 gets or sets second associated factor
  90096. */
  90097. constructor(
  90098. /**
  90099. * Gets or sets the gradient value (between 0 and 1)
  90100. */
  90101. gradient: number,
  90102. /**
  90103. * Gets or sets first associated factor
  90104. */
  90105. factor1: number,
  90106. /**
  90107. * Gets or sets second associated factor
  90108. */
  90109. factor2?: number | undefined);
  90110. /**
  90111. * Will get a number picked randomly between factor1 and factor2.
  90112. * If factor2 is undefined then factor1 will be used
  90113. * @returns the picked number
  90114. */
  90115. getFactor(): number;
  90116. }
  90117. /**
  90118. * Helper used to simplify some generic gradient tasks
  90119. */
  90120. export class GradientHelper {
  90121. /**
  90122. * Gets the current gradient from an array of IValueGradient
  90123. * @param ratio defines the current ratio to get
  90124. * @param gradients defines the array of IValueGradient
  90125. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90126. */
  90127. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90128. }
  90129. }
  90130. declare module BABYLON {
  90131. interface ThinEngine {
  90132. /**
  90133. * Creates a raw texture
  90134. * @param data defines the data to store in the texture
  90135. * @param width defines the width of the texture
  90136. * @param height defines the height of the texture
  90137. * @param format defines the format of the data
  90138. * @param generateMipMaps defines if the engine should generate the mip levels
  90139. * @param invertY defines if data must be stored with Y axis inverted
  90140. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90141. * @param compression defines the compression used (null by default)
  90142. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90143. * @returns the raw texture inside an InternalTexture
  90144. */
  90145. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90146. /**
  90147. * Update a raw texture
  90148. * @param texture defines the texture to update
  90149. * @param data defines the data to store in the texture
  90150. * @param format defines the format of the data
  90151. * @param invertY defines if data must be stored with Y axis inverted
  90152. */
  90153. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90154. /**
  90155. * Update a raw texture
  90156. * @param texture defines the texture to update
  90157. * @param data defines the data to store in the texture
  90158. * @param format defines the format of the data
  90159. * @param invertY defines if data must be stored with Y axis inverted
  90160. * @param compression defines the compression used (null by default)
  90161. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90162. */
  90163. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90164. /**
  90165. * Creates a new raw cube texture
  90166. * @param data defines the array of data to use to create each face
  90167. * @param size defines the size of the textures
  90168. * @param format defines the format of the data
  90169. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90170. * @param generateMipMaps defines if the engine should generate the mip levels
  90171. * @param invertY defines if data must be stored with Y axis inverted
  90172. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90173. * @param compression defines the compression used (null by default)
  90174. * @returns the cube texture as an InternalTexture
  90175. */
  90176. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90177. /**
  90178. * Update a raw cube texture
  90179. * @param texture defines the texture to udpdate
  90180. * @param data defines the data to store
  90181. * @param format defines the data format
  90182. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90183. * @param invertY defines if data must be stored with Y axis inverted
  90184. */
  90185. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90186. /**
  90187. * Update a raw cube texture
  90188. * @param texture defines the texture to udpdate
  90189. * @param data defines the data to store
  90190. * @param format defines the data format
  90191. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90192. * @param invertY defines if data must be stored with Y axis inverted
  90193. * @param compression defines the compression used (null by default)
  90194. */
  90195. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90196. /**
  90197. * Update a raw cube texture
  90198. * @param texture defines the texture to udpdate
  90199. * @param data defines the data to store
  90200. * @param format defines the data format
  90201. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90202. * @param invertY defines if data must be stored with Y axis inverted
  90203. * @param compression defines the compression used (null by default)
  90204. * @param level defines which level of the texture to update
  90205. */
  90206. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90207. /**
  90208. * Creates a new raw cube texture from a specified url
  90209. * @param url defines the url where the data is located
  90210. * @param scene defines the current scene
  90211. * @param size defines the size of the textures
  90212. * @param format defines the format of the data
  90213. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90214. * @param noMipmap defines if the engine should avoid generating the mip levels
  90215. * @param callback defines a callback used to extract texture data from loaded data
  90216. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90217. * @param onLoad defines a callback called when texture is loaded
  90218. * @param onError defines a callback called if there is an error
  90219. * @returns the cube texture as an InternalTexture
  90220. */
  90221. 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;
  90222. /**
  90223. * Creates a new raw cube texture from a specified url
  90224. * @param url defines the url where the data is located
  90225. * @param scene defines the current scene
  90226. * @param size defines the size of the textures
  90227. * @param format defines the format of the data
  90228. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90229. * @param noMipmap defines if the engine should avoid generating the mip levels
  90230. * @param callback defines a callback used to extract texture data from loaded data
  90231. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90232. * @param onLoad defines a callback called when texture is loaded
  90233. * @param onError defines a callback called if there is an error
  90234. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90235. * @param invertY defines if data must be stored with Y axis inverted
  90236. * @returns the cube texture as an InternalTexture
  90237. */
  90238. 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;
  90239. /**
  90240. * Creates a new raw 3D texture
  90241. * @param data defines the data used to create the texture
  90242. * @param width defines the width of the texture
  90243. * @param height defines the height of the texture
  90244. * @param depth defines the depth of the texture
  90245. * @param format defines the format of the texture
  90246. * @param generateMipMaps defines if the engine must generate mip levels
  90247. * @param invertY defines if data must be stored with Y axis inverted
  90248. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90249. * @param compression defines the compressed used (can be null)
  90250. * @param textureType defines the compressed used (can be null)
  90251. * @returns a new raw 3D texture (stored in an InternalTexture)
  90252. */
  90253. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90254. /**
  90255. * Update a raw 3D texture
  90256. * @param texture defines the texture to update
  90257. * @param data defines the data to store
  90258. * @param format defines the data format
  90259. * @param invertY defines if data must be stored with Y axis inverted
  90260. */
  90261. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90262. /**
  90263. * Update a raw 3D texture
  90264. * @param texture defines the texture to update
  90265. * @param data defines the data to store
  90266. * @param format defines the data format
  90267. * @param invertY defines if data must be stored with Y axis inverted
  90268. * @param compression defines the used compression (can be null)
  90269. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90270. */
  90271. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90272. /**
  90273. * Creates a new raw 2D array texture
  90274. * @param data defines the data used to create the texture
  90275. * @param width defines the width of the texture
  90276. * @param height defines the height of the texture
  90277. * @param depth defines the number of layers of the texture
  90278. * @param format defines the format of the texture
  90279. * @param generateMipMaps defines if the engine must generate mip levels
  90280. * @param invertY defines if data must be stored with Y axis inverted
  90281. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90282. * @param compression defines the compressed used (can be null)
  90283. * @param textureType defines the compressed used (can be null)
  90284. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90285. */
  90286. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90287. /**
  90288. * Update a raw 2D array texture
  90289. * @param texture defines the texture to update
  90290. * @param data defines the data to store
  90291. * @param format defines the data format
  90292. * @param invertY defines if data must be stored with Y axis inverted
  90293. */
  90294. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90295. /**
  90296. * Update a raw 2D array texture
  90297. * @param texture defines the texture to update
  90298. * @param data defines the data to store
  90299. * @param format defines the data format
  90300. * @param invertY defines if data must be stored with Y axis inverted
  90301. * @param compression defines the used compression (can be null)
  90302. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90303. */
  90304. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90305. }
  90306. }
  90307. declare module BABYLON {
  90308. /**
  90309. * Raw texture can help creating a texture directly from an array of data.
  90310. * This can be super useful if you either get the data from an uncompressed source or
  90311. * if you wish to create your texture pixel by pixel.
  90312. */
  90313. export class RawTexture extends Texture {
  90314. /**
  90315. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90316. */
  90317. format: number;
  90318. /**
  90319. * Instantiates a new RawTexture.
  90320. * Raw texture can help creating a texture directly from an array of data.
  90321. * This can be super useful if you either get the data from an uncompressed source or
  90322. * if you wish to create your texture pixel by pixel.
  90323. * @param data define the array of data to use to create the texture
  90324. * @param width define the width of the texture
  90325. * @param height define the height of the texture
  90326. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90327. * @param scene define the scene the texture belongs to
  90328. * @param generateMipMaps define whether mip maps should be generated or not
  90329. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90330. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90331. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90332. */
  90333. constructor(data: ArrayBufferView, width: number, height: number,
  90334. /**
  90335. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90336. */
  90337. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90338. /**
  90339. * Updates the texture underlying data.
  90340. * @param data Define the new data of the texture
  90341. */
  90342. update(data: ArrayBufferView): void;
  90343. /**
  90344. * Creates a luminance texture from some data.
  90345. * @param data Define the texture data
  90346. * @param width Define the width of the texture
  90347. * @param height Define the height of the texture
  90348. * @param scene Define the scene the texture belongs to
  90349. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90350. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90351. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90352. * @returns the luminance texture
  90353. */
  90354. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90355. /**
  90356. * Creates a luminance alpha texture from some data.
  90357. * @param data Define the texture data
  90358. * @param width Define the width of the texture
  90359. * @param height Define the height of the texture
  90360. * @param scene Define the scene the texture belongs to
  90361. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90362. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90363. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90364. * @returns the luminance alpha texture
  90365. */
  90366. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90367. /**
  90368. * Creates an alpha texture from some data.
  90369. * @param data Define the texture data
  90370. * @param width Define the width of the texture
  90371. * @param height Define the height of the texture
  90372. * @param scene Define the scene the texture belongs to
  90373. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90374. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90375. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90376. * @returns the alpha texture
  90377. */
  90378. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90379. /**
  90380. * Creates a RGB texture from some data.
  90381. * @param data Define the texture data
  90382. * @param width Define the width of the texture
  90383. * @param height Define the height of the texture
  90384. * @param scene Define the scene the texture belongs to
  90385. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90386. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90387. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90388. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90389. * @returns the RGB alpha texture
  90390. */
  90391. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90392. /**
  90393. * Creates a RGBA texture from some data.
  90394. * @param data Define the texture data
  90395. * @param width Define the width of the texture
  90396. * @param height Define the height of the texture
  90397. * @param scene Define the scene the texture belongs to
  90398. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90399. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90400. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90401. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90402. * @returns the RGBA texture
  90403. */
  90404. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90405. /**
  90406. * Creates a R texture from some data.
  90407. * @param data Define the texture data
  90408. * @param width Define the width of the texture
  90409. * @param height Define the height of the texture
  90410. * @param scene Define the scene the texture belongs to
  90411. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90414. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90415. * @returns the R texture
  90416. */
  90417. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90418. }
  90419. }
  90420. declare module BABYLON {
  90421. interface AbstractScene {
  90422. /**
  90423. * The list of procedural textures added to the scene
  90424. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90425. */
  90426. proceduralTextures: Array<ProceduralTexture>;
  90427. }
  90428. /**
  90429. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90430. * in a given scene.
  90431. */
  90432. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90433. /**
  90434. * The component name helpfull to identify the component in the list of scene components.
  90435. */
  90436. readonly name: string;
  90437. /**
  90438. * The scene the component belongs to.
  90439. */
  90440. scene: Scene;
  90441. /**
  90442. * Creates a new instance of the component for the given scene
  90443. * @param scene Defines the scene to register the component in
  90444. */
  90445. constructor(scene: Scene);
  90446. /**
  90447. * Registers the component in a given scene
  90448. */
  90449. register(): void;
  90450. /**
  90451. * Rebuilds the elements related to this component in case of
  90452. * context lost for instance.
  90453. */
  90454. rebuild(): void;
  90455. /**
  90456. * Disposes the component and the associated ressources.
  90457. */
  90458. dispose(): void;
  90459. private _beforeClear;
  90460. }
  90461. }
  90462. declare module BABYLON {
  90463. interface ThinEngine {
  90464. /**
  90465. * Creates a new render target cube texture
  90466. * @param size defines the size of the texture
  90467. * @param options defines the options used to create the texture
  90468. * @returns a new render target cube texture stored in an InternalTexture
  90469. */
  90470. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90471. }
  90472. }
  90473. declare module BABYLON {
  90474. /** @hidden */
  90475. export var proceduralVertexShader: {
  90476. name: string;
  90477. shader: string;
  90478. };
  90479. }
  90480. declare module BABYLON {
  90481. /**
  90482. * 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.
  90483. * This is the base class of any Procedural texture and contains most of the shareable code.
  90484. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90485. */
  90486. export class ProceduralTexture extends Texture {
  90487. isCube: boolean;
  90488. /**
  90489. * Define if the texture is enabled or not (disabled texture will not render)
  90490. */
  90491. isEnabled: boolean;
  90492. /**
  90493. * Define if the texture must be cleared before rendering (default is true)
  90494. */
  90495. autoClear: boolean;
  90496. /**
  90497. * Callback called when the texture is generated
  90498. */
  90499. onGenerated: () => void;
  90500. /**
  90501. * Event raised when the texture is generated
  90502. */
  90503. onGeneratedObservable: Observable<ProceduralTexture>;
  90504. /** @hidden */
  90505. _generateMipMaps: boolean;
  90506. /** @hidden **/
  90507. _effect: Effect;
  90508. /** @hidden */
  90509. _textures: {
  90510. [key: string]: Texture;
  90511. };
  90512. /** @hidden */
  90513. protected _fallbackTexture: Nullable<Texture>;
  90514. private _size;
  90515. private _currentRefreshId;
  90516. private _frameId;
  90517. private _refreshRate;
  90518. private _vertexBuffers;
  90519. private _indexBuffer;
  90520. private _uniforms;
  90521. private _samplers;
  90522. private _fragment;
  90523. private _floats;
  90524. private _ints;
  90525. private _floatsArrays;
  90526. private _colors3;
  90527. private _colors4;
  90528. private _vectors2;
  90529. private _vectors3;
  90530. private _matrices;
  90531. private _fallbackTextureUsed;
  90532. private _fullEngine;
  90533. private _cachedDefines;
  90534. private _contentUpdateId;
  90535. private _contentData;
  90536. /**
  90537. * Instantiates a new procedural texture.
  90538. * 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.
  90539. * This is the base class of any Procedural texture and contains most of the shareable code.
  90540. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90541. * @param name Define the name of the texture
  90542. * @param size Define the size of the texture to create
  90543. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90544. * @param scene Define the scene the texture belongs to
  90545. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90546. * @param generateMipMaps Define if the texture should creates mip maps or not
  90547. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90548. */
  90549. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90550. /**
  90551. * The effect that is created when initializing the post process.
  90552. * @returns The created effect corresponding the the postprocess.
  90553. */
  90554. getEffect(): Effect;
  90555. /**
  90556. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90557. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90558. */
  90559. getContent(): Nullable<ArrayBufferView>;
  90560. private _createIndexBuffer;
  90561. /** @hidden */
  90562. _rebuild(): void;
  90563. /**
  90564. * Resets the texture in order to recreate its associated resources.
  90565. * This can be called in case of context loss
  90566. */
  90567. reset(): void;
  90568. protected _getDefines(): string;
  90569. /**
  90570. * Is the texture ready to be used ? (rendered at least once)
  90571. * @returns true if ready, otherwise, false.
  90572. */
  90573. isReady(): boolean;
  90574. /**
  90575. * Resets the refresh counter of the texture and start bak from scratch.
  90576. * Could be useful to regenerate the texture if it is setup to render only once.
  90577. */
  90578. resetRefreshCounter(): void;
  90579. /**
  90580. * Set the fragment shader to use in order to render the texture.
  90581. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90582. */
  90583. setFragment(fragment: any): void;
  90584. /**
  90585. * Define the refresh rate of the texture or the rendering frequency.
  90586. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90587. */
  90588. get refreshRate(): number;
  90589. set refreshRate(value: number);
  90590. /** @hidden */
  90591. _shouldRender(): boolean;
  90592. /**
  90593. * Get the size the texture is rendering at.
  90594. * @returns the size (texture is always squared)
  90595. */
  90596. getRenderSize(): number;
  90597. /**
  90598. * Resize the texture to new value.
  90599. * @param size Define the new size the texture should have
  90600. * @param generateMipMaps Define whether the new texture should create mip maps
  90601. */
  90602. resize(size: number, generateMipMaps: boolean): void;
  90603. private _checkUniform;
  90604. /**
  90605. * Set a texture in the shader program used to render.
  90606. * @param name Define the name of the uniform samplers as defined in the shader
  90607. * @param texture Define the texture to bind to this sampler
  90608. * @return the texture itself allowing "fluent" like uniform updates
  90609. */
  90610. setTexture(name: string, texture: Texture): ProceduralTexture;
  90611. /**
  90612. * Set a float in the shader.
  90613. * @param name Define the name of the uniform as defined in the shader
  90614. * @param value Define the value to give to the uniform
  90615. * @return the texture itself allowing "fluent" like uniform updates
  90616. */
  90617. setFloat(name: string, value: number): ProceduralTexture;
  90618. /**
  90619. * Set a int in the shader.
  90620. * @param name Define the name of the uniform as defined in the shader
  90621. * @param value Define the value to give to the uniform
  90622. * @return the texture itself allowing "fluent" like uniform updates
  90623. */
  90624. setInt(name: string, value: number): ProceduralTexture;
  90625. /**
  90626. * Set an array of floats in the shader.
  90627. * @param name Define the name of the uniform as defined in the shader
  90628. * @param value Define the value to give to the uniform
  90629. * @return the texture itself allowing "fluent" like uniform updates
  90630. */
  90631. setFloats(name: string, value: number[]): ProceduralTexture;
  90632. /**
  90633. * Set a vec3 in the shader from a Color3.
  90634. * @param name Define the name of the uniform as defined in the shader
  90635. * @param value Define the value to give to the uniform
  90636. * @return the texture itself allowing "fluent" like uniform updates
  90637. */
  90638. setColor3(name: string, value: Color3): ProceduralTexture;
  90639. /**
  90640. * Set a vec4 in the shader from a Color4.
  90641. * @param name Define the name of the uniform as defined in the shader
  90642. * @param value Define the value to give to the uniform
  90643. * @return the texture itself allowing "fluent" like uniform updates
  90644. */
  90645. setColor4(name: string, value: Color4): ProceduralTexture;
  90646. /**
  90647. * Set a vec2 in the shader from a Vector2.
  90648. * @param name Define the name of the uniform as defined in the shader
  90649. * @param value Define the value to give to the uniform
  90650. * @return the texture itself allowing "fluent" like uniform updates
  90651. */
  90652. setVector2(name: string, value: Vector2): ProceduralTexture;
  90653. /**
  90654. * Set a vec3 in the shader from a Vector3.
  90655. * @param name Define the name of the uniform as defined in the shader
  90656. * @param value Define the value to give to the uniform
  90657. * @return the texture itself allowing "fluent" like uniform updates
  90658. */
  90659. setVector3(name: string, value: Vector3): ProceduralTexture;
  90660. /**
  90661. * Set a mat4 in the shader from a MAtrix.
  90662. * @param name Define the name of the uniform as defined in the shader
  90663. * @param value Define the value to give to the uniform
  90664. * @return the texture itself allowing "fluent" like uniform updates
  90665. */
  90666. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90667. /**
  90668. * Render the texture to its associated render target.
  90669. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90670. */
  90671. render(useCameraPostProcess?: boolean): void;
  90672. /**
  90673. * Clone the texture.
  90674. * @returns the cloned texture
  90675. */
  90676. clone(): ProceduralTexture;
  90677. /**
  90678. * Dispose the texture and release its asoociated resources.
  90679. */
  90680. dispose(): void;
  90681. }
  90682. }
  90683. declare module BABYLON {
  90684. /**
  90685. * This represents the base class for particle system in Babylon.
  90686. * 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.
  90687. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90688. * @example https://doc.babylonjs.com/babylon101/particles
  90689. */
  90690. export class BaseParticleSystem {
  90691. /**
  90692. * Source color is added to the destination color without alpha affecting the result
  90693. */
  90694. static BLENDMODE_ONEONE: number;
  90695. /**
  90696. * Blend current color and particle color using particle’s alpha
  90697. */
  90698. static BLENDMODE_STANDARD: number;
  90699. /**
  90700. * Add current color and particle color multiplied by particle’s alpha
  90701. */
  90702. static BLENDMODE_ADD: number;
  90703. /**
  90704. * Multiply current color with particle color
  90705. */
  90706. static BLENDMODE_MULTIPLY: number;
  90707. /**
  90708. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90709. */
  90710. static BLENDMODE_MULTIPLYADD: number;
  90711. /**
  90712. * List of animations used by the particle system.
  90713. */
  90714. animations: Animation[];
  90715. /**
  90716. * Gets or sets the unique id of the particle system
  90717. */
  90718. uniqueId: number;
  90719. /**
  90720. * The id of the Particle system.
  90721. */
  90722. id: string;
  90723. /**
  90724. * The friendly name of the Particle system.
  90725. */
  90726. name: string;
  90727. /**
  90728. * Snippet ID if the particle system was created from the snippet server
  90729. */
  90730. snippetId: string;
  90731. /**
  90732. * The rendering group used by the Particle system to chose when to render.
  90733. */
  90734. renderingGroupId: number;
  90735. /**
  90736. * The emitter represents the Mesh or position we are attaching the particle system to.
  90737. */
  90738. emitter: Nullable<AbstractMesh | Vector3>;
  90739. /**
  90740. * The maximum number of particles to emit per frame
  90741. */
  90742. emitRate: number;
  90743. /**
  90744. * If you want to launch only a few particles at once, that can be done, as well.
  90745. */
  90746. manualEmitCount: number;
  90747. /**
  90748. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90749. */
  90750. updateSpeed: number;
  90751. /**
  90752. * The amount of time the particle system is running (depends of the overall update speed).
  90753. */
  90754. targetStopDuration: number;
  90755. /**
  90756. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90757. */
  90758. disposeOnStop: boolean;
  90759. /**
  90760. * Minimum power of emitting particles.
  90761. */
  90762. minEmitPower: number;
  90763. /**
  90764. * Maximum power of emitting particles.
  90765. */
  90766. maxEmitPower: number;
  90767. /**
  90768. * Minimum life time of emitting particles.
  90769. */
  90770. minLifeTime: number;
  90771. /**
  90772. * Maximum life time of emitting particles.
  90773. */
  90774. maxLifeTime: number;
  90775. /**
  90776. * Minimum Size of emitting particles.
  90777. */
  90778. minSize: number;
  90779. /**
  90780. * Maximum Size of emitting particles.
  90781. */
  90782. maxSize: number;
  90783. /**
  90784. * Minimum scale of emitting particles on X axis.
  90785. */
  90786. minScaleX: number;
  90787. /**
  90788. * Maximum scale of emitting particles on X axis.
  90789. */
  90790. maxScaleX: number;
  90791. /**
  90792. * Minimum scale of emitting particles on Y axis.
  90793. */
  90794. minScaleY: number;
  90795. /**
  90796. * Maximum scale of emitting particles on Y axis.
  90797. */
  90798. maxScaleY: number;
  90799. /**
  90800. * Gets or sets the minimal initial rotation in radians.
  90801. */
  90802. minInitialRotation: number;
  90803. /**
  90804. * Gets or sets the maximal initial rotation in radians.
  90805. */
  90806. maxInitialRotation: number;
  90807. /**
  90808. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90809. */
  90810. minAngularSpeed: number;
  90811. /**
  90812. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90813. */
  90814. maxAngularSpeed: number;
  90815. /**
  90816. * The texture used to render each particle. (this can be a spritesheet)
  90817. */
  90818. particleTexture: Nullable<Texture>;
  90819. /**
  90820. * The layer mask we are rendering the particles through.
  90821. */
  90822. layerMask: number;
  90823. /**
  90824. * This can help using your own shader to render the particle system.
  90825. * The according effect will be created
  90826. */
  90827. customShader: any;
  90828. /**
  90829. * By default particle system starts as soon as they are created. This prevents the
  90830. * automatic start to happen and let you decide when to start emitting particles.
  90831. */
  90832. preventAutoStart: boolean;
  90833. private _noiseTexture;
  90834. /**
  90835. * Gets or sets a texture used to add random noise to particle positions
  90836. */
  90837. get noiseTexture(): Nullable<ProceduralTexture>;
  90838. set noiseTexture(value: Nullable<ProceduralTexture>);
  90839. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90840. noiseStrength: Vector3;
  90841. /**
  90842. * Callback triggered when the particle animation is ending.
  90843. */
  90844. onAnimationEnd: Nullable<() => void>;
  90845. /**
  90846. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90847. */
  90848. blendMode: number;
  90849. /**
  90850. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90851. * to override the particles.
  90852. */
  90853. forceDepthWrite: boolean;
  90854. /** 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 */
  90855. preWarmCycles: number;
  90856. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90857. preWarmStepOffset: number;
  90858. /**
  90859. * 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)
  90860. */
  90861. spriteCellChangeSpeed: number;
  90862. /**
  90863. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90864. */
  90865. startSpriteCellID: number;
  90866. /**
  90867. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90868. */
  90869. endSpriteCellID: number;
  90870. /**
  90871. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90872. */
  90873. spriteCellWidth: number;
  90874. /**
  90875. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90876. */
  90877. spriteCellHeight: number;
  90878. /**
  90879. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90880. */
  90881. spriteRandomStartCell: boolean;
  90882. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90883. translationPivot: Vector2;
  90884. /** @hidden */
  90885. protected _isAnimationSheetEnabled: boolean;
  90886. /**
  90887. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90888. */
  90889. beginAnimationOnStart: boolean;
  90890. /**
  90891. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90892. */
  90893. beginAnimationFrom: number;
  90894. /**
  90895. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90896. */
  90897. beginAnimationTo: number;
  90898. /**
  90899. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90900. */
  90901. beginAnimationLoop: boolean;
  90902. /**
  90903. * Gets or sets a world offset applied to all particles
  90904. */
  90905. worldOffset: Vector3;
  90906. /**
  90907. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90908. */
  90909. get isAnimationSheetEnabled(): boolean;
  90910. set isAnimationSheetEnabled(value: boolean);
  90911. /**
  90912. * Get hosting scene
  90913. * @returns the scene
  90914. */
  90915. getScene(): Scene;
  90916. /**
  90917. * You can use gravity if you want to give an orientation to your particles.
  90918. */
  90919. gravity: Vector3;
  90920. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90921. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90922. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90923. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90924. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90925. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90926. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90927. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90928. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90929. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90930. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90931. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90932. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90933. /**
  90934. * Defines the delay in milliseconds before starting the system (0 by default)
  90935. */
  90936. startDelay: number;
  90937. /**
  90938. * Gets the current list of drag gradients.
  90939. * You must use addDragGradient and removeDragGradient to udpate this list
  90940. * @returns the list of drag gradients
  90941. */
  90942. getDragGradients(): Nullable<Array<FactorGradient>>;
  90943. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90944. limitVelocityDamping: number;
  90945. /**
  90946. * Gets the current list of limit velocity gradients.
  90947. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90948. * @returns the list of limit velocity gradients
  90949. */
  90950. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90951. /**
  90952. * Gets the current list of color gradients.
  90953. * You must use addColorGradient and removeColorGradient to udpate this list
  90954. * @returns the list of color gradients
  90955. */
  90956. getColorGradients(): Nullable<Array<ColorGradient>>;
  90957. /**
  90958. * Gets the current list of size gradients.
  90959. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90960. * @returns the list of size gradients
  90961. */
  90962. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90963. /**
  90964. * Gets the current list of color remap gradients.
  90965. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90966. * @returns the list of color remap gradients
  90967. */
  90968. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90969. /**
  90970. * Gets the current list of alpha remap gradients.
  90971. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90972. * @returns the list of alpha remap gradients
  90973. */
  90974. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90975. /**
  90976. * Gets the current list of life time gradients.
  90977. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90978. * @returns the list of life time gradients
  90979. */
  90980. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90981. /**
  90982. * Gets the current list of angular speed gradients.
  90983. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90984. * @returns the list of angular speed gradients
  90985. */
  90986. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90987. /**
  90988. * Gets the current list of velocity gradients.
  90989. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90990. * @returns the list of velocity gradients
  90991. */
  90992. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90993. /**
  90994. * Gets the current list of start size gradients.
  90995. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90996. * @returns the list of start size gradients
  90997. */
  90998. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90999. /**
  91000. * Gets the current list of emit rate gradients.
  91001. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91002. * @returns the list of emit rate gradients
  91003. */
  91004. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91005. /**
  91006. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91007. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91008. */
  91009. get direction1(): Vector3;
  91010. set direction1(value: Vector3);
  91011. /**
  91012. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91013. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91014. */
  91015. get direction2(): Vector3;
  91016. set direction2(value: Vector3);
  91017. /**
  91018. * 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.
  91019. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91020. */
  91021. get minEmitBox(): Vector3;
  91022. set minEmitBox(value: Vector3);
  91023. /**
  91024. * 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.
  91025. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91026. */
  91027. get maxEmitBox(): Vector3;
  91028. set maxEmitBox(value: Vector3);
  91029. /**
  91030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91031. */
  91032. color1: Color4;
  91033. /**
  91034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91035. */
  91036. color2: Color4;
  91037. /**
  91038. * Color the particle will have at the end of its lifetime
  91039. */
  91040. colorDead: Color4;
  91041. /**
  91042. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91043. */
  91044. textureMask: Color4;
  91045. /**
  91046. * The particle emitter type defines the emitter used by the particle system.
  91047. * It can be for example box, sphere, or cone...
  91048. */
  91049. particleEmitterType: IParticleEmitterType;
  91050. /** @hidden */
  91051. _isSubEmitter: boolean;
  91052. /**
  91053. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91054. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91055. */
  91056. billboardMode: number;
  91057. protected _isBillboardBased: boolean;
  91058. /**
  91059. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91060. */
  91061. get isBillboardBased(): boolean;
  91062. set isBillboardBased(value: boolean);
  91063. /**
  91064. * The scene the particle system belongs to.
  91065. */
  91066. protected _scene: Scene;
  91067. /**
  91068. * Local cache of defines for image processing.
  91069. */
  91070. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91071. /**
  91072. * Default configuration related to image processing available in the standard Material.
  91073. */
  91074. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91075. /**
  91076. * Gets the image processing configuration used either in this material.
  91077. */
  91078. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  91079. /**
  91080. * Sets the Default image processing configuration used either in the this material.
  91081. *
  91082. * If sets to null, the scene one is in use.
  91083. */
  91084. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  91085. /**
  91086. * Attaches a new image processing configuration to the Standard Material.
  91087. * @param configuration
  91088. */
  91089. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91090. /** @hidden */
  91091. protected _reset(): void;
  91092. /** @hidden */
  91093. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91094. /**
  91095. * Instantiates a particle system.
  91096. * 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.
  91097. * @param name The name of the particle system
  91098. */
  91099. constructor(name: string);
  91100. /**
  91101. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91104. * @returns the emitter
  91105. */
  91106. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91107. /**
  91108. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91109. * @param radius The radius of the hemisphere to emit from
  91110. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91111. * @returns the emitter
  91112. */
  91113. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91114. /**
  91115. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91116. * @param radius The radius of the sphere to emit from
  91117. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91118. * @returns the emitter
  91119. */
  91120. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91121. /**
  91122. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91123. * @param radius The radius of the sphere to emit from
  91124. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91125. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91126. * @returns the emitter
  91127. */
  91128. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91129. /**
  91130. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91131. * @param radius The radius of the emission cylinder
  91132. * @param height The height of the emission cylinder
  91133. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91134. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91135. * @returns the emitter
  91136. */
  91137. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91138. /**
  91139. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91140. * @param radius The radius of the cylinder to emit from
  91141. * @param height The height of the emission cylinder
  91142. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91145. * @returns the emitter
  91146. */
  91147. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91148. /**
  91149. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91150. * @param radius The radius of the cone to emit from
  91151. * @param angle The base angle of the cone
  91152. * @returns the emitter
  91153. */
  91154. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91155. /**
  91156. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91157. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91158. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91159. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91160. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91161. * @returns the emitter
  91162. */
  91163. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91164. }
  91165. }
  91166. declare module BABYLON {
  91167. /**
  91168. * Type of sub emitter
  91169. */
  91170. export enum SubEmitterType {
  91171. /**
  91172. * Attached to the particle over it's lifetime
  91173. */
  91174. ATTACHED = 0,
  91175. /**
  91176. * Created when the particle dies
  91177. */
  91178. END = 1
  91179. }
  91180. /**
  91181. * Sub emitter class used to emit particles from an existing particle
  91182. */
  91183. export class SubEmitter {
  91184. /**
  91185. * the particle system to be used by the sub emitter
  91186. */
  91187. particleSystem: ParticleSystem;
  91188. /**
  91189. * Type of the submitter (Default: END)
  91190. */
  91191. type: SubEmitterType;
  91192. /**
  91193. * 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)
  91194. * Note: This only is supported when using an emitter of type Mesh
  91195. */
  91196. inheritDirection: boolean;
  91197. /**
  91198. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91199. */
  91200. inheritedVelocityAmount: number;
  91201. /**
  91202. * Creates a sub emitter
  91203. * @param particleSystem the particle system to be used by the sub emitter
  91204. */
  91205. constructor(
  91206. /**
  91207. * the particle system to be used by the sub emitter
  91208. */
  91209. particleSystem: ParticleSystem);
  91210. /**
  91211. * Clones the sub emitter
  91212. * @returns the cloned sub emitter
  91213. */
  91214. clone(): SubEmitter;
  91215. /**
  91216. * Serialize current object to a JSON object
  91217. * @returns the serialized object
  91218. */
  91219. serialize(): any;
  91220. /** @hidden */
  91221. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  91222. /**
  91223. * Creates a new SubEmitter from a serialized JSON version
  91224. * @param serializationObject defines the JSON object to read from
  91225. * @param scene defines the hosting scene
  91226. * @param rootUrl defines the rootUrl for data loading
  91227. * @returns a new SubEmitter
  91228. */
  91229. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  91230. /** Release associated resources */
  91231. dispose(): void;
  91232. }
  91233. }
  91234. declare module BABYLON {
  91235. /** @hidden */
  91236. export var imageProcessingDeclaration: {
  91237. name: string;
  91238. shader: string;
  91239. };
  91240. }
  91241. declare module BABYLON {
  91242. /** @hidden */
  91243. export var imageProcessingFunctions: {
  91244. name: string;
  91245. shader: string;
  91246. };
  91247. }
  91248. declare module BABYLON {
  91249. /** @hidden */
  91250. export var particlesPixelShader: {
  91251. name: string;
  91252. shader: string;
  91253. };
  91254. }
  91255. declare module BABYLON {
  91256. /** @hidden */
  91257. export var particlesVertexShader: {
  91258. name: string;
  91259. shader: string;
  91260. };
  91261. }
  91262. declare module BABYLON {
  91263. /**
  91264. * This represents a particle system in Babylon.
  91265. * 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.
  91266. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91267. * @example https://doc.babylonjs.com/babylon101/particles
  91268. */
  91269. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91270. /**
  91271. * Billboard mode will only apply to Y axis
  91272. */
  91273. static readonly BILLBOARDMODE_Y: number;
  91274. /**
  91275. * Billboard mode will apply to all axes
  91276. */
  91277. static readonly BILLBOARDMODE_ALL: number;
  91278. /**
  91279. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91280. */
  91281. static readonly BILLBOARDMODE_STRETCHED: number;
  91282. /**
  91283. * This function can be defined to provide custom update for active particles.
  91284. * This function will be called instead of regular update (age, position, color, etc.).
  91285. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91286. */
  91287. updateFunction: (particles: Particle[]) => void;
  91288. private _emitterWorldMatrix;
  91289. /**
  91290. * This function can be defined to specify initial direction for every new particle.
  91291. * It by default use the emitterType defined function
  91292. */
  91293. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91294. /**
  91295. * This function can be defined to specify initial position for every new particle.
  91296. * It by default use the emitterType defined function
  91297. */
  91298. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91299. /**
  91300. * @hidden
  91301. */
  91302. _inheritedVelocityOffset: Vector3;
  91303. /**
  91304. * An event triggered when the system is disposed
  91305. */
  91306. onDisposeObservable: Observable<IParticleSystem>;
  91307. private _onDisposeObserver;
  91308. /**
  91309. * Sets a callback that will be triggered when the system is disposed
  91310. */
  91311. set onDispose(callback: () => void);
  91312. private _particles;
  91313. private _epsilon;
  91314. private _capacity;
  91315. private _stockParticles;
  91316. private _newPartsExcess;
  91317. private _vertexData;
  91318. private _vertexBuffer;
  91319. private _vertexBuffers;
  91320. private _spriteBuffer;
  91321. private _indexBuffer;
  91322. private _effect;
  91323. private _customEffect;
  91324. private _cachedDefines;
  91325. private _scaledColorStep;
  91326. private _colorDiff;
  91327. private _scaledDirection;
  91328. private _scaledGravity;
  91329. private _currentRenderId;
  91330. private _alive;
  91331. private _useInstancing;
  91332. private _started;
  91333. private _stopped;
  91334. private _actualFrame;
  91335. private _scaledUpdateSpeed;
  91336. private _vertexBufferSize;
  91337. /** @hidden */
  91338. _currentEmitRateGradient: Nullable<FactorGradient>;
  91339. /** @hidden */
  91340. _currentEmitRate1: number;
  91341. /** @hidden */
  91342. _currentEmitRate2: number;
  91343. /** @hidden */
  91344. _currentStartSizeGradient: Nullable<FactorGradient>;
  91345. /** @hidden */
  91346. _currentStartSize1: number;
  91347. /** @hidden */
  91348. _currentStartSize2: number;
  91349. private readonly _rawTextureWidth;
  91350. private _rampGradientsTexture;
  91351. private _useRampGradients;
  91352. /** Gets or sets a boolean indicating that ramp gradients must be used
  91353. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91354. */
  91355. get useRampGradients(): boolean;
  91356. set useRampGradients(value: boolean);
  91357. /**
  91358. * 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.
  91359. * 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: [])
  91360. */
  91361. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91362. private _subEmitters;
  91363. /**
  91364. * @hidden
  91365. * If the particle systems emitter should be disposed when the particle system is disposed
  91366. */
  91367. _disposeEmitterOnDispose: boolean;
  91368. /**
  91369. * The current active Sub-systems, this property is used by the root particle system only.
  91370. */
  91371. activeSubSystems: Array<ParticleSystem>;
  91372. /**
  91373. * Specifies if the particles are updated in emitter local space or world space
  91374. */
  91375. isLocal: boolean;
  91376. private _rootParticleSystem;
  91377. /**
  91378. * Gets the current list of active particles
  91379. */
  91380. get particles(): Particle[];
  91381. /**
  91382. * Gets the number of particles active at the same time.
  91383. * @returns The number of active particles.
  91384. */
  91385. getActiveCount(): number;
  91386. /**
  91387. * Returns the string "ParticleSystem"
  91388. * @returns a string containing the class name
  91389. */
  91390. getClassName(): string;
  91391. /**
  91392. * Gets a boolean indicating that the system is stopping
  91393. * @returns true if the system is currently stopping
  91394. */
  91395. isStopping(): boolean;
  91396. /**
  91397. * Gets the custom effect used to render the particles
  91398. * @param blendMode Blend mode for which the effect should be retrieved
  91399. * @returns The effect
  91400. */
  91401. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91402. /**
  91403. * Sets the custom effect used to render the particles
  91404. * @param effect The effect to set
  91405. * @param blendMode Blend mode for which the effect should be set
  91406. */
  91407. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91408. /** @hidden */
  91409. private _onBeforeDrawParticlesObservable;
  91410. /**
  91411. * Observable that will be called just before the particles are drawn
  91412. */
  91413. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91414. /**
  91415. * Gets the name of the particle vertex shader
  91416. */
  91417. get vertexShaderName(): string;
  91418. /**
  91419. * Instantiates a particle system.
  91420. * 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.
  91421. * @param name The name of the particle system
  91422. * @param capacity The max number of particles alive at the same time
  91423. * @param scene The scene the particle system belongs to
  91424. * @param customEffect a custom effect used to change the way particles are rendered by default
  91425. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91426. * @param epsilon Offset used to render the particles
  91427. */
  91428. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91429. private _addFactorGradient;
  91430. private _removeFactorGradient;
  91431. /**
  91432. * Adds a new life time gradient
  91433. * @param gradient defines the gradient to use (between 0 and 1)
  91434. * @param factor defines the life time factor to affect to the specified gradient
  91435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91436. * @returns the current particle system
  91437. */
  91438. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91439. /**
  91440. * Remove a specific life time gradient
  91441. * @param gradient defines the gradient to remove
  91442. * @returns the current particle system
  91443. */
  91444. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91445. /**
  91446. * Adds a new size gradient
  91447. * @param gradient defines the gradient to use (between 0 and 1)
  91448. * @param factor defines the size factor to affect to the specified gradient
  91449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91450. * @returns the current particle system
  91451. */
  91452. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91453. /**
  91454. * Remove a specific size gradient
  91455. * @param gradient defines the gradient to remove
  91456. * @returns the current particle system
  91457. */
  91458. removeSizeGradient(gradient: number): IParticleSystem;
  91459. /**
  91460. * Adds a new color remap gradient
  91461. * @param gradient defines the gradient to use (between 0 and 1)
  91462. * @param min defines the color remap minimal range
  91463. * @param max defines the color remap maximal range
  91464. * @returns the current particle system
  91465. */
  91466. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91467. /**
  91468. * Remove a specific color remap gradient
  91469. * @param gradient defines the gradient to remove
  91470. * @returns the current particle system
  91471. */
  91472. removeColorRemapGradient(gradient: number): IParticleSystem;
  91473. /**
  91474. * Adds a new alpha remap gradient
  91475. * @param gradient defines the gradient to use (between 0 and 1)
  91476. * @param min defines the alpha remap minimal range
  91477. * @param max defines the alpha remap maximal range
  91478. * @returns the current particle system
  91479. */
  91480. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91481. /**
  91482. * Remove a specific alpha remap gradient
  91483. * @param gradient defines the gradient to remove
  91484. * @returns the current particle system
  91485. */
  91486. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91487. /**
  91488. * Adds a new angular speed gradient
  91489. * @param gradient defines the gradient to use (between 0 and 1)
  91490. * @param factor defines the angular speed to affect to the specified gradient
  91491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91492. * @returns the current particle system
  91493. */
  91494. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91495. /**
  91496. * Remove a specific angular speed gradient
  91497. * @param gradient defines the gradient to remove
  91498. * @returns the current particle system
  91499. */
  91500. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91501. /**
  91502. * Adds a new velocity gradient
  91503. * @param gradient defines the gradient to use (between 0 and 1)
  91504. * @param factor defines the velocity to affect to the specified gradient
  91505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91506. * @returns the current particle system
  91507. */
  91508. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91509. /**
  91510. * Remove a specific velocity gradient
  91511. * @param gradient defines the gradient to remove
  91512. * @returns the current particle system
  91513. */
  91514. removeVelocityGradient(gradient: number): IParticleSystem;
  91515. /**
  91516. * Adds a new limit velocity gradient
  91517. * @param gradient defines the gradient to use (between 0 and 1)
  91518. * @param factor defines the limit velocity value to affect to the specified gradient
  91519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91520. * @returns the current particle system
  91521. */
  91522. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91523. /**
  91524. * Remove a specific limit velocity gradient
  91525. * @param gradient defines the gradient to remove
  91526. * @returns the current particle system
  91527. */
  91528. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91529. /**
  91530. * Adds a new drag gradient
  91531. * @param gradient defines the gradient to use (between 0 and 1)
  91532. * @param factor defines the drag value to affect to the specified gradient
  91533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91534. * @returns the current particle system
  91535. */
  91536. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91537. /**
  91538. * Remove a specific drag gradient
  91539. * @param gradient defines the gradient to remove
  91540. * @returns the current particle system
  91541. */
  91542. removeDragGradient(gradient: number): IParticleSystem;
  91543. /**
  91544. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91545. * @param gradient defines the gradient to use (between 0 and 1)
  91546. * @param factor defines the emit rate value to affect to the specified gradient
  91547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91548. * @returns the current particle system
  91549. */
  91550. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91551. /**
  91552. * Remove a specific emit rate gradient
  91553. * @param gradient defines the gradient to remove
  91554. * @returns the current particle system
  91555. */
  91556. removeEmitRateGradient(gradient: number): IParticleSystem;
  91557. /**
  91558. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91559. * @param gradient defines the gradient to use (between 0 and 1)
  91560. * @param factor defines the start size value to affect to the specified gradient
  91561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91562. * @returns the current particle system
  91563. */
  91564. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91565. /**
  91566. * Remove a specific start size gradient
  91567. * @param gradient defines the gradient to remove
  91568. * @returns the current particle system
  91569. */
  91570. removeStartSizeGradient(gradient: number): IParticleSystem;
  91571. private _createRampGradientTexture;
  91572. /**
  91573. * Gets the current list of ramp gradients.
  91574. * You must use addRampGradient and removeRampGradient to udpate this list
  91575. * @returns the list of ramp gradients
  91576. */
  91577. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91578. /** Force the system to rebuild all gradients that need to be resync */
  91579. forceRefreshGradients(): void;
  91580. private _syncRampGradientTexture;
  91581. /**
  91582. * Adds a new ramp gradient used to remap particle colors
  91583. * @param gradient defines the gradient to use (between 0 and 1)
  91584. * @param color defines the color to affect to the specified gradient
  91585. * @returns the current particle system
  91586. */
  91587. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91588. /**
  91589. * Remove a specific ramp gradient
  91590. * @param gradient defines the gradient to remove
  91591. * @returns the current particle system
  91592. */
  91593. removeRampGradient(gradient: number): ParticleSystem;
  91594. /**
  91595. * Adds a new color gradient
  91596. * @param gradient defines the gradient to use (between 0 and 1)
  91597. * @param color1 defines the color to affect to the specified gradient
  91598. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91599. * @returns this particle system
  91600. */
  91601. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91602. /**
  91603. * Remove a specific color gradient
  91604. * @param gradient defines the gradient to remove
  91605. * @returns this particle system
  91606. */
  91607. removeColorGradient(gradient: number): IParticleSystem;
  91608. private _fetchR;
  91609. protected _reset(): void;
  91610. private _resetEffect;
  91611. private _createVertexBuffers;
  91612. private _createIndexBuffer;
  91613. /**
  91614. * Gets the maximum number of particles active at the same time.
  91615. * @returns The max number of active particles.
  91616. */
  91617. getCapacity(): number;
  91618. /**
  91619. * Gets whether there are still active particles in the system.
  91620. * @returns True if it is alive, otherwise false.
  91621. */
  91622. isAlive(): boolean;
  91623. /**
  91624. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91625. * @returns True if it has been started, otherwise false.
  91626. */
  91627. isStarted(): boolean;
  91628. private _prepareSubEmitterInternalArray;
  91629. /**
  91630. * Starts the particle system and begins to emit
  91631. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91632. */
  91633. start(delay?: number): void;
  91634. /**
  91635. * Stops the particle system.
  91636. * @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.
  91637. */
  91638. stop(stopSubEmitters?: boolean): void;
  91639. /**
  91640. * Remove all active particles
  91641. */
  91642. reset(): void;
  91643. /**
  91644. * @hidden (for internal use only)
  91645. */
  91646. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91647. /**
  91648. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91649. * Its lifetime will start back at 0.
  91650. */
  91651. recycleParticle: (particle: Particle) => void;
  91652. private _stopSubEmitters;
  91653. private _createParticle;
  91654. private _removeFromRoot;
  91655. private _emitFromParticle;
  91656. private _update;
  91657. /** @hidden */
  91658. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91659. /** @hidden */
  91660. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91661. /**
  91662. * Fill the defines array according to the current settings of the particle system
  91663. * @param defines Array to be updated
  91664. * @param blendMode blend mode to take into account when updating the array
  91665. */
  91666. fillDefines(defines: Array<string>, blendMode: number): void;
  91667. /**
  91668. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91669. * @param uniforms Uniforms array to fill
  91670. * @param attributes Attributes array to fill
  91671. * @param samplers Samplers array to fill
  91672. */
  91673. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91674. /** @hidden */
  91675. private _getEffect;
  91676. /**
  91677. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91678. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91679. */
  91680. animate(preWarmOnly?: boolean): void;
  91681. private _appendParticleVertices;
  91682. /**
  91683. * Rebuilds the particle system.
  91684. */
  91685. rebuild(): void;
  91686. /**
  91687. * Is this system ready to be used/rendered
  91688. * @return true if the system is ready
  91689. */
  91690. isReady(): boolean;
  91691. private _render;
  91692. /**
  91693. * Renders the particle system in its current state.
  91694. * @returns the current number of particles
  91695. */
  91696. render(): number;
  91697. /**
  91698. * Disposes the particle system and free the associated resources
  91699. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91700. */
  91701. dispose(disposeTexture?: boolean): void;
  91702. /**
  91703. * Clones the particle system.
  91704. * @param name The name of the cloned object
  91705. * @param newEmitter The new emitter to use
  91706. * @returns the cloned particle system
  91707. */
  91708. clone(name: string, newEmitter: any): ParticleSystem;
  91709. /**
  91710. * Serializes the particle system to a JSON object
  91711. * @param serializeTexture defines if the texture must be serialized as well
  91712. * @returns the JSON object
  91713. */
  91714. serialize(serializeTexture?: boolean): any;
  91715. /** @hidden */
  91716. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91717. /** @hidden */
  91718. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91719. /**
  91720. * Parses a JSON object to create a particle system.
  91721. * @param parsedParticleSystem The JSON object to parse
  91722. * @param scene The scene to create the particle system in
  91723. * @param rootUrl The root url to use to load external dependencies like texture
  91724. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91725. * @returns the Parsed particle system
  91726. */
  91727. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91728. }
  91729. }
  91730. declare module BABYLON {
  91731. /**
  91732. * A particle represents one of the element emitted by a particle system.
  91733. * This is mainly define by its coordinates, direction, velocity and age.
  91734. */
  91735. export class Particle {
  91736. /**
  91737. * The particle system the particle belongs to.
  91738. */
  91739. particleSystem: ParticleSystem;
  91740. private static _Count;
  91741. /**
  91742. * Unique ID of the particle
  91743. */
  91744. id: number;
  91745. /**
  91746. * The world position of the particle in the scene.
  91747. */
  91748. position: Vector3;
  91749. /**
  91750. * The world direction of the particle in the scene.
  91751. */
  91752. direction: Vector3;
  91753. /**
  91754. * The color of the particle.
  91755. */
  91756. color: Color4;
  91757. /**
  91758. * The color change of the particle per step.
  91759. */
  91760. colorStep: Color4;
  91761. /**
  91762. * Defines how long will the life of the particle be.
  91763. */
  91764. lifeTime: number;
  91765. /**
  91766. * The current age of the particle.
  91767. */
  91768. age: number;
  91769. /**
  91770. * The current size of the particle.
  91771. */
  91772. size: number;
  91773. /**
  91774. * The current scale of the particle.
  91775. */
  91776. scale: Vector2;
  91777. /**
  91778. * The current angle of the particle.
  91779. */
  91780. angle: number;
  91781. /**
  91782. * Defines how fast is the angle changing.
  91783. */
  91784. angularSpeed: number;
  91785. /**
  91786. * Defines the cell index used by the particle to be rendered from a sprite.
  91787. */
  91788. cellIndex: number;
  91789. /**
  91790. * The information required to support color remapping
  91791. */
  91792. remapData: Vector4;
  91793. /** @hidden */
  91794. _randomCellOffset?: number;
  91795. /** @hidden */
  91796. _initialDirection: Nullable<Vector3>;
  91797. /** @hidden */
  91798. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91799. /** @hidden */
  91800. _initialStartSpriteCellID: number;
  91801. /** @hidden */
  91802. _initialEndSpriteCellID: number;
  91803. /** @hidden */
  91804. _currentColorGradient: Nullable<ColorGradient>;
  91805. /** @hidden */
  91806. _currentColor1: Color4;
  91807. /** @hidden */
  91808. _currentColor2: Color4;
  91809. /** @hidden */
  91810. _currentSizeGradient: Nullable<FactorGradient>;
  91811. /** @hidden */
  91812. _currentSize1: number;
  91813. /** @hidden */
  91814. _currentSize2: number;
  91815. /** @hidden */
  91816. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91817. /** @hidden */
  91818. _currentAngularSpeed1: number;
  91819. /** @hidden */
  91820. _currentAngularSpeed2: number;
  91821. /** @hidden */
  91822. _currentVelocityGradient: Nullable<FactorGradient>;
  91823. /** @hidden */
  91824. _currentVelocity1: number;
  91825. /** @hidden */
  91826. _currentVelocity2: number;
  91827. /** @hidden */
  91828. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91829. /** @hidden */
  91830. _currentLimitVelocity1: number;
  91831. /** @hidden */
  91832. _currentLimitVelocity2: number;
  91833. /** @hidden */
  91834. _currentDragGradient: Nullable<FactorGradient>;
  91835. /** @hidden */
  91836. _currentDrag1: number;
  91837. /** @hidden */
  91838. _currentDrag2: number;
  91839. /** @hidden */
  91840. _randomNoiseCoordinates1: Vector3;
  91841. /** @hidden */
  91842. _randomNoiseCoordinates2: Vector3;
  91843. /** @hidden */
  91844. _localPosition?: Vector3;
  91845. /**
  91846. * Creates a new instance Particle
  91847. * @param particleSystem the particle system the particle belongs to
  91848. */
  91849. constructor(
  91850. /**
  91851. * The particle system the particle belongs to.
  91852. */
  91853. particleSystem: ParticleSystem);
  91854. private updateCellInfoFromSystem;
  91855. /**
  91856. * Defines how the sprite cell index is updated for the particle
  91857. */
  91858. updateCellIndex(): void;
  91859. /** @hidden */
  91860. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91861. /** @hidden */
  91862. _inheritParticleInfoToSubEmitters(): void;
  91863. /** @hidden */
  91864. _reset(): void;
  91865. /**
  91866. * Copy the properties of particle to another one.
  91867. * @param other the particle to copy the information to.
  91868. */
  91869. copyTo(other: Particle): void;
  91870. }
  91871. }
  91872. declare module BABYLON {
  91873. /**
  91874. * Particle emitter represents a volume emitting particles.
  91875. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91876. */
  91877. export interface IParticleEmitterType {
  91878. /**
  91879. * Called by the particle System when the direction is computed for the created particle.
  91880. * @param worldMatrix is the world matrix of the particle system
  91881. * @param directionToUpdate is the direction vector to update with the result
  91882. * @param particle is the particle we are computed the direction for
  91883. * @param isLocal defines if the direction should be set in local space
  91884. */
  91885. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91886. /**
  91887. * Called by the particle System when the position is computed for the created particle.
  91888. * @param worldMatrix is the world matrix of the particle system
  91889. * @param positionToUpdate is the position vector to update with the result
  91890. * @param particle is the particle we are computed the position for
  91891. * @param isLocal defines if the position should be set in local space
  91892. */
  91893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91894. /**
  91895. * Clones the current emitter and returns a copy of it
  91896. * @returns the new emitter
  91897. */
  91898. clone(): IParticleEmitterType;
  91899. /**
  91900. * Called by the GPUParticleSystem to setup the update shader
  91901. * @param effect defines the update shader
  91902. */
  91903. applyToShader(effect: Effect): void;
  91904. /**
  91905. * Returns a string to use to update the GPU particles update shader
  91906. * @returns the effect defines string
  91907. */
  91908. getEffectDefines(): string;
  91909. /**
  91910. * Returns a string representing the class name
  91911. * @returns a string containing the class name
  91912. */
  91913. getClassName(): string;
  91914. /**
  91915. * Serializes the particle system to a JSON object.
  91916. * @returns the JSON object
  91917. */
  91918. serialize(): any;
  91919. /**
  91920. * Parse properties from a JSON object
  91921. * @param serializationObject defines the JSON object
  91922. * @param scene defines the hosting scene
  91923. */
  91924. parse(serializationObject: any, scene: Scene): void;
  91925. }
  91926. }
  91927. declare module BABYLON {
  91928. /**
  91929. * Particle emitter emitting particles from the inside of a box.
  91930. * It emits the particles randomly between 2 given directions.
  91931. */
  91932. export class BoxParticleEmitter implements IParticleEmitterType {
  91933. /**
  91934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91935. */
  91936. direction1: Vector3;
  91937. /**
  91938. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91939. */
  91940. direction2: Vector3;
  91941. /**
  91942. * 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.
  91943. */
  91944. minEmitBox: Vector3;
  91945. /**
  91946. * 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.
  91947. */
  91948. maxEmitBox: Vector3;
  91949. /**
  91950. * Creates a new instance BoxParticleEmitter
  91951. */
  91952. constructor();
  91953. /**
  91954. * Called by the particle System when the direction is computed for the created particle.
  91955. * @param worldMatrix is the world matrix of the particle system
  91956. * @param directionToUpdate is the direction vector to update with the result
  91957. * @param particle is the particle we are computed the direction for
  91958. * @param isLocal defines if the direction should be set in local space
  91959. */
  91960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91961. /**
  91962. * Called by the particle System when the position is computed for the created particle.
  91963. * @param worldMatrix is the world matrix of the particle system
  91964. * @param positionToUpdate is the position vector to update with the result
  91965. * @param particle is the particle we are computed the position for
  91966. * @param isLocal defines if the position should be set in local space
  91967. */
  91968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91969. /**
  91970. * Clones the current emitter and returns a copy of it
  91971. * @returns the new emitter
  91972. */
  91973. clone(): BoxParticleEmitter;
  91974. /**
  91975. * Called by the GPUParticleSystem to setup the update shader
  91976. * @param effect defines the update shader
  91977. */
  91978. applyToShader(effect: Effect): void;
  91979. /**
  91980. * Returns a string to use to update the GPU particles update shader
  91981. * @returns a string containng the defines string
  91982. */
  91983. getEffectDefines(): string;
  91984. /**
  91985. * Returns the string "BoxParticleEmitter"
  91986. * @returns a string containing the class name
  91987. */
  91988. getClassName(): string;
  91989. /**
  91990. * Serializes the particle system to a JSON object.
  91991. * @returns the JSON object
  91992. */
  91993. serialize(): any;
  91994. /**
  91995. * Parse properties from a JSON object
  91996. * @param serializationObject defines the JSON object
  91997. */
  91998. parse(serializationObject: any): void;
  91999. }
  92000. }
  92001. declare module BABYLON {
  92002. /**
  92003. * Particle emitter emitting particles from the inside of a cone.
  92004. * It emits the particles alongside the cone volume from the base to the particle.
  92005. * The emission direction might be randomized.
  92006. */
  92007. export class ConeParticleEmitter implements IParticleEmitterType {
  92008. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92009. directionRandomizer: number;
  92010. private _radius;
  92011. private _angle;
  92012. private _height;
  92013. /**
  92014. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92015. */
  92016. radiusRange: number;
  92017. /**
  92018. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92019. */
  92020. heightRange: number;
  92021. /**
  92022. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92023. */
  92024. emitFromSpawnPointOnly: boolean;
  92025. /**
  92026. * Gets or sets the radius of the emission cone
  92027. */
  92028. get radius(): number;
  92029. set radius(value: number);
  92030. /**
  92031. * Gets or sets the angle of the emission cone
  92032. */
  92033. get angle(): number;
  92034. set angle(value: number);
  92035. private _buildHeight;
  92036. /**
  92037. * Creates a new instance ConeParticleEmitter
  92038. * @param radius the radius of the emission cone (1 by default)
  92039. * @param angle the cone base angle (PI by default)
  92040. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92041. */
  92042. constructor(radius?: number, angle?: number,
  92043. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92044. directionRandomizer?: number);
  92045. /**
  92046. * Called by the particle System when the direction is computed for the created particle.
  92047. * @param worldMatrix is the world matrix of the particle system
  92048. * @param directionToUpdate is the direction vector to update with the result
  92049. * @param particle is the particle we are computed the direction for
  92050. * @param isLocal defines if the direction should be set in local space
  92051. */
  92052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92053. /**
  92054. * Called by the particle System when the position is computed for the created particle.
  92055. * @param worldMatrix is the world matrix of the particle system
  92056. * @param positionToUpdate is the position vector to update with the result
  92057. * @param particle is the particle we are computed the position for
  92058. * @param isLocal defines if the position should be set in local space
  92059. */
  92060. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92061. /**
  92062. * Clones the current emitter and returns a copy of it
  92063. * @returns the new emitter
  92064. */
  92065. clone(): ConeParticleEmitter;
  92066. /**
  92067. * Called by the GPUParticleSystem to setup the update shader
  92068. * @param effect defines the update shader
  92069. */
  92070. applyToShader(effect: Effect): void;
  92071. /**
  92072. * Returns a string to use to update the GPU particles update shader
  92073. * @returns a string containng the defines string
  92074. */
  92075. getEffectDefines(): string;
  92076. /**
  92077. * Returns the string "ConeParticleEmitter"
  92078. * @returns a string containing the class name
  92079. */
  92080. getClassName(): string;
  92081. /**
  92082. * Serializes the particle system to a JSON object.
  92083. * @returns the JSON object
  92084. */
  92085. serialize(): any;
  92086. /**
  92087. * Parse properties from a JSON object
  92088. * @param serializationObject defines the JSON object
  92089. */
  92090. parse(serializationObject: any): void;
  92091. }
  92092. }
  92093. declare module BABYLON {
  92094. /**
  92095. * Particle emitter emitting particles from the inside of a cylinder.
  92096. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92097. */
  92098. export class CylinderParticleEmitter implements IParticleEmitterType {
  92099. /**
  92100. * The radius of the emission cylinder.
  92101. */
  92102. radius: number;
  92103. /**
  92104. * The height of the emission cylinder.
  92105. */
  92106. height: number;
  92107. /**
  92108. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92109. */
  92110. radiusRange: number;
  92111. /**
  92112. * How much to randomize the particle direction [0-1].
  92113. */
  92114. directionRandomizer: number;
  92115. /**
  92116. * Creates a new instance CylinderParticleEmitter
  92117. * @param radius the radius of the emission cylinder (1 by default)
  92118. * @param height the height of the emission cylinder (1 by default)
  92119. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92120. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92121. */
  92122. constructor(
  92123. /**
  92124. * The radius of the emission cylinder.
  92125. */
  92126. radius?: number,
  92127. /**
  92128. * The height of the emission cylinder.
  92129. */
  92130. height?: number,
  92131. /**
  92132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92133. */
  92134. radiusRange?: number,
  92135. /**
  92136. * How much to randomize the particle direction [0-1].
  92137. */
  92138. directionRandomizer?: number);
  92139. /**
  92140. * Called by the particle System when the direction is computed for the created particle.
  92141. * @param worldMatrix is the world matrix of the particle system
  92142. * @param directionToUpdate is the direction vector to update with the result
  92143. * @param particle is the particle we are computed the direction for
  92144. * @param isLocal defines if the direction should be set in local space
  92145. */
  92146. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92147. /**
  92148. * Called by the particle System when the position is computed for the created particle.
  92149. * @param worldMatrix is the world matrix of the particle system
  92150. * @param positionToUpdate is the position vector to update with the result
  92151. * @param particle is the particle we are computed the position for
  92152. * @param isLocal defines if the position should be set in local space
  92153. */
  92154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92155. /**
  92156. * Clones the current emitter and returns a copy of it
  92157. * @returns the new emitter
  92158. */
  92159. clone(): CylinderParticleEmitter;
  92160. /**
  92161. * Called by the GPUParticleSystem to setup the update shader
  92162. * @param effect defines the update shader
  92163. */
  92164. applyToShader(effect: Effect): void;
  92165. /**
  92166. * Returns a string to use to update the GPU particles update shader
  92167. * @returns a string containng the defines string
  92168. */
  92169. getEffectDefines(): string;
  92170. /**
  92171. * Returns the string "CylinderParticleEmitter"
  92172. * @returns a string containing the class name
  92173. */
  92174. getClassName(): string;
  92175. /**
  92176. * Serializes the particle system to a JSON object.
  92177. * @returns the JSON object
  92178. */
  92179. serialize(): any;
  92180. /**
  92181. * Parse properties from a JSON object
  92182. * @param serializationObject defines the JSON object
  92183. */
  92184. parse(serializationObject: any): void;
  92185. }
  92186. /**
  92187. * Particle emitter emitting particles from the inside of a cylinder.
  92188. * It emits the particles randomly between two vectors.
  92189. */
  92190. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92191. /**
  92192. * The min limit of the emission direction.
  92193. */
  92194. direction1: Vector3;
  92195. /**
  92196. * The max limit of the emission direction.
  92197. */
  92198. direction2: Vector3;
  92199. /**
  92200. * Creates a new instance CylinderDirectedParticleEmitter
  92201. * @param radius the radius of the emission cylinder (1 by default)
  92202. * @param height the height of the emission cylinder (1 by default)
  92203. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92204. * @param direction1 the min limit of the emission direction (up vector by default)
  92205. * @param direction2 the max limit of the emission direction (up vector by default)
  92206. */
  92207. constructor(radius?: number, height?: number, radiusRange?: number,
  92208. /**
  92209. * The min limit of the emission direction.
  92210. */
  92211. direction1?: Vector3,
  92212. /**
  92213. * The max limit of the emission direction.
  92214. */
  92215. direction2?: Vector3);
  92216. /**
  92217. * Called by the particle System when the direction is computed for the created particle.
  92218. * @param worldMatrix is the world matrix of the particle system
  92219. * @param directionToUpdate is the direction vector to update with the result
  92220. * @param particle is the particle we are computed the direction for
  92221. */
  92222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92223. /**
  92224. * Clones the current emitter and returns a copy of it
  92225. * @returns the new emitter
  92226. */
  92227. clone(): CylinderDirectedParticleEmitter;
  92228. /**
  92229. * Called by the GPUParticleSystem to setup the update shader
  92230. * @param effect defines the update shader
  92231. */
  92232. applyToShader(effect: Effect): void;
  92233. /**
  92234. * Returns a string to use to update the GPU particles update shader
  92235. * @returns a string containng the defines string
  92236. */
  92237. getEffectDefines(): string;
  92238. /**
  92239. * Returns the string "CylinderDirectedParticleEmitter"
  92240. * @returns a string containing the class name
  92241. */
  92242. getClassName(): string;
  92243. /**
  92244. * Serializes the particle system to a JSON object.
  92245. * @returns the JSON object
  92246. */
  92247. serialize(): any;
  92248. /**
  92249. * Parse properties from a JSON object
  92250. * @param serializationObject defines the JSON object
  92251. */
  92252. parse(serializationObject: any): void;
  92253. }
  92254. }
  92255. declare module BABYLON {
  92256. /**
  92257. * Particle emitter emitting particles from the inside of a hemisphere.
  92258. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92259. */
  92260. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92261. /**
  92262. * The radius of the emission hemisphere.
  92263. */
  92264. radius: number;
  92265. /**
  92266. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92267. */
  92268. radiusRange: number;
  92269. /**
  92270. * How much to randomize the particle direction [0-1].
  92271. */
  92272. directionRandomizer: number;
  92273. /**
  92274. * Creates a new instance HemisphericParticleEmitter
  92275. * @param radius the radius of the emission hemisphere (1 by default)
  92276. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92277. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92278. */
  92279. constructor(
  92280. /**
  92281. * The radius of the emission hemisphere.
  92282. */
  92283. radius?: number,
  92284. /**
  92285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92286. */
  92287. radiusRange?: number,
  92288. /**
  92289. * How much to randomize the particle direction [0-1].
  92290. */
  92291. directionRandomizer?: number);
  92292. /**
  92293. * Called by the particle System when the direction is computed for the created particle.
  92294. * @param worldMatrix is the world matrix of the particle system
  92295. * @param directionToUpdate is the direction vector to update with the result
  92296. * @param particle is the particle we are computed the direction for
  92297. * @param isLocal defines if the direction should be set in local space
  92298. */
  92299. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92300. /**
  92301. * Called by the particle System when the position is computed for the created particle.
  92302. * @param worldMatrix is the world matrix of the particle system
  92303. * @param positionToUpdate is the position vector to update with the result
  92304. * @param particle is the particle we are computed the position for
  92305. * @param isLocal defines if the position should be set in local space
  92306. */
  92307. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92308. /**
  92309. * Clones the current emitter and returns a copy of it
  92310. * @returns the new emitter
  92311. */
  92312. clone(): HemisphericParticleEmitter;
  92313. /**
  92314. * Called by the GPUParticleSystem to setup the update shader
  92315. * @param effect defines the update shader
  92316. */
  92317. applyToShader(effect: Effect): void;
  92318. /**
  92319. * Returns a string to use to update the GPU particles update shader
  92320. * @returns a string containng the defines string
  92321. */
  92322. getEffectDefines(): string;
  92323. /**
  92324. * Returns the string "HemisphericParticleEmitter"
  92325. * @returns a string containing the class name
  92326. */
  92327. getClassName(): string;
  92328. /**
  92329. * Serializes the particle system to a JSON object.
  92330. * @returns the JSON object
  92331. */
  92332. serialize(): any;
  92333. /**
  92334. * Parse properties from a JSON object
  92335. * @param serializationObject defines the JSON object
  92336. */
  92337. parse(serializationObject: any): void;
  92338. }
  92339. }
  92340. declare module BABYLON {
  92341. /**
  92342. * Particle emitter emitting particles from a point.
  92343. * It emits the particles randomly between 2 given directions.
  92344. */
  92345. export class PointParticleEmitter implements IParticleEmitterType {
  92346. /**
  92347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92348. */
  92349. direction1: Vector3;
  92350. /**
  92351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92352. */
  92353. direction2: Vector3;
  92354. /**
  92355. * Creates a new instance PointParticleEmitter
  92356. */
  92357. constructor();
  92358. /**
  92359. * Called by the particle System when the direction is computed for the created particle.
  92360. * @param worldMatrix is the world matrix of the particle system
  92361. * @param directionToUpdate is the direction vector to update with the result
  92362. * @param particle is the particle we are computed the direction for
  92363. * @param isLocal defines if the direction should be set in local space
  92364. */
  92365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92366. /**
  92367. * Called by the particle System when the position is computed for the created particle.
  92368. * @param worldMatrix is the world matrix of the particle system
  92369. * @param positionToUpdate is the position vector to update with the result
  92370. * @param particle is the particle we are computed the position for
  92371. * @param isLocal defines if the position should be set in local space
  92372. */
  92373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92374. /**
  92375. * Clones the current emitter and returns a copy of it
  92376. * @returns the new emitter
  92377. */
  92378. clone(): PointParticleEmitter;
  92379. /**
  92380. * Called by the GPUParticleSystem to setup the update shader
  92381. * @param effect defines the update shader
  92382. */
  92383. applyToShader(effect: Effect): void;
  92384. /**
  92385. * Returns a string to use to update the GPU particles update shader
  92386. * @returns a string containng the defines string
  92387. */
  92388. getEffectDefines(): string;
  92389. /**
  92390. * Returns the string "PointParticleEmitter"
  92391. * @returns a string containing the class name
  92392. */
  92393. getClassName(): string;
  92394. /**
  92395. * Serializes the particle system to a JSON object.
  92396. * @returns the JSON object
  92397. */
  92398. serialize(): any;
  92399. /**
  92400. * Parse properties from a JSON object
  92401. * @param serializationObject defines the JSON object
  92402. */
  92403. parse(serializationObject: any): void;
  92404. }
  92405. }
  92406. declare module BABYLON {
  92407. /**
  92408. * Particle emitter emitting particles from the inside of a sphere.
  92409. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92410. */
  92411. export class SphereParticleEmitter implements IParticleEmitterType {
  92412. /**
  92413. * The radius of the emission sphere.
  92414. */
  92415. radius: number;
  92416. /**
  92417. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92418. */
  92419. radiusRange: number;
  92420. /**
  92421. * How much to randomize the particle direction [0-1].
  92422. */
  92423. directionRandomizer: number;
  92424. /**
  92425. * Creates a new instance SphereParticleEmitter
  92426. * @param radius the radius of the emission sphere (1 by default)
  92427. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92428. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92429. */
  92430. constructor(
  92431. /**
  92432. * The radius of the emission sphere.
  92433. */
  92434. radius?: number,
  92435. /**
  92436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92437. */
  92438. radiusRange?: number,
  92439. /**
  92440. * How much to randomize the particle direction [0-1].
  92441. */
  92442. directionRandomizer?: number);
  92443. /**
  92444. * Called by the particle System when the direction is computed for the created particle.
  92445. * @param worldMatrix is the world matrix of the particle system
  92446. * @param directionToUpdate is the direction vector to update with the result
  92447. * @param particle is the particle we are computed the direction for
  92448. * @param isLocal defines if the direction should be set in local space
  92449. */
  92450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92451. /**
  92452. * Called by the particle System when the position is computed for the created particle.
  92453. * @param worldMatrix is the world matrix of the particle system
  92454. * @param positionToUpdate is the position vector to update with the result
  92455. * @param particle is the particle we are computed the position for
  92456. * @param isLocal defines if the position should be set in local space
  92457. */
  92458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92459. /**
  92460. * Clones the current emitter and returns a copy of it
  92461. * @returns the new emitter
  92462. */
  92463. clone(): SphereParticleEmitter;
  92464. /**
  92465. * Called by the GPUParticleSystem to setup the update shader
  92466. * @param effect defines the update shader
  92467. */
  92468. applyToShader(effect: Effect): void;
  92469. /**
  92470. * Returns a string to use to update the GPU particles update shader
  92471. * @returns a string containng the defines string
  92472. */
  92473. getEffectDefines(): string;
  92474. /**
  92475. * Returns the string "SphereParticleEmitter"
  92476. * @returns a string containing the class name
  92477. */
  92478. getClassName(): string;
  92479. /**
  92480. * Serializes the particle system to a JSON object.
  92481. * @returns the JSON object
  92482. */
  92483. serialize(): any;
  92484. /**
  92485. * Parse properties from a JSON object
  92486. * @param serializationObject defines the JSON object
  92487. */
  92488. parse(serializationObject: any): void;
  92489. }
  92490. /**
  92491. * Particle emitter emitting particles from the inside of a sphere.
  92492. * It emits the particles randomly between two vectors.
  92493. */
  92494. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92495. /**
  92496. * The min limit of the emission direction.
  92497. */
  92498. direction1: Vector3;
  92499. /**
  92500. * The max limit of the emission direction.
  92501. */
  92502. direction2: Vector3;
  92503. /**
  92504. * Creates a new instance SphereDirectedParticleEmitter
  92505. * @param radius the radius of the emission sphere (1 by default)
  92506. * @param direction1 the min limit of the emission direction (up vector by default)
  92507. * @param direction2 the max limit of the emission direction (up vector by default)
  92508. */
  92509. constructor(radius?: number,
  92510. /**
  92511. * The min limit of the emission direction.
  92512. */
  92513. direction1?: Vector3,
  92514. /**
  92515. * The max limit of the emission direction.
  92516. */
  92517. direction2?: Vector3);
  92518. /**
  92519. * Called by the particle System when the direction is computed for the created particle.
  92520. * @param worldMatrix is the world matrix of the particle system
  92521. * @param directionToUpdate is the direction vector to update with the result
  92522. * @param particle is the particle we are computed the direction for
  92523. */
  92524. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92525. /**
  92526. * Clones the current emitter and returns a copy of it
  92527. * @returns the new emitter
  92528. */
  92529. clone(): SphereDirectedParticleEmitter;
  92530. /**
  92531. * Called by the GPUParticleSystem to setup the update shader
  92532. * @param effect defines the update shader
  92533. */
  92534. applyToShader(effect: Effect): void;
  92535. /**
  92536. * Returns a string to use to update the GPU particles update shader
  92537. * @returns a string containng the defines string
  92538. */
  92539. getEffectDefines(): string;
  92540. /**
  92541. * Returns the string "SphereDirectedParticleEmitter"
  92542. * @returns a string containing the class name
  92543. */
  92544. getClassName(): string;
  92545. /**
  92546. * Serializes the particle system to a JSON object.
  92547. * @returns the JSON object
  92548. */
  92549. serialize(): any;
  92550. /**
  92551. * Parse properties from a JSON object
  92552. * @param serializationObject defines the JSON object
  92553. */
  92554. parse(serializationObject: any): void;
  92555. }
  92556. }
  92557. declare module BABYLON {
  92558. /**
  92559. * Particle emitter emitting particles from a custom list of positions.
  92560. */
  92561. export class CustomParticleEmitter implements IParticleEmitterType {
  92562. /**
  92563. * Gets or sets the position generator that will create the inital position of each particle.
  92564. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92565. */
  92566. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92567. /**
  92568. * Gets or sets the destination generator that will create the final destination of each particle.
  92569. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92570. */
  92571. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92572. /**
  92573. * Creates a new instance CustomParticleEmitter
  92574. */
  92575. constructor();
  92576. /**
  92577. * Called by the particle System when the direction is computed for the created particle.
  92578. * @param worldMatrix is the world matrix of the particle system
  92579. * @param directionToUpdate is the direction vector to update with the result
  92580. * @param particle is the particle we are computed the direction for
  92581. * @param isLocal defines if the direction should be set in local space
  92582. */
  92583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92584. /**
  92585. * Called by the particle System when the position is computed for the created particle.
  92586. * @param worldMatrix is the world matrix of the particle system
  92587. * @param positionToUpdate is the position vector to update with the result
  92588. * @param particle is the particle we are computed the position for
  92589. * @param isLocal defines if the position should be set in local space
  92590. */
  92591. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92592. /**
  92593. * Clones the current emitter and returns a copy of it
  92594. * @returns the new emitter
  92595. */
  92596. clone(): CustomParticleEmitter;
  92597. /**
  92598. * Called by the GPUParticleSystem to setup the update shader
  92599. * @param effect defines the update shader
  92600. */
  92601. applyToShader(effect: Effect): void;
  92602. /**
  92603. * Returns a string to use to update the GPU particles update shader
  92604. * @returns a string containng the defines string
  92605. */
  92606. getEffectDefines(): string;
  92607. /**
  92608. * Returns the string "PointParticleEmitter"
  92609. * @returns a string containing the class name
  92610. */
  92611. getClassName(): string;
  92612. /**
  92613. * Serializes the particle system to a JSON object.
  92614. * @returns the JSON object
  92615. */
  92616. serialize(): any;
  92617. /**
  92618. * Parse properties from a JSON object
  92619. * @param serializationObject defines the JSON object
  92620. */
  92621. parse(serializationObject: any): void;
  92622. }
  92623. }
  92624. declare module BABYLON {
  92625. /**
  92626. * Particle emitter emitting particles from the inside of a box.
  92627. * It emits the particles randomly between 2 given directions.
  92628. */
  92629. export class MeshParticleEmitter implements IParticleEmitterType {
  92630. private _indices;
  92631. private _positions;
  92632. private _normals;
  92633. private _storedNormal;
  92634. private _mesh;
  92635. /**
  92636. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92637. */
  92638. direction1: Vector3;
  92639. /**
  92640. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92641. */
  92642. direction2: Vector3;
  92643. /**
  92644. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92645. */
  92646. useMeshNormalsForDirection: boolean;
  92647. /** Defines the mesh to use as source */
  92648. get mesh(): Nullable<AbstractMesh>;
  92649. set mesh(value: Nullable<AbstractMesh>);
  92650. /**
  92651. * Creates a new instance MeshParticleEmitter
  92652. * @param mesh defines the mesh to use as source
  92653. */
  92654. constructor(mesh?: Nullable<AbstractMesh>);
  92655. /**
  92656. * Called by the particle System when the direction is computed for the created particle.
  92657. * @param worldMatrix is the world matrix of the particle system
  92658. * @param directionToUpdate is the direction vector to update with the result
  92659. * @param particle is the particle we are computed the direction for
  92660. * @param isLocal defines if the direction should be set in local space
  92661. */
  92662. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92663. /**
  92664. * Called by the particle System when the position is computed for the created particle.
  92665. * @param worldMatrix is the world matrix of the particle system
  92666. * @param positionToUpdate is the position vector to update with the result
  92667. * @param particle is the particle we are computed the position for
  92668. * @param isLocal defines if the position should be set in local space
  92669. */
  92670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92671. /**
  92672. * Clones the current emitter and returns a copy of it
  92673. * @returns the new emitter
  92674. */
  92675. clone(): MeshParticleEmitter;
  92676. /**
  92677. * Called by the GPUParticleSystem to setup the update shader
  92678. * @param effect defines the update shader
  92679. */
  92680. applyToShader(effect: Effect): void;
  92681. /**
  92682. * Returns a string to use to update the GPU particles update shader
  92683. * @returns a string containng the defines string
  92684. */
  92685. getEffectDefines(): string;
  92686. /**
  92687. * Returns the string "BoxParticleEmitter"
  92688. * @returns a string containing the class name
  92689. */
  92690. getClassName(): string;
  92691. /**
  92692. * Serializes the particle system to a JSON object.
  92693. * @returns the JSON object
  92694. */
  92695. serialize(): any;
  92696. /**
  92697. * Parse properties from a JSON object
  92698. * @param serializationObject defines the JSON object
  92699. * @param scene defines the hosting scene
  92700. */
  92701. parse(serializationObject: any, scene: Scene): void;
  92702. }
  92703. }
  92704. declare module BABYLON {
  92705. /**
  92706. * Interface representing a particle system in Babylon.js.
  92707. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92708. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92709. */
  92710. export interface IParticleSystem {
  92711. /**
  92712. * List of animations used by the particle system.
  92713. */
  92714. animations: Animation[];
  92715. /**
  92716. * The id of the Particle system.
  92717. */
  92718. id: string;
  92719. /**
  92720. * The name of the Particle system.
  92721. */
  92722. name: string;
  92723. /**
  92724. * The emitter represents the Mesh or position we are attaching the particle system to.
  92725. */
  92726. emitter: Nullable<AbstractMesh | Vector3>;
  92727. /**
  92728. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92729. */
  92730. isBillboardBased: boolean;
  92731. /**
  92732. * The rendering group used by the Particle system to chose when to render.
  92733. */
  92734. renderingGroupId: number;
  92735. /**
  92736. * The layer mask we are rendering the particles through.
  92737. */
  92738. layerMask: number;
  92739. /**
  92740. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92741. */
  92742. updateSpeed: number;
  92743. /**
  92744. * The amount of time the particle system is running (depends of the overall update speed).
  92745. */
  92746. targetStopDuration: number;
  92747. /**
  92748. * The texture used to render each particle. (this can be a spritesheet)
  92749. */
  92750. particleTexture: Nullable<Texture>;
  92751. /**
  92752. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92753. */
  92754. blendMode: number;
  92755. /**
  92756. * Minimum life time of emitting particles.
  92757. */
  92758. minLifeTime: number;
  92759. /**
  92760. * Maximum life time of emitting particles.
  92761. */
  92762. maxLifeTime: number;
  92763. /**
  92764. * Minimum Size of emitting particles.
  92765. */
  92766. minSize: number;
  92767. /**
  92768. * Maximum Size of emitting particles.
  92769. */
  92770. maxSize: number;
  92771. /**
  92772. * Minimum scale of emitting particles on X axis.
  92773. */
  92774. minScaleX: number;
  92775. /**
  92776. * Maximum scale of emitting particles on X axis.
  92777. */
  92778. maxScaleX: number;
  92779. /**
  92780. * Minimum scale of emitting particles on Y axis.
  92781. */
  92782. minScaleY: number;
  92783. /**
  92784. * Maximum scale of emitting particles on Y axis.
  92785. */
  92786. maxScaleY: number;
  92787. /**
  92788. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92789. */
  92790. color1: Color4;
  92791. /**
  92792. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92793. */
  92794. color2: Color4;
  92795. /**
  92796. * Color the particle will have at the end of its lifetime.
  92797. */
  92798. colorDead: Color4;
  92799. /**
  92800. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92801. */
  92802. emitRate: number;
  92803. /**
  92804. * You can use gravity if you want to give an orientation to your particles.
  92805. */
  92806. gravity: Vector3;
  92807. /**
  92808. * Minimum power of emitting particles.
  92809. */
  92810. minEmitPower: number;
  92811. /**
  92812. * Maximum power of emitting particles.
  92813. */
  92814. maxEmitPower: number;
  92815. /**
  92816. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92817. */
  92818. minAngularSpeed: number;
  92819. /**
  92820. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92821. */
  92822. maxAngularSpeed: number;
  92823. /**
  92824. * Gets or sets the minimal initial rotation in radians.
  92825. */
  92826. minInitialRotation: number;
  92827. /**
  92828. * Gets or sets the maximal initial rotation in radians.
  92829. */
  92830. maxInitialRotation: number;
  92831. /**
  92832. * The particle emitter type defines the emitter used by the particle system.
  92833. * It can be for example box, sphere, or cone...
  92834. */
  92835. particleEmitterType: Nullable<IParticleEmitterType>;
  92836. /**
  92837. * Defines the delay in milliseconds before starting the system (0 by default)
  92838. */
  92839. startDelay: number;
  92840. /**
  92841. * 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
  92842. */
  92843. preWarmCycles: number;
  92844. /**
  92845. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92846. */
  92847. preWarmStepOffset: number;
  92848. /**
  92849. * 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)
  92850. */
  92851. spriteCellChangeSpeed: number;
  92852. /**
  92853. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92854. */
  92855. startSpriteCellID: number;
  92856. /**
  92857. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92858. */
  92859. endSpriteCellID: number;
  92860. /**
  92861. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92862. */
  92863. spriteCellWidth: number;
  92864. /**
  92865. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92866. */
  92867. spriteCellHeight: number;
  92868. /**
  92869. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92870. */
  92871. spriteRandomStartCell: boolean;
  92872. /**
  92873. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92874. */
  92875. isAnimationSheetEnabled: boolean;
  92876. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92877. translationPivot: Vector2;
  92878. /**
  92879. * Gets or sets a texture used to add random noise to particle positions
  92880. */
  92881. noiseTexture: Nullable<BaseTexture>;
  92882. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92883. noiseStrength: Vector3;
  92884. /**
  92885. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92886. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92887. */
  92888. billboardMode: number;
  92889. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92890. limitVelocityDamping: number;
  92891. /**
  92892. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92893. */
  92894. beginAnimationOnStart: boolean;
  92895. /**
  92896. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92897. */
  92898. beginAnimationFrom: number;
  92899. /**
  92900. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92901. */
  92902. beginAnimationTo: number;
  92903. /**
  92904. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92905. */
  92906. beginAnimationLoop: boolean;
  92907. /**
  92908. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92909. */
  92910. disposeOnStop: boolean;
  92911. /**
  92912. * Specifies if the particles are updated in emitter local space or world space
  92913. */
  92914. isLocal: boolean;
  92915. /** Snippet ID if the particle system was created from the snippet server */
  92916. snippetId: string;
  92917. /**
  92918. * Gets the maximum number of particles active at the same time.
  92919. * @returns The max number of active particles.
  92920. */
  92921. getCapacity(): number;
  92922. /**
  92923. * Gets the number of particles active at the same time.
  92924. * @returns The number of active particles.
  92925. */
  92926. getActiveCount(): number;
  92927. /**
  92928. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92929. * @returns True if it has been started, otherwise false.
  92930. */
  92931. isStarted(): boolean;
  92932. /**
  92933. * Animates the particle system for this frame.
  92934. */
  92935. animate(): void;
  92936. /**
  92937. * Renders the particle system in its current state.
  92938. * @returns the current number of particles
  92939. */
  92940. render(): number;
  92941. /**
  92942. * Dispose the particle system and frees its associated resources.
  92943. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92944. */
  92945. dispose(disposeTexture?: boolean): void;
  92946. /**
  92947. * An event triggered when the system is disposed
  92948. */
  92949. onDisposeObservable: Observable<IParticleSystem>;
  92950. /**
  92951. * Clones the particle system.
  92952. * @param name The name of the cloned object
  92953. * @param newEmitter The new emitter to use
  92954. * @returns the cloned particle system
  92955. */
  92956. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92957. /**
  92958. * Serializes the particle system to a JSON object
  92959. * @param serializeTexture defines if the texture must be serialized as well
  92960. * @returns the JSON object
  92961. */
  92962. serialize(serializeTexture: boolean): any;
  92963. /**
  92964. * Rebuild the particle system
  92965. */
  92966. rebuild(): void;
  92967. /** Force the system to rebuild all gradients that need to be resync */
  92968. forceRefreshGradients(): void;
  92969. /**
  92970. * Starts the particle system and begins to emit
  92971. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92972. */
  92973. start(delay?: number): void;
  92974. /**
  92975. * Stops the particle system.
  92976. */
  92977. stop(): void;
  92978. /**
  92979. * Remove all active particles
  92980. */
  92981. reset(): void;
  92982. /**
  92983. * Gets a boolean indicating that the system is stopping
  92984. * @returns true if the system is currently stopping
  92985. */
  92986. isStopping(): boolean;
  92987. /**
  92988. * Is this system ready to be used/rendered
  92989. * @return true if the system is ready
  92990. */
  92991. isReady(): boolean;
  92992. /**
  92993. * Returns the string "ParticleSystem"
  92994. * @returns a string containing the class name
  92995. */
  92996. getClassName(): string;
  92997. /**
  92998. * Gets the custom effect used to render the particles
  92999. * @param blendMode Blend mode for which the effect should be retrieved
  93000. * @returns The effect
  93001. */
  93002. getCustomEffect(blendMode: number): Nullable<Effect>;
  93003. /**
  93004. * Sets the custom effect used to render the particles
  93005. * @param effect The effect to set
  93006. * @param blendMode Blend mode for which the effect should be set
  93007. */
  93008. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93009. /**
  93010. * Fill the defines array according to the current settings of the particle system
  93011. * @param defines Array to be updated
  93012. * @param blendMode blend mode to take into account when updating the array
  93013. */
  93014. fillDefines(defines: Array<string>, blendMode: number): void;
  93015. /**
  93016. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93017. * @param uniforms Uniforms array to fill
  93018. * @param attributes Attributes array to fill
  93019. * @param samplers Samplers array to fill
  93020. */
  93021. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93022. /**
  93023. * Observable that will be called just before the particles are drawn
  93024. */
  93025. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93026. /**
  93027. * Gets the name of the particle vertex shader
  93028. */
  93029. vertexShaderName: string;
  93030. /**
  93031. * Adds a new color gradient
  93032. * @param gradient defines the gradient to use (between 0 and 1)
  93033. * @param color1 defines the color to affect to the specified gradient
  93034. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93035. * @returns the current particle system
  93036. */
  93037. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93038. /**
  93039. * Remove a specific color gradient
  93040. * @param gradient defines the gradient to remove
  93041. * @returns the current particle system
  93042. */
  93043. removeColorGradient(gradient: number): IParticleSystem;
  93044. /**
  93045. * Adds a new size gradient
  93046. * @param gradient defines the gradient to use (between 0 and 1)
  93047. * @param factor defines the size factor to affect to the specified gradient
  93048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93049. * @returns the current particle system
  93050. */
  93051. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93052. /**
  93053. * Remove a specific size gradient
  93054. * @param gradient defines the gradient to remove
  93055. * @returns the current particle system
  93056. */
  93057. removeSizeGradient(gradient: number): IParticleSystem;
  93058. /**
  93059. * Gets the current list of color gradients.
  93060. * You must use addColorGradient and removeColorGradient to udpate this list
  93061. * @returns the list of color gradients
  93062. */
  93063. getColorGradients(): Nullable<Array<ColorGradient>>;
  93064. /**
  93065. * Gets the current list of size gradients.
  93066. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93067. * @returns the list of size gradients
  93068. */
  93069. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93070. /**
  93071. * Gets the current list of angular speed gradients.
  93072. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93073. * @returns the list of angular speed gradients
  93074. */
  93075. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93076. /**
  93077. * Adds a new angular speed gradient
  93078. * @param gradient defines the gradient to use (between 0 and 1)
  93079. * @param factor defines the angular speed to affect to the specified gradient
  93080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93081. * @returns the current particle system
  93082. */
  93083. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93084. /**
  93085. * Remove a specific angular speed gradient
  93086. * @param gradient defines the gradient to remove
  93087. * @returns the current particle system
  93088. */
  93089. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93090. /**
  93091. * Gets the current list of velocity gradients.
  93092. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93093. * @returns the list of velocity gradients
  93094. */
  93095. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93096. /**
  93097. * Adds a new velocity gradient
  93098. * @param gradient defines the gradient to use (between 0 and 1)
  93099. * @param factor defines the velocity to affect to the specified gradient
  93100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93101. * @returns the current particle system
  93102. */
  93103. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93104. /**
  93105. * Remove a specific velocity gradient
  93106. * @param gradient defines the gradient to remove
  93107. * @returns the current particle system
  93108. */
  93109. removeVelocityGradient(gradient: number): IParticleSystem;
  93110. /**
  93111. * Gets the current list of limit velocity gradients.
  93112. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93113. * @returns the list of limit velocity gradients
  93114. */
  93115. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93116. /**
  93117. * Adds a new limit velocity gradient
  93118. * @param gradient defines the gradient to use (between 0 and 1)
  93119. * @param factor defines the limit velocity to affect to the specified gradient
  93120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93121. * @returns the current particle system
  93122. */
  93123. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93124. /**
  93125. * Remove a specific limit velocity gradient
  93126. * @param gradient defines the gradient to remove
  93127. * @returns the current particle system
  93128. */
  93129. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93130. /**
  93131. * Adds a new drag gradient
  93132. * @param gradient defines the gradient to use (between 0 and 1)
  93133. * @param factor defines the drag to affect to the specified gradient
  93134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93135. * @returns the current particle system
  93136. */
  93137. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93138. /**
  93139. * Remove a specific drag gradient
  93140. * @param gradient defines the gradient to remove
  93141. * @returns the current particle system
  93142. */
  93143. removeDragGradient(gradient: number): IParticleSystem;
  93144. /**
  93145. * Gets the current list of drag gradients.
  93146. * You must use addDragGradient and removeDragGradient to udpate this list
  93147. * @returns the list of drag gradients
  93148. */
  93149. getDragGradients(): Nullable<Array<FactorGradient>>;
  93150. /**
  93151. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93152. * @param gradient defines the gradient to use (between 0 and 1)
  93153. * @param factor defines the emit rate to affect to the specified gradient
  93154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93155. * @returns the current particle system
  93156. */
  93157. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93158. /**
  93159. * Remove a specific emit rate gradient
  93160. * @param gradient defines the gradient to remove
  93161. * @returns the current particle system
  93162. */
  93163. removeEmitRateGradient(gradient: number): IParticleSystem;
  93164. /**
  93165. * Gets the current list of emit rate gradients.
  93166. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93167. * @returns the list of emit rate gradients
  93168. */
  93169. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93170. /**
  93171. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93172. * @param gradient defines the gradient to use (between 0 and 1)
  93173. * @param factor defines the start size to affect to the specified gradient
  93174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93175. * @returns the current particle system
  93176. */
  93177. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93178. /**
  93179. * Remove a specific start size gradient
  93180. * @param gradient defines the gradient to remove
  93181. * @returns the current particle system
  93182. */
  93183. removeStartSizeGradient(gradient: number): IParticleSystem;
  93184. /**
  93185. * Gets the current list of start size gradients.
  93186. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93187. * @returns the list of start size gradients
  93188. */
  93189. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93190. /**
  93191. * Adds a new life time gradient
  93192. * @param gradient defines the gradient to use (between 0 and 1)
  93193. * @param factor defines the life time factor to affect to the specified gradient
  93194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93195. * @returns the current particle system
  93196. */
  93197. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93198. /**
  93199. * Remove a specific life time gradient
  93200. * @param gradient defines the gradient to remove
  93201. * @returns the current particle system
  93202. */
  93203. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93204. /**
  93205. * Gets the current list of life time gradients.
  93206. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93207. * @returns the list of life time gradients
  93208. */
  93209. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93210. /**
  93211. * Gets the current list of color gradients.
  93212. * You must use addColorGradient and removeColorGradient to udpate this list
  93213. * @returns the list of color gradients
  93214. */
  93215. getColorGradients(): Nullable<Array<ColorGradient>>;
  93216. /**
  93217. * Adds a new ramp gradient used to remap particle colors
  93218. * @param gradient defines the gradient to use (between 0 and 1)
  93219. * @param color defines the color to affect to the specified gradient
  93220. * @returns the current particle system
  93221. */
  93222. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93223. /**
  93224. * Gets the current list of ramp gradients.
  93225. * You must use addRampGradient and removeRampGradient to udpate this list
  93226. * @returns the list of ramp gradients
  93227. */
  93228. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93229. /** Gets or sets a boolean indicating that ramp gradients must be used
  93230. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93231. */
  93232. useRampGradients: boolean;
  93233. /**
  93234. * Adds a new color remap gradient
  93235. * @param gradient defines the gradient to use (between 0 and 1)
  93236. * @param min defines the color remap minimal range
  93237. * @param max defines the color remap maximal range
  93238. * @returns the current particle system
  93239. */
  93240. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93241. /**
  93242. * Gets the current list of color remap gradients.
  93243. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93244. * @returns the list of color remap gradients
  93245. */
  93246. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93247. /**
  93248. * Adds a new alpha remap gradient
  93249. * @param gradient defines the gradient to use (between 0 and 1)
  93250. * @param min defines the alpha remap minimal range
  93251. * @param max defines the alpha remap maximal range
  93252. * @returns the current particle system
  93253. */
  93254. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93255. /**
  93256. * Gets the current list of alpha remap gradients.
  93257. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93258. * @returns the list of alpha remap gradients
  93259. */
  93260. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93261. /**
  93262. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93263. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93264. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93265. * @returns the emitter
  93266. */
  93267. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93268. /**
  93269. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93270. * @param radius The radius of the hemisphere to emit from
  93271. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93272. * @returns the emitter
  93273. */
  93274. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93275. /**
  93276. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93277. * @param radius The radius of the sphere to emit from
  93278. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93279. * @returns the emitter
  93280. */
  93281. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93282. /**
  93283. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93284. * @param radius The radius of the sphere to emit from
  93285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93287. * @returns the emitter
  93288. */
  93289. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93290. /**
  93291. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93292. * @param radius The radius of the emission cylinder
  93293. * @param height The height of the emission cylinder
  93294. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93295. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93296. * @returns the emitter
  93297. */
  93298. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93299. /**
  93300. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93301. * @param radius The radius of the cylinder to emit from
  93302. * @param height The height of the emission cylinder
  93303. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93304. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93305. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93306. * @returns the emitter
  93307. */
  93308. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93309. /**
  93310. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93311. * @param radius The radius of the cone to emit from
  93312. * @param angle The base angle of the cone
  93313. * @returns the emitter
  93314. */
  93315. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93316. /**
  93317. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93318. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93319. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93320. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93321. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93322. * @returns the emitter
  93323. */
  93324. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93325. /**
  93326. * Get hosting scene
  93327. * @returns the scene
  93328. */
  93329. getScene(): Scene;
  93330. }
  93331. }
  93332. declare module BABYLON {
  93333. /**
  93334. * 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.
  93335. * @see https://doc.babylonjs.com/how_to/transformnode
  93336. */
  93337. export class TransformNode extends Node {
  93338. /**
  93339. * Object will not rotate to face the camera
  93340. */
  93341. static BILLBOARDMODE_NONE: number;
  93342. /**
  93343. * Object will rotate to face the camera but only on the x axis
  93344. */
  93345. static BILLBOARDMODE_X: number;
  93346. /**
  93347. * Object will rotate to face the camera but only on the y axis
  93348. */
  93349. static BILLBOARDMODE_Y: number;
  93350. /**
  93351. * Object will rotate to face the camera but only on the z axis
  93352. */
  93353. static BILLBOARDMODE_Z: number;
  93354. /**
  93355. * Object will rotate to face the camera
  93356. */
  93357. static BILLBOARDMODE_ALL: number;
  93358. /**
  93359. * Object will rotate to face the camera's position instead of orientation
  93360. */
  93361. static BILLBOARDMODE_USE_POSITION: number;
  93362. private static _TmpRotation;
  93363. private static _TmpScaling;
  93364. private static _TmpTranslation;
  93365. private _forward;
  93366. private _forwardInverted;
  93367. private _up;
  93368. private _right;
  93369. private _rightInverted;
  93370. private _position;
  93371. private _rotation;
  93372. private _rotationQuaternion;
  93373. protected _scaling: Vector3;
  93374. protected _isDirty: boolean;
  93375. private _transformToBoneReferal;
  93376. private _isAbsoluteSynced;
  93377. private _billboardMode;
  93378. /**
  93379. * Gets or sets the billboard mode. Default is 0.
  93380. *
  93381. * | Value | Type | Description |
  93382. * | --- | --- | --- |
  93383. * | 0 | BILLBOARDMODE_NONE | |
  93384. * | 1 | BILLBOARDMODE_X | |
  93385. * | 2 | BILLBOARDMODE_Y | |
  93386. * | 4 | BILLBOARDMODE_Z | |
  93387. * | 7 | BILLBOARDMODE_ALL | |
  93388. *
  93389. */
  93390. get billboardMode(): number;
  93391. set billboardMode(value: number);
  93392. private _preserveParentRotationForBillboard;
  93393. /**
  93394. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93395. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93396. */
  93397. get preserveParentRotationForBillboard(): boolean;
  93398. set preserveParentRotationForBillboard(value: boolean);
  93399. /**
  93400. * 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
  93401. */
  93402. scalingDeterminant: number;
  93403. private _infiniteDistance;
  93404. /**
  93405. * Gets or sets the distance of the object to max, often used by skybox
  93406. */
  93407. get infiniteDistance(): boolean;
  93408. set infiniteDistance(value: boolean);
  93409. /**
  93410. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93411. * By default the system will update normals to compensate
  93412. */
  93413. ignoreNonUniformScaling: boolean;
  93414. /**
  93415. * 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
  93416. */
  93417. reIntegrateRotationIntoRotationQuaternion: boolean;
  93418. /** @hidden */
  93419. _poseMatrix: Nullable<Matrix>;
  93420. /** @hidden */
  93421. _localMatrix: Matrix;
  93422. private _usePivotMatrix;
  93423. private _absolutePosition;
  93424. private _absoluteScaling;
  93425. private _absoluteRotationQuaternion;
  93426. private _pivotMatrix;
  93427. private _pivotMatrixInverse;
  93428. protected _postMultiplyPivotMatrix: boolean;
  93429. protected _isWorldMatrixFrozen: boolean;
  93430. /** @hidden */
  93431. _indexInSceneTransformNodesArray: number;
  93432. /**
  93433. * An event triggered after the world matrix is updated
  93434. */
  93435. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93436. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93437. /**
  93438. * Gets a string identifying the name of the class
  93439. * @returns "TransformNode" string
  93440. */
  93441. getClassName(): string;
  93442. /**
  93443. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93444. */
  93445. get position(): Vector3;
  93446. set position(newPosition: Vector3);
  93447. /**
  93448. * 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)).
  93449. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93450. */
  93451. get rotation(): Vector3;
  93452. set rotation(newRotation: Vector3);
  93453. /**
  93454. * 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)).
  93455. */
  93456. get scaling(): Vector3;
  93457. set scaling(newScaling: Vector3);
  93458. /**
  93459. * 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).
  93460. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93461. */
  93462. get rotationQuaternion(): Nullable<Quaternion>;
  93463. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93464. /**
  93465. * The forward direction of that transform in world space.
  93466. */
  93467. get forward(): Vector3;
  93468. /**
  93469. * The up direction of that transform in world space.
  93470. */
  93471. get up(): Vector3;
  93472. /**
  93473. * The right direction of that transform in world space.
  93474. */
  93475. get right(): Vector3;
  93476. /**
  93477. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93478. * @param matrix the matrix to copy the pose from
  93479. * @returns this TransformNode.
  93480. */
  93481. updatePoseMatrix(matrix: Matrix): TransformNode;
  93482. /**
  93483. * Returns the mesh Pose matrix.
  93484. * @returns the pose matrix
  93485. */
  93486. getPoseMatrix(): Matrix;
  93487. /** @hidden */
  93488. _isSynchronized(): boolean;
  93489. /** @hidden */
  93490. _initCache(): void;
  93491. /**
  93492. * Flag the transform node as dirty (Forcing it to update everything)
  93493. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93494. * @returns this transform node
  93495. */
  93496. markAsDirty(property: string): TransformNode;
  93497. /**
  93498. * Returns the current mesh absolute position.
  93499. * Returns a Vector3.
  93500. */
  93501. get absolutePosition(): Vector3;
  93502. /**
  93503. * Returns the current mesh absolute scaling.
  93504. * Returns a Vector3.
  93505. */
  93506. get absoluteScaling(): Vector3;
  93507. /**
  93508. * Returns the current mesh absolute rotation.
  93509. * Returns a Quaternion.
  93510. */
  93511. get absoluteRotationQuaternion(): Quaternion;
  93512. /**
  93513. * Sets a new matrix to apply before all other transformation
  93514. * @param matrix defines the transform matrix
  93515. * @returns the current TransformNode
  93516. */
  93517. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93518. /**
  93519. * Sets a new pivot matrix to the current node
  93520. * @param matrix defines the new pivot matrix to use
  93521. * @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
  93522. * @returns the current TransformNode
  93523. */
  93524. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93525. /**
  93526. * Returns the mesh pivot matrix.
  93527. * Default : Identity.
  93528. * @returns the matrix
  93529. */
  93530. getPivotMatrix(): Matrix;
  93531. /**
  93532. * Instantiate (when possible) or clone that node with its hierarchy
  93533. * @param newParent defines the new parent to use for the instance (or clone)
  93534. * @param options defines options to configure how copy is done
  93535. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93536. * @returns an instance (or a clone) of the current node with its hiearchy
  93537. */
  93538. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93539. doNotInstantiate: boolean;
  93540. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93541. /**
  93542. * Prevents the World matrix to be computed any longer
  93543. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93544. * @returns the TransformNode.
  93545. */
  93546. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93547. /**
  93548. * Allows back the World matrix computation.
  93549. * @returns the TransformNode.
  93550. */
  93551. unfreezeWorldMatrix(): this;
  93552. /**
  93553. * True if the World matrix has been frozen.
  93554. */
  93555. get isWorldMatrixFrozen(): boolean;
  93556. /**
  93557. * Retuns the mesh absolute position in the World.
  93558. * @returns a Vector3.
  93559. */
  93560. getAbsolutePosition(): Vector3;
  93561. /**
  93562. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93563. * @param absolutePosition the absolute position to set
  93564. * @returns the TransformNode.
  93565. */
  93566. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93567. /**
  93568. * Sets the mesh position in its local space.
  93569. * @param vector3 the position to set in localspace
  93570. * @returns the TransformNode.
  93571. */
  93572. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93573. /**
  93574. * Returns the mesh position in the local space from the current World matrix values.
  93575. * @returns a new Vector3.
  93576. */
  93577. getPositionExpressedInLocalSpace(): Vector3;
  93578. /**
  93579. * Translates the mesh along the passed Vector3 in its local space.
  93580. * @param vector3 the distance to translate in localspace
  93581. * @returns the TransformNode.
  93582. */
  93583. locallyTranslate(vector3: Vector3): TransformNode;
  93584. private static _lookAtVectorCache;
  93585. /**
  93586. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93587. * @param targetPoint the position (must be in same space as current mesh) to look at
  93588. * @param yawCor optional yaw (y-axis) correction in radians
  93589. * @param pitchCor optional pitch (x-axis) correction in radians
  93590. * @param rollCor optional roll (z-axis) correction in radians
  93591. * @param space the choosen space of the target
  93592. * @returns the TransformNode.
  93593. */
  93594. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93595. /**
  93596. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93597. * This Vector3 is expressed in the World space.
  93598. * @param localAxis axis to rotate
  93599. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93600. */
  93601. getDirection(localAxis: Vector3): Vector3;
  93602. /**
  93603. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93604. * localAxis is expressed in the mesh local space.
  93605. * result is computed in the Wordl space from the mesh World matrix.
  93606. * @param localAxis axis to rotate
  93607. * @param result the resulting transformnode
  93608. * @returns this TransformNode.
  93609. */
  93610. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93611. /**
  93612. * Sets this transform node rotation to the given local axis.
  93613. * @param localAxis the axis in local space
  93614. * @param yawCor optional yaw (y-axis) correction in radians
  93615. * @param pitchCor optional pitch (x-axis) correction in radians
  93616. * @param rollCor optional roll (z-axis) correction in radians
  93617. * @returns this TransformNode
  93618. */
  93619. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93620. /**
  93621. * Sets a new pivot point to the current node
  93622. * @param point defines the new pivot point to use
  93623. * @param space defines if the point is in world or local space (local by default)
  93624. * @returns the current TransformNode
  93625. */
  93626. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93627. /**
  93628. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93629. * @returns the pivot point
  93630. */
  93631. getPivotPoint(): Vector3;
  93632. /**
  93633. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93634. * @param result the vector3 to store the result
  93635. * @returns this TransformNode.
  93636. */
  93637. getPivotPointToRef(result: Vector3): TransformNode;
  93638. /**
  93639. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93640. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93641. */
  93642. getAbsolutePivotPoint(): Vector3;
  93643. /**
  93644. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93645. * @param result vector3 to store the result
  93646. * @returns this TransformNode.
  93647. */
  93648. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93649. /**
  93650. * Defines the passed node as the parent of the current node.
  93651. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93652. * @see https://doc.babylonjs.com/how_to/parenting
  93653. * @param node the node ot set as the parent
  93654. * @returns this TransformNode.
  93655. */
  93656. setParent(node: Nullable<Node>): TransformNode;
  93657. private _nonUniformScaling;
  93658. /**
  93659. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93660. */
  93661. get nonUniformScaling(): boolean;
  93662. /** @hidden */
  93663. _updateNonUniformScalingState(value: boolean): boolean;
  93664. /**
  93665. * Attach the current TransformNode to another TransformNode associated with a bone
  93666. * @param bone Bone affecting the TransformNode
  93667. * @param affectedTransformNode TransformNode associated with the bone
  93668. * @returns this object
  93669. */
  93670. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93671. /**
  93672. * Detach the transform node if its associated with a bone
  93673. * @returns this object
  93674. */
  93675. detachFromBone(): TransformNode;
  93676. private static _rotationAxisCache;
  93677. /**
  93678. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93679. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93680. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93681. * The passed axis is also normalized.
  93682. * @param axis the axis to rotate around
  93683. * @param amount the amount to rotate in radians
  93684. * @param space Space to rotate in (Default: local)
  93685. * @returns the TransformNode.
  93686. */
  93687. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93688. /**
  93689. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93690. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93691. * The passed axis is also normalized. .
  93692. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93693. * @param point the point to rotate around
  93694. * @param axis the axis to rotate around
  93695. * @param amount the amount to rotate in radians
  93696. * @returns the TransformNode
  93697. */
  93698. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93699. /**
  93700. * Translates the mesh along the axis vector for the passed distance in the given space.
  93701. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93702. * @param axis the axis to translate in
  93703. * @param distance the distance to translate
  93704. * @param space Space to rotate in (Default: local)
  93705. * @returns the TransformNode.
  93706. */
  93707. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93708. /**
  93709. * Adds a rotation step to the mesh current rotation.
  93710. * x, y, z are Euler angles expressed in radians.
  93711. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93712. * This means this rotation is made in the mesh local space only.
  93713. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93714. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93715. * ```javascript
  93716. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93717. * ```
  93718. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93719. * 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.
  93720. * @param x Rotation to add
  93721. * @param y Rotation to add
  93722. * @param z Rotation to add
  93723. * @returns the TransformNode.
  93724. */
  93725. addRotation(x: number, y: number, z: number): TransformNode;
  93726. /**
  93727. * @hidden
  93728. */
  93729. protected _getEffectiveParent(): Nullable<Node>;
  93730. /**
  93731. * Computes the world matrix of the node
  93732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93733. * @returns the world matrix
  93734. */
  93735. computeWorldMatrix(force?: boolean): Matrix;
  93736. /**
  93737. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93738. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93739. */
  93740. resetLocalMatrix(independentOfChildren?: boolean): void;
  93741. protected _afterComputeWorldMatrix(): void;
  93742. /**
  93743. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93744. * @param func callback function to add
  93745. *
  93746. * @returns the TransformNode.
  93747. */
  93748. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93749. /**
  93750. * Removes a registered callback function.
  93751. * @param func callback function to remove
  93752. * @returns the TransformNode.
  93753. */
  93754. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93755. /**
  93756. * Gets the position of the current mesh in camera space
  93757. * @param camera defines the camera to use
  93758. * @returns a position
  93759. */
  93760. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93761. /**
  93762. * Returns the distance from the mesh to the active camera
  93763. * @param camera defines the camera to use
  93764. * @returns the distance
  93765. */
  93766. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93767. /**
  93768. * Clone the current transform node
  93769. * @param name Name of the new clone
  93770. * @param newParent New parent for the clone
  93771. * @param doNotCloneChildren Do not clone children hierarchy
  93772. * @returns the new transform node
  93773. */
  93774. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93775. /**
  93776. * Serializes the objects information.
  93777. * @param currentSerializationObject defines the object to serialize in
  93778. * @returns the serialized object
  93779. */
  93780. serialize(currentSerializationObject?: any): any;
  93781. /**
  93782. * Returns a new TransformNode object parsed from the source provided.
  93783. * @param parsedTransformNode is the source.
  93784. * @param scene the scne the object belongs to
  93785. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93786. * @returns a new TransformNode object parsed from the source provided.
  93787. */
  93788. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93789. /**
  93790. * Get all child-transformNodes of this node
  93791. * @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
  93792. * @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
  93793. * @returns an array of TransformNode
  93794. */
  93795. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93796. /**
  93797. * Releases resources associated with this transform node.
  93798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93800. */
  93801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93802. /**
  93803. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93804. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93805. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93806. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93807. * @returns the current mesh
  93808. */
  93809. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93810. private _syncAbsoluteScalingAndRotation;
  93811. }
  93812. }
  93813. declare module BABYLON {
  93814. /**
  93815. * Class used to override all child animations of a given target
  93816. */
  93817. export class AnimationPropertiesOverride {
  93818. /**
  93819. * Gets or sets a value indicating if animation blending must be used
  93820. */
  93821. enableBlending: boolean;
  93822. /**
  93823. * Gets or sets the blending speed to use when enableBlending is true
  93824. */
  93825. blendingSpeed: number;
  93826. /**
  93827. * Gets or sets the default loop mode to use
  93828. */
  93829. loopMode: number;
  93830. }
  93831. }
  93832. declare module BABYLON {
  93833. /**
  93834. * Class used to store bone information
  93835. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93836. */
  93837. export class Bone extends Node {
  93838. /**
  93839. * defines the bone name
  93840. */
  93841. name: string;
  93842. private static _tmpVecs;
  93843. private static _tmpQuat;
  93844. private static _tmpMats;
  93845. /**
  93846. * Gets the list of child bones
  93847. */
  93848. children: Bone[];
  93849. /** Gets the animations associated with this bone */
  93850. animations: Animation[];
  93851. /**
  93852. * Gets or sets bone length
  93853. */
  93854. length: number;
  93855. /**
  93856. * @hidden Internal only
  93857. * Set this value to map this bone to a different index in the transform matrices
  93858. * Set this value to -1 to exclude the bone from the transform matrices
  93859. */
  93860. _index: Nullable<number>;
  93861. private _skeleton;
  93862. private _localMatrix;
  93863. private _restPose;
  93864. private _baseMatrix;
  93865. private _absoluteTransform;
  93866. private _invertedAbsoluteTransform;
  93867. private _parent;
  93868. private _scalingDeterminant;
  93869. private _worldTransform;
  93870. private _localScaling;
  93871. private _localRotation;
  93872. private _localPosition;
  93873. private _needToDecompose;
  93874. private _needToCompose;
  93875. /** @hidden */
  93876. _linkedTransformNode: Nullable<TransformNode>;
  93877. /** @hidden */
  93878. _waitingTransformNodeId: Nullable<string>;
  93879. /** @hidden */
  93880. get _matrix(): Matrix;
  93881. /** @hidden */
  93882. set _matrix(value: Matrix);
  93883. /**
  93884. * Create a new bone
  93885. * @param name defines the bone name
  93886. * @param skeleton defines the parent skeleton
  93887. * @param parentBone defines the parent (can be null if the bone is the root)
  93888. * @param localMatrix defines the local matrix
  93889. * @param restPose defines the rest pose matrix
  93890. * @param baseMatrix defines the base matrix
  93891. * @param index defines index of the bone in the hiearchy
  93892. */
  93893. constructor(
  93894. /**
  93895. * defines the bone name
  93896. */
  93897. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93898. /**
  93899. * Gets the current object class name.
  93900. * @return the class name
  93901. */
  93902. getClassName(): string;
  93903. /**
  93904. * Gets the parent skeleton
  93905. * @returns a skeleton
  93906. */
  93907. getSkeleton(): Skeleton;
  93908. /**
  93909. * Gets parent bone
  93910. * @returns a bone or null if the bone is the root of the bone hierarchy
  93911. */
  93912. getParent(): Nullable<Bone>;
  93913. /**
  93914. * Returns an array containing the root bones
  93915. * @returns an array containing the root bones
  93916. */
  93917. getChildren(): Array<Bone>;
  93918. /**
  93919. * Gets the node index in matrix array generated for rendering
  93920. * @returns the node index
  93921. */
  93922. getIndex(): number;
  93923. /**
  93924. * Sets the parent bone
  93925. * @param parent defines the parent (can be null if the bone is the root)
  93926. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93927. */
  93928. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93929. /**
  93930. * Gets the local matrix
  93931. * @returns a matrix
  93932. */
  93933. getLocalMatrix(): Matrix;
  93934. /**
  93935. * Gets the base matrix (initial matrix which remains unchanged)
  93936. * @returns a matrix
  93937. */
  93938. getBaseMatrix(): Matrix;
  93939. /**
  93940. * Gets the rest pose matrix
  93941. * @returns a matrix
  93942. */
  93943. getRestPose(): Matrix;
  93944. /**
  93945. * Sets the rest pose matrix
  93946. * @param matrix the local-space rest pose to set for this bone
  93947. */
  93948. setRestPose(matrix: Matrix): void;
  93949. /**
  93950. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93951. */
  93952. getWorldMatrix(): Matrix;
  93953. /**
  93954. * Sets the local matrix to rest pose matrix
  93955. */
  93956. returnToRest(): void;
  93957. /**
  93958. * Gets the inverse of the absolute transform matrix.
  93959. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93960. * @returns a matrix
  93961. */
  93962. getInvertedAbsoluteTransform(): Matrix;
  93963. /**
  93964. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93965. * @returns a matrix
  93966. */
  93967. getAbsoluteTransform(): Matrix;
  93968. /**
  93969. * Links with the given transform node.
  93970. * The local matrix of this bone is copied from the transform node every frame.
  93971. * @param transformNode defines the transform node to link to
  93972. */
  93973. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93974. /**
  93975. * Gets the node used to drive the bone's transformation
  93976. * @returns a transform node or null
  93977. */
  93978. getTransformNode(): Nullable<TransformNode>;
  93979. /** Gets or sets current position (in local space) */
  93980. get position(): Vector3;
  93981. set position(newPosition: Vector3);
  93982. /** Gets or sets current rotation (in local space) */
  93983. get rotation(): Vector3;
  93984. set rotation(newRotation: Vector3);
  93985. /** Gets or sets current rotation quaternion (in local space) */
  93986. get rotationQuaternion(): Quaternion;
  93987. set rotationQuaternion(newRotation: Quaternion);
  93988. /** Gets or sets current scaling (in local space) */
  93989. get scaling(): Vector3;
  93990. set scaling(newScaling: Vector3);
  93991. /**
  93992. * Gets the animation properties override
  93993. */
  93994. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93995. private _decompose;
  93996. private _compose;
  93997. /**
  93998. * Update the base and local matrices
  93999. * @param matrix defines the new base or local matrix
  94000. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94001. * @param updateLocalMatrix defines if the local matrix should be updated
  94002. */
  94003. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94004. /** @hidden */
  94005. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94006. /**
  94007. * Flag the bone as dirty (Forcing it to update everything)
  94008. */
  94009. markAsDirty(): void;
  94010. /** @hidden */
  94011. _markAsDirtyAndCompose(): void;
  94012. private _markAsDirtyAndDecompose;
  94013. /**
  94014. * Translate the bone in local or world space
  94015. * @param vec The amount to translate the bone
  94016. * @param space The space that the translation is in
  94017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94018. */
  94019. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94020. /**
  94021. * Set the postion of the bone in local or world space
  94022. * @param position The position to set the bone
  94023. * @param space The space that the position is in
  94024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94025. */
  94026. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94027. /**
  94028. * Set the absolute position of the bone (world space)
  94029. * @param position The position to set the bone
  94030. * @param mesh The mesh that this bone is attached to
  94031. */
  94032. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94033. /**
  94034. * Scale the bone on the x, y and z axes (in local space)
  94035. * @param x The amount to scale the bone on the x axis
  94036. * @param y The amount to scale the bone on the y axis
  94037. * @param z The amount to scale the bone on the z axis
  94038. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94039. */
  94040. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94041. /**
  94042. * Set the bone scaling in local space
  94043. * @param scale defines the scaling vector
  94044. */
  94045. setScale(scale: Vector3): void;
  94046. /**
  94047. * Gets the current scaling in local space
  94048. * @returns the current scaling vector
  94049. */
  94050. getScale(): Vector3;
  94051. /**
  94052. * Gets the current scaling in local space and stores it in a target vector
  94053. * @param result defines the target vector
  94054. */
  94055. getScaleToRef(result: Vector3): void;
  94056. /**
  94057. * Set the yaw, pitch, and roll of the bone in local or world space
  94058. * @param yaw The rotation of the bone on the y axis
  94059. * @param pitch The rotation of the bone on the x axis
  94060. * @param roll The rotation of the bone on the z axis
  94061. * @param space The space that the axes of rotation are in
  94062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94063. */
  94064. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94065. /**
  94066. * Add a rotation to the bone on an axis in local or world space
  94067. * @param axis The axis to rotate the bone on
  94068. * @param amount The amount to rotate the bone
  94069. * @param space The space that the axis is in
  94070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94071. */
  94072. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94073. /**
  94074. * Set the rotation of the bone to a particular axis angle in local or world space
  94075. * @param axis The axis to rotate the bone on
  94076. * @param angle The angle that the bone should be rotated to
  94077. * @param space The space that the axis is in
  94078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94079. */
  94080. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94081. /**
  94082. * Set the euler rotation of the bone in local of world space
  94083. * @param rotation The euler rotation that the bone should be set to
  94084. * @param space The space that the rotation is in
  94085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94086. */
  94087. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94088. /**
  94089. * Set the quaternion rotation of the bone in local of world space
  94090. * @param quat The quaternion rotation that the bone should be set to
  94091. * @param space The space that the rotation is in
  94092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94093. */
  94094. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94095. /**
  94096. * Set the rotation matrix of the bone in local of world space
  94097. * @param rotMat The rotation matrix that the bone should be set to
  94098. * @param space The space that the rotation is in
  94099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94100. */
  94101. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  94102. private _rotateWithMatrix;
  94103. private _getNegativeRotationToRef;
  94104. /**
  94105. * Get the position of the bone in local or world space
  94106. * @param space The space that the returned position is in
  94107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94108. * @returns The position of the bone
  94109. */
  94110. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94111. /**
  94112. * Copy the position of the bone to a vector3 in local or world space
  94113. * @param space The space that the returned position is in
  94114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94115. * @param result The vector3 to copy the position to
  94116. */
  94117. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  94118. /**
  94119. * Get the absolute position of the bone (world space)
  94120. * @param mesh The mesh that this bone is attached to
  94121. * @returns The absolute position of the bone
  94122. */
  94123. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  94124. /**
  94125. * Copy the absolute position of the bone (world space) to the result param
  94126. * @param mesh The mesh that this bone is attached to
  94127. * @param result The vector3 to copy the absolute position to
  94128. */
  94129. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  94130. /**
  94131. * Compute the absolute transforms of this bone and its children
  94132. */
  94133. computeAbsoluteTransforms(): void;
  94134. /**
  94135. * Get the world direction from an axis that is in the local space of the bone
  94136. * @param localAxis The local direction that is used to compute the world direction
  94137. * @param mesh The mesh that this bone is attached to
  94138. * @returns The world direction
  94139. */
  94140. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94141. /**
  94142. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  94143. * @param localAxis The local direction that is used to compute the world direction
  94144. * @param mesh The mesh that this bone is attached to
  94145. * @param result The vector3 that the world direction will be copied to
  94146. */
  94147. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94148. /**
  94149. * Get the euler rotation of the bone in local or world space
  94150. * @param space The space that the rotation should be in
  94151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94152. * @returns The euler rotation
  94153. */
  94154. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94155. /**
  94156. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  94157. * @param space The space that the rotation should be in
  94158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94159. * @param result The vector3 that the rotation should be copied to
  94160. */
  94161. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94162. /**
  94163. * Get the quaternion rotation of the bone in either local or world space
  94164. * @param space The space that the rotation should be in
  94165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94166. * @returns The quaternion rotation
  94167. */
  94168. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  94169. /**
  94170. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  94171. * @param space The space that the rotation should be in
  94172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94173. * @param result The quaternion that the rotation should be copied to
  94174. */
  94175. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94176. /**
  94177. * Get the rotation matrix of the bone in local or world space
  94178. * @param space The space that the rotation should be in
  94179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94180. * @returns The rotation matrix
  94181. */
  94182. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94183. /**
  94184. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94185. * @param space The space that the rotation should be in
  94186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94187. * @param result The quaternion that the rotation should be copied to
  94188. */
  94189. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94190. /**
  94191. * Get the world position of a point that is in the local space of the bone
  94192. * @param position The local position
  94193. * @param mesh The mesh that this bone is attached to
  94194. * @returns The world position
  94195. */
  94196. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94197. /**
  94198. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94199. * @param position The local position
  94200. * @param mesh The mesh that this bone is attached to
  94201. * @param result The vector3 that the world position should be copied to
  94202. */
  94203. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94204. /**
  94205. * Get the local position of a point that is in world space
  94206. * @param position The world position
  94207. * @param mesh The mesh that this bone is attached to
  94208. * @returns The local position
  94209. */
  94210. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94211. /**
  94212. * Get the local position of a point that is in world space and copy it to the result param
  94213. * @param position The world position
  94214. * @param mesh The mesh that this bone is attached to
  94215. * @param result The vector3 that the local position should be copied to
  94216. */
  94217. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94218. }
  94219. }
  94220. declare module BABYLON {
  94221. /**
  94222. * Defines a runtime animation
  94223. */
  94224. export class RuntimeAnimation {
  94225. private _events;
  94226. /**
  94227. * The current frame of the runtime animation
  94228. */
  94229. private _currentFrame;
  94230. /**
  94231. * The animation used by the runtime animation
  94232. */
  94233. private _animation;
  94234. /**
  94235. * The target of the runtime animation
  94236. */
  94237. private _target;
  94238. /**
  94239. * The initiating animatable
  94240. */
  94241. private _host;
  94242. /**
  94243. * The original value of the runtime animation
  94244. */
  94245. private _originalValue;
  94246. /**
  94247. * The original blend value of the runtime animation
  94248. */
  94249. private _originalBlendValue;
  94250. /**
  94251. * The offsets cache of the runtime animation
  94252. */
  94253. private _offsetsCache;
  94254. /**
  94255. * The high limits cache of the runtime animation
  94256. */
  94257. private _highLimitsCache;
  94258. /**
  94259. * Specifies if the runtime animation has been stopped
  94260. */
  94261. private _stopped;
  94262. /**
  94263. * The blending factor of the runtime animation
  94264. */
  94265. private _blendingFactor;
  94266. /**
  94267. * The BabylonJS scene
  94268. */
  94269. private _scene;
  94270. /**
  94271. * The current value of the runtime animation
  94272. */
  94273. private _currentValue;
  94274. /** @hidden */
  94275. _animationState: _IAnimationState;
  94276. /**
  94277. * The active target of the runtime animation
  94278. */
  94279. private _activeTargets;
  94280. private _currentActiveTarget;
  94281. private _directTarget;
  94282. /**
  94283. * The target path of the runtime animation
  94284. */
  94285. private _targetPath;
  94286. /**
  94287. * The weight of the runtime animation
  94288. */
  94289. private _weight;
  94290. /**
  94291. * The ratio offset of the runtime animation
  94292. */
  94293. private _ratioOffset;
  94294. /**
  94295. * The previous delay of the runtime animation
  94296. */
  94297. private _previousDelay;
  94298. /**
  94299. * The previous ratio of the runtime animation
  94300. */
  94301. private _previousRatio;
  94302. private _enableBlending;
  94303. private _keys;
  94304. private _minFrame;
  94305. private _maxFrame;
  94306. private _minValue;
  94307. private _maxValue;
  94308. private _targetIsArray;
  94309. /**
  94310. * Gets the current frame of the runtime animation
  94311. */
  94312. get currentFrame(): number;
  94313. /**
  94314. * Gets the weight of the runtime animation
  94315. */
  94316. get weight(): number;
  94317. /**
  94318. * Gets the current value of the runtime animation
  94319. */
  94320. get currentValue(): any;
  94321. /**
  94322. * Gets the target path of the runtime animation
  94323. */
  94324. get targetPath(): string;
  94325. /**
  94326. * Gets the actual target of the runtime animation
  94327. */
  94328. get target(): any;
  94329. /**
  94330. * Gets the additive state of the runtime animation
  94331. */
  94332. get isAdditive(): boolean;
  94333. /** @hidden */
  94334. _onLoop: () => void;
  94335. /**
  94336. * Create a new RuntimeAnimation object
  94337. * @param target defines the target of the animation
  94338. * @param animation defines the source animation object
  94339. * @param scene defines the hosting scene
  94340. * @param host defines the initiating Animatable
  94341. */
  94342. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94343. private _preparePath;
  94344. /**
  94345. * Gets the animation from the runtime animation
  94346. */
  94347. get animation(): Animation;
  94348. /**
  94349. * Resets the runtime animation to the beginning
  94350. * @param restoreOriginal defines whether to restore the target property to the original value
  94351. */
  94352. reset(restoreOriginal?: boolean): void;
  94353. /**
  94354. * Specifies if the runtime animation is stopped
  94355. * @returns Boolean specifying if the runtime animation is stopped
  94356. */
  94357. isStopped(): boolean;
  94358. /**
  94359. * Disposes of the runtime animation
  94360. */
  94361. dispose(): void;
  94362. /**
  94363. * Apply the interpolated value to the target
  94364. * @param currentValue defines the value computed by the animation
  94365. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94366. */
  94367. setValue(currentValue: any, weight: number): void;
  94368. private _getOriginalValues;
  94369. private _setValue;
  94370. /**
  94371. * Gets the loop pmode of the runtime animation
  94372. * @returns Loop Mode
  94373. */
  94374. private _getCorrectLoopMode;
  94375. /**
  94376. * Move the current animation to a given frame
  94377. * @param frame defines the frame to move to
  94378. */
  94379. goToFrame(frame: number): void;
  94380. /**
  94381. * @hidden Internal use only
  94382. */
  94383. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94384. /**
  94385. * Execute the current animation
  94386. * @param delay defines the delay to add to the current frame
  94387. * @param from defines the lower bound of the animation range
  94388. * @param to defines the upper bound of the animation range
  94389. * @param loop defines if the current animation must loop
  94390. * @param speedRatio defines the current speed ratio
  94391. * @param weight defines the weight of the animation (default is -1 so no weight)
  94392. * @param onLoop optional callback called when animation loops
  94393. * @returns a boolean indicating if the animation is running
  94394. */
  94395. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94396. }
  94397. }
  94398. declare module BABYLON {
  94399. /**
  94400. * Class used to store an actual running animation
  94401. */
  94402. export class Animatable {
  94403. /** defines the target object */
  94404. target: any;
  94405. /** defines the starting frame number (default is 0) */
  94406. fromFrame: number;
  94407. /** defines the ending frame number (default is 100) */
  94408. toFrame: number;
  94409. /** defines if the animation must loop (default is false) */
  94410. loopAnimation: boolean;
  94411. /** defines a callback to call when animation ends if it is not looping */
  94412. onAnimationEnd?: (() => void) | null | undefined;
  94413. /** defines a callback to call when animation loops */
  94414. onAnimationLoop?: (() => void) | null | undefined;
  94415. /** defines whether the animation should be evaluated additively */
  94416. isAdditive: boolean;
  94417. private _localDelayOffset;
  94418. private _pausedDelay;
  94419. private _runtimeAnimations;
  94420. private _paused;
  94421. private _scene;
  94422. private _speedRatio;
  94423. private _weight;
  94424. private _syncRoot;
  94425. /**
  94426. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94427. * This will only apply for non looping animation (default is true)
  94428. */
  94429. disposeOnEnd: boolean;
  94430. /**
  94431. * Gets a boolean indicating if the animation has started
  94432. */
  94433. animationStarted: boolean;
  94434. /**
  94435. * Observer raised when the animation ends
  94436. */
  94437. onAnimationEndObservable: Observable<Animatable>;
  94438. /**
  94439. * Observer raised when the animation loops
  94440. */
  94441. onAnimationLoopObservable: Observable<Animatable>;
  94442. /**
  94443. * Gets the root Animatable used to synchronize and normalize animations
  94444. */
  94445. get syncRoot(): Nullable<Animatable>;
  94446. /**
  94447. * Gets the current frame of the first RuntimeAnimation
  94448. * Used to synchronize Animatables
  94449. */
  94450. get masterFrame(): number;
  94451. /**
  94452. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  94453. */
  94454. get weight(): number;
  94455. set weight(value: number);
  94456. /**
  94457. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  94458. */
  94459. get speedRatio(): number;
  94460. set speedRatio(value: number);
  94461. /**
  94462. * Creates a new Animatable
  94463. * @param scene defines the hosting scene
  94464. * @param target defines the target object
  94465. * @param fromFrame defines the starting frame number (default is 0)
  94466. * @param toFrame defines the ending frame number (default is 100)
  94467. * @param loopAnimation defines if the animation must loop (default is false)
  94468. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94469. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94470. * @param animations defines a group of animation to add to the new Animatable
  94471. * @param onAnimationLoop defines a callback to call when animation loops
  94472. * @param isAdditive defines whether the animation should be evaluated additively
  94473. */
  94474. constructor(scene: Scene,
  94475. /** defines the target object */
  94476. target: any,
  94477. /** defines the starting frame number (default is 0) */
  94478. fromFrame?: number,
  94479. /** defines the ending frame number (default is 100) */
  94480. toFrame?: number,
  94481. /** defines if the animation must loop (default is false) */
  94482. loopAnimation?: boolean, speedRatio?: number,
  94483. /** defines a callback to call when animation ends if it is not looping */
  94484. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94485. /** defines a callback to call when animation loops */
  94486. onAnimationLoop?: (() => void) | null | undefined,
  94487. /** defines whether the animation should be evaluated additively */
  94488. isAdditive?: boolean);
  94489. /**
  94490. * Synchronize and normalize current Animatable with a source Animatable
  94491. * This is useful when using animation weights and when animations are not of the same length
  94492. * @param root defines the root Animatable to synchronize with
  94493. * @returns the current Animatable
  94494. */
  94495. syncWith(root: Animatable): Animatable;
  94496. /**
  94497. * Gets the list of runtime animations
  94498. * @returns an array of RuntimeAnimation
  94499. */
  94500. getAnimations(): RuntimeAnimation[];
  94501. /**
  94502. * Adds more animations to the current animatable
  94503. * @param target defines the target of the animations
  94504. * @param animations defines the new animations to add
  94505. */
  94506. appendAnimations(target: any, animations: Animation[]): void;
  94507. /**
  94508. * Gets the source animation for a specific property
  94509. * @param property defines the propertyu to look for
  94510. * @returns null or the source animation for the given property
  94511. */
  94512. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94513. /**
  94514. * Gets the runtime animation for a specific property
  94515. * @param property defines the propertyu to look for
  94516. * @returns null or the runtime animation for the given property
  94517. */
  94518. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94519. /**
  94520. * Resets the animatable to its original state
  94521. */
  94522. reset(): void;
  94523. /**
  94524. * Allows the animatable to blend with current running animations
  94525. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94526. * @param blendingSpeed defines the blending speed to use
  94527. */
  94528. enableBlending(blendingSpeed: number): void;
  94529. /**
  94530. * Disable animation blending
  94531. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94532. */
  94533. disableBlending(): void;
  94534. /**
  94535. * Jump directly to a given frame
  94536. * @param frame defines the frame to jump to
  94537. */
  94538. goToFrame(frame: number): void;
  94539. /**
  94540. * Pause the animation
  94541. */
  94542. pause(): void;
  94543. /**
  94544. * Restart the animation
  94545. */
  94546. restart(): void;
  94547. private _raiseOnAnimationEnd;
  94548. /**
  94549. * Stop and delete the current animation
  94550. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94551. * @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)
  94552. */
  94553. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94554. /**
  94555. * Wait asynchronously for the animation to end
  94556. * @returns a promise which will be fullfilled when the animation ends
  94557. */
  94558. waitAsync(): Promise<Animatable>;
  94559. /** @hidden */
  94560. _animate(delay: number): boolean;
  94561. }
  94562. interface Scene {
  94563. /** @hidden */
  94564. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94565. /** @hidden */
  94566. _processLateAnimationBindingsForMatrices(holder: {
  94567. totalWeight: number;
  94568. totalAdditiveWeight: number;
  94569. animations: RuntimeAnimation[];
  94570. additiveAnimations: RuntimeAnimation[];
  94571. originalValue: Matrix;
  94572. }): any;
  94573. /** @hidden */
  94574. _processLateAnimationBindingsForQuaternions(holder: {
  94575. totalWeight: number;
  94576. totalAdditiveWeight: number;
  94577. animations: RuntimeAnimation[];
  94578. additiveAnimations: RuntimeAnimation[];
  94579. originalValue: Quaternion;
  94580. }, refQuaternion: Quaternion): Quaternion;
  94581. /** @hidden */
  94582. _processLateAnimationBindings(): void;
  94583. /**
  94584. * Will start the animation sequence of a given target
  94585. * @param target defines the target
  94586. * @param from defines from which frame should animation start
  94587. * @param to defines until which frame should animation run.
  94588. * @param weight defines the weight to apply to the animation (1.0 by default)
  94589. * @param loop defines if the animation loops
  94590. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94591. * @param onAnimationEnd defines the function to be executed when the animation ends
  94592. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94593. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94594. * @param onAnimationLoop defines the callback to call when an animation loops
  94595. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94596. * @returns the animatable object created for this animation
  94597. */
  94598. 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;
  94599. /**
  94600. * Will start the animation sequence of a given target
  94601. * @param target defines the target
  94602. * @param from defines from which frame should animation start
  94603. * @param to defines until which frame should animation run.
  94604. * @param loop defines if the animation loops
  94605. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94606. * @param onAnimationEnd defines the function to be executed when the animation ends
  94607. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94608. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94609. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94610. * @param onAnimationLoop defines the callback to call when an animation loops
  94611. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94612. * @returns the animatable object created for this animation
  94613. */
  94614. 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;
  94615. /**
  94616. * Will start the animation sequence of a given target and its hierarchy
  94617. * @param target defines the target
  94618. * @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.
  94619. * @param from defines from which frame should animation start
  94620. * @param to defines until which frame should animation run.
  94621. * @param loop defines if the animation loops
  94622. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94623. * @param onAnimationEnd defines the function to be executed when the animation ends
  94624. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94625. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94626. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94627. * @param onAnimationLoop defines the callback to call when an animation loops
  94628. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94629. * @returns the list of created animatables
  94630. */
  94631. 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[];
  94632. /**
  94633. * Begin a new animation on a given node
  94634. * @param target defines the target where the animation will take place
  94635. * @param animations defines the list of animations to start
  94636. * @param from defines the initial value
  94637. * @param to defines the final value
  94638. * @param loop defines if you want animation to loop (off by default)
  94639. * @param speedRatio defines the speed ratio to apply to all animations
  94640. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94641. * @param onAnimationLoop defines the callback to call when an animation loops
  94642. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94643. * @returns the list of created animatables
  94644. */
  94645. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94646. /**
  94647. * Begin a new animation on a given node and its hierarchy
  94648. * @param target defines the root node where the animation will take place
  94649. * @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.
  94650. * @param animations defines the list of animations to start
  94651. * @param from defines the initial value
  94652. * @param to defines the final value
  94653. * @param loop defines if you want animation to loop (off by default)
  94654. * @param speedRatio defines the speed ratio to apply to all animations
  94655. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94656. * @param onAnimationLoop defines the callback to call when an animation loops
  94657. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94658. * @returns the list of animatables created for all nodes
  94659. */
  94660. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94661. /**
  94662. * Gets the animatable associated with a specific target
  94663. * @param target defines the target of the animatable
  94664. * @returns the required animatable if found
  94665. */
  94666. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94667. /**
  94668. * Gets all animatables associated with a given target
  94669. * @param target defines the target to look animatables for
  94670. * @returns an array of Animatables
  94671. */
  94672. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94673. /**
  94674. * Stops and removes all animations that have been applied to the scene
  94675. */
  94676. stopAllAnimations(): void;
  94677. /**
  94678. * Gets the current delta time used by animation engine
  94679. */
  94680. deltaTime: number;
  94681. }
  94682. interface Bone {
  94683. /**
  94684. * Copy an animation range from another bone
  94685. * @param source defines the source bone
  94686. * @param rangeName defines the range name to copy
  94687. * @param frameOffset defines the frame offset
  94688. * @param rescaleAsRequired defines if rescaling must be applied if required
  94689. * @param skelDimensionsRatio defines the scaling ratio
  94690. * @returns true if operation was successful
  94691. */
  94692. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94693. }
  94694. }
  94695. declare module BABYLON {
  94696. /**
  94697. * Class used to handle skinning animations
  94698. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94699. */
  94700. export class Skeleton implements IAnimatable {
  94701. /** defines the skeleton name */
  94702. name: string;
  94703. /** defines the skeleton Id */
  94704. id: string;
  94705. /**
  94706. * Defines the list of child bones
  94707. */
  94708. bones: Bone[];
  94709. /**
  94710. * Defines an estimate of the dimension of the skeleton at rest
  94711. */
  94712. dimensionsAtRest: Vector3;
  94713. /**
  94714. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94715. */
  94716. needInitialSkinMatrix: boolean;
  94717. /**
  94718. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94719. */
  94720. overrideMesh: Nullable<AbstractMesh>;
  94721. /**
  94722. * Gets the list of animations attached to this skeleton
  94723. */
  94724. animations: Array<Animation>;
  94725. private _scene;
  94726. private _isDirty;
  94727. private _transformMatrices;
  94728. private _transformMatrixTexture;
  94729. private _meshesWithPoseMatrix;
  94730. private _animatables;
  94731. private _identity;
  94732. private _synchronizedWithMesh;
  94733. private _ranges;
  94734. private _lastAbsoluteTransformsUpdateId;
  94735. private _canUseTextureForBones;
  94736. private _uniqueId;
  94737. /** @hidden */
  94738. _numBonesWithLinkedTransformNode: number;
  94739. /** @hidden */
  94740. _hasWaitingData: Nullable<boolean>;
  94741. /**
  94742. * Specifies if the skeleton should be serialized
  94743. */
  94744. doNotSerialize: boolean;
  94745. private _useTextureToStoreBoneMatrices;
  94746. /**
  94747. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94748. * Please note that this option is not available if the hardware does not support it
  94749. */
  94750. get useTextureToStoreBoneMatrices(): boolean;
  94751. set useTextureToStoreBoneMatrices(value: boolean);
  94752. private _animationPropertiesOverride;
  94753. /**
  94754. * Gets or sets the animation properties override
  94755. */
  94756. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94757. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94758. /**
  94759. * List of inspectable custom properties (used by the Inspector)
  94760. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94761. */
  94762. inspectableCustomProperties: IInspectable[];
  94763. /**
  94764. * An observable triggered before computing the skeleton's matrices
  94765. */
  94766. onBeforeComputeObservable: Observable<Skeleton>;
  94767. /**
  94768. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94769. */
  94770. get isUsingTextureForMatrices(): boolean;
  94771. /**
  94772. * Gets the unique ID of this skeleton
  94773. */
  94774. get uniqueId(): number;
  94775. /**
  94776. * Creates a new skeleton
  94777. * @param name defines the skeleton name
  94778. * @param id defines the skeleton Id
  94779. * @param scene defines the hosting scene
  94780. */
  94781. constructor(
  94782. /** defines the skeleton name */
  94783. name: string,
  94784. /** defines the skeleton Id */
  94785. id: string, scene: Scene);
  94786. /**
  94787. * Gets the current object class name.
  94788. * @return the class name
  94789. */
  94790. getClassName(): string;
  94791. /**
  94792. * Returns an array containing the root bones
  94793. * @returns an array containing the root bones
  94794. */
  94795. getChildren(): Array<Bone>;
  94796. /**
  94797. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94798. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94799. * @returns a Float32Array containing matrices data
  94800. */
  94801. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94802. /**
  94803. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94804. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94805. * @returns a raw texture containing the data
  94806. */
  94807. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94808. /**
  94809. * Gets the current hosting scene
  94810. * @returns a scene object
  94811. */
  94812. getScene(): Scene;
  94813. /**
  94814. * Gets a string representing the current skeleton data
  94815. * @param fullDetails defines a boolean indicating if we want a verbose version
  94816. * @returns a string representing the current skeleton data
  94817. */
  94818. toString(fullDetails?: boolean): string;
  94819. /**
  94820. * Get bone's index searching by name
  94821. * @param name defines bone's name to search for
  94822. * @return the indice of the bone. Returns -1 if not found
  94823. */
  94824. getBoneIndexByName(name: string): number;
  94825. /**
  94826. * Creater a new animation range
  94827. * @param name defines the name of the range
  94828. * @param from defines the start key
  94829. * @param to defines the end key
  94830. */
  94831. createAnimationRange(name: string, from: number, to: number): void;
  94832. /**
  94833. * Delete a specific animation range
  94834. * @param name defines the name of the range
  94835. * @param deleteFrames defines if frames must be removed as well
  94836. */
  94837. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94838. /**
  94839. * Gets a specific animation range
  94840. * @param name defines the name of the range to look for
  94841. * @returns the requested animation range or null if not found
  94842. */
  94843. getAnimationRange(name: string): Nullable<AnimationRange>;
  94844. /**
  94845. * Gets the list of all animation ranges defined on this skeleton
  94846. * @returns an array
  94847. */
  94848. getAnimationRanges(): Nullable<AnimationRange>[];
  94849. /**
  94850. * Copy animation range from a source skeleton.
  94851. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94852. * @param source defines the source skeleton
  94853. * @param name defines the name of the range to copy
  94854. * @param rescaleAsRequired defines if rescaling must be applied if required
  94855. * @returns true if operation was successful
  94856. */
  94857. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94858. /**
  94859. * Forces the skeleton to go to rest pose
  94860. */
  94861. returnToRest(): void;
  94862. private _getHighestAnimationFrame;
  94863. /**
  94864. * Begin a specific animation range
  94865. * @param name defines the name of the range to start
  94866. * @param loop defines if looping must be turned on (false by default)
  94867. * @param speedRatio defines the speed ratio to apply (1 by default)
  94868. * @param onAnimationEnd defines a callback which will be called when animation will end
  94869. * @returns a new animatable
  94870. */
  94871. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94872. /**
  94873. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94874. * @param skeleton defines the Skeleton containing the animation range to convert
  94875. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94876. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94877. * @returns the original skeleton
  94878. */
  94879. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94880. /** @hidden */
  94881. _markAsDirty(): void;
  94882. /** @hidden */
  94883. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94884. /** @hidden */
  94885. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94886. private _computeTransformMatrices;
  94887. /**
  94888. * Build all resources required to render a skeleton
  94889. */
  94890. prepare(): void;
  94891. /**
  94892. * Gets the list of animatables currently running for this skeleton
  94893. * @returns an array of animatables
  94894. */
  94895. getAnimatables(): IAnimatable[];
  94896. /**
  94897. * Clone the current skeleton
  94898. * @param name defines the name of the new skeleton
  94899. * @param id defines the id of the new skeleton
  94900. * @returns the new skeleton
  94901. */
  94902. clone(name: string, id?: string): Skeleton;
  94903. /**
  94904. * Enable animation blending for this skeleton
  94905. * @param blendingSpeed defines the blending speed to apply
  94906. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94907. */
  94908. enableBlending(blendingSpeed?: number): void;
  94909. /**
  94910. * Releases all resources associated with the current skeleton
  94911. */
  94912. dispose(): void;
  94913. /**
  94914. * Serialize the skeleton in a JSON object
  94915. * @returns a JSON object
  94916. */
  94917. serialize(): any;
  94918. /**
  94919. * Creates a new skeleton from serialized data
  94920. * @param parsedSkeleton defines the serialized data
  94921. * @param scene defines the hosting scene
  94922. * @returns a new skeleton
  94923. */
  94924. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94925. /**
  94926. * Compute all node absolute transforms
  94927. * @param forceUpdate defines if computation must be done even if cache is up to date
  94928. */
  94929. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94930. /**
  94931. * Gets the root pose matrix
  94932. * @returns a matrix
  94933. */
  94934. getPoseMatrix(): Nullable<Matrix>;
  94935. /**
  94936. * Sorts bones per internal index
  94937. */
  94938. sortBones(): void;
  94939. private _sortBones;
  94940. }
  94941. }
  94942. declare module BABYLON {
  94943. /**
  94944. * Creates an instance based on a source mesh.
  94945. */
  94946. export class InstancedMesh extends AbstractMesh {
  94947. private _sourceMesh;
  94948. private _currentLOD;
  94949. /** @hidden */
  94950. _indexInSourceMeshInstanceArray: number;
  94951. constructor(name: string, source: Mesh);
  94952. /**
  94953. * Returns the string "InstancedMesh".
  94954. */
  94955. getClassName(): string;
  94956. /** Gets the list of lights affecting that mesh */
  94957. get lightSources(): Light[];
  94958. _resyncLightSources(): void;
  94959. _resyncLightSource(light: Light): void;
  94960. _removeLightSource(light: Light, dispose: boolean): void;
  94961. /**
  94962. * If the source mesh receives shadows
  94963. */
  94964. get receiveShadows(): boolean;
  94965. /**
  94966. * The material of the source mesh
  94967. */
  94968. get material(): Nullable<Material>;
  94969. /**
  94970. * Visibility of the source mesh
  94971. */
  94972. get visibility(): number;
  94973. /**
  94974. * Skeleton of the source mesh
  94975. */
  94976. get skeleton(): Nullable<Skeleton>;
  94977. /**
  94978. * Rendering ground id of the source mesh
  94979. */
  94980. get renderingGroupId(): number;
  94981. set renderingGroupId(value: number);
  94982. /**
  94983. * Returns the total number of vertices (integer).
  94984. */
  94985. getTotalVertices(): number;
  94986. /**
  94987. * Returns a positive integer : the total number of indices in this mesh geometry.
  94988. * @returns the numner of indices or zero if the mesh has no geometry.
  94989. */
  94990. getTotalIndices(): number;
  94991. /**
  94992. * The source mesh of the instance
  94993. */
  94994. get sourceMesh(): Mesh;
  94995. /**
  94996. * Creates a new InstancedMesh object from the mesh model.
  94997. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94998. * @param name defines the name of the new instance
  94999. * @returns a new InstancedMesh
  95000. */
  95001. createInstance(name: string): InstancedMesh;
  95002. /**
  95003. * Is this node ready to be used/rendered
  95004. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95005. * @return {boolean} is it ready
  95006. */
  95007. isReady(completeCheck?: boolean): boolean;
  95008. /**
  95009. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95010. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95011. * @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.
  95012. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95013. */
  95014. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95015. /**
  95016. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95017. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95018. * The `data` are either a numeric array either a Float32Array.
  95019. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95020. * 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).
  95021. * Note that a new underlying VertexBuffer object is created each call.
  95022. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95023. *
  95024. * Possible `kind` values :
  95025. * - VertexBuffer.PositionKind
  95026. * - VertexBuffer.UVKind
  95027. * - VertexBuffer.UV2Kind
  95028. * - VertexBuffer.UV3Kind
  95029. * - VertexBuffer.UV4Kind
  95030. * - VertexBuffer.UV5Kind
  95031. * - VertexBuffer.UV6Kind
  95032. * - VertexBuffer.ColorKind
  95033. * - VertexBuffer.MatricesIndicesKind
  95034. * - VertexBuffer.MatricesIndicesExtraKind
  95035. * - VertexBuffer.MatricesWeightsKind
  95036. * - VertexBuffer.MatricesWeightsExtraKind
  95037. *
  95038. * Returns the Mesh.
  95039. */
  95040. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95041. /**
  95042. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95043. * If the mesh has no geometry, it is simply returned as it is.
  95044. * The `data` are either a numeric array either a Float32Array.
  95045. * No new underlying VertexBuffer object is created.
  95046. * 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.
  95047. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95048. *
  95049. * Possible `kind` values :
  95050. * - VertexBuffer.PositionKind
  95051. * - VertexBuffer.UVKind
  95052. * - VertexBuffer.UV2Kind
  95053. * - VertexBuffer.UV3Kind
  95054. * - VertexBuffer.UV4Kind
  95055. * - VertexBuffer.UV5Kind
  95056. * - VertexBuffer.UV6Kind
  95057. * - VertexBuffer.ColorKind
  95058. * - VertexBuffer.MatricesIndicesKind
  95059. * - VertexBuffer.MatricesIndicesExtraKind
  95060. * - VertexBuffer.MatricesWeightsKind
  95061. * - VertexBuffer.MatricesWeightsExtraKind
  95062. *
  95063. * Returns the Mesh.
  95064. */
  95065. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95066. /**
  95067. * Sets the mesh indices.
  95068. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95069. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95070. * This method creates a new index buffer each call.
  95071. * Returns the Mesh.
  95072. */
  95073. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95074. /**
  95075. * Boolean : True if the mesh owns the requested kind of data.
  95076. */
  95077. isVerticesDataPresent(kind: string): boolean;
  95078. /**
  95079. * Returns an array of indices (IndicesArray).
  95080. */
  95081. getIndices(): Nullable<IndicesArray>;
  95082. get _positions(): Nullable<Vector3[]>;
  95083. /**
  95084. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95085. * This means the mesh underlying bounding box and sphere are recomputed.
  95086. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95087. * @returns the current mesh
  95088. */
  95089. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95090. /** @hidden */
  95091. _preActivate(): InstancedMesh;
  95092. /** @hidden */
  95093. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95094. /** @hidden */
  95095. _postActivate(): void;
  95096. getWorldMatrix(): Matrix;
  95097. get isAnInstance(): boolean;
  95098. /**
  95099. * Returns the current associated LOD AbstractMesh.
  95100. */
  95101. getLOD(camera: Camera): AbstractMesh;
  95102. /** @hidden */
  95103. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95104. /** @hidden */
  95105. _syncSubMeshes(): InstancedMesh;
  95106. /** @hidden */
  95107. _generatePointsArray(): boolean;
  95108. /**
  95109. * Creates a new InstancedMesh from the current mesh.
  95110. * - name (string) : the cloned mesh name
  95111. * - newParent (optional Node) : the optional Node to parent the clone to.
  95112. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  95113. *
  95114. * Returns the clone.
  95115. */
  95116. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  95117. /**
  95118. * Disposes the InstancedMesh.
  95119. * Returns nothing.
  95120. */
  95121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95122. }
  95123. interface Mesh {
  95124. /**
  95125. * Register a custom buffer that will be instanced
  95126. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95127. * @param kind defines the buffer kind
  95128. * @param stride defines the stride in floats
  95129. */
  95130. registerInstancedBuffer(kind: string, stride: number): void;
  95131. /**
  95132. * true to use the edge renderer for all instances of this mesh
  95133. */
  95134. edgesShareWithInstances: boolean;
  95135. /** @hidden */
  95136. _userInstancedBuffersStorage: {
  95137. data: {
  95138. [key: string]: Float32Array;
  95139. };
  95140. sizes: {
  95141. [key: string]: number;
  95142. };
  95143. vertexBuffers: {
  95144. [key: string]: Nullable<VertexBuffer>;
  95145. };
  95146. strides: {
  95147. [key: string]: number;
  95148. };
  95149. };
  95150. }
  95151. interface AbstractMesh {
  95152. /**
  95153. * Object used to store instanced buffers defined by user
  95154. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95155. */
  95156. instancedBuffers: {
  95157. [key: string]: any;
  95158. };
  95159. }
  95160. }
  95161. declare module BABYLON {
  95162. /**
  95163. * Defines the options associated with the creation of a shader material.
  95164. */
  95165. export interface IShaderMaterialOptions {
  95166. /**
  95167. * Does the material work in alpha blend mode
  95168. */
  95169. needAlphaBlending: boolean;
  95170. /**
  95171. * Does the material work in alpha test mode
  95172. */
  95173. needAlphaTesting: boolean;
  95174. /**
  95175. * The list of attribute names used in the shader
  95176. */
  95177. attributes: string[];
  95178. /**
  95179. * The list of unifrom names used in the shader
  95180. */
  95181. uniforms: string[];
  95182. /**
  95183. * The list of UBO names used in the shader
  95184. */
  95185. uniformBuffers: string[];
  95186. /**
  95187. * The list of sampler names used in the shader
  95188. */
  95189. samplers: string[];
  95190. /**
  95191. * The list of defines used in the shader
  95192. */
  95193. defines: string[];
  95194. }
  95195. /**
  95196. * 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.
  95197. *
  95198. * This returned material effects how the mesh will look based on the code in the shaders.
  95199. *
  95200. * @see https://doc.babylonjs.com/how_to/shader_material
  95201. */
  95202. export class ShaderMaterial extends Material {
  95203. private _shaderPath;
  95204. private _options;
  95205. private _textures;
  95206. private _textureArrays;
  95207. private _floats;
  95208. private _ints;
  95209. private _floatsArrays;
  95210. private _colors3;
  95211. private _colors3Arrays;
  95212. private _colors4;
  95213. private _colors4Arrays;
  95214. private _vectors2;
  95215. private _vectors3;
  95216. private _vectors4;
  95217. private _matrices;
  95218. private _matrixArrays;
  95219. private _matrices3x3;
  95220. private _matrices2x2;
  95221. private _vectors2Arrays;
  95222. private _vectors3Arrays;
  95223. private _vectors4Arrays;
  95224. private _cachedWorldViewMatrix;
  95225. private _cachedWorldViewProjectionMatrix;
  95226. private _renderId;
  95227. private _multiview;
  95228. private _cachedDefines;
  95229. /** Define the Url to load snippets */
  95230. static SnippetUrl: string;
  95231. /** Snippet ID if the material was created from the snippet server */
  95232. snippetId: string;
  95233. /**
  95234. * Instantiate a new shader material.
  95235. * 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.
  95236. * This returned material effects how the mesh will look based on the code in the shaders.
  95237. * @see https://doc.babylonjs.com/how_to/shader_material
  95238. * @param name Define the name of the material in the scene
  95239. * @param scene Define the scene the material belongs to
  95240. * @param shaderPath Defines the route to the shader code in one of three ways:
  95241. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95242. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95243. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95244. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95245. * @param options Define the options used to create the shader
  95246. */
  95247. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95248. /**
  95249. * Gets the shader path used to define the shader code
  95250. * It can be modified to trigger a new compilation
  95251. */
  95252. get shaderPath(): any;
  95253. /**
  95254. * Sets the shader path used to define the shader code
  95255. * It can be modified to trigger a new compilation
  95256. */
  95257. set shaderPath(shaderPath: any);
  95258. /**
  95259. * Gets the options used to compile the shader.
  95260. * They can be modified to trigger a new compilation
  95261. */
  95262. get options(): IShaderMaterialOptions;
  95263. /**
  95264. * Gets the current class name of the material e.g. "ShaderMaterial"
  95265. * Mainly use in serialization.
  95266. * @returns the class name
  95267. */
  95268. getClassName(): string;
  95269. /**
  95270. * Specifies if the material will require alpha blending
  95271. * @returns a boolean specifying if alpha blending is needed
  95272. */
  95273. needAlphaBlending(): boolean;
  95274. /**
  95275. * Specifies if this material should be rendered in alpha test mode
  95276. * @returns a boolean specifying if an alpha test is needed.
  95277. */
  95278. needAlphaTesting(): boolean;
  95279. private _checkUniform;
  95280. /**
  95281. * Set a texture in the shader.
  95282. * @param name Define the name of the uniform samplers as defined in the shader
  95283. * @param texture Define the texture to bind to this sampler
  95284. * @return the material itself allowing "fluent" like uniform updates
  95285. */
  95286. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95287. /**
  95288. * Set a texture array in the shader.
  95289. * @param name Define the name of the uniform sampler array as defined in the shader
  95290. * @param textures Define the list of textures to bind to this sampler
  95291. * @return the material itself allowing "fluent" like uniform updates
  95292. */
  95293. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95294. /**
  95295. * Set a float in the shader.
  95296. * @param name Define the name of the uniform as defined in the shader
  95297. * @param value Define the value to give to the uniform
  95298. * @return the material itself allowing "fluent" like uniform updates
  95299. */
  95300. setFloat(name: string, value: number): ShaderMaterial;
  95301. /**
  95302. * Set a int in the shader.
  95303. * @param name Define the name of the uniform as defined in the shader
  95304. * @param value Define the value to give to the uniform
  95305. * @return the material itself allowing "fluent" like uniform updates
  95306. */
  95307. setInt(name: string, value: number): ShaderMaterial;
  95308. /**
  95309. * Set an array of floats in the shader.
  95310. * @param name Define the name of the uniform as defined in the shader
  95311. * @param value Define the value to give to the uniform
  95312. * @return the material itself allowing "fluent" like uniform updates
  95313. */
  95314. setFloats(name: string, value: number[]): ShaderMaterial;
  95315. /**
  95316. * Set a vec3 in the shader from a Color3.
  95317. * @param name Define the name of the uniform as defined in the shader
  95318. * @param value Define the value to give to the uniform
  95319. * @return the material itself allowing "fluent" like uniform updates
  95320. */
  95321. setColor3(name: string, value: Color3): ShaderMaterial;
  95322. /**
  95323. * Set a vec3 array in the shader from a Color3 array.
  95324. * @param name Define the name of the uniform as defined in the shader
  95325. * @param value Define the value to give to the uniform
  95326. * @return the material itself allowing "fluent" like uniform updates
  95327. */
  95328. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95329. /**
  95330. * Set a vec4 in the shader from a Color4.
  95331. * @param name Define the name of the uniform as defined in the shader
  95332. * @param value Define the value to give to the uniform
  95333. * @return the material itself allowing "fluent" like uniform updates
  95334. */
  95335. setColor4(name: string, value: Color4): ShaderMaterial;
  95336. /**
  95337. * Set a vec4 array in the shader from a Color4 array.
  95338. * @param name Define the name of the uniform as defined in the shader
  95339. * @param value Define the value to give to the uniform
  95340. * @return the material itself allowing "fluent" like uniform updates
  95341. */
  95342. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95343. /**
  95344. * Set a vec2 in the shader from a Vector2.
  95345. * @param name Define the name of the uniform as defined in the shader
  95346. * @param value Define the value to give to the uniform
  95347. * @return the material itself allowing "fluent" like uniform updates
  95348. */
  95349. setVector2(name: string, value: Vector2): ShaderMaterial;
  95350. /**
  95351. * Set a vec3 in the shader from a Vector3.
  95352. * @param name Define the name of the uniform as defined in the shader
  95353. * @param value Define the value to give to the uniform
  95354. * @return the material itself allowing "fluent" like uniform updates
  95355. */
  95356. setVector3(name: string, value: Vector3): ShaderMaterial;
  95357. /**
  95358. * Set a vec4 in the shader from a Vector4.
  95359. * @param name Define the name of the uniform as defined in the shader
  95360. * @param value Define the value to give to the uniform
  95361. * @return the material itself allowing "fluent" like uniform updates
  95362. */
  95363. setVector4(name: string, value: Vector4): ShaderMaterial;
  95364. /**
  95365. * Set a mat4 in the shader from a Matrix.
  95366. * @param name Define the name of the uniform as defined in the shader
  95367. * @param value Define the value to give to the uniform
  95368. * @return the material itself allowing "fluent" like uniform updates
  95369. */
  95370. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95371. /**
  95372. * Set a float32Array in the shader from a matrix array.
  95373. * @param name Define the name of the uniform as defined in the shader
  95374. * @param value Define the value to give to the uniform
  95375. * @return the material itself allowing "fluent" like uniform updates
  95376. */
  95377. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95378. /**
  95379. * Set a mat3 in the shader from a Float32Array.
  95380. * @param name Define the name of the uniform as defined in the shader
  95381. * @param value Define the value to give to the uniform
  95382. * @return the material itself allowing "fluent" like uniform updates
  95383. */
  95384. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95385. /**
  95386. * Set a mat2 in the shader from a Float32Array.
  95387. * @param name Define the name of the uniform as defined in the shader
  95388. * @param value Define the value to give to the uniform
  95389. * @return the material itself allowing "fluent" like uniform updates
  95390. */
  95391. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95392. /**
  95393. * Set a vec2 array in the shader from a number array.
  95394. * @param name Define the name of the uniform as defined in the shader
  95395. * @param value Define the value to give to the uniform
  95396. * @return the material itself allowing "fluent" like uniform updates
  95397. */
  95398. setArray2(name: string, value: number[]): ShaderMaterial;
  95399. /**
  95400. * Set a vec3 array in the shader from a number array.
  95401. * @param name Define the name of the uniform as defined in the shader
  95402. * @param value Define the value to give to the uniform
  95403. * @return the material itself allowing "fluent" like uniform updates
  95404. */
  95405. setArray3(name: string, value: number[]): ShaderMaterial;
  95406. /**
  95407. * Set a vec4 array in the shader from a number array.
  95408. * @param name Define the name of the uniform as defined in the shader
  95409. * @param value Define the value to give to the uniform
  95410. * @return the material itself allowing "fluent" like uniform updates
  95411. */
  95412. setArray4(name: string, value: number[]): ShaderMaterial;
  95413. private _checkCache;
  95414. /**
  95415. * Specifies that the submesh is ready to be used
  95416. * @param mesh defines the mesh to check
  95417. * @param subMesh defines which submesh to check
  95418. * @param useInstances specifies that instances should be used
  95419. * @returns a boolean indicating that the submesh is ready or not
  95420. */
  95421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95422. /**
  95423. * Checks if the material is ready to render the requested mesh
  95424. * @param mesh Define the mesh to render
  95425. * @param useInstances Define whether or not the material is used with instances
  95426. * @returns true if ready, otherwise false
  95427. */
  95428. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95429. /**
  95430. * Binds the world matrix to the material
  95431. * @param world defines the world transformation matrix
  95432. * @param effectOverride - If provided, use this effect instead of internal effect
  95433. */
  95434. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95435. /**
  95436. * Binds the submesh to this material by preparing the effect and shader to draw
  95437. * @param world defines the world transformation matrix
  95438. * @param mesh defines the mesh containing the submesh
  95439. * @param subMesh defines the submesh to bind the material to
  95440. */
  95441. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95442. /**
  95443. * Binds the material to the mesh
  95444. * @param world defines the world transformation matrix
  95445. * @param mesh defines the mesh to bind the material to
  95446. * @param effectOverride - If provided, use this effect instead of internal effect
  95447. */
  95448. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  95449. protected _afterBind(mesh?: Mesh): void;
  95450. /**
  95451. * Gets the active textures from the material
  95452. * @returns an array of textures
  95453. */
  95454. getActiveTextures(): BaseTexture[];
  95455. /**
  95456. * Specifies if the material uses a texture
  95457. * @param texture defines the texture to check against the material
  95458. * @returns a boolean specifying if the material uses the texture
  95459. */
  95460. hasTexture(texture: BaseTexture): boolean;
  95461. /**
  95462. * Makes a duplicate of the material, and gives it a new name
  95463. * @param name defines the new name for the duplicated material
  95464. * @returns the cloned material
  95465. */
  95466. clone(name: string): ShaderMaterial;
  95467. /**
  95468. * Disposes the material
  95469. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95470. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95471. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95472. */
  95473. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95474. /**
  95475. * Serializes this material in a JSON representation
  95476. * @returns the serialized material object
  95477. */
  95478. serialize(): any;
  95479. /**
  95480. * Creates a shader material from parsed shader material data
  95481. * @param source defines the JSON represnetation of the material
  95482. * @param scene defines the hosting scene
  95483. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95484. * @returns a new material
  95485. */
  95486. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95487. /**
  95488. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95489. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95490. * @param url defines the url to load from
  95491. * @param scene defines the hosting scene
  95492. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95493. * @returns a promise that will resolve to the new ShaderMaterial
  95494. */
  95495. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95496. /**
  95497. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95498. * @param snippetId defines the snippet to load
  95499. * @param scene defines the hosting scene
  95500. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95501. * @returns a promise that will resolve to the new ShaderMaterial
  95502. */
  95503. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95504. }
  95505. }
  95506. declare module BABYLON {
  95507. /** @hidden */
  95508. export var colorPixelShader: {
  95509. name: string;
  95510. shader: string;
  95511. };
  95512. }
  95513. declare module BABYLON {
  95514. /** @hidden */
  95515. export var colorVertexShader: {
  95516. name: string;
  95517. shader: string;
  95518. };
  95519. }
  95520. declare module BABYLON {
  95521. /**
  95522. * Line mesh
  95523. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95524. */
  95525. export class LinesMesh extends Mesh {
  95526. /**
  95527. * If vertex color should be applied to the mesh
  95528. */
  95529. readonly useVertexColor?: boolean | undefined;
  95530. /**
  95531. * If vertex alpha should be applied to the mesh
  95532. */
  95533. readonly useVertexAlpha?: boolean | undefined;
  95534. /**
  95535. * Color of the line (Default: White)
  95536. */
  95537. color: Color3;
  95538. /**
  95539. * Alpha of the line (Default: 1)
  95540. */
  95541. alpha: number;
  95542. /**
  95543. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95544. * This margin is expressed in world space coordinates, so its value may vary.
  95545. * Default value is 0.1
  95546. */
  95547. intersectionThreshold: number;
  95548. private _colorShader;
  95549. private color4;
  95550. /**
  95551. * Creates a new LinesMesh
  95552. * @param name defines the name
  95553. * @param scene defines the hosting scene
  95554. * @param parent defines the parent mesh if any
  95555. * @param source defines the optional source LinesMesh used to clone data from
  95556. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95557. * When false, achieved by calling a clone(), also passing False.
  95558. * This will make creation of children, recursive.
  95559. * @param useVertexColor defines if this LinesMesh supports vertex color
  95560. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95561. */
  95562. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95563. /**
  95564. * If vertex color should be applied to the mesh
  95565. */
  95566. useVertexColor?: boolean | undefined,
  95567. /**
  95568. * If vertex alpha should be applied to the mesh
  95569. */
  95570. useVertexAlpha?: boolean | undefined);
  95571. private _addClipPlaneDefine;
  95572. private _removeClipPlaneDefine;
  95573. isReady(): boolean;
  95574. /**
  95575. * Returns the string "LineMesh"
  95576. */
  95577. getClassName(): string;
  95578. /**
  95579. * @hidden
  95580. */
  95581. get material(): Material;
  95582. /**
  95583. * @hidden
  95584. */
  95585. set material(value: Material);
  95586. /**
  95587. * @hidden
  95588. */
  95589. get checkCollisions(): boolean;
  95590. /** @hidden */
  95591. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95592. /** @hidden */
  95593. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95594. /**
  95595. * Disposes of the line mesh
  95596. * @param doNotRecurse If children should be disposed
  95597. */
  95598. dispose(doNotRecurse?: boolean): void;
  95599. /**
  95600. * Returns a new LineMesh object cloned from the current one.
  95601. */
  95602. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95603. /**
  95604. * Creates a new InstancedLinesMesh object from the mesh model.
  95605. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95606. * @param name defines the name of the new instance
  95607. * @returns a new InstancedLinesMesh
  95608. */
  95609. createInstance(name: string): InstancedLinesMesh;
  95610. }
  95611. /**
  95612. * Creates an instance based on a source LinesMesh
  95613. */
  95614. export class InstancedLinesMesh extends InstancedMesh {
  95615. /**
  95616. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95617. * This margin is expressed in world space coordinates, so its value may vary.
  95618. * Initilized with the intersectionThreshold value of the source LinesMesh
  95619. */
  95620. intersectionThreshold: number;
  95621. constructor(name: string, source: LinesMesh);
  95622. /**
  95623. * Returns the string "InstancedLinesMesh".
  95624. */
  95625. getClassName(): string;
  95626. }
  95627. }
  95628. declare module BABYLON {
  95629. /** @hidden */
  95630. export var linePixelShader: {
  95631. name: string;
  95632. shader: string;
  95633. };
  95634. }
  95635. declare module BABYLON {
  95636. /** @hidden */
  95637. export var lineVertexShader: {
  95638. name: string;
  95639. shader: string;
  95640. };
  95641. }
  95642. declare module BABYLON {
  95643. interface Scene {
  95644. /** @hidden */
  95645. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95646. }
  95647. interface AbstractMesh {
  95648. /**
  95649. * Gets the edgesRenderer associated with the mesh
  95650. */
  95651. edgesRenderer: Nullable<EdgesRenderer>;
  95652. }
  95653. interface LinesMesh {
  95654. /**
  95655. * Enables the edge rendering mode on the mesh.
  95656. * This mode makes the mesh edges visible
  95657. * @param epsilon defines the maximal distance between two angles to detect a face
  95658. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95659. * @returns the currentAbstractMesh
  95660. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95661. */
  95662. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95663. }
  95664. interface InstancedLinesMesh {
  95665. /**
  95666. * Enables the edge rendering mode on the mesh.
  95667. * This mode makes the mesh edges visible
  95668. * @param epsilon defines the maximal distance between two angles to detect a face
  95669. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95670. * @returns the current InstancedLinesMesh
  95671. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95672. */
  95673. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95674. }
  95675. /**
  95676. * Defines the minimum contract an Edges renderer should follow.
  95677. */
  95678. export interface IEdgesRenderer extends IDisposable {
  95679. /**
  95680. * Gets or sets a boolean indicating if the edgesRenderer is active
  95681. */
  95682. isEnabled: boolean;
  95683. /**
  95684. * Renders the edges of the attached mesh,
  95685. */
  95686. render(): void;
  95687. /**
  95688. * Checks wether or not the edges renderer is ready to render.
  95689. * @return true if ready, otherwise false.
  95690. */
  95691. isReady(): boolean;
  95692. /**
  95693. * List of instances to render in case the source mesh has instances
  95694. */
  95695. customInstances: SmartArray<Matrix>;
  95696. }
  95697. /**
  95698. * Defines the additional options of the edges renderer
  95699. */
  95700. export interface IEdgesRendererOptions {
  95701. /**
  95702. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95703. * If not defined, the default value is true
  95704. */
  95705. useAlternateEdgeFinder?: boolean;
  95706. /**
  95707. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95708. * If not defined, the default value is true.
  95709. * 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)
  95710. * This option is used only if useAlternateEdgeFinder = true
  95711. */
  95712. useFastVertexMerger?: boolean;
  95713. /**
  95714. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95715. * The default value is 1e-6
  95716. * This option is used only if useAlternateEdgeFinder = true
  95717. */
  95718. epsilonVertexMerge?: number;
  95719. /**
  95720. * 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
  95721. * 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.
  95722. * This option is used only if useAlternateEdgeFinder = true
  95723. */
  95724. applyTessellation?: boolean;
  95725. /**
  95726. * 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
  95727. * The default value is 1e-6
  95728. * This option is used only if useAlternateEdgeFinder = true
  95729. */
  95730. epsilonVertexAligned?: number;
  95731. }
  95732. /**
  95733. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95734. */
  95735. export class EdgesRenderer implements IEdgesRenderer {
  95736. /**
  95737. * Define the size of the edges with an orthographic camera
  95738. */
  95739. edgesWidthScalerForOrthographic: number;
  95740. /**
  95741. * Define the size of the edges with a perspective camera
  95742. */
  95743. edgesWidthScalerForPerspective: number;
  95744. protected _source: AbstractMesh;
  95745. protected _linesPositions: number[];
  95746. protected _linesNormals: number[];
  95747. protected _linesIndices: number[];
  95748. protected _epsilon: number;
  95749. protected _indicesCount: number;
  95750. protected _lineShader: ShaderMaterial;
  95751. protected _ib: DataBuffer;
  95752. protected _buffers: {
  95753. [key: string]: Nullable<VertexBuffer>;
  95754. };
  95755. protected _buffersForInstances: {
  95756. [key: string]: Nullable<VertexBuffer>;
  95757. };
  95758. protected _checkVerticesInsteadOfIndices: boolean;
  95759. protected _options: Nullable<IEdgesRendererOptions>;
  95760. private _meshRebuildObserver;
  95761. private _meshDisposeObserver;
  95762. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95763. isEnabled: boolean;
  95764. /**
  95765. * List of instances to render in case the source mesh has instances
  95766. */
  95767. customInstances: SmartArray<Matrix>;
  95768. private static GetShader;
  95769. /**
  95770. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95771. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95772. * @param source Mesh used to create edges
  95773. * @param epsilon sum of angles in adjacency to check for edge
  95774. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95775. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95776. * @param options The options to apply when generating the edges
  95777. */
  95778. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95779. protected _prepareRessources(): void;
  95780. /** @hidden */
  95781. _rebuild(): void;
  95782. /**
  95783. * Releases the required resources for the edges renderer
  95784. */
  95785. dispose(): void;
  95786. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95787. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95788. /**
  95789. * Checks if the pair of p0 and p1 is en edge
  95790. * @param faceIndex
  95791. * @param edge
  95792. * @param faceNormals
  95793. * @param p0
  95794. * @param p1
  95795. * @private
  95796. */
  95797. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95798. /**
  95799. * push line into the position, normal and index buffer
  95800. * @protected
  95801. */
  95802. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95803. /**
  95804. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  95805. */
  95806. private _tessellateTriangle;
  95807. private _generateEdgesLinesAlternate;
  95808. /**
  95809. * Generates lines edges from adjacencjes
  95810. * @private
  95811. */
  95812. _generateEdgesLines(): void;
  95813. /**
  95814. * Checks wether or not the edges renderer is ready to render.
  95815. * @return true if ready, otherwise false.
  95816. */
  95817. isReady(): boolean;
  95818. /**
  95819. * Renders the edges of the attached mesh,
  95820. */
  95821. render(): void;
  95822. }
  95823. /**
  95824. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95825. */
  95826. export class LineEdgesRenderer extends EdgesRenderer {
  95827. /**
  95828. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95829. * @param source LineMesh used to generate edges
  95830. * @param epsilon not important (specified angle for edge detection)
  95831. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95832. */
  95833. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95834. /**
  95835. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95836. */
  95837. _generateEdgesLines(): void;
  95838. }
  95839. }
  95840. declare module BABYLON {
  95841. /**
  95842. * This represents the object necessary to create a rendering group.
  95843. * This is exclusively used and created by the rendering manager.
  95844. * To modify the behavior, you use the available helpers in your scene or meshes.
  95845. * @hidden
  95846. */
  95847. export class RenderingGroup {
  95848. index: number;
  95849. private static _zeroVector;
  95850. private _scene;
  95851. private _opaqueSubMeshes;
  95852. private _transparentSubMeshes;
  95853. private _alphaTestSubMeshes;
  95854. private _depthOnlySubMeshes;
  95855. private _particleSystems;
  95856. private _spriteManagers;
  95857. private _opaqueSortCompareFn;
  95858. private _alphaTestSortCompareFn;
  95859. private _transparentSortCompareFn;
  95860. private _renderOpaque;
  95861. private _renderAlphaTest;
  95862. private _renderTransparent;
  95863. /** @hidden */
  95864. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95865. onBeforeTransparentRendering: () => void;
  95866. /**
  95867. * Set the opaque sort comparison function.
  95868. * If null the sub meshes will be render in the order they were created
  95869. */
  95870. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95871. /**
  95872. * Set the alpha test sort comparison function.
  95873. * If null the sub meshes will be render in the order they were created
  95874. */
  95875. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95876. /**
  95877. * Set the transparent sort comparison function.
  95878. * If null the sub meshes will be render in the order they were created
  95879. */
  95880. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95881. /**
  95882. * Creates a new rendering group.
  95883. * @param index The rendering group index
  95884. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95885. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95886. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95887. */
  95888. 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>);
  95889. /**
  95890. * Render all the sub meshes contained in the group.
  95891. * @param customRenderFunction Used to override the default render behaviour of the group.
  95892. * @returns true if rendered some submeshes.
  95893. */
  95894. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95895. /**
  95896. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95897. * @param subMeshes The submeshes to render
  95898. */
  95899. private renderOpaqueSorted;
  95900. /**
  95901. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95902. * @param subMeshes The submeshes to render
  95903. */
  95904. private renderAlphaTestSorted;
  95905. /**
  95906. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95907. * @param subMeshes The submeshes to render
  95908. */
  95909. private renderTransparentSorted;
  95910. /**
  95911. * Renders the submeshes in a specified order.
  95912. * @param subMeshes The submeshes to sort before render
  95913. * @param sortCompareFn The comparison function use to sort
  95914. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95915. * @param transparent Specifies to activate blending if true
  95916. */
  95917. private static renderSorted;
  95918. /**
  95919. * Renders the submeshes in the order they were dispatched (no sort applied).
  95920. * @param subMeshes The submeshes to render
  95921. */
  95922. private static renderUnsorted;
  95923. /**
  95924. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95925. * are rendered back to front if in the same alpha index.
  95926. *
  95927. * @param a The first submesh
  95928. * @param b The second submesh
  95929. * @returns The result of the comparison
  95930. */
  95931. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95932. /**
  95933. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95934. * are rendered back to front.
  95935. *
  95936. * @param a The first submesh
  95937. * @param b The second submesh
  95938. * @returns The result of the comparison
  95939. */
  95940. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95941. /**
  95942. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95943. * are rendered front to back (prevent overdraw).
  95944. *
  95945. * @param a The first submesh
  95946. * @param b The second submesh
  95947. * @returns The result of the comparison
  95948. */
  95949. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95950. /**
  95951. * Resets the different lists of submeshes to prepare a new frame.
  95952. */
  95953. prepare(): void;
  95954. dispose(): void;
  95955. /**
  95956. * Inserts the submesh in its correct queue depending on its material.
  95957. * @param subMesh The submesh to dispatch
  95958. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95959. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95960. */
  95961. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95962. dispatchSprites(spriteManager: ISpriteManager): void;
  95963. dispatchParticles(particleSystem: IParticleSystem): void;
  95964. private _renderParticles;
  95965. private _renderSprites;
  95966. }
  95967. }
  95968. declare module BABYLON {
  95969. /**
  95970. * Interface describing the different options available in the rendering manager
  95971. * regarding Auto Clear between groups.
  95972. */
  95973. export interface IRenderingManagerAutoClearSetup {
  95974. /**
  95975. * Defines whether or not autoclear is enable.
  95976. */
  95977. autoClear: boolean;
  95978. /**
  95979. * Defines whether or not to autoclear the depth buffer.
  95980. */
  95981. depth: boolean;
  95982. /**
  95983. * Defines whether or not to autoclear the stencil buffer.
  95984. */
  95985. stencil: boolean;
  95986. }
  95987. /**
  95988. * This class is used by the onRenderingGroupObservable
  95989. */
  95990. export class RenderingGroupInfo {
  95991. /**
  95992. * The Scene that being rendered
  95993. */
  95994. scene: Scene;
  95995. /**
  95996. * The camera currently used for the rendering pass
  95997. */
  95998. camera: Nullable<Camera>;
  95999. /**
  96000. * The ID of the renderingGroup being processed
  96001. */
  96002. renderingGroupId: number;
  96003. }
  96004. /**
  96005. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96006. * It is enable to manage the different groups as well as the different necessary sort functions.
  96007. * This should not be used directly aside of the few static configurations
  96008. */
  96009. export class RenderingManager {
  96010. /**
  96011. * The max id used for rendering groups (not included)
  96012. */
  96013. static MAX_RENDERINGGROUPS: number;
  96014. /**
  96015. * The min id used for rendering groups (included)
  96016. */
  96017. static MIN_RENDERINGGROUPS: number;
  96018. /**
  96019. * Used to globally prevent autoclearing scenes.
  96020. */
  96021. static AUTOCLEAR: boolean;
  96022. /**
  96023. * @hidden
  96024. */
  96025. _useSceneAutoClearSetup: boolean;
  96026. private _scene;
  96027. private _renderingGroups;
  96028. private _depthStencilBufferAlreadyCleaned;
  96029. private _autoClearDepthStencil;
  96030. private _customOpaqueSortCompareFn;
  96031. private _customAlphaTestSortCompareFn;
  96032. private _customTransparentSortCompareFn;
  96033. private _renderingGroupInfo;
  96034. /**
  96035. * Instantiates a new rendering group for a particular scene
  96036. * @param scene Defines the scene the groups belongs to
  96037. */
  96038. constructor(scene: Scene);
  96039. private _clearDepthStencilBuffer;
  96040. /**
  96041. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96042. * @hidden
  96043. */
  96044. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96045. /**
  96046. * Resets the different information of the group to prepare a new frame
  96047. * @hidden
  96048. */
  96049. reset(): void;
  96050. /**
  96051. * Dispose and release the group and its associated resources.
  96052. * @hidden
  96053. */
  96054. dispose(): void;
  96055. /**
  96056. * Clear the info related to rendering groups preventing retention points during dispose.
  96057. */
  96058. freeRenderingGroups(): void;
  96059. private _prepareRenderingGroup;
  96060. /**
  96061. * Add a sprite manager to the rendering manager in order to render it this frame.
  96062. * @param spriteManager Define the sprite manager to render
  96063. */
  96064. dispatchSprites(spriteManager: ISpriteManager): void;
  96065. /**
  96066. * Add a particle system to the rendering manager in order to render it this frame.
  96067. * @param particleSystem Define the particle system to render
  96068. */
  96069. dispatchParticles(particleSystem: IParticleSystem): void;
  96070. /**
  96071. * Add a submesh to the manager in order to render it this frame
  96072. * @param subMesh The submesh to dispatch
  96073. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96074. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96075. */
  96076. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96077. /**
  96078. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96079. * This allowed control for front to back rendering or reversly depending of the special needs.
  96080. *
  96081. * @param renderingGroupId The rendering group id corresponding to its index
  96082. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96083. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96084. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96085. */
  96086. 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;
  96087. /**
  96088. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96089. *
  96090. * @param renderingGroupId The rendering group id corresponding to its index
  96091. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96092. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96093. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96094. */
  96095. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96096. /**
  96097. * Gets the current auto clear configuration for one rendering group of the rendering
  96098. * manager.
  96099. * @param index the rendering group index to get the information for
  96100. * @returns The auto clear setup for the requested rendering group
  96101. */
  96102. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96103. }
  96104. }
  96105. declare module BABYLON {
  96106. /**
  96107. * Defines the options associated with the creation of a custom shader for a shadow generator.
  96108. */
  96109. export interface ICustomShaderOptions {
  96110. /**
  96111. * Gets or sets the custom shader name to use
  96112. */
  96113. shaderName: string;
  96114. /**
  96115. * The list of attribute names used in the shader
  96116. */
  96117. attributes?: string[];
  96118. /**
  96119. * The list of unifrom names used in the shader
  96120. */
  96121. uniforms?: string[];
  96122. /**
  96123. * The list of sampler names used in the shader
  96124. */
  96125. samplers?: string[];
  96126. /**
  96127. * The list of defines used in the shader
  96128. */
  96129. defines?: string[];
  96130. }
  96131. /**
  96132. * Interface to implement to create a shadow generator compatible with BJS.
  96133. */
  96134. export interface IShadowGenerator {
  96135. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96136. id: string;
  96137. /**
  96138. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96139. * @returns The render target texture if present otherwise, null
  96140. */
  96141. getShadowMap(): Nullable<RenderTargetTexture>;
  96142. /**
  96143. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96144. * @param subMesh The submesh we want to render in the shadow map
  96145. * @param useInstances Defines wether will draw in the map using instances
  96146. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96147. * @returns true if ready otherwise, false
  96148. */
  96149. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96150. /**
  96151. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96152. * @param defines Defines of the material we want to update
  96153. * @param lightIndex Index of the light in the enabled light list of the material
  96154. */
  96155. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  96156. /**
  96157. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96158. * defined in the generator but impacting the effect).
  96159. * It implies the unifroms available on the materials are the standard BJS ones.
  96160. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96161. * @param effect The effect we are binfing the information for
  96162. */
  96163. bindShadowLight(lightIndex: string, effect: Effect): void;
  96164. /**
  96165. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96166. * (eq to shadow prjection matrix * light transform matrix)
  96167. * @returns The transform matrix used to create the shadow map
  96168. */
  96169. getTransformMatrix(): Matrix;
  96170. /**
  96171. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96172. * Cube and 2D textures for instance.
  96173. */
  96174. recreateShadowMap(): void;
  96175. /**
  96176. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96177. * @param onCompiled Callback triggered at the and of the effects compilation
  96178. * @param options Sets of optional options forcing the compilation with different modes
  96179. */
  96180. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96181. useInstances: boolean;
  96182. }>): void;
  96183. /**
  96184. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96185. * @param options Sets of optional options forcing the compilation with different modes
  96186. * @returns A promise that resolves when the compilation completes
  96187. */
  96188. forceCompilationAsync(options?: Partial<{
  96189. useInstances: boolean;
  96190. }>): Promise<void>;
  96191. /**
  96192. * Serializes the shadow generator setup to a json object.
  96193. * @returns The serialized JSON object
  96194. */
  96195. serialize(): any;
  96196. /**
  96197. * Disposes the Shadow map and related Textures and effects.
  96198. */
  96199. dispose(): void;
  96200. }
  96201. /**
  96202. * Default implementation IShadowGenerator.
  96203. * This is the main object responsible of generating shadows in the framework.
  96204. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96205. */
  96206. export class ShadowGenerator implements IShadowGenerator {
  96207. /**
  96208. * Name of the shadow generator class
  96209. */
  96210. static CLASSNAME: string;
  96211. /**
  96212. * Shadow generator mode None: no filtering applied.
  96213. */
  96214. static readonly FILTER_NONE: number;
  96215. /**
  96216. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96217. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96218. */
  96219. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96220. /**
  96221. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96222. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96223. */
  96224. static readonly FILTER_POISSONSAMPLING: number;
  96225. /**
  96226. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96227. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96228. */
  96229. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96230. /**
  96231. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96232. * edge artifacts on steep falloff.
  96233. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96234. */
  96235. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96236. /**
  96237. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96238. * edge artifacts on steep falloff.
  96239. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96240. */
  96241. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96242. /**
  96243. * Shadow generator mode PCF: Percentage Closer Filtering
  96244. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96245. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96246. */
  96247. static readonly FILTER_PCF: number;
  96248. /**
  96249. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96250. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96251. * Contact Hardening
  96252. */
  96253. static readonly FILTER_PCSS: number;
  96254. /**
  96255. * Reserved for PCF and PCSS
  96256. * Highest Quality.
  96257. *
  96258. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96259. *
  96260. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96261. */
  96262. static readonly QUALITY_HIGH: number;
  96263. /**
  96264. * Reserved for PCF and PCSS
  96265. * Good tradeoff for quality/perf cross devices
  96266. *
  96267. * Execute PCF on a 3*3 kernel.
  96268. *
  96269. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96270. */
  96271. static readonly QUALITY_MEDIUM: number;
  96272. /**
  96273. * Reserved for PCF and PCSS
  96274. * The lowest quality but the fastest.
  96275. *
  96276. * Execute PCF on a 1*1 kernel.
  96277. *
  96278. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96279. */
  96280. static readonly QUALITY_LOW: number;
  96281. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96282. id: string;
  96283. /** Gets or sets the custom shader name to use */
  96284. customShaderOptions: ICustomShaderOptions;
  96285. /**
  96286. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96287. */
  96288. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96289. /**
  96290. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96291. */
  96292. onAfterShadowMapRenderObservable: Observable<Effect>;
  96293. /**
  96294. * Observable triggered before a mesh is rendered in the shadow map.
  96295. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96296. */
  96297. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96298. /**
  96299. * Observable triggered after a mesh is rendered in the shadow map.
  96300. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96301. */
  96302. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96303. protected _bias: number;
  96304. /**
  96305. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96306. */
  96307. get bias(): number;
  96308. /**
  96309. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96310. */
  96311. set bias(bias: number);
  96312. protected _normalBias: number;
  96313. /**
  96314. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96315. */
  96316. get normalBias(): number;
  96317. /**
  96318. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96319. */
  96320. set normalBias(normalBias: number);
  96321. protected _blurBoxOffset: number;
  96322. /**
  96323. * Gets the blur box offset: offset applied during the blur pass.
  96324. * Only useful if useKernelBlur = false
  96325. */
  96326. get blurBoxOffset(): number;
  96327. /**
  96328. * Sets the blur box offset: offset applied during the blur pass.
  96329. * Only useful if useKernelBlur = false
  96330. */
  96331. set blurBoxOffset(value: number);
  96332. protected _blurScale: number;
  96333. /**
  96334. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96335. * 2 means half of the size.
  96336. */
  96337. get blurScale(): number;
  96338. /**
  96339. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96340. * 2 means half of the size.
  96341. */
  96342. set blurScale(value: number);
  96343. protected _blurKernel: number;
  96344. /**
  96345. * Gets the blur kernel: kernel size of the blur pass.
  96346. * Only useful if useKernelBlur = true
  96347. */
  96348. get blurKernel(): number;
  96349. /**
  96350. * Sets the blur kernel: kernel size of the blur pass.
  96351. * Only useful if useKernelBlur = true
  96352. */
  96353. set blurKernel(value: number);
  96354. protected _useKernelBlur: boolean;
  96355. /**
  96356. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96357. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96358. */
  96359. get useKernelBlur(): boolean;
  96360. /**
  96361. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96362. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96363. */
  96364. set useKernelBlur(value: boolean);
  96365. protected _depthScale: number;
  96366. /**
  96367. * Gets the depth scale used in ESM mode.
  96368. */
  96369. get depthScale(): number;
  96370. /**
  96371. * Sets the depth scale used in ESM mode.
  96372. * This can override the scale stored on the light.
  96373. */
  96374. set depthScale(value: number);
  96375. protected _validateFilter(filter: number): number;
  96376. protected _filter: number;
  96377. /**
  96378. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96379. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96380. */
  96381. get filter(): number;
  96382. /**
  96383. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96384. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96385. */
  96386. set filter(value: number);
  96387. /**
  96388. * Gets if the current filter is set to Poisson Sampling.
  96389. */
  96390. get usePoissonSampling(): boolean;
  96391. /**
  96392. * Sets the current filter to Poisson Sampling.
  96393. */
  96394. set usePoissonSampling(value: boolean);
  96395. /**
  96396. * Gets if the current filter is set to ESM.
  96397. */
  96398. get useExponentialShadowMap(): boolean;
  96399. /**
  96400. * Sets the current filter is to ESM.
  96401. */
  96402. set useExponentialShadowMap(value: boolean);
  96403. /**
  96404. * Gets if the current filter is set to filtered ESM.
  96405. */
  96406. get useBlurExponentialShadowMap(): boolean;
  96407. /**
  96408. * Gets if the current filter is set to filtered ESM.
  96409. */
  96410. set useBlurExponentialShadowMap(value: boolean);
  96411. /**
  96412. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96413. * exponential to prevent steep falloff artifacts).
  96414. */
  96415. get useCloseExponentialShadowMap(): boolean;
  96416. /**
  96417. * Sets the current filter to "close ESM" (using the inverse of the
  96418. * exponential to prevent steep falloff artifacts).
  96419. */
  96420. set useCloseExponentialShadowMap(value: boolean);
  96421. /**
  96422. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96423. * exponential to prevent steep falloff artifacts).
  96424. */
  96425. get useBlurCloseExponentialShadowMap(): boolean;
  96426. /**
  96427. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96428. * exponential to prevent steep falloff artifacts).
  96429. */
  96430. set useBlurCloseExponentialShadowMap(value: boolean);
  96431. /**
  96432. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96433. */
  96434. get usePercentageCloserFiltering(): boolean;
  96435. /**
  96436. * Sets the current filter to "PCF" (percentage closer filtering).
  96437. */
  96438. set usePercentageCloserFiltering(value: boolean);
  96439. protected _filteringQuality: number;
  96440. /**
  96441. * Gets the PCF or PCSS Quality.
  96442. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96443. */
  96444. get filteringQuality(): number;
  96445. /**
  96446. * Sets the PCF or PCSS Quality.
  96447. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96448. */
  96449. set filteringQuality(filteringQuality: number);
  96450. /**
  96451. * Gets if the current filter is set to "PCSS" (contact hardening).
  96452. */
  96453. get useContactHardeningShadow(): boolean;
  96454. /**
  96455. * Sets the current filter to "PCSS" (contact hardening).
  96456. */
  96457. set useContactHardeningShadow(value: boolean);
  96458. protected _contactHardeningLightSizeUVRatio: number;
  96459. /**
  96460. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96461. * Using a ratio helps keeping shape stability independently of the map size.
  96462. *
  96463. * It does not account for the light projection as it was having too much
  96464. * instability during the light setup or during light position changes.
  96465. *
  96466. * Only valid if useContactHardeningShadow is true.
  96467. */
  96468. get contactHardeningLightSizeUVRatio(): number;
  96469. /**
  96470. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96471. * Using a ratio helps keeping shape stability independently of the map size.
  96472. *
  96473. * It does not account for the light projection as it was having too much
  96474. * instability during the light setup or during light position changes.
  96475. *
  96476. * Only valid if useContactHardeningShadow is true.
  96477. */
  96478. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96479. protected _darkness: number;
  96480. /** Gets or sets the actual darkness of a shadow */
  96481. get darkness(): number;
  96482. set darkness(value: number);
  96483. /**
  96484. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96485. * 0 means strongest and 1 would means no shadow.
  96486. * @returns the darkness.
  96487. */
  96488. getDarkness(): number;
  96489. /**
  96490. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96491. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96492. * @returns the shadow generator allowing fluent coding.
  96493. */
  96494. setDarkness(darkness: number): ShadowGenerator;
  96495. protected _transparencyShadow: boolean;
  96496. /** Gets or sets the ability to have transparent shadow */
  96497. get transparencyShadow(): boolean;
  96498. set transparencyShadow(value: boolean);
  96499. /**
  96500. * Sets the ability to have transparent shadow (boolean).
  96501. * @param transparent True if transparent else False
  96502. * @returns the shadow generator allowing fluent coding
  96503. */
  96504. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96505. /**
  96506. * Enables or disables shadows with varying strength based on the transparency
  96507. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96508. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96509. * mesh.visibility * alphaTexture.a
  96510. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96511. */
  96512. enableSoftTransparentShadow: boolean;
  96513. protected _shadowMap: Nullable<RenderTargetTexture>;
  96514. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96515. /**
  96516. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96517. * @returns The render target texture if present otherwise, null
  96518. */
  96519. getShadowMap(): Nullable<RenderTargetTexture>;
  96520. /**
  96521. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96522. * @returns The render target texture if the shadow map is present otherwise, null
  96523. */
  96524. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96525. /**
  96526. * Gets the class name of that object
  96527. * @returns "ShadowGenerator"
  96528. */
  96529. getClassName(): string;
  96530. /**
  96531. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96532. * @param mesh Mesh to add
  96533. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96534. * @returns the Shadow Generator itself
  96535. */
  96536. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96537. /**
  96538. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96539. * @param mesh Mesh to remove
  96540. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96541. * @returns the Shadow Generator itself
  96542. */
  96543. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96544. /**
  96545. * Controls the extent to which the shadows fade out at the edge of the frustum
  96546. */
  96547. frustumEdgeFalloff: number;
  96548. protected _light: IShadowLight;
  96549. /**
  96550. * Returns the associated light object.
  96551. * @returns the light generating the shadow
  96552. */
  96553. getLight(): IShadowLight;
  96554. /**
  96555. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96556. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96557. * It might on the other hand introduce peter panning.
  96558. */
  96559. forceBackFacesOnly: boolean;
  96560. protected _scene: Scene;
  96561. protected _lightDirection: Vector3;
  96562. protected _effect: Effect;
  96563. protected _viewMatrix: Matrix;
  96564. protected _projectionMatrix: Matrix;
  96565. protected _transformMatrix: Matrix;
  96566. protected _cachedPosition: Vector3;
  96567. protected _cachedDirection: Vector3;
  96568. protected _cachedDefines: string;
  96569. protected _currentRenderID: number;
  96570. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96571. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96572. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96573. protected _blurPostProcesses: PostProcess[];
  96574. protected _mapSize: number;
  96575. protected _currentFaceIndex: number;
  96576. protected _currentFaceIndexCache: number;
  96577. protected _textureType: number;
  96578. protected _defaultTextureMatrix: Matrix;
  96579. protected _storedUniqueId: Nullable<number>;
  96580. /** @hidden */
  96581. static _SceneComponentInitialization: (scene: Scene) => void;
  96582. /**
  96583. * Creates a ShadowGenerator object.
  96584. * A ShadowGenerator is the required tool to use the shadows.
  96585. * Each light casting shadows needs to use its own ShadowGenerator.
  96586. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96587. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96588. * @param light The light object generating the shadows.
  96589. * @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.
  96590. */
  96591. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96592. protected _initializeGenerator(): void;
  96593. protected _createTargetRenderTexture(): void;
  96594. protected _initializeShadowMap(): void;
  96595. protected _initializeBlurRTTAndPostProcesses(): void;
  96596. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96597. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96598. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96599. protected _applyFilterValues(): void;
  96600. /**
  96601. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96602. * @param onCompiled Callback triggered at the and of the effects compilation
  96603. * @param options Sets of optional options forcing the compilation with different modes
  96604. */
  96605. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96606. useInstances: boolean;
  96607. }>): void;
  96608. /**
  96609. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96610. * @param options Sets of optional options forcing the compilation with different modes
  96611. * @returns A promise that resolves when the compilation completes
  96612. */
  96613. forceCompilationAsync(options?: Partial<{
  96614. useInstances: boolean;
  96615. }>): Promise<void>;
  96616. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96617. private _prepareShadowDefines;
  96618. /**
  96619. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96620. * @param subMesh The submesh we want to render in the shadow map
  96621. * @param useInstances Defines wether will draw in the map using instances
  96622. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96623. * @returns true if ready otherwise, false
  96624. */
  96625. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96626. /**
  96627. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96628. * @param defines Defines of the material we want to update
  96629. * @param lightIndex Index of the light in the enabled light list of the material
  96630. */
  96631. prepareDefines(defines: any, lightIndex: number): void;
  96632. /**
  96633. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96634. * defined in the generator but impacting the effect).
  96635. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96636. * @param effect The effect we are binfing the information for
  96637. */
  96638. bindShadowLight(lightIndex: string, effect: Effect): void;
  96639. /**
  96640. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96641. * (eq to shadow prjection matrix * light transform matrix)
  96642. * @returns The transform matrix used to create the shadow map
  96643. */
  96644. getTransformMatrix(): Matrix;
  96645. /**
  96646. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96647. * Cube and 2D textures for instance.
  96648. */
  96649. recreateShadowMap(): void;
  96650. protected _disposeBlurPostProcesses(): void;
  96651. protected _disposeRTTandPostProcesses(): void;
  96652. /**
  96653. * Disposes the ShadowGenerator.
  96654. * Returns nothing.
  96655. */
  96656. dispose(): void;
  96657. /**
  96658. * Serializes the shadow generator setup to a json object.
  96659. * @returns The serialized JSON object
  96660. */
  96661. serialize(): any;
  96662. /**
  96663. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96664. * @param parsedShadowGenerator The JSON object to parse
  96665. * @param scene The scene to create the shadow map for
  96666. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96667. * @returns The parsed shadow generator
  96668. */
  96669. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96670. }
  96671. }
  96672. declare module BABYLON {
  96673. /**
  96674. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96675. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96676. * 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.
  96677. */
  96678. export abstract class Light extends Node {
  96679. /**
  96680. * Falloff Default: light is falling off following the material specification:
  96681. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96682. */
  96683. static readonly FALLOFF_DEFAULT: number;
  96684. /**
  96685. * Falloff Physical: light is falling off following the inverse squared distance law.
  96686. */
  96687. static readonly FALLOFF_PHYSICAL: number;
  96688. /**
  96689. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96690. * to enhance interoperability with other engines.
  96691. */
  96692. static readonly FALLOFF_GLTF: number;
  96693. /**
  96694. * Falloff Standard: light is falling off like in the standard material
  96695. * to enhance interoperability with other materials.
  96696. */
  96697. static readonly FALLOFF_STANDARD: number;
  96698. /**
  96699. * If every light affecting the material is in this lightmapMode,
  96700. * material.lightmapTexture adds or multiplies
  96701. * (depends on material.useLightmapAsShadowmap)
  96702. * after every other light calculations.
  96703. */
  96704. static readonly LIGHTMAP_DEFAULT: number;
  96705. /**
  96706. * material.lightmapTexture as only diffuse lighting from this light
  96707. * adds only specular lighting from this light
  96708. * adds dynamic shadows
  96709. */
  96710. static readonly LIGHTMAP_SPECULAR: number;
  96711. /**
  96712. * material.lightmapTexture as only lighting
  96713. * no light calculation from this light
  96714. * only adds dynamic shadows from this light
  96715. */
  96716. static readonly LIGHTMAP_SHADOWSONLY: number;
  96717. /**
  96718. * Each light type uses the default quantity according to its type:
  96719. * point/spot lights use luminous intensity
  96720. * directional lights use illuminance
  96721. */
  96722. static readonly INTENSITYMODE_AUTOMATIC: number;
  96723. /**
  96724. * lumen (lm)
  96725. */
  96726. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96727. /**
  96728. * candela (lm/sr)
  96729. */
  96730. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96731. /**
  96732. * lux (lm/m^2)
  96733. */
  96734. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96735. /**
  96736. * nit (cd/m^2)
  96737. */
  96738. static readonly INTENSITYMODE_LUMINANCE: number;
  96739. /**
  96740. * Light type const id of the point light.
  96741. */
  96742. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96743. /**
  96744. * Light type const id of the directional light.
  96745. */
  96746. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96747. /**
  96748. * Light type const id of the spot light.
  96749. */
  96750. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96751. /**
  96752. * Light type const id of the hemispheric light.
  96753. */
  96754. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96755. /**
  96756. * Diffuse gives the basic color to an object.
  96757. */
  96758. diffuse: Color3;
  96759. /**
  96760. * Specular produces a highlight color on an object.
  96761. * Note: This is note affecting PBR materials.
  96762. */
  96763. specular: Color3;
  96764. /**
  96765. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96766. * falling off base on range or angle.
  96767. * This can be set to any values in Light.FALLOFF_x.
  96768. *
  96769. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96770. * other types of materials.
  96771. */
  96772. falloffType: number;
  96773. /**
  96774. * Strength of the light.
  96775. * Note: By default it is define in the framework own unit.
  96776. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96777. */
  96778. intensity: number;
  96779. private _range;
  96780. protected _inverseSquaredRange: number;
  96781. /**
  96782. * Defines how far from the source the light is impacting in scene units.
  96783. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96784. */
  96785. get range(): number;
  96786. /**
  96787. * Defines how far from the source the light is impacting in scene units.
  96788. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96789. */
  96790. set range(value: number);
  96791. /**
  96792. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96793. * of light.
  96794. */
  96795. private _photometricScale;
  96796. private _intensityMode;
  96797. /**
  96798. * Gets the photometric scale used to interpret the intensity.
  96799. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96800. */
  96801. get intensityMode(): number;
  96802. /**
  96803. * Sets the photometric scale used to interpret the intensity.
  96804. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96805. */
  96806. set intensityMode(value: number);
  96807. private _radius;
  96808. /**
  96809. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96810. */
  96811. get radius(): number;
  96812. /**
  96813. * sets the light radius used by PBR Materials to simulate soft area lights.
  96814. */
  96815. set radius(value: number);
  96816. private _renderPriority;
  96817. /**
  96818. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96819. * exceeding the number allowed of the materials.
  96820. */
  96821. renderPriority: number;
  96822. private _shadowEnabled;
  96823. /**
  96824. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96825. * the current shadow generator.
  96826. */
  96827. get shadowEnabled(): boolean;
  96828. /**
  96829. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96830. * the current shadow generator.
  96831. */
  96832. set shadowEnabled(value: boolean);
  96833. private _includedOnlyMeshes;
  96834. /**
  96835. * Gets the only meshes impacted by this light.
  96836. */
  96837. get includedOnlyMeshes(): AbstractMesh[];
  96838. /**
  96839. * Sets the only meshes impacted by this light.
  96840. */
  96841. set includedOnlyMeshes(value: AbstractMesh[]);
  96842. private _excludedMeshes;
  96843. /**
  96844. * Gets the meshes not impacted by this light.
  96845. */
  96846. get excludedMeshes(): AbstractMesh[];
  96847. /**
  96848. * Sets the meshes not impacted by this light.
  96849. */
  96850. set excludedMeshes(value: AbstractMesh[]);
  96851. private _excludeWithLayerMask;
  96852. /**
  96853. * Gets the layer id use to find what meshes are not impacted by the light.
  96854. * Inactive if 0
  96855. */
  96856. get excludeWithLayerMask(): number;
  96857. /**
  96858. * Sets the layer id use to find what meshes are not impacted by the light.
  96859. * Inactive if 0
  96860. */
  96861. set excludeWithLayerMask(value: number);
  96862. private _includeOnlyWithLayerMask;
  96863. /**
  96864. * Gets the layer id use to find what meshes are impacted by the light.
  96865. * Inactive if 0
  96866. */
  96867. get includeOnlyWithLayerMask(): number;
  96868. /**
  96869. * Sets the layer id use to find what meshes are impacted by the light.
  96870. * Inactive if 0
  96871. */
  96872. set includeOnlyWithLayerMask(value: number);
  96873. private _lightmapMode;
  96874. /**
  96875. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96876. */
  96877. get lightmapMode(): number;
  96878. /**
  96879. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96880. */
  96881. set lightmapMode(value: number);
  96882. /**
  96883. * Shadow generator associted to the light.
  96884. * @hidden Internal use only.
  96885. */
  96886. _shadowGenerator: Nullable<IShadowGenerator>;
  96887. /**
  96888. * @hidden Internal use only.
  96889. */
  96890. _excludedMeshesIds: string[];
  96891. /**
  96892. * @hidden Internal use only.
  96893. */
  96894. _includedOnlyMeshesIds: string[];
  96895. /**
  96896. * The current light unifom buffer.
  96897. * @hidden Internal use only.
  96898. */
  96899. _uniformBuffer: UniformBuffer;
  96900. /** @hidden */
  96901. _renderId: number;
  96902. /**
  96903. * Creates a Light object in the scene.
  96904. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96905. * @param name The firendly name of the light
  96906. * @param scene The scene the light belongs too
  96907. */
  96908. constructor(name: string, scene: Scene);
  96909. protected abstract _buildUniformLayout(): void;
  96910. /**
  96911. * Sets the passed Effect "effect" with the Light information.
  96912. * @param effect The effect to update
  96913. * @param lightIndex The index of the light in the effect to update
  96914. * @returns The light
  96915. */
  96916. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96917. /**
  96918. * Sets the passed Effect "effect" with the Light textures.
  96919. * @param effect The effect to update
  96920. * @param lightIndex The index of the light in the effect to update
  96921. * @returns The light
  96922. */
  96923. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96924. /**
  96925. * Binds the lights information from the scene to the effect for the given mesh.
  96926. * @param lightIndex Light index
  96927. * @param scene The scene where the light belongs to
  96928. * @param effect The effect we are binding the data to
  96929. * @param useSpecular Defines if specular is supported
  96930. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96931. */
  96932. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96933. /**
  96934. * Sets the passed Effect "effect" with the Light information.
  96935. * @param effect The effect to update
  96936. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96937. * @returns The light
  96938. */
  96939. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96940. /**
  96941. * Returns the string "Light".
  96942. * @returns the class name
  96943. */
  96944. getClassName(): string;
  96945. /** @hidden */
  96946. readonly _isLight: boolean;
  96947. /**
  96948. * Converts the light information to a readable string for debug purpose.
  96949. * @param fullDetails Supports for multiple levels of logging within scene loading
  96950. * @returns the human readable light info
  96951. */
  96952. toString(fullDetails?: boolean): string;
  96953. /** @hidden */
  96954. protected _syncParentEnabledState(): void;
  96955. /**
  96956. * Set the enabled state of this node.
  96957. * @param value - the new enabled state
  96958. */
  96959. setEnabled(value: boolean): void;
  96960. /**
  96961. * Returns the Light associated shadow generator if any.
  96962. * @return the associated shadow generator.
  96963. */
  96964. getShadowGenerator(): Nullable<IShadowGenerator>;
  96965. /**
  96966. * Returns a Vector3, the absolute light position in the World.
  96967. * @returns the world space position of the light
  96968. */
  96969. getAbsolutePosition(): Vector3;
  96970. /**
  96971. * Specifies if the light will affect the passed mesh.
  96972. * @param mesh The mesh to test against the light
  96973. * @return true the mesh is affected otherwise, false.
  96974. */
  96975. canAffectMesh(mesh: AbstractMesh): boolean;
  96976. /**
  96977. * Sort function to order lights for rendering.
  96978. * @param a First Light object to compare to second.
  96979. * @param b Second Light object to compare first.
  96980. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96981. */
  96982. static CompareLightsPriority(a: Light, b: Light): number;
  96983. /**
  96984. * Releases resources associated with this node.
  96985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96987. */
  96988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96989. /**
  96990. * Returns the light type ID (integer).
  96991. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96992. */
  96993. getTypeID(): number;
  96994. /**
  96995. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96996. * @returns the scaled intensity in intensity mode unit
  96997. */
  96998. getScaledIntensity(): number;
  96999. /**
  97000. * Returns a new Light object, named "name", from the current one.
  97001. * @param name The name of the cloned light
  97002. * @param newParent The parent of this light, if it has one
  97003. * @returns the new created light
  97004. */
  97005. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97006. /**
  97007. * Serializes the current light into a Serialization object.
  97008. * @returns the serialized object.
  97009. */
  97010. serialize(): any;
  97011. /**
  97012. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97013. * This new light is named "name" and added to the passed scene.
  97014. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97015. * @param name The friendly name of the light
  97016. * @param scene The scene the new light will belong to
  97017. * @returns the constructor function
  97018. */
  97019. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97020. /**
  97021. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97022. * @param parsedLight The JSON representation of the light
  97023. * @param scene The scene to create the parsed light in
  97024. * @returns the created light after parsing
  97025. */
  97026. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97027. private _hookArrayForExcluded;
  97028. private _hookArrayForIncludedOnly;
  97029. private _resyncMeshes;
  97030. /**
  97031. * Forces the meshes to update their light related information in their rendering used effects
  97032. * @hidden Internal Use Only
  97033. */
  97034. _markMeshesAsLightDirty(): void;
  97035. /**
  97036. * Recomputes the cached photometric scale if needed.
  97037. */
  97038. private _computePhotometricScale;
  97039. /**
  97040. * Returns the Photometric Scale according to the light type and intensity mode.
  97041. */
  97042. private _getPhotometricScale;
  97043. /**
  97044. * Reorder the light in the scene according to their defined priority.
  97045. * @hidden Internal Use Only
  97046. */
  97047. _reorderLightsInScene(): void;
  97048. /**
  97049. * Prepares the list of defines specific to the light type.
  97050. * @param defines the list of defines
  97051. * @param lightIndex defines the index of the light for the effect
  97052. */
  97053. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97054. }
  97055. }
  97056. declare module BABYLON {
  97057. /**
  97058. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97059. * This is the base of the follow, arc rotate cameras and Free camera
  97060. * @see https://doc.babylonjs.com/features/cameras
  97061. */
  97062. export class TargetCamera extends Camera {
  97063. private static _RigCamTransformMatrix;
  97064. private static _TargetTransformMatrix;
  97065. private static _TargetFocalPoint;
  97066. private _tmpUpVector;
  97067. private _tmpTargetVector;
  97068. /**
  97069. * Define the current direction the camera is moving to
  97070. */
  97071. cameraDirection: Vector3;
  97072. /**
  97073. * Define the current rotation the camera is rotating to
  97074. */
  97075. cameraRotation: Vector2;
  97076. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97077. ignoreParentScaling: boolean;
  97078. /**
  97079. * When set, the up vector of the camera will be updated by the rotation of the camera
  97080. */
  97081. updateUpVectorFromRotation: boolean;
  97082. private _tmpQuaternion;
  97083. /**
  97084. * Define the current rotation of the camera
  97085. */
  97086. rotation: Vector3;
  97087. /**
  97088. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97089. */
  97090. rotationQuaternion: Quaternion;
  97091. /**
  97092. * Define the current speed of the camera
  97093. */
  97094. speed: number;
  97095. /**
  97096. * Add constraint to the camera to prevent it to move freely in all directions and
  97097. * around all axis.
  97098. */
  97099. noRotationConstraint: boolean;
  97100. /**
  97101. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  97102. * panning
  97103. */
  97104. invertRotation: boolean;
  97105. /**
  97106. * Speed multiplier for inverse camera panning
  97107. */
  97108. inverseRotationSpeed: number;
  97109. /**
  97110. * Define the current target of the camera as an object or a position.
  97111. */
  97112. lockedTarget: any;
  97113. /** @hidden */
  97114. _currentTarget: Vector3;
  97115. /** @hidden */
  97116. _initialFocalDistance: number;
  97117. /** @hidden */
  97118. _viewMatrix: Matrix;
  97119. /** @hidden */
  97120. _camMatrix: Matrix;
  97121. /** @hidden */
  97122. _cameraTransformMatrix: Matrix;
  97123. /** @hidden */
  97124. _cameraRotationMatrix: Matrix;
  97125. /** @hidden */
  97126. _referencePoint: Vector3;
  97127. /** @hidden */
  97128. _transformedReferencePoint: Vector3;
  97129. /** @hidden */
  97130. _reset: () => void;
  97131. private _defaultUp;
  97132. /**
  97133. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  97134. * This is the base of the follow, arc rotate cameras and Free camera
  97135. * @see https://doc.babylonjs.com/features/cameras
  97136. * @param name Defines the name of the camera in the scene
  97137. * @param position Defines the start position of the camera in the scene
  97138. * @param scene Defines the scene the camera belongs to
  97139. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97140. */
  97141. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97142. /**
  97143. * Gets the position in front of the camera at a given distance.
  97144. * @param distance The distance from the camera we want the position to be
  97145. * @returns the position
  97146. */
  97147. getFrontPosition(distance: number): Vector3;
  97148. /** @hidden */
  97149. _getLockedTargetPosition(): Nullable<Vector3>;
  97150. private _storedPosition;
  97151. private _storedRotation;
  97152. private _storedRotationQuaternion;
  97153. /**
  97154. * Store current camera state of the camera (fov, position, rotation, etc..)
  97155. * @returns the camera
  97156. */
  97157. storeState(): Camera;
  97158. /**
  97159. * Restored camera state. You must call storeState() first
  97160. * @returns whether it was successful or not
  97161. * @hidden
  97162. */
  97163. _restoreStateValues(): boolean;
  97164. /** @hidden */
  97165. _initCache(): void;
  97166. /** @hidden */
  97167. _updateCache(ignoreParentClass?: boolean): void;
  97168. /** @hidden */
  97169. _isSynchronizedViewMatrix(): boolean;
  97170. /** @hidden */
  97171. _computeLocalCameraSpeed(): number;
  97172. /**
  97173. * Defines the target the camera should look at.
  97174. * @param target Defines the new target as a Vector or a mesh
  97175. */
  97176. setTarget(target: Vector3): void;
  97177. /**
  97178. * Return the current target position of the camera. This value is expressed in local space.
  97179. * @returns the target position
  97180. */
  97181. getTarget(): Vector3;
  97182. /** @hidden */
  97183. _decideIfNeedsToMove(): boolean;
  97184. /** @hidden */
  97185. _updatePosition(): void;
  97186. /** @hidden */
  97187. _checkInputs(): void;
  97188. protected _updateCameraRotationMatrix(): void;
  97189. /**
  97190. * 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)
  97191. * @returns the current camera
  97192. */
  97193. private _rotateUpVectorWithCameraRotationMatrix;
  97194. private _cachedRotationZ;
  97195. private _cachedQuaternionRotationZ;
  97196. /** @hidden */
  97197. _getViewMatrix(): Matrix;
  97198. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97199. /**
  97200. * @hidden
  97201. */
  97202. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97203. /**
  97204. * @hidden
  97205. */
  97206. _updateRigCameras(): void;
  97207. private _getRigCamPositionAndTarget;
  97208. /**
  97209. * Gets the current object class name.
  97210. * @return the class name
  97211. */
  97212. getClassName(): string;
  97213. }
  97214. }
  97215. declare module BABYLON {
  97216. /**
  97217. * Gather the list of keyboard event types as constants.
  97218. */
  97219. export class KeyboardEventTypes {
  97220. /**
  97221. * The keydown event is fired when a key becomes active (pressed).
  97222. */
  97223. static readonly KEYDOWN: number;
  97224. /**
  97225. * The keyup event is fired when a key has been released.
  97226. */
  97227. static readonly KEYUP: number;
  97228. }
  97229. /**
  97230. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97231. */
  97232. export class KeyboardInfo {
  97233. /**
  97234. * Defines the type of event (KeyboardEventTypes)
  97235. */
  97236. type: number;
  97237. /**
  97238. * Defines the related dom event
  97239. */
  97240. event: KeyboardEvent;
  97241. /**
  97242. * Instantiates a new keyboard info.
  97243. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97244. * @param type Defines the type of event (KeyboardEventTypes)
  97245. * @param event Defines the related dom event
  97246. */
  97247. constructor(
  97248. /**
  97249. * Defines the type of event (KeyboardEventTypes)
  97250. */
  97251. type: number,
  97252. /**
  97253. * Defines the related dom event
  97254. */
  97255. event: KeyboardEvent);
  97256. }
  97257. /**
  97258. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97259. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97260. */
  97261. export class KeyboardInfoPre extends KeyboardInfo {
  97262. /**
  97263. * Defines the type of event (KeyboardEventTypes)
  97264. */
  97265. type: number;
  97266. /**
  97267. * Defines the related dom event
  97268. */
  97269. event: KeyboardEvent;
  97270. /**
  97271. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97272. */
  97273. skipOnPointerObservable: boolean;
  97274. /**
  97275. * Instantiates a new keyboard pre info.
  97276. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97277. * @param type Defines the type of event (KeyboardEventTypes)
  97278. * @param event Defines the related dom event
  97279. */
  97280. constructor(
  97281. /**
  97282. * Defines the type of event (KeyboardEventTypes)
  97283. */
  97284. type: number,
  97285. /**
  97286. * Defines the related dom event
  97287. */
  97288. event: KeyboardEvent);
  97289. }
  97290. }
  97291. declare module BABYLON {
  97292. /**
  97293. * Manage the keyboard inputs to control the movement of a free camera.
  97294. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97295. */
  97296. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97297. /**
  97298. * Defines the camera the input is attached to.
  97299. */
  97300. camera: FreeCamera;
  97301. /**
  97302. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97303. */
  97304. keysUp: number[];
  97305. /**
  97306. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97307. */
  97308. keysUpward: number[];
  97309. /**
  97310. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97311. */
  97312. keysDown: number[];
  97313. /**
  97314. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97315. */
  97316. keysDownward: number[];
  97317. /**
  97318. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97319. */
  97320. keysLeft: number[];
  97321. /**
  97322. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97323. */
  97324. keysRight: number[];
  97325. private _keys;
  97326. private _onCanvasBlurObserver;
  97327. private _onKeyboardObserver;
  97328. private _engine;
  97329. private _scene;
  97330. /**
  97331. * Attach the input controls to a specific dom element to get the input from.
  97332. * @param element Defines the element the controls should be listened from
  97333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97334. */
  97335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97336. /**
  97337. * Detach the current controls from the specified dom element.
  97338. * @param element Defines the element to stop listening the inputs from
  97339. */
  97340. detachControl(element: Nullable<HTMLElement>): void;
  97341. /**
  97342. * Update the current camera state depending on the inputs that have been used this frame.
  97343. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97344. */
  97345. checkInputs(): void;
  97346. /**
  97347. * Gets the class name of the current intput.
  97348. * @returns the class name
  97349. */
  97350. getClassName(): string;
  97351. /** @hidden */
  97352. _onLostFocus(): void;
  97353. /**
  97354. * Get the friendly name associated with the input class.
  97355. * @returns the input friendly name
  97356. */
  97357. getSimpleName(): string;
  97358. }
  97359. }
  97360. declare module BABYLON {
  97361. /**
  97362. * Gather the list of pointer event types as constants.
  97363. */
  97364. export class PointerEventTypes {
  97365. /**
  97366. * 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.
  97367. */
  97368. static readonly POINTERDOWN: number;
  97369. /**
  97370. * The pointerup event is fired when a pointer is no longer active.
  97371. */
  97372. static readonly POINTERUP: number;
  97373. /**
  97374. * The pointermove event is fired when a pointer changes coordinates.
  97375. */
  97376. static readonly POINTERMOVE: number;
  97377. /**
  97378. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97379. */
  97380. static readonly POINTERWHEEL: number;
  97381. /**
  97382. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97383. */
  97384. static readonly POINTERPICK: number;
  97385. /**
  97386. * The pointertap event is fired when a the object has been touched and released without drag.
  97387. */
  97388. static readonly POINTERTAP: number;
  97389. /**
  97390. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97391. */
  97392. static readonly POINTERDOUBLETAP: number;
  97393. }
  97394. /**
  97395. * Base class of pointer info types.
  97396. */
  97397. export class PointerInfoBase {
  97398. /**
  97399. * Defines the type of event (PointerEventTypes)
  97400. */
  97401. type: number;
  97402. /**
  97403. * Defines the related dom event
  97404. */
  97405. event: PointerEvent | MouseWheelEvent;
  97406. /**
  97407. * Instantiates the base class of pointers info.
  97408. * @param type Defines the type of event (PointerEventTypes)
  97409. * @param event Defines the related dom event
  97410. */
  97411. constructor(
  97412. /**
  97413. * Defines the type of event (PointerEventTypes)
  97414. */
  97415. type: number,
  97416. /**
  97417. * Defines the related dom event
  97418. */
  97419. event: PointerEvent | MouseWheelEvent);
  97420. }
  97421. /**
  97422. * This class is used to store pointer related info for the onPrePointerObservable event.
  97423. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97424. */
  97425. export class PointerInfoPre extends PointerInfoBase {
  97426. /**
  97427. * Ray from a pointer if availible (eg. 6dof controller)
  97428. */
  97429. ray: Nullable<Ray>;
  97430. /**
  97431. * Defines the local position of the pointer on the canvas.
  97432. */
  97433. localPosition: Vector2;
  97434. /**
  97435. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97436. */
  97437. skipOnPointerObservable: boolean;
  97438. /**
  97439. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  97440. * @param type Defines the type of event (PointerEventTypes)
  97441. * @param event Defines the related dom event
  97442. * @param localX Defines the local x coordinates of the pointer when the event occured
  97443. * @param localY Defines the local y coordinates of the pointer when the event occured
  97444. */
  97445. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  97446. }
  97447. /**
  97448. * This type contains all the data related to a pointer event in Babylon.js.
  97449. * 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.
  97450. */
  97451. export class PointerInfo extends PointerInfoBase {
  97452. /**
  97453. * Defines the picking info associated to the info (if any)\
  97454. */
  97455. pickInfo: Nullable<PickingInfo>;
  97456. /**
  97457. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  97458. * @param type Defines the type of event (PointerEventTypes)
  97459. * @param event Defines the related dom event
  97460. * @param pickInfo Defines the picking info associated to the info (if any)\
  97461. */
  97462. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  97463. /**
  97464. * Defines the picking info associated to the info (if any)\
  97465. */
  97466. pickInfo: Nullable<PickingInfo>);
  97467. }
  97468. /**
  97469. * Data relating to a touch event on the screen.
  97470. */
  97471. export interface PointerTouch {
  97472. /**
  97473. * X coordinate of touch.
  97474. */
  97475. x: number;
  97476. /**
  97477. * Y coordinate of touch.
  97478. */
  97479. y: number;
  97480. /**
  97481. * Id of touch. Unique for each finger.
  97482. */
  97483. pointerId: number;
  97484. /**
  97485. * Event type passed from DOM.
  97486. */
  97487. type: any;
  97488. }
  97489. }
  97490. declare module BABYLON {
  97491. /**
  97492. * Manage the mouse inputs to control the movement of a free camera.
  97493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97494. */
  97495. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97496. /**
  97497. * Define if touch is enabled in the mouse input
  97498. */
  97499. touchEnabled: boolean;
  97500. /**
  97501. * Defines the camera the input is attached to.
  97502. */
  97503. camera: FreeCamera;
  97504. /**
  97505. * Defines the buttons associated with the input to handle camera move.
  97506. */
  97507. buttons: number[];
  97508. /**
  97509. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97510. */
  97511. angularSensibility: number;
  97512. private _pointerInput;
  97513. private _onMouseMove;
  97514. private _observer;
  97515. private previousPosition;
  97516. /**
  97517. * Observable for when a pointer move event occurs containing the move offset
  97518. */
  97519. onPointerMovedObservable: Observable<{
  97520. offsetX: number;
  97521. offsetY: number;
  97522. }>;
  97523. /**
  97524. * @hidden
  97525. * If the camera should be rotated automatically based on pointer movement
  97526. */
  97527. _allowCameraRotation: boolean;
  97528. /**
  97529. * Manage the mouse inputs to control the movement of a free camera.
  97530. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97531. * @param touchEnabled Defines if touch is enabled or not
  97532. */
  97533. constructor(
  97534. /**
  97535. * Define if touch is enabled in the mouse input
  97536. */
  97537. touchEnabled?: boolean);
  97538. /**
  97539. * Attach the input controls to a specific dom element to get the input from.
  97540. * @param element Defines the element the controls should be listened from
  97541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97542. */
  97543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97544. /**
  97545. * Called on JS contextmenu event.
  97546. * Override this method to provide functionality.
  97547. */
  97548. protected onContextMenu(evt: PointerEvent): void;
  97549. /**
  97550. * Detach the current controls from the specified dom element.
  97551. * @param element Defines the element to stop listening the inputs from
  97552. */
  97553. detachControl(element: Nullable<HTMLElement>): void;
  97554. /**
  97555. * Gets the class name of the current intput.
  97556. * @returns the class name
  97557. */
  97558. getClassName(): string;
  97559. /**
  97560. * Get the friendly name associated with the input class.
  97561. * @returns the input friendly name
  97562. */
  97563. getSimpleName(): string;
  97564. }
  97565. }
  97566. declare module BABYLON {
  97567. /**
  97568. * Manage the touch inputs to control the movement of a free camera.
  97569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97570. */
  97571. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97572. /**
  97573. * Defines the camera the input is attached to.
  97574. */
  97575. camera: FreeCamera;
  97576. /**
  97577. * Defines the touch sensibility for rotation.
  97578. * The higher the faster.
  97579. */
  97580. touchAngularSensibility: number;
  97581. /**
  97582. * Defines the touch sensibility for move.
  97583. * The higher the faster.
  97584. */
  97585. touchMoveSensibility: number;
  97586. private _offsetX;
  97587. private _offsetY;
  97588. private _pointerPressed;
  97589. private _pointerInput;
  97590. private _observer;
  97591. private _onLostFocus;
  97592. /**
  97593. * Attach the input controls to a specific dom element to get the input from.
  97594. * @param element Defines the element the controls should be listened from
  97595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97596. */
  97597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97598. /**
  97599. * Detach the current controls from the specified dom element.
  97600. * @param element Defines the element to stop listening the inputs from
  97601. */
  97602. detachControl(element: Nullable<HTMLElement>): void;
  97603. /**
  97604. * Update the current camera state depending on the inputs that have been used this frame.
  97605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97606. */
  97607. checkInputs(): void;
  97608. /**
  97609. * Gets the class name of the current intput.
  97610. * @returns the class name
  97611. */
  97612. getClassName(): string;
  97613. /**
  97614. * Get the friendly name associated with the input class.
  97615. * @returns the input friendly name
  97616. */
  97617. getSimpleName(): string;
  97618. }
  97619. }
  97620. declare module BABYLON {
  97621. /**
  97622. * Default Inputs manager for the FreeCamera.
  97623. * It groups all the default supported inputs for ease of use.
  97624. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97625. */
  97626. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97627. /**
  97628. * @hidden
  97629. */
  97630. _mouseInput: Nullable<FreeCameraMouseInput>;
  97631. /**
  97632. * Instantiates a new FreeCameraInputsManager.
  97633. * @param camera Defines the camera the inputs belong to
  97634. */
  97635. constructor(camera: FreeCamera);
  97636. /**
  97637. * Add keyboard input support to the input manager.
  97638. * @returns the current input manager
  97639. */
  97640. addKeyboard(): FreeCameraInputsManager;
  97641. /**
  97642. * Add mouse input support to the input manager.
  97643. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97644. * @returns the current input manager
  97645. */
  97646. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97647. /**
  97648. * Removes the mouse input support from the manager
  97649. * @returns the current input manager
  97650. */
  97651. removeMouse(): FreeCameraInputsManager;
  97652. /**
  97653. * Add touch input support to the input manager.
  97654. * @returns the current input manager
  97655. */
  97656. addTouch(): FreeCameraInputsManager;
  97657. /**
  97658. * Remove all attached input methods from a camera
  97659. */
  97660. clear(): void;
  97661. }
  97662. }
  97663. declare module BABYLON {
  97664. /**
  97665. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97666. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97667. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97668. */
  97669. export class FreeCamera extends TargetCamera {
  97670. /**
  97671. * Define the collision ellipsoid of the camera.
  97672. * This is helpful to simulate a camera body like the player body around the camera
  97673. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97674. */
  97675. ellipsoid: Vector3;
  97676. /**
  97677. * Define an offset for the position of the ellipsoid around the camera.
  97678. * This can be helpful to determine the center of the body near the gravity center of the body
  97679. * instead of its head.
  97680. */
  97681. ellipsoidOffset: Vector3;
  97682. /**
  97683. * Enable or disable collisions of the camera with the rest of the scene objects.
  97684. */
  97685. checkCollisions: boolean;
  97686. /**
  97687. * Enable or disable gravity on the camera.
  97688. */
  97689. applyGravity: boolean;
  97690. /**
  97691. * Define the input manager associated to the camera.
  97692. */
  97693. inputs: FreeCameraInputsManager;
  97694. /**
  97695. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97696. * Higher values reduce sensitivity.
  97697. */
  97698. get angularSensibility(): number;
  97699. /**
  97700. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97701. * Higher values reduce sensitivity.
  97702. */
  97703. set angularSensibility(value: number);
  97704. /**
  97705. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97706. */
  97707. get keysUp(): number[];
  97708. set keysUp(value: number[]);
  97709. /**
  97710. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97711. */
  97712. get keysUpward(): number[];
  97713. set keysUpward(value: number[]);
  97714. /**
  97715. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97716. */
  97717. get keysDown(): number[];
  97718. set keysDown(value: number[]);
  97719. /**
  97720. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97721. */
  97722. get keysDownward(): number[];
  97723. set keysDownward(value: number[]);
  97724. /**
  97725. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97726. */
  97727. get keysLeft(): number[];
  97728. set keysLeft(value: number[]);
  97729. /**
  97730. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97731. */
  97732. get keysRight(): number[];
  97733. set keysRight(value: number[]);
  97734. /**
  97735. * Event raised when the camera collide with a mesh in the scene.
  97736. */
  97737. onCollide: (collidedMesh: AbstractMesh) => void;
  97738. private _collider;
  97739. private _needMoveForGravity;
  97740. private _oldPosition;
  97741. private _diffPosition;
  97742. private _newPosition;
  97743. /** @hidden */
  97744. _localDirection: Vector3;
  97745. /** @hidden */
  97746. _transformedDirection: Vector3;
  97747. /**
  97748. * Instantiates a Free Camera.
  97749. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97750. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97751. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97752. * @param name Define the name of the camera in the scene
  97753. * @param position Define the start position of the camera in the scene
  97754. * @param scene Define the scene the camera belongs to
  97755. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97756. */
  97757. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97758. /**
  97759. * Attached controls to the current camera.
  97760. * @param element Defines the element the controls should be listened from
  97761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97762. */
  97763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97764. /**
  97765. * Detach the current controls from the camera.
  97766. * The camera will stop reacting to inputs.
  97767. * @param element Defines the element to stop listening the inputs from
  97768. */
  97769. detachControl(element: HTMLElement): void;
  97770. private _collisionMask;
  97771. /**
  97772. * Define a collision mask to limit the list of object the camera can collide with
  97773. */
  97774. get collisionMask(): number;
  97775. set collisionMask(mask: number);
  97776. /** @hidden */
  97777. _collideWithWorld(displacement: Vector3): void;
  97778. private _onCollisionPositionChange;
  97779. /** @hidden */
  97780. _checkInputs(): void;
  97781. /** @hidden */
  97782. _decideIfNeedsToMove(): boolean;
  97783. /** @hidden */
  97784. _updatePosition(): void;
  97785. /**
  97786. * Destroy the camera and release the current resources hold by it.
  97787. */
  97788. dispose(): void;
  97789. /**
  97790. * Gets the current object class name.
  97791. * @return the class name
  97792. */
  97793. getClassName(): string;
  97794. }
  97795. }
  97796. declare module BABYLON {
  97797. /**
  97798. * Represents a gamepad control stick position
  97799. */
  97800. export class StickValues {
  97801. /**
  97802. * The x component of the control stick
  97803. */
  97804. x: number;
  97805. /**
  97806. * The y component of the control stick
  97807. */
  97808. y: number;
  97809. /**
  97810. * Initializes the gamepad x and y control stick values
  97811. * @param x The x component of the gamepad control stick value
  97812. * @param y The y component of the gamepad control stick value
  97813. */
  97814. constructor(
  97815. /**
  97816. * The x component of the control stick
  97817. */
  97818. x: number,
  97819. /**
  97820. * The y component of the control stick
  97821. */
  97822. y: number);
  97823. }
  97824. /**
  97825. * An interface which manages callbacks for gamepad button changes
  97826. */
  97827. export interface GamepadButtonChanges {
  97828. /**
  97829. * Called when a gamepad has been changed
  97830. */
  97831. changed: boolean;
  97832. /**
  97833. * Called when a gamepad press event has been triggered
  97834. */
  97835. pressChanged: boolean;
  97836. /**
  97837. * Called when a touch event has been triggered
  97838. */
  97839. touchChanged: boolean;
  97840. /**
  97841. * Called when a value has changed
  97842. */
  97843. valueChanged: boolean;
  97844. }
  97845. /**
  97846. * Represents a gamepad
  97847. */
  97848. export class Gamepad {
  97849. /**
  97850. * The id of the gamepad
  97851. */
  97852. id: string;
  97853. /**
  97854. * The index of the gamepad
  97855. */
  97856. index: number;
  97857. /**
  97858. * The browser gamepad
  97859. */
  97860. browserGamepad: any;
  97861. /**
  97862. * Specifies what type of gamepad this represents
  97863. */
  97864. type: number;
  97865. private _leftStick;
  97866. private _rightStick;
  97867. /** @hidden */
  97868. _isConnected: boolean;
  97869. private _leftStickAxisX;
  97870. private _leftStickAxisY;
  97871. private _rightStickAxisX;
  97872. private _rightStickAxisY;
  97873. /**
  97874. * Triggered when the left control stick has been changed
  97875. */
  97876. private _onleftstickchanged;
  97877. /**
  97878. * Triggered when the right control stick has been changed
  97879. */
  97880. private _onrightstickchanged;
  97881. /**
  97882. * Represents a gamepad controller
  97883. */
  97884. static GAMEPAD: number;
  97885. /**
  97886. * Represents a generic controller
  97887. */
  97888. static GENERIC: number;
  97889. /**
  97890. * Represents an XBox controller
  97891. */
  97892. static XBOX: number;
  97893. /**
  97894. * Represents a pose-enabled controller
  97895. */
  97896. static POSE_ENABLED: number;
  97897. /**
  97898. * Represents an Dual Shock controller
  97899. */
  97900. static DUALSHOCK: number;
  97901. /**
  97902. * Specifies whether the left control stick should be Y-inverted
  97903. */
  97904. protected _invertLeftStickY: boolean;
  97905. /**
  97906. * Specifies if the gamepad has been connected
  97907. */
  97908. get isConnected(): boolean;
  97909. /**
  97910. * Initializes the gamepad
  97911. * @param id The id of the gamepad
  97912. * @param index The index of the gamepad
  97913. * @param browserGamepad The browser gamepad
  97914. * @param leftStickX The x component of the left joystick
  97915. * @param leftStickY The y component of the left joystick
  97916. * @param rightStickX The x component of the right joystick
  97917. * @param rightStickY The y component of the right joystick
  97918. */
  97919. constructor(
  97920. /**
  97921. * The id of the gamepad
  97922. */
  97923. id: string,
  97924. /**
  97925. * The index of the gamepad
  97926. */
  97927. index: number,
  97928. /**
  97929. * The browser gamepad
  97930. */
  97931. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97932. /**
  97933. * Callback triggered when the left joystick has changed
  97934. * @param callback
  97935. */
  97936. onleftstickchanged(callback: (values: StickValues) => void): void;
  97937. /**
  97938. * Callback triggered when the right joystick has changed
  97939. * @param callback
  97940. */
  97941. onrightstickchanged(callback: (values: StickValues) => void): void;
  97942. /**
  97943. * Gets the left joystick
  97944. */
  97945. get leftStick(): StickValues;
  97946. /**
  97947. * Sets the left joystick values
  97948. */
  97949. set leftStick(newValues: StickValues);
  97950. /**
  97951. * Gets the right joystick
  97952. */
  97953. get rightStick(): StickValues;
  97954. /**
  97955. * Sets the right joystick value
  97956. */
  97957. set rightStick(newValues: StickValues);
  97958. /**
  97959. * Updates the gamepad joystick positions
  97960. */
  97961. update(): void;
  97962. /**
  97963. * Disposes the gamepad
  97964. */
  97965. dispose(): void;
  97966. }
  97967. /**
  97968. * Represents a generic gamepad
  97969. */
  97970. export class GenericPad extends Gamepad {
  97971. private _buttons;
  97972. private _onbuttondown;
  97973. private _onbuttonup;
  97974. /**
  97975. * Observable triggered when a button has been pressed
  97976. */
  97977. onButtonDownObservable: Observable<number>;
  97978. /**
  97979. * Observable triggered when a button has been released
  97980. */
  97981. onButtonUpObservable: Observable<number>;
  97982. /**
  97983. * Callback triggered when a button has been pressed
  97984. * @param callback Called when a button has been pressed
  97985. */
  97986. onbuttondown(callback: (buttonPressed: number) => void): void;
  97987. /**
  97988. * Callback triggered when a button has been released
  97989. * @param callback Called when a button has been released
  97990. */
  97991. onbuttonup(callback: (buttonReleased: number) => void): void;
  97992. /**
  97993. * Initializes the generic gamepad
  97994. * @param id The id of the generic gamepad
  97995. * @param index The index of the generic gamepad
  97996. * @param browserGamepad The browser gamepad
  97997. */
  97998. constructor(id: string, index: number, browserGamepad: any);
  97999. private _setButtonValue;
  98000. /**
  98001. * Updates the generic gamepad
  98002. */
  98003. update(): void;
  98004. /**
  98005. * Disposes the generic gamepad
  98006. */
  98007. dispose(): void;
  98008. }
  98009. }
  98010. declare module BABYLON {
  98011. /**
  98012. * Defines the types of pose enabled controllers that are supported
  98013. */
  98014. export enum PoseEnabledControllerType {
  98015. /**
  98016. * HTC Vive
  98017. */
  98018. VIVE = 0,
  98019. /**
  98020. * Oculus Rift
  98021. */
  98022. OCULUS = 1,
  98023. /**
  98024. * Windows mixed reality
  98025. */
  98026. WINDOWS = 2,
  98027. /**
  98028. * Samsung gear VR
  98029. */
  98030. GEAR_VR = 3,
  98031. /**
  98032. * Google Daydream
  98033. */
  98034. DAYDREAM = 4,
  98035. /**
  98036. * Generic
  98037. */
  98038. GENERIC = 5
  98039. }
  98040. /**
  98041. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98042. */
  98043. export interface MutableGamepadButton {
  98044. /**
  98045. * Value of the button/trigger
  98046. */
  98047. value: number;
  98048. /**
  98049. * If the button/trigger is currently touched
  98050. */
  98051. touched: boolean;
  98052. /**
  98053. * If the button/trigger is currently pressed
  98054. */
  98055. pressed: boolean;
  98056. }
  98057. /**
  98058. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98059. * @hidden
  98060. */
  98061. export interface ExtendedGamepadButton extends GamepadButton {
  98062. /**
  98063. * If the button/trigger is currently pressed
  98064. */
  98065. readonly pressed: boolean;
  98066. /**
  98067. * If the button/trigger is currently touched
  98068. */
  98069. readonly touched: boolean;
  98070. /**
  98071. * Value of the button/trigger
  98072. */
  98073. readonly value: number;
  98074. }
  98075. /** @hidden */
  98076. export interface _GamePadFactory {
  98077. /**
  98078. * Returns whether or not the current gamepad can be created for this type of controller.
  98079. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98080. * @returns true if it can be created, otherwise false
  98081. */
  98082. canCreate(gamepadInfo: any): boolean;
  98083. /**
  98084. * Creates a new instance of the Gamepad.
  98085. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98086. * @returns the new gamepad instance
  98087. */
  98088. create(gamepadInfo: any): Gamepad;
  98089. }
  98090. /**
  98091. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98092. */
  98093. export class PoseEnabledControllerHelper {
  98094. /** @hidden */
  98095. static _ControllerFactories: _GamePadFactory[];
  98096. /** @hidden */
  98097. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  98098. /**
  98099. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98100. * @param vrGamepad the gamepad to initialized
  98101. * @returns a vr controller of the type the gamepad identified as
  98102. */
  98103. static InitiateController(vrGamepad: any): Gamepad;
  98104. }
  98105. /**
  98106. * Defines the PoseEnabledController object that contains state of a vr capable controller
  98107. */
  98108. export class PoseEnabledController extends Gamepad implements PoseControlled {
  98109. /**
  98110. * If the controller is used in a webXR session
  98111. */
  98112. isXR: boolean;
  98113. private _deviceRoomPosition;
  98114. private _deviceRoomRotationQuaternion;
  98115. /**
  98116. * The device position in babylon space
  98117. */
  98118. devicePosition: Vector3;
  98119. /**
  98120. * The device rotation in babylon space
  98121. */
  98122. deviceRotationQuaternion: Quaternion;
  98123. /**
  98124. * The scale factor of the device in babylon space
  98125. */
  98126. deviceScaleFactor: number;
  98127. /**
  98128. * (Likely devicePosition should be used instead) The device position in its room space
  98129. */
  98130. position: Vector3;
  98131. /**
  98132. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  98133. */
  98134. rotationQuaternion: Quaternion;
  98135. /**
  98136. * The type of controller (Eg. Windows mixed reality)
  98137. */
  98138. controllerType: PoseEnabledControllerType;
  98139. protected _calculatedPosition: Vector3;
  98140. private _calculatedRotation;
  98141. /**
  98142. * The raw pose from the device
  98143. */
  98144. rawPose: DevicePose;
  98145. private _trackPosition;
  98146. private _maxRotationDistFromHeadset;
  98147. private _draggedRoomRotation;
  98148. /**
  98149. * @hidden
  98150. */
  98151. _disableTrackPosition(fixedPosition: Vector3): void;
  98152. /**
  98153. * Internal, the mesh attached to the controller
  98154. * @hidden
  98155. */
  98156. _mesh: Nullable<AbstractMesh>;
  98157. private _poseControlledCamera;
  98158. private _leftHandSystemQuaternion;
  98159. /**
  98160. * Internal, matrix used to convert room space to babylon space
  98161. * @hidden
  98162. */
  98163. _deviceToWorld: Matrix;
  98164. /**
  98165. * Node to be used when casting a ray from the controller
  98166. * @hidden
  98167. */
  98168. _pointingPoseNode: Nullable<TransformNode>;
  98169. /**
  98170. * Name of the child mesh that can be used to cast a ray from the controller
  98171. */
  98172. static readonly POINTING_POSE: string;
  98173. /**
  98174. * Creates a new PoseEnabledController from a gamepad
  98175. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98176. */
  98177. constructor(browserGamepad: any);
  98178. private _workingMatrix;
  98179. /**
  98180. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98181. */
  98182. update(): void;
  98183. /**
  98184. * Updates only the pose device and mesh without doing any button event checking
  98185. */
  98186. protected _updatePoseAndMesh(): void;
  98187. /**
  98188. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98189. * @param poseData raw pose fromthe device
  98190. */
  98191. updateFromDevice(poseData: DevicePose): void;
  98192. /**
  98193. * @hidden
  98194. */
  98195. _meshAttachedObservable: Observable<AbstractMesh>;
  98196. /**
  98197. * Attaches a mesh to the controller
  98198. * @param mesh the mesh to be attached
  98199. */
  98200. attachToMesh(mesh: AbstractMesh): void;
  98201. /**
  98202. * Attaches the controllers mesh to a camera
  98203. * @param camera the camera the mesh should be attached to
  98204. */
  98205. attachToPoseControlledCamera(camera: TargetCamera): void;
  98206. /**
  98207. * Disposes of the controller
  98208. */
  98209. dispose(): void;
  98210. /**
  98211. * The mesh that is attached to the controller
  98212. */
  98213. get mesh(): Nullable<AbstractMesh>;
  98214. /**
  98215. * Gets the ray of the controller in the direction the controller is pointing
  98216. * @param length the length the resulting ray should be
  98217. * @returns a ray in the direction the controller is pointing
  98218. */
  98219. getForwardRay(length?: number): Ray;
  98220. }
  98221. }
  98222. declare module BABYLON {
  98223. /**
  98224. * Defines the WebVRController object that represents controllers tracked in 3D space
  98225. */
  98226. export abstract class WebVRController extends PoseEnabledController {
  98227. /**
  98228. * Internal, the default controller model for the controller
  98229. */
  98230. protected _defaultModel: Nullable<AbstractMesh>;
  98231. /**
  98232. * Fired when the trigger state has changed
  98233. */
  98234. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98235. /**
  98236. * Fired when the main button state has changed
  98237. */
  98238. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98239. /**
  98240. * Fired when the secondary button state has changed
  98241. */
  98242. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98243. /**
  98244. * Fired when the pad state has changed
  98245. */
  98246. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98247. /**
  98248. * Fired when controllers stick values have changed
  98249. */
  98250. onPadValuesChangedObservable: Observable<StickValues>;
  98251. /**
  98252. * Array of button availible on the controller
  98253. */
  98254. protected _buttons: Array<MutableGamepadButton>;
  98255. private _onButtonStateChange;
  98256. /**
  98257. * Fired when a controller button's state has changed
  98258. * @param callback the callback containing the button that was modified
  98259. */
  98260. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98261. /**
  98262. * X and Y axis corresponding to the controllers joystick
  98263. */
  98264. pad: StickValues;
  98265. /**
  98266. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98267. */
  98268. hand: string;
  98269. /**
  98270. * The default controller model for the controller
  98271. */
  98272. get defaultModel(): Nullable<AbstractMesh>;
  98273. /**
  98274. * Creates a new WebVRController from a gamepad
  98275. * @param vrGamepad the gamepad that the WebVRController should be created from
  98276. */
  98277. constructor(vrGamepad: any);
  98278. /**
  98279. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98280. */
  98281. update(): void;
  98282. /**
  98283. * Function to be called when a button is modified
  98284. */
  98285. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98286. /**
  98287. * Loads a mesh and attaches it to the controller
  98288. * @param scene the scene the mesh should be added to
  98289. * @param meshLoaded callback for when the mesh has been loaded
  98290. */
  98291. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98292. private _setButtonValue;
  98293. private _changes;
  98294. private _checkChanges;
  98295. /**
  98296. * Disposes of th webVRCOntroller
  98297. */
  98298. dispose(): void;
  98299. }
  98300. }
  98301. declare module BABYLON {
  98302. /**
  98303. * The HemisphericLight simulates the ambient environment light,
  98304. * so the passed direction is the light reflection direction, not the incoming direction.
  98305. */
  98306. export class HemisphericLight extends Light {
  98307. /**
  98308. * The groundColor is the light in the opposite direction to the one specified during creation.
  98309. * 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.
  98310. */
  98311. groundColor: Color3;
  98312. /**
  98313. * The light reflection direction, not the incoming direction.
  98314. */
  98315. direction: Vector3;
  98316. /**
  98317. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98318. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98319. * The HemisphericLight can't cast shadows.
  98320. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98321. * @param name The friendly name of the light
  98322. * @param direction The direction of the light reflection
  98323. * @param scene The scene the light belongs to
  98324. */
  98325. constructor(name: string, direction: Vector3, scene: Scene);
  98326. protected _buildUniformLayout(): void;
  98327. /**
  98328. * Returns the string "HemisphericLight".
  98329. * @return The class name
  98330. */
  98331. getClassName(): string;
  98332. /**
  98333. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98334. * Returns the updated direction.
  98335. * @param target The target the direction should point to
  98336. * @return The computed direction
  98337. */
  98338. setDirectionToTarget(target: Vector3): Vector3;
  98339. /**
  98340. * Returns the shadow generator associated to the light.
  98341. * @returns Always null for hemispheric lights because it does not support shadows.
  98342. */
  98343. getShadowGenerator(): Nullable<IShadowGenerator>;
  98344. /**
  98345. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98346. * @param effect The effect to update
  98347. * @param lightIndex The index of the light in the effect to update
  98348. * @returns The hemispheric light
  98349. */
  98350. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98351. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98352. /**
  98353. * Computes the world matrix of the node
  98354. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98355. * @param useWasUpdatedFlag defines a reserved property
  98356. * @returns the world matrix
  98357. */
  98358. computeWorldMatrix(): Matrix;
  98359. /**
  98360. * Returns the integer 3.
  98361. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98362. */
  98363. getTypeID(): number;
  98364. /**
  98365. * Prepares the list of defines specific to the light type.
  98366. * @param defines the list of defines
  98367. * @param lightIndex defines the index of the light for the effect
  98368. */
  98369. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98370. }
  98371. }
  98372. declare module BABYLON {
  98373. /** @hidden */
  98374. export var vrMultiviewToSingleviewPixelShader: {
  98375. name: string;
  98376. shader: string;
  98377. };
  98378. }
  98379. declare module BABYLON {
  98380. /**
  98381. * Renders to multiple views with a single draw call
  98382. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98383. */
  98384. export class MultiviewRenderTarget extends RenderTargetTexture {
  98385. /**
  98386. * Creates a multiview render target
  98387. * @param scene scene used with the render target
  98388. * @param size the size of the render target (used for each view)
  98389. */
  98390. constructor(scene: Scene, size?: number | {
  98391. width: number;
  98392. height: number;
  98393. } | {
  98394. ratio: number;
  98395. });
  98396. /**
  98397. * @hidden
  98398. * @param faceIndex the face index, if its a cube texture
  98399. */
  98400. _bindFrameBuffer(faceIndex?: number): void;
  98401. /**
  98402. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98403. * @returns the view count
  98404. */
  98405. getViewCount(): number;
  98406. }
  98407. }
  98408. declare module BABYLON {
  98409. interface Engine {
  98410. /**
  98411. * Creates a new multiview render target
  98412. * @param width defines the width of the texture
  98413. * @param height defines the height of the texture
  98414. * @returns the created multiview texture
  98415. */
  98416. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98417. /**
  98418. * Binds a multiview framebuffer to be drawn to
  98419. * @param multiviewTexture texture to bind
  98420. */
  98421. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98422. }
  98423. interface Camera {
  98424. /**
  98425. * @hidden
  98426. * 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)
  98427. */
  98428. _useMultiviewToSingleView: boolean;
  98429. /**
  98430. * @hidden
  98431. * 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)
  98432. */
  98433. _multiviewTexture: Nullable<RenderTargetTexture>;
  98434. /**
  98435. * @hidden
  98436. * ensures the multiview texture of the camera exists and has the specified width/height
  98437. * @param width height to set on the multiview texture
  98438. * @param height width to set on the multiview texture
  98439. */
  98440. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  98441. }
  98442. interface Scene {
  98443. /** @hidden */
  98444. _transformMatrixR: Matrix;
  98445. /** @hidden */
  98446. _multiviewSceneUbo: Nullable<UniformBuffer>;
  98447. /** @hidden */
  98448. _createMultiviewUbo(): void;
  98449. /** @hidden */
  98450. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  98451. /** @hidden */
  98452. _renderMultiviewToSingleView(camera: Camera): void;
  98453. }
  98454. }
  98455. declare module BABYLON {
  98456. /**
  98457. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  98458. * This will not be used for webXR as it supports displaying texture arrays directly
  98459. */
  98460. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  98461. /**
  98462. * Initializes a VRMultiviewToSingleview
  98463. * @param name name of the post process
  98464. * @param camera camera to be applied to
  98465. * @param scaleFactor scaling factor to the size of the output texture
  98466. */
  98467. constructor(name: string, camera: Camera, scaleFactor: number);
  98468. }
  98469. }
  98470. declare module BABYLON {
  98471. /**
  98472. * Interface used to define additional presentation attributes
  98473. */
  98474. export interface IVRPresentationAttributes {
  98475. /**
  98476. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98477. */
  98478. highRefreshRate: boolean;
  98479. /**
  98480. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98481. */
  98482. foveationLevel: number;
  98483. }
  98484. interface Engine {
  98485. /** @hidden */
  98486. _vrDisplay: any;
  98487. /** @hidden */
  98488. _vrSupported: boolean;
  98489. /** @hidden */
  98490. _oldSize: Size;
  98491. /** @hidden */
  98492. _oldHardwareScaleFactor: number;
  98493. /** @hidden */
  98494. _vrExclusivePointerMode: boolean;
  98495. /** @hidden */
  98496. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98497. /** @hidden */
  98498. _onVRDisplayPointerRestricted: () => void;
  98499. /** @hidden */
  98500. _onVRDisplayPointerUnrestricted: () => void;
  98501. /** @hidden */
  98502. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98503. /** @hidden */
  98504. _onVrDisplayDisconnect: Nullable<() => void>;
  98505. /** @hidden */
  98506. _onVrDisplayPresentChange: Nullable<() => void>;
  98507. /**
  98508. * Observable signaled when VR display mode changes
  98509. */
  98510. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98511. /**
  98512. * Observable signaled when VR request present is complete
  98513. */
  98514. onVRRequestPresentComplete: Observable<boolean>;
  98515. /**
  98516. * Observable signaled when VR request present starts
  98517. */
  98518. onVRRequestPresentStart: Observable<Engine>;
  98519. /**
  98520. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98521. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98522. */
  98523. isInVRExclusivePointerMode: boolean;
  98524. /**
  98525. * Gets a boolean indicating if a webVR device was detected
  98526. * @returns true if a webVR device was detected
  98527. */
  98528. isVRDevicePresent(): boolean;
  98529. /**
  98530. * Gets the current webVR device
  98531. * @returns the current webVR device (or null)
  98532. */
  98533. getVRDevice(): any;
  98534. /**
  98535. * Initializes a webVR display and starts listening to display change events
  98536. * The onVRDisplayChangedObservable will be notified upon these changes
  98537. * @returns A promise containing a VRDisplay and if vr is supported
  98538. */
  98539. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98540. /** @hidden */
  98541. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98542. /**
  98543. * Gets or sets the presentation attributes used to configure VR rendering
  98544. */
  98545. vrPresentationAttributes?: IVRPresentationAttributes;
  98546. /**
  98547. * Call this function to switch to webVR mode
  98548. * Will do nothing if webVR is not supported or if there is no webVR device
  98549. * @param options the webvr options provided to the camera. mainly used for multiview
  98550. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98551. */
  98552. enableVR(options: WebVROptions): void;
  98553. /** @hidden */
  98554. _onVRFullScreenTriggered(): void;
  98555. }
  98556. }
  98557. declare module BABYLON {
  98558. /**
  98559. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98560. * IMPORTANT!! The data is right-hand data.
  98561. * @export
  98562. * @interface DevicePose
  98563. */
  98564. export interface DevicePose {
  98565. /**
  98566. * The position of the device, values in array are [x,y,z].
  98567. */
  98568. readonly position: Nullable<Float32Array>;
  98569. /**
  98570. * The linearVelocity of the device, values in array are [x,y,z].
  98571. */
  98572. readonly linearVelocity: Nullable<Float32Array>;
  98573. /**
  98574. * The linearAcceleration of the device, values in array are [x,y,z].
  98575. */
  98576. readonly linearAcceleration: Nullable<Float32Array>;
  98577. /**
  98578. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98579. */
  98580. readonly orientation: Nullable<Float32Array>;
  98581. /**
  98582. * The angularVelocity of the device, values in array are [x,y,z].
  98583. */
  98584. readonly angularVelocity: Nullable<Float32Array>;
  98585. /**
  98586. * The angularAcceleration of the device, values in array are [x,y,z].
  98587. */
  98588. readonly angularAcceleration: Nullable<Float32Array>;
  98589. }
  98590. /**
  98591. * Interface representing a pose controlled object in Babylon.
  98592. * A pose controlled object has both regular pose values as well as pose values
  98593. * from an external device such as a VR head mounted display
  98594. */
  98595. export interface PoseControlled {
  98596. /**
  98597. * The position of the object in babylon space.
  98598. */
  98599. position: Vector3;
  98600. /**
  98601. * The rotation quaternion of the object in babylon space.
  98602. */
  98603. rotationQuaternion: Quaternion;
  98604. /**
  98605. * The position of the device in babylon space.
  98606. */
  98607. devicePosition?: Vector3;
  98608. /**
  98609. * The rotation quaternion of the device in babylon space.
  98610. */
  98611. deviceRotationQuaternion: Quaternion;
  98612. /**
  98613. * The raw pose coming from the device.
  98614. */
  98615. rawPose: Nullable<DevicePose>;
  98616. /**
  98617. * The scale of the device to be used when translating from device space to babylon space.
  98618. */
  98619. deviceScaleFactor: number;
  98620. /**
  98621. * Updates the poseControlled values based on the input device pose.
  98622. * @param poseData the pose data to update the object with
  98623. */
  98624. updateFromDevice(poseData: DevicePose): void;
  98625. }
  98626. /**
  98627. * Set of options to customize the webVRCamera
  98628. */
  98629. export interface WebVROptions {
  98630. /**
  98631. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98632. */
  98633. trackPosition?: boolean;
  98634. /**
  98635. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98636. */
  98637. positionScale?: number;
  98638. /**
  98639. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98640. */
  98641. displayName?: string;
  98642. /**
  98643. * Should the native controller meshes be initialized. (default: true)
  98644. */
  98645. controllerMeshes?: boolean;
  98646. /**
  98647. * Creating a default HemiLight only on controllers. (default: true)
  98648. */
  98649. defaultLightingOnControllers?: boolean;
  98650. /**
  98651. * If you don't want to use the default VR button of the helper. (default: false)
  98652. */
  98653. useCustomVRButton?: boolean;
  98654. /**
  98655. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98656. */
  98657. customVRButton?: HTMLButtonElement;
  98658. /**
  98659. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98660. */
  98661. rayLength?: number;
  98662. /**
  98663. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98664. */
  98665. defaultHeight?: number;
  98666. /**
  98667. * If multiview should be used if availible (default: false)
  98668. */
  98669. useMultiview?: boolean;
  98670. }
  98671. /**
  98672. * This represents a WebVR camera.
  98673. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98674. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98675. */
  98676. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98677. private webVROptions;
  98678. /**
  98679. * @hidden
  98680. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98681. */
  98682. _vrDevice: any;
  98683. /**
  98684. * The rawPose of the vrDevice.
  98685. */
  98686. rawPose: Nullable<DevicePose>;
  98687. private _onVREnabled;
  98688. private _specsVersion;
  98689. private _attached;
  98690. private _frameData;
  98691. protected _descendants: Array<Node>;
  98692. private _deviceRoomPosition;
  98693. /** @hidden */
  98694. _deviceRoomRotationQuaternion: Quaternion;
  98695. private _standingMatrix;
  98696. /**
  98697. * Represents device position in babylon space.
  98698. */
  98699. devicePosition: Vector3;
  98700. /**
  98701. * Represents device rotation in babylon space.
  98702. */
  98703. deviceRotationQuaternion: Quaternion;
  98704. /**
  98705. * The scale of the device to be used when translating from device space to babylon space.
  98706. */
  98707. deviceScaleFactor: number;
  98708. private _deviceToWorld;
  98709. private _worldToDevice;
  98710. /**
  98711. * References to the webVR controllers for the vrDevice.
  98712. */
  98713. controllers: Array<WebVRController>;
  98714. /**
  98715. * Emits an event when a controller is attached.
  98716. */
  98717. onControllersAttachedObservable: Observable<WebVRController[]>;
  98718. /**
  98719. * Emits an event when a controller's mesh has been loaded;
  98720. */
  98721. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98722. /**
  98723. * Emits an event when the HMD's pose has been updated.
  98724. */
  98725. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98726. private _poseSet;
  98727. /**
  98728. * If the rig cameras be used as parent instead of this camera.
  98729. */
  98730. rigParenting: boolean;
  98731. private _lightOnControllers;
  98732. private _defaultHeight?;
  98733. /**
  98734. * Instantiates a WebVRFreeCamera.
  98735. * @param name The name of the WebVRFreeCamera
  98736. * @param position The starting anchor position for the camera
  98737. * @param scene The scene the camera belongs to
  98738. * @param webVROptions a set of customizable options for the webVRCamera
  98739. */
  98740. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98741. /**
  98742. * Gets the device distance from the ground in meters.
  98743. * @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.
  98744. */
  98745. deviceDistanceToRoomGround(): number;
  98746. /**
  98747. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98748. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98749. */
  98750. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98751. /**
  98752. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98753. * @returns A promise with a boolean set to if the standing matrix is supported.
  98754. */
  98755. useStandingMatrixAsync(): Promise<boolean>;
  98756. /**
  98757. * Disposes the camera
  98758. */
  98759. dispose(): void;
  98760. /**
  98761. * Gets a vrController by name.
  98762. * @param name The name of the controller to retreive
  98763. * @returns the controller matching the name specified or null if not found
  98764. */
  98765. getControllerByName(name: string): Nullable<WebVRController>;
  98766. private _leftController;
  98767. /**
  98768. * The controller corresponding to the users left hand.
  98769. */
  98770. get leftController(): Nullable<WebVRController>;
  98771. private _rightController;
  98772. /**
  98773. * The controller corresponding to the users right hand.
  98774. */
  98775. get rightController(): Nullable<WebVRController>;
  98776. /**
  98777. * Casts a ray forward from the vrCamera's gaze.
  98778. * @param length Length of the ray (default: 100)
  98779. * @returns the ray corresponding to the gaze
  98780. */
  98781. getForwardRay(length?: number): Ray;
  98782. /**
  98783. * @hidden
  98784. * Updates the camera based on device's frame data
  98785. */
  98786. _checkInputs(): void;
  98787. /**
  98788. * Updates the poseControlled values based on the input device pose.
  98789. * @param poseData Pose coming from the device
  98790. */
  98791. updateFromDevice(poseData: DevicePose): void;
  98792. private _htmlElementAttached;
  98793. private _detachIfAttached;
  98794. /**
  98795. * WebVR's attach control will start broadcasting frames to the device.
  98796. * Note that in certain browsers (chrome for example) this function must be called
  98797. * within a user-interaction callback. Example:
  98798. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98799. *
  98800. * @param element html element to attach the vrDevice to
  98801. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98802. */
  98803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98804. /**
  98805. * Detaches the camera from the html element and disables VR
  98806. *
  98807. * @param element html element to detach from
  98808. */
  98809. detachControl(element: HTMLElement): void;
  98810. /**
  98811. * @returns the name of this class
  98812. */
  98813. getClassName(): string;
  98814. /**
  98815. * Calls resetPose on the vrDisplay
  98816. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98817. */
  98818. resetToCurrentRotation(): void;
  98819. /**
  98820. * @hidden
  98821. * Updates the rig cameras (left and right eye)
  98822. */
  98823. _updateRigCameras(): void;
  98824. private _workingVector;
  98825. private _oneVector;
  98826. private _workingMatrix;
  98827. private updateCacheCalled;
  98828. private _correctPositionIfNotTrackPosition;
  98829. /**
  98830. * @hidden
  98831. * Updates the cached values of the camera
  98832. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98833. */
  98834. _updateCache(ignoreParentClass?: boolean): void;
  98835. /**
  98836. * @hidden
  98837. * Get current device position in babylon world
  98838. */
  98839. _computeDevicePosition(): void;
  98840. /**
  98841. * Updates the current device position and rotation in the babylon world
  98842. */
  98843. update(): void;
  98844. /**
  98845. * @hidden
  98846. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98847. * @returns an identity matrix
  98848. */
  98849. _getViewMatrix(): Matrix;
  98850. private _tmpMatrix;
  98851. /**
  98852. * This function is called by the two RIG cameras.
  98853. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98854. * @hidden
  98855. */
  98856. _getWebVRViewMatrix(): Matrix;
  98857. /** @hidden */
  98858. _getWebVRProjectionMatrix(): Matrix;
  98859. private _onGamepadConnectedObserver;
  98860. private _onGamepadDisconnectedObserver;
  98861. private _updateCacheWhenTrackingDisabledObserver;
  98862. /**
  98863. * Initializes the controllers and their meshes
  98864. */
  98865. initControllers(): void;
  98866. }
  98867. }
  98868. declare module BABYLON {
  98869. /**
  98870. * "Static Class" containing the most commonly used helper while dealing with material for
  98871. * rendering purpose.
  98872. *
  98873. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98874. *
  98875. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98876. */
  98877. export class MaterialHelper {
  98878. /**
  98879. * Bind the current view position to an effect.
  98880. * @param effect The effect to be bound
  98881. * @param scene The scene the eyes position is used from
  98882. * @param variableName name of the shader variable that will hold the eye position
  98883. */
  98884. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98885. /**
  98886. * Helps preparing the defines values about the UVs in used in the effect.
  98887. * UVs are shared as much as we can accross channels in the shaders.
  98888. * @param texture The texture we are preparing the UVs for
  98889. * @param defines The defines to update
  98890. * @param key The channel key "diffuse", "specular"... used in the shader
  98891. */
  98892. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98893. /**
  98894. * Binds a texture matrix value to its corrsponding uniform
  98895. * @param texture The texture to bind the matrix for
  98896. * @param uniformBuffer The uniform buffer receivin the data
  98897. * @param key The channel key "diffuse", "specular"... used in the shader
  98898. */
  98899. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98900. /**
  98901. * Gets the current status of the fog (should it be enabled?)
  98902. * @param mesh defines the mesh to evaluate for fog support
  98903. * @param scene defines the hosting scene
  98904. * @returns true if fog must be enabled
  98905. */
  98906. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98907. /**
  98908. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98909. * @param mesh defines the current mesh
  98910. * @param scene defines the current scene
  98911. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98912. * @param pointsCloud defines if point cloud rendering has to be turned on
  98913. * @param fogEnabled defines if fog has to be turned on
  98914. * @param alphaTest defines if alpha testing has to be turned on
  98915. * @param defines defines the current list of defines
  98916. */
  98917. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98918. /**
  98919. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98920. * @param scene defines the current scene
  98921. * @param engine defines the current engine
  98922. * @param defines specifies the list of active defines
  98923. * @param useInstances defines if instances have to be turned on
  98924. * @param useClipPlane defines if clip plane have to be turned on
  98925. * @param useInstances defines if instances have to be turned on
  98926. * @param useThinInstances defines if thin instances have to be turned on
  98927. */
  98928. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98929. /**
  98930. * Prepares the defines for bones
  98931. * @param mesh The mesh containing the geometry data we will draw
  98932. * @param defines The defines to update
  98933. */
  98934. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98935. /**
  98936. * Prepares the defines for morph targets
  98937. * @param mesh The mesh containing the geometry data we will draw
  98938. * @param defines The defines to update
  98939. */
  98940. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98941. /**
  98942. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98943. * @param mesh The mesh containing the geometry data we will draw
  98944. * @param defines The defines to update
  98945. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98946. * @param useBones Precise whether bones should be used or not (override mesh info)
  98947. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98948. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98949. * @returns false if defines are considered not dirty and have not been checked
  98950. */
  98951. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98952. /**
  98953. * Prepares the defines related to multiview
  98954. * @param scene The scene we are intending to draw
  98955. * @param defines The defines to update
  98956. */
  98957. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98958. /**
  98959. * Prepares the defines related to the prepass
  98960. * @param scene The scene we are intending to draw
  98961. * @param defines The defines to update
  98962. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  98963. */
  98964. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  98965. /**
  98966. * Prepares the defines related to the light information passed in parameter
  98967. * @param scene The scene we are intending to draw
  98968. * @param mesh The mesh the effect is compiling for
  98969. * @param light The light the effect is compiling for
  98970. * @param lightIndex The index of the light
  98971. * @param defines The defines to update
  98972. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98973. * @param state Defines the current state regarding what is needed (normals, etc...)
  98974. */
  98975. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98976. needNormals: boolean;
  98977. needRebuild: boolean;
  98978. shadowEnabled: boolean;
  98979. specularEnabled: boolean;
  98980. lightmapMode: boolean;
  98981. }): void;
  98982. /**
  98983. * Prepares the defines related to the light information passed in parameter
  98984. * @param scene The scene we are intending to draw
  98985. * @param mesh The mesh the effect is compiling for
  98986. * @param defines The defines to update
  98987. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98988. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98989. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98990. * @returns true if normals will be required for the rest of the effect
  98991. */
  98992. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98993. /**
  98994. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98995. * @param lightIndex defines the light index
  98996. * @param uniformsList The uniform list
  98997. * @param samplersList The sampler list
  98998. * @param projectedLightTexture defines if projected texture must be used
  98999. * @param uniformBuffersList defines an optional list of uniform buffers
  99000. */
  99001. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99002. /**
  99003. * Prepares the uniforms and samplers list to be used in the effect
  99004. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99005. * @param samplersList The sampler list
  99006. * @param defines The defines helping in the list generation
  99007. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99008. */
  99009. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99010. /**
  99011. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99012. * @param defines The defines to update while falling back
  99013. * @param fallbacks The authorized effect fallbacks
  99014. * @param maxSimultaneousLights The maximum number of lights allowed
  99015. * @param rank the current rank of the Effect
  99016. * @returns The newly affected rank
  99017. */
  99018. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99019. private static _TmpMorphInfluencers;
  99020. /**
  99021. * Prepares the list of attributes required for morph targets according to the effect defines.
  99022. * @param attribs The current list of supported attribs
  99023. * @param mesh The mesh to prepare the morph targets attributes for
  99024. * @param influencers The number of influencers
  99025. */
  99026. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99027. /**
  99028. * Prepares the list of attributes required for morph targets according to the effect defines.
  99029. * @param attribs The current list of supported attribs
  99030. * @param mesh The mesh to prepare the morph targets attributes for
  99031. * @param defines The current Defines of the effect
  99032. */
  99033. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99034. /**
  99035. * Prepares the list of attributes required for bones according to the effect defines.
  99036. * @param attribs The current list of supported attribs
  99037. * @param mesh The mesh to prepare the bones attributes for
  99038. * @param defines The current Defines of the effect
  99039. * @param fallbacks The current efffect fallback strategy
  99040. */
  99041. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99042. /**
  99043. * Check and prepare the list of attributes required for instances according to the effect defines.
  99044. * @param attribs The current list of supported attribs
  99045. * @param defines The current MaterialDefines of the effect
  99046. */
  99047. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99048. /**
  99049. * Add the list of attributes required for instances to the attribs array.
  99050. * @param attribs The current list of supported attribs
  99051. */
  99052. static PushAttributesForInstances(attribs: string[]): void;
  99053. /**
  99054. * Binds the light information to the effect.
  99055. * @param light The light containing the generator
  99056. * @param effect The effect we are binding the data to
  99057. * @param lightIndex The light index in the effect used to render
  99058. */
  99059. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99060. /**
  99061. * Binds the lights information from the scene to the effect for the given mesh.
  99062. * @param light Light to bind
  99063. * @param lightIndex Light index
  99064. * @param scene The scene where the light belongs to
  99065. * @param effect The effect we are binding the data to
  99066. * @param useSpecular Defines if specular is supported
  99067. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99068. */
  99069. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99070. /**
  99071. * Binds the lights information from the scene to the effect for the given mesh.
  99072. * @param scene The scene the lights belongs to
  99073. * @param mesh The mesh we are binding the information to render
  99074. * @param effect The effect we are binding the data to
  99075. * @param defines The generated defines for the effect
  99076. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  99077. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99078. */
  99079. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  99080. private static _tempFogColor;
  99081. /**
  99082. * Binds the fog information from the scene to the effect for the given mesh.
  99083. * @param scene The scene the lights belongs to
  99084. * @param mesh The mesh we are binding the information to render
  99085. * @param effect The effect we are binding the data to
  99086. * @param linearSpace Defines if the fog effect is applied in linear space
  99087. */
  99088. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  99089. /**
  99090. * Binds the bones information from the mesh to the effect.
  99091. * @param mesh The mesh we are binding the information to render
  99092. * @param effect The effect we are binding the data to
  99093. */
  99094. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  99095. /**
  99096. * Binds the morph targets information from the mesh to the effect.
  99097. * @param abstractMesh The mesh we are binding the information to render
  99098. * @param effect The effect we are binding the data to
  99099. */
  99100. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  99101. /**
  99102. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  99103. * @param defines The generated defines used in the effect
  99104. * @param effect The effect we are binding the data to
  99105. * @param scene The scene we are willing to render with logarithmic scale for
  99106. */
  99107. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  99108. /**
  99109. * Binds the clip plane information from the scene to the effect.
  99110. * @param scene The scene the clip plane information are extracted from
  99111. * @param effect The effect we are binding the data to
  99112. */
  99113. static BindClipPlane(effect: Effect, scene: Scene): void;
  99114. }
  99115. }
  99116. declare module BABYLON {
  99117. /**
  99118. * Block used to expose an input value
  99119. */
  99120. export class InputBlock extends NodeMaterialBlock {
  99121. private _mode;
  99122. private _associatedVariableName;
  99123. private _storedValue;
  99124. private _valueCallback;
  99125. private _type;
  99126. private _animationType;
  99127. /** Gets or set a value used to limit the range of float values */
  99128. min: number;
  99129. /** Gets or set a value used to limit the range of float values */
  99130. max: number;
  99131. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  99132. isBoolean: boolean;
  99133. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  99134. matrixMode: number;
  99135. /** @hidden */
  99136. _systemValue: Nullable<NodeMaterialSystemValues>;
  99137. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99138. visibleInInspector: boolean;
  99139. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  99140. isConstant: boolean;
  99141. /** Gets or sets the group to use to display this block in the Inspector */
  99142. groupInInspector: string;
  99143. /** Gets an observable raised when the value is changed */
  99144. onValueChangedObservable: Observable<InputBlock>;
  99145. /**
  99146. * Gets or sets the connection point type (default is float)
  99147. */
  99148. get type(): NodeMaterialBlockConnectionPointTypes;
  99149. /**
  99150. * Creates a new InputBlock
  99151. * @param name defines the block name
  99152. * @param target defines the target of that block (Vertex by default)
  99153. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  99154. */
  99155. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  99156. /**
  99157. * Validates if a name is a reserve word.
  99158. * @param newName the new name to be given to the node.
  99159. * @returns false if the name is a reserve word, else true.
  99160. */
  99161. validateBlockName(newName: string): boolean;
  99162. /**
  99163. * Gets the output component
  99164. */
  99165. get output(): NodeMaterialConnectionPoint;
  99166. /**
  99167. * Set the source of this connection point to a vertex attribute
  99168. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  99169. * @returns the current connection point
  99170. */
  99171. setAsAttribute(attributeName?: string): InputBlock;
  99172. /**
  99173. * Set the source of this connection point to a system value
  99174. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  99175. * @returns the current connection point
  99176. */
  99177. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99178. /**
  99179. * Gets or sets the value of that point.
  99180. * Please note that this value will be ignored if valueCallback is defined
  99181. */
  99182. get value(): any;
  99183. set value(value: any);
  99184. /**
  99185. * Gets or sets a callback used to get the value of that point.
  99186. * Please note that setting this value will force the connection point to ignore the value property
  99187. */
  99188. get valueCallback(): () => any;
  99189. set valueCallback(value: () => any);
  99190. /**
  99191. * Gets or sets the associated variable name in the shader
  99192. */
  99193. get associatedVariableName(): string;
  99194. set associatedVariableName(value: string);
  99195. /** Gets or sets the type of animation applied to the input */
  99196. get animationType(): AnimatedInputBlockTypes;
  99197. set animationType(value: AnimatedInputBlockTypes);
  99198. /**
  99199. * Gets a boolean indicating that this connection point not defined yet
  99200. */
  99201. get isUndefined(): boolean;
  99202. /**
  99203. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99204. * In this case the connection point name must be the name of the uniform to use.
  99205. * Can only be set on inputs
  99206. */
  99207. get isUniform(): boolean;
  99208. set isUniform(value: boolean);
  99209. /**
  99210. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99211. * In this case the connection point name must be the name of the attribute to use
  99212. * Can only be set on inputs
  99213. */
  99214. get isAttribute(): boolean;
  99215. set isAttribute(value: boolean);
  99216. /**
  99217. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99218. * Can only be set on exit points
  99219. */
  99220. get isVarying(): boolean;
  99221. set isVarying(value: boolean);
  99222. /**
  99223. * Gets a boolean indicating that the current connection point is a system value
  99224. */
  99225. get isSystemValue(): boolean;
  99226. /**
  99227. * Gets or sets the current well known value or null if not defined as a system value
  99228. */
  99229. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99230. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99231. /**
  99232. * Gets the current class name
  99233. * @returns the class name
  99234. */
  99235. getClassName(): string;
  99236. /**
  99237. * Animate the input if animationType !== None
  99238. * @param scene defines the rendering scene
  99239. */
  99240. animate(scene: Scene): void;
  99241. private _emitDefine;
  99242. initialize(state: NodeMaterialBuildState): void;
  99243. /**
  99244. * Set the input block to its default value (based on its type)
  99245. */
  99246. setDefaultValue(): void;
  99247. private _emitConstant;
  99248. /** @hidden */
  99249. get _noContextSwitch(): boolean;
  99250. private _emit;
  99251. /** @hidden */
  99252. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99253. /** @hidden */
  99254. _transmit(effect: Effect, scene: Scene): void;
  99255. protected _buildBlock(state: NodeMaterialBuildState): void;
  99256. protected _dumpPropertiesCode(): string;
  99257. dispose(): void;
  99258. serialize(): any;
  99259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99260. }
  99261. }
  99262. declare module BABYLON {
  99263. /**
  99264. * Enum used to define the compatibility state between two connection points
  99265. */
  99266. export enum NodeMaterialConnectionPointCompatibilityStates {
  99267. /** Points are compatibles */
  99268. Compatible = 0,
  99269. /** Points are incompatible because of their types */
  99270. TypeIncompatible = 1,
  99271. /** Points are incompatible because of their targets (vertex vs fragment) */
  99272. TargetIncompatible = 2
  99273. }
  99274. /**
  99275. * Defines the direction of a connection point
  99276. */
  99277. export enum NodeMaterialConnectionPointDirection {
  99278. /** Input */
  99279. Input = 0,
  99280. /** Output */
  99281. Output = 1
  99282. }
  99283. /**
  99284. * Defines a connection point for a block
  99285. */
  99286. export class NodeMaterialConnectionPoint {
  99287. /** @hidden */
  99288. _ownerBlock: NodeMaterialBlock;
  99289. /** @hidden */
  99290. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99291. private _endpoints;
  99292. private _associatedVariableName;
  99293. private _direction;
  99294. /** @hidden */
  99295. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99296. /** @hidden */
  99297. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99298. private _type;
  99299. /** @hidden */
  99300. _enforceAssociatedVariableName: boolean;
  99301. /** Gets the direction of the point */
  99302. get direction(): NodeMaterialConnectionPointDirection;
  99303. /** Indicates that this connection point needs dual validation before being connected to another point */
  99304. needDualDirectionValidation: boolean;
  99305. /**
  99306. * Gets or sets the additional types supported by this connection point
  99307. */
  99308. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99309. /**
  99310. * Gets or sets the additional types excluded by this connection point
  99311. */
  99312. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99313. /**
  99314. * Observable triggered when this point is connected
  99315. */
  99316. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99317. /**
  99318. * Gets or sets the associated variable name in the shader
  99319. */
  99320. get associatedVariableName(): string;
  99321. set associatedVariableName(value: string);
  99322. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99323. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99324. /**
  99325. * Gets or sets the connection point type (default is float)
  99326. */
  99327. get type(): NodeMaterialBlockConnectionPointTypes;
  99328. set type(value: NodeMaterialBlockConnectionPointTypes);
  99329. /**
  99330. * Gets or sets the connection point name
  99331. */
  99332. name: string;
  99333. /**
  99334. * Gets or sets the connection point name
  99335. */
  99336. displayName: string;
  99337. /**
  99338. * Gets or sets a boolean indicating that this connection point can be omitted
  99339. */
  99340. isOptional: boolean;
  99341. /**
  99342. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99343. */
  99344. isExposedOnFrame: boolean;
  99345. /**
  99346. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99347. */
  99348. define: string;
  99349. /** @hidden */
  99350. _prioritizeVertex: boolean;
  99351. private _target;
  99352. /** Gets or sets the target of that connection point */
  99353. get target(): NodeMaterialBlockTargets;
  99354. set target(value: NodeMaterialBlockTargets);
  99355. /**
  99356. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99357. */
  99358. get isConnected(): boolean;
  99359. /**
  99360. * Gets a boolean indicating that the current point is connected to an input block
  99361. */
  99362. get isConnectedToInputBlock(): boolean;
  99363. /**
  99364. * Gets a the connected input block (if any)
  99365. */
  99366. get connectInputBlock(): Nullable<InputBlock>;
  99367. /** Get the other side of the connection (if any) */
  99368. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99369. /** Get the block that owns this connection point */
  99370. get ownerBlock(): NodeMaterialBlock;
  99371. /** Get the block connected on the other side of this connection (if any) */
  99372. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99373. /** Get the block connected on the endpoints of this connection (if any) */
  99374. get connectedBlocks(): Array<NodeMaterialBlock>;
  99375. /** Gets the list of connected endpoints */
  99376. get endpoints(): NodeMaterialConnectionPoint[];
  99377. /** Gets a boolean indicating if that output point is connected to at least one input */
  99378. get hasEndpoints(): boolean;
  99379. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99380. get isConnectedInVertexShader(): boolean;
  99381. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99382. get isConnectedInFragmentShader(): boolean;
  99383. /**
  99384. * Creates a block suitable to be used as an input for this input point.
  99385. * If null is returned, a block based on the point type will be created.
  99386. * @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
  99387. */
  99388. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99389. /**
  99390. * Creates a new connection point
  99391. * @param name defines the connection point name
  99392. * @param ownerBlock defines the block hosting this connection point
  99393. * @param direction defines the direction of the connection point
  99394. */
  99395. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99396. /**
  99397. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99398. * @returns the class name
  99399. */
  99400. getClassName(): string;
  99401. /**
  99402. * Gets a boolean indicating if the current point can be connected to another point
  99403. * @param connectionPoint defines the other connection point
  99404. * @returns a boolean
  99405. */
  99406. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99407. /**
  99408. * Gets a number indicating if the current point can be connected to another point
  99409. * @param connectionPoint defines the other connection point
  99410. * @returns a number defining the compatibility state
  99411. */
  99412. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99413. /**
  99414. * Connect this point to another connection point
  99415. * @param connectionPoint defines the other connection point
  99416. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99417. * @returns the current connection point
  99418. */
  99419. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99420. /**
  99421. * Disconnect this point from one of his endpoint
  99422. * @param endpoint defines the other connection point
  99423. * @returns the current connection point
  99424. */
  99425. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99426. /**
  99427. * Serializes this point in a JSON representation
  99428. * @param isInput defines if the connection point is an input (default is true)
  99429. * @returns the serialized point object
  99430. */
  99431. serialize(isInput?: boolean): any;
  99432. /**
  99433. * Release resources
  99434. */
  99435. dispose(): void;
  99436. }
  99437. }
  99438. declare module BABYLON {
  99439. /**
  99440. * Enum used to define the material modes
  99441. */
  99442. export enum NodeMaterialModes {
  99443. /** Regular material */
  99444. Material = 0,
  99445. /** For post process */
  99446. PostProcess = 1,
  99447. /** For particle system */
  99448. Particle = 2
  99449. }
  99450. }
  99451. declare module BABYLON {
  99452. /**
  99453. * Block used to read a texture from a sampler
  99454. */
  99455. export class TextureBlock extends NodeMaterialBlock {
  99456. private _defineName;
  99457. private _linearDefineName;
  99458. private _gammaDefineName;
  99459. private _tempTextureRead;
  99460. private _samplerName;
  99461. private _transformedUVName;
  99462. private _textureTransformName;
  99463. private _textureInfoName;
  99464. private _mainUVName;
  99465. private _mainUVDefineName;
  99466. private _fragmentOnly;
  99467. /**
  99468. * Gets or sets the texture associated with the node
  99469. */
  99470. texture: Nullable<Texture>;
  99471. /**
  99472. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99473. */
  99474. convertToGammaSpace: boolean;
  99475. /**
  99476. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99477. */
  99478. convertToLinearSpace: boolean;
  99479. /**
  99480. * Create a new TextureBlock
  99481. * @param name defines the block name
  99482. */
  99483. constructor(name: string, fragmentOnly?: boolean);
  99484. /**
  99485. * Gets the current class name
  99486. * @returns the class name
  99487. */
  99488. getClassName(): string;
  99489. /**
  99490. * Gets the uv input component
  99491. */
  99492. get uv(): NodeMaterialConnectionPoint;
  99493. /**
  99494. * Gets the rgba output component
  99495. */
  99496. get rgba(): NodeMaterialConnectionPoint;
  99497. /**
  99498. * Gets the rgb output component
  99499. */
  99500. get rgb(): NodeMaterialConnectionPoint;
  99501. /**
  99502. * Gets the r output component
  99503. */
  99504. get r(): NodeMaterialConnectionPoint;
  99505. /**
  99506. * Gets the g output component
  99507. */
  99508. get g(): NodeMaterialConnectionPoint;
  99509. /**
  99510. * Gets the b output component
  99511. */
  99512. get b(): NodeMaterialConnectionPoint;
  99513. /**
  99514. * Gets the a output component
  99515. */
  99516. get a(): NodeMaterialConnectionPoint;
  99517. get target(): NodeMaterialBlockTargets;
  99518. autoConfigure(material: NodeMaterial): void;
  99519. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99521. isReady(): boolean;
  99522. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99523. private get _isMixed();
  99524. private _injectVertexCode;
  99525. private _writeTextureRead;
  99526. private _writeOutput;
  99527. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99528. protected _dumpPropertiesCode(): string;
  99529. serialize(): any;
  99530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99531. }
  99532. }
  99533. declare module BABYLON {
  99534. /** @hidden */
  99535. export var reflectionFunction: {
  99536. name: string;
  99537. shader: string;
  99538. };
  99539. }
  99540. declare module BABYLON {
  99541. /**
  99542. * Base block used to read a reflection texture from a sampler
  99543. */
  99544. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99545. /** @hidden */
  99546. _define3DName: string;
  99547. /** @hidden */
  99548. _defineCubicName: string;
  99549. /** @hidden */
  99550. _defineExplicitName: string;
  99551. /** @hidden */
  99552. _defineProjectionName: string;
  99553. /** @hidden */
  99554. _defineLocalCubicName: string;
  99555. /** @hidden */
  99556. _defineSphericalName: string;
  99557. /** @hidden */
  99558. _definePlanarName: string;
  99559. /** @hidden */
  99560. _defineEquirectangularName: string;
  99561. /** @hidden */
  99562. _defineMirroredEquirectangularFixedName: string;
  99563. /** @hidden */
  99564. _defineEquirectangularFixedName: string;
  99565. /** @hidden */
  99566. _defineSkyboxName: string;
  99567. /** @hidden */
  99568. _defineOppositeZ: string;
  99569. /** @hidden */
  99570. _cubeSamplerName: string;
  99571. /** @hidden */
  99572. _2DSamplerName: string;
  99573. protected _positionUVWName: string;
  99574. protected _directionWName: string;
  99575. protected _reflectionVectorName: string;
  99576. /** @hidden */
  99577. _reflectionCoordsName: string;
  99578. /** @hidden */
  99579. _reflectionMatrixName: string;
  99580. protected _reflectionColorName: string;
  99581. /**
  99582. * Gets or sets the texture associated with the node
  99583. */
  99584. texture: Nullable<BaseTexture>;
  99585. /**
  99586. * Create a new ReflectionTextureBaseBlock
  99587. * @param name defines the block name
  99588. */
  99589. constructor(name: string);
  99590. /**
  99591. * Gets the current class name
  99592. * @returns the class name
  99593. */
  99594. getClassName(): string;
  99595. /**
  99596. * Gets the world position input component
  99597. */
  99598. abstract get position(): NodeMaterialConnectionPoint;
  99599. /**
  99600. * Gets the world position input component
  99601. */
  99602. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99603. /**
  99604. * Gets the world normal input component
  99605. */
  99606. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99607. /**
  99608. * Gets the world input component
  99609. */
  99610. abstract get world(): NodeMaterialConnectionPoint;
  99611. /**
  99612. * Gets the camera (or eye) position component
  99613. */
  99614. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99615. /**
  99616. * Gets the view input component
  99617. */
  99618. abstract get view(): NodeMaterialConnectionPoint;
  99619. protected _getTexture(): Nullable<BaseTexture>;
  99620. autoConfigure(material: NodeMaterial): void;
  99621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99622. isReady(): boolean;
  99623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99624. /**
  99625. * Gets the code to inject in the vertex shader
  99626. * @param state current state of the node material building
  99627. * @returns the shader code
  99628. */
  99629. handleVertexSide(state: NodeMaterialBuildState): string;
  99630. /**
  99631. * Handles the inits for the fragment code path
  99632. * @param state node material build state
  99633. */
  99634. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99635. /**
  99636. * Generates the reflection coords code for the fragment code path
  99637. * @param worldNormalVarName name of the world normal variable
  99638. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99639. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99640. * @returns the shader code
  99641. */
  99642. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99643. /**
  99644. * Generates the reflection color code for the fragment code path
  99645. * @param lodVarName name of the lod variable
  99646. * @param swizzleLookupTexture swizzle to use for the final color variable
  99647. * @returns the shader code
  99648. */
  99649. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99650. /**
  99651. * Generates the code corresponding to the connected output points
  99652. * @param state node material build state
  99653. * @param varName name of the variable to output
  99654. * @returns the shader code
  99655. */
  99656. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99657. protected _buildBlock(state: NodeMaterialBuildState): this;
  99658. protected _dumpPropertiesCode(): string;
  99659. serialize(): any;
  99660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99661. }
  99662. }
  99663. declare module BABYLON {
  99664. /**
  99665. * Defines a connection point to be used for points with a custom object type
  99666. */
  99667. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99668. private _blockType;
  99669. private _blockName;
  99670. private _nameForCheking?;
  99671. /**
  99672. * Creates a new connection point
  99673. * @param name defines the connection point name
  99674. * @param ownerBlock defines the block hosting this connection point
  99675. * @param direction defines the direction of the connection point
  99676. */
  99677. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99678. /**
  99679. * Gets a number indicating if the current point can be connected to another point
  99680. * @param connectionPoint defines the other connection point
  99681. * @returns a number defining the compatibility state
  99682. */
  99683. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99684. /**
  99685. * Creates a block suitable to be used as an input for this input point.
  99686. * If null is returned, a block based on the point type will be created.
  99687. * @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
  99688. */
  99689. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99690. }
  99691. }
  99692. declare module BABYLON {
  99693. /**
  99694. * Enum defining the type of properties that can be edited in the property pages in the NME
  99695. */
  99696. export enum PropertyTypeForEdition {
  99697. /** property is a boolean */
  99698. Boolean = 0,
  99699. /** property is a float */
  99700. Float = 1,
  99701. /** property is a Vector2 */
  99702. Vector2 = 2,
  99703. /** property is a list of values */
  99704. List = 3
  99705. }
  99706. /**
  99707. * Interface that defines an option in a variable of type list
  99708. */
  99709. export interface IEditablePropertyListOption {
  99710. /** label of the option */
  99711. "label": string;
  99712. /** value of the option */
  99713. "value": number;
  99714. }
  99715. /**
  99716. * Interface that defines the options available for an editable property
  99717. */
  99718. export interface IEditablePropertyOption {
  99719. /** min value */
  99720. "min"?: number;
  99721. /** max value */
  99722. "max"?: number;
  99723. /** notifiers: indicates which actions to take when the property is changed */
  99724. "notifiers"?: {
  99725. /** the material should be rebuilt */
  99726. "rebuild"?: boolean;
  99727. /** the preview should be updated */
  99728. "update"?: boolean;
  99729. };
  99730. /** list of the options for a variable of type list */
  99731. "options"?: IEditablePropertyListOption[];
  99732. }
  99733. /**
  99734. * Interface that describes an editable property
  99735. */
  99736. export interface IPropertyDescriptionForEdition {
  99737. /** name of the property */
  99738. "propertyName": string;
  99739. /** display name of the property */
  99740. "displayName": string;
  99741. /** type of the property */
  99742. "type": PropertyTypeForEdition;
  99743. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99744. "groupName": string;
  99745. /** options for the property */
  99746. "options": IEditablePropertyOption;
  99747. }
  99748. /**
  99749. * Decorator that flags a property in a node material block as being editable
  99750. */
  99751. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99752. }
  99753. declare module BABYLON {
  99754. /**
  99755. * Block used to implement the refraction part of the sub surface module of the PBR material
  99756. */
  99757. export class RefractionBlock extends NodeMaterialBlock {
  99758. /** @hidden */
  99759. _define3DName: string;
  99760. /** @hidden */
  99761. _refractionMatrixName: string;
  99762. /** @hidden */
  99763. _defineLODRefractionAlpha: string;
  99764. /** @hidden */
  99765. _defineLinearSpecularRefraction: string;
  99766. /** @hidden */
  99767. _defineOppositeZ: string;
  99768. /** @hidden */
  99769. _cubeSamplerName: string;
  99770. /** @hidden */
  99771. _2DSamplerName: string;
  99772. /** @hidden */
  99773. _vRefractionMicrosurfaceInfosName: string;
  99774. /** @hidden */
  99775. _vRefractionInfosName: string;
  99776. private _scene;
  99777. /**
  99778. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99779. * Materials half opaque for instance using refraction could benefit from this control.
  99780. */
  99781. linkRefractionWithTransparency: boolean;
  99782. /**
  99783. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99784. */
  99785. invertRefractionY: boolean;
  99786. /**
  99787. * Gets or sets the texture associated with the node
  99788. */
  99789. texture: Nullable<BaseTexture>;
  99790. /**
  99791. * Create a new RefractionBlock
  99792. * @param name defines the block name
  99793. */
  99794. constructor(name: string);
  99795. /**
  99796. * Gets the current class name
  99797. * @returns the class name
  99798. */
  99799. getClassName(): string;
  99800. /**
  99801. * Gets the intensity input component
  99802. */
  99803. get intensity(): NodeMaterialConnectionPoint;
  99804. /**
  99805. * Gets the index of refraction input component
  99806. */
  99807. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99808. /**
  99809. * Gets the tint at distance input component
  99810. */
  99811. get tintAtDistance(): NodeMaterialConnectionPoint;
  99812. /**
  99813. * Gets the view input component
  99814. */
  99815. get view(): NodeMaterialConnectionPoint;
  99816. /**
  99817. * Gets the refraction object output component
  99818. */
  99819. get refraction(): NodeMaterialConnectionPoint;
  99820. /**
  99821. * Returns true if the block has a texture
  99822. */
  99823. get hasTexture(): boolean;
  99824. protected _getTexture(): Nullable<BaseTexture>;
  99825. autoConfigure(material: NodeMaterial): void;
  99826. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99827. isReady(): boolean;
  99828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99829. /**
  99830. * Gets the main code of the block (fragment side)
  99831. * @param state current state of the node material building
  99832. * @returns the shader code
  99833. */
  99834. getCode(state: NodeMaterialBuildState): string;
  99835. protected _buildBlock(state: NodeMaterialBuildState): this;
  99836. protected _dumpPropertiesCode(): string;
  99837. serialize(): any;
  99838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99839. }
  99840. }
  99841. declare module BABYLON {
  99842. /**
  99843. * Base block used as input for post process
  99844. */
  99845. export class CurrentScreenBlock extends NodeMaterialBlock {
  99846. private _samplerName;
  99847. private _linearDefineName;
  99848. private _gammaDefineName;
  99849. private _mainUVName;
  99850. private _tempTextureRead;
  99851. /**
  99852. * Gets or sets the texture associated with the node
  99853. */
  99854. texture: Nullable<BaseTexture>;
  99855. /**
  99856. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99857. */
  99858. convertToGammaSpace: boolean;
  99859. /**
  99860. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99861. */
  99862. convertToLinearSpace: boolean;
  99863. /**
  99864. * Create a new CurrentScreenBlock
  99865. * @param name defines the block name
  99866. */
  99867. constructor(name: string);
  99868. /**
  99869. * Gets the current class name
  99870. * @returns the class name
  99871. */
  99872. getClassName(): string;
  99873. /**
  99874. * Gets the uv input component
  99875. */
  99876. get uv(): NodeMaterialConnectionPoint;
  99877. /**
  99878. * Gets the rgba output component
  99879. */
  99880. get rgba(): NodeMaterialConnectionPoint;
  99881. /**
  99882. * Gets the rgb output component
  99883. */
  99884. get rgb(): NodeMaterialConnectionPoint;
  99885. /**
  99886. * Gets the r output component
  99887. */
  99888. get r(): NodeMaterialConnectionPoint;
  99889. /**
  99890. * Gets the g output component
  99891. */
  99892. get g(): NodeMaterialConnectionPoint;
  99893. /**
  99894. * Gets the b output component
  99895. */
  99896. get b(): NodeMaterialConnectionPoint;
  99897. /**
  99898. * Gets the a output component
  99899. */
  99900. get a(): NodeMaterialConnectionPoint;
  99901. /**
  99902. * Initialize the block and prepare the context for build
  99903. * @param state defines the state that will be used for the build
  99904. */
  99905. initialize(state: NodeMaterialBuildState): void;
  99906. get target(): NodeMaterialBlockTargets;
  99907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99908. isReady(): boolean;
  99909. private _injectVertexCode;
  99910. private _writeTextureRead;
  99911. private _writeOutput;
  99912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99913. serialize(): any;
  99914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99915. }
  99916. }
  99917. declare module BABYLON {
  99918. /**
  99919. * Base block used for the particle texture
  99920. */
  99921. export class ParticleTextureBlock extends NodeMaterialBlock {
  99922. private _samplerName;
  99923. private _linearDefineName;
  99924. private _gammaDefineName;
  99925. private _tempTextureRead;
  99926. /**
  99927. * Gets or sets the texture associated with the node
  99928. */
  99929. texture: Nullable<BaseTexture>;
  99930. /**
  99931. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99932. */
  99933. convertToGammaSpace: boolean;
  99934. /**
  99935. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99936. */
  99937. convertToLinearSpace: boolean;
  99938. /**
  99939. * Create a new ParticleTextureBlock
  99940. * @param name defines the block name
  99941. */
  99942. constructor(name: string);
  99943. /**
  99944. * Gets the current class name
  99945. * @returns the class name
  99946. */
  99947. getClassName(): string;
  99948. /**
  99949. * Gets the uv input component
  99950. */
  99951. get uv(): NodeMaterialConnectionPoint;
  99952. /**
  99953. * Gets the rgba output component
  99954. */
  99955. get rgba(): NodeMaterialConnectionPoint;
  99956. /**
  99957. * Gets the rgb output component
  99958. */
  99959. get rgb(): NodeMaterialConnectionPoint;
  99960. /**
  99961. * Gets the r output component
  99962. */
  99963. get r(): NodeMaterialConnectionPoint;
  99964. /**
  99965. * Gets the g output component
  99966. */
  99967. get g(): NodeMaterialConnectionPoint;
  99968. /**
  99969. * Gets the b output component
  99970. */
  99971. get b(): NodeMaterialConnectionPoint;
  99972. /**
  99973. * Gets the a output component
  99974. */
  99975. get a(): NodeMaterialConnectionPoint;
  99976. /**
  99977. * Initialize the block and prepare the context for build
  99978. * @param state defines the state that will be used for the build
  99979. */
  99980. initialize(state: NodeMaterialBuildState): void;
  99981. autoConfigure(material: NodeMaterial): void;
  99982. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99983. isReady(): boolean;
  99984. private _writeOutput;
  99985. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99986. serialize(): any;
  99987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99988. }
  99989. }
  99990. declare module BABYLON {
  99991. /**
  99992. * Class used to store shared data between 2 NodeMaterialBuildState
  99993. */
  99994. export class NodeMaterialBuildStateSharedData {
  99995. /**
  99996. * Gets the list of emitted varyings
  99997. */
  99998. temps: string[];
  99999. /**
  100000. * Gets the list of emitted varyings
  100001. */
  100002. varyings: string[];
  100003. /**
  100004. * Gets the varying declaration string
  100005. */
  100006. varyingDeclaration: string;
  100007. /**
  100008. * Input blocks
  100009. */
  100010. inputBlocks: InputBlock[];
  100011. /**
  100012. * Input blocks
  100013. */
  100014. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100015. /**
  100016. * Bindable blocks (Blocks that need to set data to the effect)
  100017. */
  100018. bindableBlocks: NodeMaterialBlock[];
  100019. /**
  100020. * List of blocks that can provide a compilation fallback
  100021. */
  100022. blocksWithFallbacks: NodeMaterialBlock[];
  100023. /**
  100024. * List of blocks that can provide a define update
  100025. */
  100026. blocksWithDefines: NodeMaterialBlock[];
  100027. /**
  100028. * List of blocks that can provide a repeatable content
  100029. */
  100030. repeatableContentBlocks: NodeMaterialBlock[];
  100031. /**
  100032. * List of blocks that can provide a dynamic list of uniforms
  100033. */
  100034. dynamicUniformBlocks: NodeMaterialBlock[];
  100035. /**
  100036. * List of blocks that can block the isReady function for the material
  100037. */
  100038. blockingBlocks: NodeMaterialBlock[];
  100039. /**
  100040. * Gets the list of animated inputs
  100041. */
  100042. animatedInputs: InputBlock[];
  100043. /**
  100044. * Build Id used to avoid multiple recompilations
  100045. */
  100046. buildId: number;
  100047. /** List of emitted variables */
  100048. variableNames: {
  100049. [key: string]: number;
  100050. };
  100051. /** List of emitted defines */
  100052. defineNames: {
  100053. [key: string]: number;
  100054. };
  100055. /** Should emit comments? */
  100056. emitComments: boolean;
  100057. /** Emit build activity */
  100058. verbose: boolean;
  100059. /** Gets or sets the hosting scene */
  100060. scene: Scene;
  100061. /**
  100062. * Gets the compilation hints emitted at compilation time
  100063. */
  100064. hints: {
  100065. needWorldViewMatrix: boolean;
  100066. needWorldViewProjectionMatrix: boolean;
  100067. needAlphaBlending: boolean;
  100068. needAlphaTesting: boolean;
  100069. };
  100070. /**
  100071. * List of compilation checks
  100072. */
  100073. checks: {
  100074. emitVertex: boolean;
  100075. emitFragment: boolean;
  100076. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  100077. };
  100078. /**
  100079. * Is vertex program allowed to be empty?
  100080. */
  100081. allowEmptyVertexProgram: boolean;
  100082. /** Creates a new shared data */
  100083. constructor();
  100084. /**
  100085. * Emits console errors and exceptions if there is a failing check
  100086. */
  100087. emitErrors(): void;
  100088. }
  100089. }
  100090. declare module BABYLON {
  100091. /**
  100092. * Class used to store node based material build state
  100093. */
  100094. export class NodeMaterialBuildState {
  100095. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  100096. supportUniformBuffers: boolean;
  100097. /**
  100098. * Gets the list of emitted attributes
  100099. */
  100100. attributes: string[];
  100101. /**
  100102. * Gets the list of emitted uniforms
  100103. */
  100104. uniforms: string[];
  100105. /**
  100106. * Gets the list of emitted constants
  100107. */
  100108. constants: string[];
  100109. /**
  100110. * Gets the list of emitted samplers
  100111. */
  100112. samplers: string[];
  100113. /**
  100114. * Gets the list of emitted functions
  100115. */
  100116. functions: {
  100117. [key: string]: string;
  100118. };
  100119. /**
  100120. * Gets the list of emitted extensions
  100121. */
  100122. extensions: {
  100123. [key: string]: string;
  100124. };
  100125. /**
  100126. * Gets the target of the compilation state
  100127. */
  100128. target: NodeMaterialBlockTargets;
  100129. /**
  100130. * Gets the list of emitted counters
  100131. */
  100132. counters: {
  100133. [key: string]: number;
  100134. };
  100135. /**
  100136. * Shared data between multiple NodeMaterialBuildState instances
  100137. */
  100138. sharedData: NodeMaterialBuildStateSharedData;
  100139. /** @hidden */
  100140. _vertexState: NodeMaterialBuildState;
  100141. /** @hidden */
  100142. _attributeDeclaration: string;
  100143. /** @hidden */
  100144. _uniformDeclaration: string;
  100145. /** @hidden */
  100146. _constantDeclaration: string;
  100147. /** @hidden */
  100148. _samplerDeclaration: string;
  100149. /** @hidden */
  100150. _varyingTransfer: string;
  100151. /** @hidden */
  100152. _injectAtEnd: string;
  100153. private _repeatableContentAnchorIndex;
  100154. /** @hidden */
  100155. _builtCompilationString: string;
  100156. /**
  100157. * Gets the emitted compilation strings
  100158. */
  100159. compilationString: string;
  100160. /**
  100161. * Finalize the compilation strings
  100162. * @param state defines the current compilation state
  100163. */
  100164. finalize(state: NodeMaterialBuildState): void;
  100165. /** @hidden */
  100166. get _repeatableContentAnchor(): string;
  100167. /** @hidden */
  100168. _getFreeVariableName(prefix: string): string;
  100169. /** @hidden */
  100170. _getFreeDefineName(prefix: string): string;
  100171. /** @hidden */
  100172. _excludeVariableName(name: string): void;
  100173. /** @hidden */
  100174. _emit2DSampler(name: string): void;
  100175. /** @hidden */
  100176. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100177. /** @hidden */
  100178. _emitExtension(name: string, extension: string, define?: string): void;
  100179. /** @hidden */
  100180. _emitFunction(name: string, code: string, comments: string): void;
  100181. /** @hidden */
  100182. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100183. replaceStrings?: {
  100184. search: RegExp;
  100185. replace: string;
  100186. }[];
  100187. repeatKey?: string;
  100188. }): string;
  100189. /** @hidden */
  100190. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100191. repeatKey?: string;
  100192. removeAttributes?: boolean;
  100193. removeUniforms?: boolean;
  100194. removeVaryings?: boolean;
  100195. removeIfDef?: boolean;
  100196. replaceStrings?: {
  100197. search: RegExp;
  100198. replace: string;
  100199. }[];
  100200. }, storeKey?: string): void;
  100201. /** @hidden */
  100202. _registerTempVariable(name: string): boolean;
  100203. /** @hidden */
  100204. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100205. /** @hidden */
  100206. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100207. /** @hidden */
  100208. _emitFloat(value: number): string;
  100209. }
  100210. }
  100211. declare module BABYLON {
  100212. /**
  100213. * Helper class used to generate session unique ID
  100214. */
  100215. export class UniqueIdGenerator {
  100216. private static _UniqueIdCounter;
  100217. /**
  100218. * Gets an unique (relatively to the current scene) Id
  100219. */
  100220. static get UniqueId(): number;
  100221. }
  100222. }
  100223. declare module BABYLON {
  100224. /**
  100225. * Defines a block that can be used inside a node based material
  100226. */
  100227. export class NodeMaterialBlock {
  100228. private _buildId;
  100229. private _buildTarget;
  100230. private _target;
  100231. private _isFinalMerger;
  100232. private _isInput;
  100233. private _name;
  100234. protected _isUnique: boolean;
  100235. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100236. inputsAreExclusive: boolean;
  100237. /** @hidden */
  100238. _codeVariableName: string;
  100239. /** @hidden */
  100240. _inputs: NodeMaterialConnectionPoint[];
  100241. /** @hidden */
  100242. _outputs: NodeMaterialConnectionPoint[];
  100243. /** @hidden */
  100244. _preparationId: number;
  100245. /**
  100246. * Gets the name of the block
  100247. */
  100248. get name(): string;
  100249. /**
  100250. * Sets the name of the block. Will check if the name is valid.
  100251. */
  100252. set name(newName: string);
  100253. /**
  100254. * Gets or sets the unique id of the node
  100255. */
  100256. uniqueId: number;
  100257. /**
  100258. * Gets or sets the comments associated with this block
  100259. */
  100260. comments: string;
  100261. /**
  100262. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100263. */
  100264. get isUnique(): boolean;
  100265. /**
  100266. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100267. */
  100268. get isFinalMerger(): boolean;
  100269. /**
  100270. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100271. */
  100272. get isInput(): boolean;
  100273. /**
  100274. * Gets or sets the build Id
  100275. */
  100276. get buildId(): number;
  100277. set buildId(value: number);
  100278. /**
  100279. * Gets or sets the target of the block
  100280. */
  100281. get target(): NodeMaterialBlockTargets;
  100282. set target(value: NodeMaterialBlockTargets);
  100283. /**
  100284. * Gets the list of input points
  100285. */
  100286. get inputs(): NodeMaterialConnectionPoint[];
  100287. /** Gets the list of output points */
  100288. get outputs(): NodeMaterialConnectionPoint[];
  100289. /**
  100290. * Find an input by its name
  100291. * @param name defines the name of the input to look for
  100292. * @returns the input or null if not found
  100293. */
  100294. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100295. /**
  100296. * Find an output by its name
  100297. * @param name defines the name of the outputto look for
  100298. * @returns the output or null if not found
  100299. */
  100300. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100301. /**
  100302. * Creates a new NodeMaterialBlock
  100303. * @param name defines the block name
  100304. * @param target defines the target of that block (Vertex by default)
  100305. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100306. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100307. */
  100308. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100309. /**
  100310. * Initialize the block and prepare the context for build
  100311. * @param state defines the state that will be used for the build
  100312. */
  100313. initialize(state: NodeMaterialBuildState): void;
  100314. /**
  100315. * Bind data to effect. Will only be called for blocks with isBindable === true
  100316. * @param effect defines the effect to bind data to
  100317. * @param nodeMaterial defines the hosting NodeMaterial
  100318. * @param mesh defines the mesh that will be rendered
  100319. * @param subMesh defines the submesh that will be rendered
  100320. */
  100321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100322. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100323. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100324. protected _writeFloat(value: number): string;
  100325. /**
  100326. * Gets the current class name e.g. "NodeMaterialBlock"
  100327. * @returns the class name
  100328. */
  100329. getClassName(): string;
  100330. /**
  100331. * Register a new input. Must be called inside a block constructor
  100332. * @param name defines the connection point name
  100333. * @param type defines the connection point type
  100334. * @param isOptional defines a boolean indicating that this input can be omitted
  100335. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100336. * @param point an already created connection point. If not provided, create a new one
  100337. * @returns the current block
  100338. */
  100339. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100340. /**
  100341. * Register a new output. Must be called inside a block constructor
  100342. * @param name defines the connection point name
  100343. * @param type defines the connection point type
  100344. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100345. * @param point an already created connection point. If not provided, create a new one
  100346. * @returns the current block
  100347. */
  100348. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100349. /**
  100350. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100351. * @param forOutput defines an optional connection point to check compatibility with
  100352. * @returns the first available input or null
  100353. */
  100354. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100355. /**
  100356. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100357. * @param forBlock defines an optional block to check compatibility with
  100358. * @returns the first available input or null
  100359. */
  100360. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100361. /**
  100362. * Gets the sibling of the given output
  100363. * @param current defines the current output
  100364. * @returns the next output in the list or null
  100365. */
  100366. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100367. /**
  100368. * Connect current block with another block
  100369. * @param other defines the block to connect with
  100370. * @param options define the various options to help pick the right connections
  100371. * @returns the current block
  100372. */
  100373. connectTo(other: NodeMaterialBlock, options?: {
  100374. input?: string;
  100375. output?: string;
  100376. outputSwizzle?: string;
  100377. }): this | undefined;
  100378. protected _buildBlock(state: NodeMaterialBuildState): void;
  100379. /**
  100380. * Add uniforms, samplers and uniform buffers at compilation time
  100381. * @param state defines the state to update
  100382. * @param nodeMaterial defines the node material requesting the update
  100383. * @param defines defines the material defines to update
  100384. * @param uniformBuffers defines the list of uniform buffer names
  100385. */
  100386. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100387. /**
  100388. * Add potential fallbacks if shader compilation fails
  100389. * @param mesh defines the mesh to be rendered
  100390. * @param fallbacks defines the current prioritized list of fallbacks
  100391. */
  100392. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100393. /**
  100394. * Initialize defines for shader compilation
  100395. * @param mesh defines the mesh to be rendered
  100396. * @param nodeMaterial defines the node material requesting the update
  100397. * @param defines defines the material defines to update
  100398. * @param useInstances specifies that instances should be used
  100399. */
  100400. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100401. /**
  100402. * Update defines for shader compilation
  100403. * @param mesh defines the mesh to be rendered
  100404. * @param nodeMaterial defines the node material requesting the update
  100405. * @param defines defines the material defines to update
  100406. * @param useInstances specifies that instances should be used
  100407. * @param subMesh defines which submesh to render
  100408. */
  100409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100410. /**
  100411. * Lets the block try to connect some inputs automatically
  100412. * @param material defines the hosting NodeMaterial
  100413. */
  100414. autoConfigure(material: NodeMaterial): void;
  100415. /**
  100416. * Function called when a block is declared as repeatable content generator
  100417. * @param vertexShaderState defines the current compilation state for the vertex shader
  100418. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100419. * @param mesh defines the mesh to be rendered
  100420. * @param defines defines the material defines to update
  100421. */
  100422. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100423. /**
  100424. * Checks if the block is ready
  100425. * @param mesh defines the mesh to be rendered
  100426. * @param nodeMaterial defines the node material requesting the update
  100427. * @param defines defines the material defines to update
  100428. * @param useInstances specifies that instances should be used
  100429. * @returns true if the block is ready
  100430. */
  100431. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100432. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100433. private _processBuild;
  100434. /**
  100435. * Validates the new name for the block node.
  100436. * @param newName the new name to be given to the node.
  100437. * @returns false if the name is a reserve word, else true.
  100438. */
  100439. validateBlockName(newName: string): boolean;
  100440. /**
  100441. * Compile the current node and generate the shader code
  100442. * @param state defines the current compilation state (uniforms, samplers, current string)
  100443. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  100444. * @returns true if already built
  100445. */
  100446. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  100447. protected _inputRename(name: string): string;
  100448. protected _outputRename(name: string): string;
  100449. protected _dumpPropertiesCode(): string;
  100450. /** @hidden */
  100451. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  100452. /** @hidden */
  100453. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  100454. /**
  100455. * Clone the current block to a new identical block
  100456. * @param scene defines the hosting scene
  100457. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100458. * @returns a copy of the current block
  100459. */
  100460. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  100461. /**
  100462. * Serializes this block in a JSON representation
  100463. * @returns the serialized block object
  100464. */
  100465. serialize(): any;
  100466. /** @hidden */
  100467. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100468. private _deserializePortDisplayNamesAndExposedOnFrame;
  100469. /**
  100470. * Release resources
  100471. */
  100472. dispose(): void;
  100473. }
  100474. }
  100475. declare module BABYLON {
  100476. /**
  100477. * Base class of materials working in push mode in babylon JS
  100478. * @hidden
  100479. */
  100480. export class PushMaterial extends Material {
  100481. protected _activeEffect: Effect;
  100482. protected _normalMatrix: Matrix;
  100483. constructor(name: string, scene: Scene);
  100484. getEffect(): Effect;
  100485. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100486. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100487. /**
  100488. * Binds the given world matrix to the active effect
  100489. *
  100490. * @param world the matrix to bind
  100491. */
  100492. bindOnlyWorldMatrix(world: Matrix): void;
  100493. /**
  100494. * Binds the given normal matrix to the active effect
  100495. *
  100496. * @param normalMatrix the matrix to bind
  100497. */
  100498. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100499. bind(world: Matrix, mesh?: Mesh): void;
  100500. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100501. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100502. }
  100503. }
  100504. declare module BABYLON {
  100505. /**
  100506. * Root class for all node material optimizers
  100507. */
  100508. export class NodeMaterialOptimizer {
  100509. /**
  100510. * Function used to optimize a NodeMaterial graph
  100511. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100512. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100513. */
  100514. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100515. }
  100516. }
  100517. declare module BABYLON {
  100518. /**
  100519. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100520. */
  100521. export class TransformBlock extends NodeMaterialBlock {
  100522. /**
  100523. * Defines the value to use to complement W value to transform it to a Vector4
  100524. */
  100525. complementW: number;
  100526. /**
  100527. * Defines the value to use to complement z value to transform it to a Vector4
  100528. */
  100529. complementZ: number;
  100530. /**
  100531. * Creates a new TransformBlock
  100532. * @param name defines the block name
  100533. */
  100534. constructor(name: string);
  100535. /**
  100536. * Gets the current class name
  100537. * @returns the class name
  100538. */
  100539. getClassName(): string;
  100540. /**
  100541. * Gets the vector input
  100542. */
  100543. get vector(): NodeMaterialConnectionPoint;
  100544. /**
  100545. * Gets the output component
  100546. */
  100547. get output(): NodeMaterialConnectionPoint;
  100548. /**
  100549. * Gets the xyz output component
  100550. */
  100551. get xyz(): NodeMaterialConnectionPoint;
  100552. /**
  100553. * Gets the matrix transform input
  100554. */
  100555. get transform(): NodeMaterialConnectionPoint;
  100556. protected _buildBlock(state: NodeMaterialBuildState): this;
  100557. /**
  100558. * Update defines for shader compilation
  100559. * @param mesh defines the mesh to be rendered
  100560. * @param nodeMaterial defines the node material requesting the update
  100561. * @param defines defines the material defines to update
  100562. * @param useInstances specifies that instances should be used
  100563. * @param subMesh defines which submesh to render
  100564. */
  100565. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100566. serialize(): any;
  100567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100568. protected _dumpPropertiesCode(): string;
  100569. }
  100570. }
  100571. declare module BABYLON {
  100572. /**
  100573. * Block used to output the vertex position
  100574. */
  100575. export class VertexOutputBlock extends NodeMaterialBlock {
  100576. /**
  100577. * Creates a new VertexOutputBlock
  100578. * @param name defines the block name
  100579. */
  100580. constructor(name: string);
  100581. /**
  100582. * Gets the current class name
  100583. * @returns the class name
  100584. */
  100585. getClassName(): string;
  100586. /**
  100587. * Gets the vector input component
  100588. */
  100589. get vector(): NodeMaterialConnectionPoint;
  100590. protected _buildBlock(state: NodeMaterialBuildState): this;
  100591. }
  100592. }
  100593. declare module BABYLON {
  100594. /**
  100595. * Block used to output the final color
  100596. */
  100597. export class FragmentOutputBlock extends NodeMaterialBlock {
  100598. /**
  100599. * Create a new FragmentOutputBlock
  100600. * @param name defines the block name
  100601. */
  100602. constructor(name: string);
  100603. /**
  100604. * Gets the current class name
  100605. * @returns the class name
  100606. */
  100607. getClassName(): string;
  100608. /**
  100609. * Gets the rgba input component
  100610. */
  100611. get rgba(): NodeMaterialConnectionPoint;
  100612. /**
  100613. * Gets the rgb input component
  100614. */
  100615. get rgb(): NodeMaterialConnectionPoint;
  100616. /**
  100617. * Gets the a input component
  100618. */
  100619. get a(): NodeMaterialConnectionPoint;
  100620. protected _buildBlock(state: NodeMaterialBuildState): this;
  100621. }
  100622. }
  100623. declare module BABYLON {
  100624. /**
  100625. * Block used for the particle ramp gradient section
  100626. */
  100627. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100628. /**
  100629. * Create a new ParticleRampGradientBlock
  100630. * @param name defines the block name
  100631. */
  100632. constructor(name: string);
  100633. /**
  100634. * Gets the current class name
  100635. * @returns the class name
  100636. */
  100637. getClassName(): string;
  100638. /**
  100639. * Gets the color input component
  100640. */
  100641. get color(): NodeMaterialConnectionPoint;
  100642. /**
  100643. * Gets the rampColor output component
  100644. */
  100645. get rampColor(): NodeMaterialConnectionPoint;
  100646. /**
  100647. * Initialize the block and prepare the context for build
  100648. * @param state defines the state that will be used for the build
  100649. */
  100650. initialize(state: NodeMaterialBuildState): void;
  100651. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100652. }
  100653. }
  100654. declare module BABYLON {
  100655. /**
  100656. * Block used for the particle blend multiply section
  100657. */
  100658. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100659. /**
  100660. * Create a new ParticleBlendMultiplyBlock
  100661. * @param name defines the block name
  100662. */
  100663. constructor(name: string);
  100664. /**
  100665. * Gets the current class name
  100666. * @returns the class name
  100667. */
  100668. getClassName(): string;
  100669. /**
  100670. * Gets the color input component
  100671. */
  100672. get color(): NodeMaterialConnectionPoint;
  100673. /**
  100674. * Gets the alphaTexture input component
  100675. */
  100676. get alphaTexture(): NodeMaterialConnectionPoint;
  100677. /**
  100678. * Gets the alphaColor input component
  100679. */
  100680. get alphaColor(): NodeMaterialConnectionPoint;
  100681. /**
  100682. * Gets the blendColor output component
  100683. */
  100684. get blendColor(): NodeMaterialConnectionPoint;
  100685. /**
  100686. * Initialize the block and prepare the context for build
  100687. * @param state defines the state that will be used for the build
  100688. */
  100689. initialize(state: NodeMaterialBuildState): void;
  100690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100691. }
  100692. }
  100693. declare module BABYLON {
  100694. /**
  100695. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100696. */
  100697. export class VectorMergerBlock extends NodeMaterialBlock {
  100698. /**
  100699. * Create a new VectorMergerBlock
  100700. * @param name defines the block name
  100701. */
  100702. constructor(name: string);
  100703. /**
  100704. * Gets the current class name
  100705. * @returns the class name
  100706. */
  100707. getClassName(): string;
  100708. /**
  100709. * Gets the xyz component (input)
  100710. */
  100711. get xyzIn(): NodeMaterialConnectionPoint;
  100712. /**
  100713. * Gets the xy component (input)
  100714. */
  100715. get xyIn(): NodeMaterialConnectionPoint;
  100716. /**
  100717. * Gets the x component (input)
  100718. */
  100719. get x(): NodeMaterialConnectionPoint;
  100720. /**
  100721. * Gets the y component (input)
  100722. */
  100723. get y(): NodeMaterialConnectionPoint;
  100724. /**
  100725. * Gets the z component (input)
  100726. */
  100727. get z(): NodeMaterialConnectionPoint;
  100728. /**
  100729. * Gets the w component (input)
  100730. */
  100731. get w(): NodeMaterialConnectionPoint;
  100732. /**
  100733. * Gets the xyzw component (output)
  100734. */
  100735. get xyzw(): NodeMaterialConnectionPoint;
  100736. /**
  100737. * Gets the xyz component (output)
  100738. */
  100739. get xyzOut(): NodeMaterialConnectionPoint;
  100740. /**
  100741. * Gets the xy component (output)
  100742. */
  100743. get xyOut(): NodeMaterialConnectionPoint;
  100744. /**
  100745. * Gets the xy component (output)
  100746. * @deprecated Please use xyOut instead.
  100747. */
  100748. get xy(): NodeMaterialConnectionPoint;
  100749. /**
  100750. * Gets the xyz component (output)
  100751. * @deprecated Please use xyzOut instead.
  100752. */
  100753. get xyz(): NodeMaterialConnectionPoint;
  100754. protected _buildBlock(state: NodeMaterialBuildState): this;
  100755. }
  100756. }
  100757. declare module BABYLON {
  100758. /**
  100759. * Block used to remap a float from a range to a new one
  100760. */
  100761. export class RemapBlock extends NodeMaterialBlock {
  100762. /**
  100763. * Gets or sets the source range
  100764. */
  100765. sourceRange: Vector2;
  100766. /**
  100767. * Gets or sets the target range
  100768. */
  100769. targetRange: Vector2;
  100770. /**
  100771. * Creates a new RemapBlock
  100772. * @param name defines the block name
  100773. */
  100774. constructor(name: string);
  100775. /**
  100776. * Gets the current class name
  100777. * @returns the class name
  100778. */
  100779. getClassName(): string;
  100780. /**
  100781. * Gets the input component
  100782. */
  100783. get input(): NodeMaterialConnectionPoint;
  100784. /**
  100785. * Gets the source min input component
  100786. */
  100787. get sourceMin(): NodeMaterialConnectionPoint;
  100788. /**
  100789. * Gets the source max input component
  100790. */
  100791. get sourceMax(): NodeMaterialConnectionPoint;
  100792. /**
  100793. * Gets the target min input component
  100794. */
  100795. get targetMin(): NodeMaterialConnectionPoint;
  100796. /**
  100797. * Gets the target max input component
  100798. */
  100799. get targetMax(): NodeMaterialConnectionPoint;
  100800. /**
  100801. * Gets the output component
  100802. */
  100803. get output(): NodeMaterialConnectionPoint;
  100804. protected _buildBlock(state: NodeMaterialBuildState): this;
  100805. protected _dumpPropertiesCode(): string;
  100806. serialize(): any;
  100807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100808. }
  100809. }
  100810. declare module BABYLON {
  100811. /**
  100812. * Block used to multiply 2 values
  100813. */
  100814. export class MultiplyBlock extends NodeMaterialBlock {
  100815. /**
  100816. * Creates a new MultiplyBlock
  100817. * @param name defines the block name
  100818. */
  100819. constructor(name: string);
  100820. /**
  100821. * Gets the current class name
  100822. * @returns the class name
  100823. */
  100824. getClassName(): string;
  100825. /**
  100826. * Gets the left operand input component
  100827. */
  100828. get left(): NodeMaterialConnectionPoint;
  100829. /**
  100830. * Gets the right operand input component
  100831. */
  100832. get right(): NodeMaterialConnectionPoint;
  100833. /**
  100834. * Gets the output component
  100835. */
  100836. get output(): NodeMaterialConnectionPoint;
  100837. protected _buildBlock(state: NodeMaterialBuildState): this;
  100838. }
  100839. }
  100840. declare module BABYLON {
  100841. /**
  100842. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100843. */
  100844. export class ColorSplitterBlock extends NodeMaterialBlock {
  100845. /**
  100846. * Create a new ColorSplitterBlock
  100847. * @param name defines the block name
  100848. */
  100849. constructor(name: string);
  100850. /**
  100851. * Gets the current class name
  100852. * @returns the class name
  100853. */
  100854. getClassName(): string;
  100855. /**
  100856. * Gets the rgba component (input)
  100857. */
  100858. get rgba(): NodeMaterialConnectionPoint;
  100859. /**
  100860. * Gets the rgb component (input)
  100861. */
  100862. get rgbIn(): NodeMaterialConnectionPoint;
  100863. /**
  100864. * Gets the rgb component (output)
  100865. */
  100866. get rgbOut(): NodeMaterialConnectionPoint;
  100867. /**
  100868. * Gets the r component (output)
  100869. */
  100870. get r(): NodeMaterialConnectionPoint;
  100871. /**
  100872. * Gets the g component (output)
  100873. */
  100874. get g(): NodeMaterialConnectionPoint;
  100875. /**
  100876. * Gets the b component (output)
  100877. */
  100878. get b(): NodeMaterialConnectionPoint;
  100879. /**
  100880. * Gets the a component (output)
  100881. */
  100882. get a(): NodeMaterialConnectionPoint;
  100883. protected _inputRename(name: string): string;
  100884. protected _outputRename(name: string): string;
  100885. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100886. }
  100887. }
  100888. declare module BABYLON {
  100889. /**
  100890. * Interface used to configure the node material editor
  100891. */
  100892. export interface INodeMaterialEditorOptions {
  100893. /** Define the URl to load node editor script */
  100894. editorURL?: string;
  100895. }
  100896. /** @hidden */
  100897. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100898. NORMAL: boolean;
  100899. TANGENT: boolean;
  100900. UV1: boolean;
  100901. /** BONES */
  100902. NUM_BONE_INFLUENCERS: number;
  100903. BonesPerMesh: number;
  100904. BONETEXTURE: boolean;
  100905. /** MORPH TARGETS */
  100906. MORPHTARGETS: boolean;
  100907. MORPHTARGETS_NORMAL: boolean;
  100908. MORPHTARGETS_TANGENT: boolean;
  100909. MORPHTARGETS_UV: boolean;
  100910. NUM_MORPH_INFLUENCERS: number;
  100911. /** IMAGE PROCESSING */
  100912. IMAGEPROCESSING: boolean;
  100913. VIGNETTE: boolean;
  100914. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100915. VIGNETTEBLENDMODEOPAQUE: boolean;
  100916. TONEMAPPING: boolean;
  100917. TONEMAPPING_ACES: boolean;
  100918. CONTRAST: boolean;
  100919. EXPOSURE: boolean;
  100920. COLORCURVES: boolean;
  100921. COLORGRADING: boolean;
  100922. COLORGRADING3D: boolean;
  100923. SAMPLER3DGREENDEPTH: boolean;
  100924. SAMPLER3DBGRMAP: boolean;
  100925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100926. /** MISC. */
  100927. BUMPDIRECTUV: number;
  100928. constructor();
  100929. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100930. }
  100931. /**
  100932. * Class used to configure NodeMaterial
  100933. */
  100934. export interface INodeMaterialOptions {
  100935. /**
  100936. * Defines if blocks should emit comments
  100937. */
  100938. emitComments: boolean;
  100939. }
  100940. /**
  100941. * Class used to create a node based material built by assembling shader blocks
  100942. */
  100943. export class NodeMaterial extends PushMaterial {
  100944. private static _BuildIdGenerator;
  100945. private _options;
  100946. private _vertexCompilationState;
  100947. private _fragmentCompilationState;
  100948. private _sharedData;
  100949. private _buildId;
  100950. private _buildWasSuccessful;
  100951. private _cachedWorldViewMatrix;
  100952. private _cachedWorldViewProjectionMatrix;
  100953. private _optimizers;
  100954. private _animationFrame;
  100955. /** Define the Url to load node editor script */
  100956. static EditorURL: string;
  100957. /** Define the Url to load snippets */
  100958. static SnippetUrl: string;
  100959. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100960. static IgnoreTexturesAtLoadTime: boolean;
  100961. private BJSNODEMATERIALEDITOR;
  100962. /** Get the inspector from bundle or global */
  100963. private _getGlobalNodeMaterialEditor;
  100964. /**
  100965. * Snippet ID if the material was created from the snippet server
  100966. */
  100967. snippetId: string;
  100968. /**
  100969. * Gets or sets data used by visual editor
  100970. * @see https://nme.babylonjs.com
  100971. */
  100972. editorData: any;
  100973. /**
  100974. * 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)
  100975. */
  100976. ignoreAlpha: boolean;
  100977. /**
  100978. * Defines the maximum number of lights that can be used in the material
  100979. */
  100980. maxSimultaneousLights: number;
  100981. /**
  100982. * Observable raised when the material is built
  100983. */
  100984. onBuildObservable: Observable<NodeMaterial>;
  100985. /**
  100986. * Gets or sets the root nodes of the material vertex shader
  100987. */
  100988. _vertexOutputNodes: NodeMaterialBlock[];
  100989. /**
  100990. * Gets or sets the root nodes of the material fragment (pixel) shader
  100991. */
  100992. _fragmentOutputNodes: NodeMaterialBlock[];
  100993. /** Gets or sets options to control the node material overall behavior */
  100994. get options(): INodeMaterialOptions;
  100995. set options(options: INodeMaterialOptions);
  100996. /**
  100997. * Default configuration related to image processing available in the standard Material.
  100998. */
  100999. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101000. /**
  101001. * Gets the image processing configuration used either in this material.
  101002. */
  101003. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101004. /**
  101005. * Sets the Default image processing configuration used either in the this material.
  101006. *
  101007. * If sets to null, the scene one is in use.
  101008. */
  101009. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101010. /**
  101011. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101012. */
  101013. attachedBlocks: NodeMaterialBlock[];
  101014. /**
  101015. * Specifies the mode of the node material
  101016. * @hidden
  101017. */
  101018. _mode: NodeMaterialModes;
  101019. /**
  101020. * Gets the mode property
  101021. */
  101022. get mode(): NodeMaterialModes;
  101023. /**
  101024. * Create a new node based material
  101025. * @param name defines the material name
  101026. * @param scene defines the hosting scene
  101027. * @param options defines creation option
  101028. */
  101029. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101030. /**
  101031. * Gets the current class name of the material e.g. "NodeMaterial"
  101032. * @returns the class name
  101033. */
  101034. getClassName(): string;
  101035. /**
  101036. * Keep track of the image processing observer to allow dispose and replace.
  101037. */
  101038. private _imageProcessingObserver;
  101039. /**
  101040. * Attaches a new image processing configuration to the Standard Material.
  101041. * @param configuration
  101042. */
  101043. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101044. /**
  101045. * Get a block by its name
  101046. * @param name defines the name of the block to retrieve
  101047. * @returns the required block or null if not found
  101048. */
  101049. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101050. /**
  101051. * Get a block by its name
  101052. * @param predicate defines the predicate used to find the good candidate
  101053. * @returns the required block or null if not found
  101054. */
  101055. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101056. /**
  101057. * Get an input block by its name
  101058. * @param predicate defines the predicate used to find the good candidate
  101059. * @returns the required input block or null if not found
  101060. */
  101061. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101062. /**
  101063. * Gets the list of input blocks attached to this material
  101064. * @returns an array of InputBlocks
  101065. */
  101066. getInputBlocks(): InputBlock[];
  101067. /**
  101068. * Adds a new optimizer to the list of optimizers
  101069. * @param optimizer defines the optimizers to add
  101070. * @returns the current material
  101071. */
  101072. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101073. /**
  101074. * Remove an optimizer from the list of optimizers
  101075. * @param optimizer defines the optimizers to remove
  101076. * @returns the current material
  101077. */
  101078. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101079. /**
  101080. * Add a new block to the list of output nodes
  101081. * @param node defines the node to add
  101082. * @returns the current material
  101083. */
  101084. addOutputNode(node: NodeMaterialBlock): this;
  101085. /**
  101086. * Remove a block from the list of root nodes
  101087. * @param node defines the node to remove
  101088. * @returns the current material
  101089. */
  101090. removeOutputNode(node: NodeMaterialBlock): this;
  101091. private _addVertexOutputNode;
  101092. private _removeVertexOutputNode;
  101093. private _addFragmentOutputNode;
  101094. private _removeFragmentOutputNode;
  101095. /**
  101096. * Specifies if the material will require alpha blending
  101097. * @returns a boolean specifying if alpha blending is needed
  101098. */
  101099. needAlphaBlending(): boolean;
  101100. /**
  101101. * Specifies if this material should be rendered in alpha test mode
  101102. * @returns a boolean specifying if an alpha test is needed.
  101103. */
  101104. needAlphaTesting(): boolean;
  101105. private _initializeBlock;
  101106. private _resetDualBlocks;
  101107. /**
  101108. * Remove a block from the current node material
  101109. * @param block defines the block to remove
  101110. */
  101111. removeBlock(block: NodeMaterialBlock): void;
  101112. /**
  101113. * Build the material and generates the inner effect
  101114. * @param verbose defines if the build should log activity
  101115. */
  101116. build(verbose?: boolean): void;
  101117. /**
  101118. * Runs an otpimization phase to try to improve the shader code
  101119. */
  101120. optimize(): void;
  101121. private _prepareDefinesForAttributes;
  101122. /**
  101123. * Create a post process from the material
  101124. * @param camera The camera to apply the render pass to.
  101125. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101127. * @param engine The engine which the post process will be applied. (default: current engine)
  101128. * @param reusable If the post process can be reused on the same frame. (default: false)
  101129. * @param textureType Type of textures used when performing the post process. (default: 0)
  101130. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101131. * @returns the post process created
  101132. */
  101133. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  101134. /**
  101135. * Create the post process effect from the material
  101136. * @param postProcess The post process to create the effect for
  101137. */
  101138. createEffectForPostProcess(postProcess: PostProcess): void;
  101139. private _createEffectOrPostProcess;
  101140. private _createEffectForParticles;
  101141. /**
  101142. * Create the effect to be used as the custom effect for a particle system
  101143. * @param particleSystem Particle system to create the effect for
  101144. * @param onCompiled defines a function to call when the effect creation is successful
  101145. * @param onError defines a function to call when the effect creation has failed
  101146. */
  101147. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101148. private _processDefines;
  101149. /**
  101150. * Get if the submesh is ready to be used and all its information available.
  101151. * Child classes can use it to update shaders
  101152. * @param mesh defines the mesh to check
  101153. * @param subMesh defines which submesh to check
  101154. * @param useInstances specifies that instances should be used
  101155. * @returns a boolean indicating that the submesh is ready or not
  101156. */
  101157. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101158. /**
  101159. * Get a string representing the shaders built by the current node graph
  101160. */
  101161. get compiledShaders(): string;
  101162. /**
  101163. * Binds the world matrix to the material
  101164. * @param world defines the world transformation matrix
  101165. */
  101166. bindOnlyWorldMatrix(world: Matrix): void;
  101167. /**
  101168. * Binds the submesh to this material by preparing the effect and shader to draw
  101169. * @param world defines the world transformation matrix
  101170. * @param mesh defines the mesh containing the submesh
  101171. * @param subMesh defines the submesh to bind the material to
  101172. */
  101173. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101174. /**
  101175. * Gets the active textures from the material
  101176. * @returns an array of textures
  101177. */
  101178. getActiveTextures(): BaseTexture[];
  101179. /**
  101180. * Gets the list of texture blocks
  101181. * @returns an array of texture blocks
  101182. */
  101183. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101184. /**
  101185. * Specifies if the material uses a texture
  101186. * @param texture defines the texture to check against the material
  101187. * @returns a boolean specifying if the material uses the texture
  101188. */
  101189. hasTexture(texture: BaseTexture): boolean;
  101190. /**
  101191. * Disposes the material
  101192. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101193. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101194. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101195. */
  101196. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101197. /** Creates the node editor window. */
  101198. private _createNodeEditor;
  101199. /**
  101200. * Launch the node material editor
  101201. * @param config Define the configuration of the editor
  101202. * @return a promise fulfilled when the node editor is visible
  101203. */
  101204. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101205. /**
  101206. * Clear the current material
  101207. */
  101208. clear(): void;
  101209. /**
  101210. * Clear the current material and set it to a default state
  101211. */
  101212. setToDefault(): void;
  101213. /**
  101214. * Clear the current material and set it to a default state for post process
  101215. */
  101216. setToDefaultPostProcess(): void;
  101217. /**
  101218. * Clear the current material and set it to a default state for particle
  101219. */
  101220. setToDefaultParticle(): void;
  101221. /**
  101222. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101223. * @param url defines the url to load from
  101224. * @returns a promise that will fullfil when the material is fully loaded
  101225. */
  101226. loadAsync(url: string): Promise<void>;
  101227. private _gatherBlocks;
  101228. /**
  101229. * Generate a string containing the code declaration required to create an equivalent of this material
  101230. * @returns a string
  101231. */
  101232. generateCode(): string;
  101233. /**
  101234. * Serializes this material in a JSON representation
  101235. * @returns the serialized material object
  101236. */
  101237. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101238. private _restoreConnections;
  101239. /**
  101240. * Clear the current graph and load a new one from a serialization object
  101241. * @param source defines the JSON representation of the material
  101242. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101243. * @param merge defines whether or not the source must be merged or replace the current content
  101244. */
  101245. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101246. /**
  101247. * Makes a duplicate of the current material.
  101248. * @param name - name to use for the new material.
  101249. */
  101250. clone(name: string): NodeMaterial;
  101251. /**
  101252. * Creates a node material from parsed material data
  101253. * @param source defines the JSON representation of the material
  101254. * @param scene defines the hosting scene
  101255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101256. * @returns a new node material
  101257. */
  101258. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101259. /**
  101260. * Creates a node material from a snippet saved in a remote file
  101261. * @param name defines the name of the material to create
  101262. * @param url defines the url to load from
  101263. * @param scene defines the hosting scene
  101264. * @returns a promise that will resolve to the new node material
  101265. */
  101266. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101267. /**
  101268. * Creates a node material from a snippet saved by the node material editor
  101269. * @param snippetId defines the snippet to load
  101270. * @param scene defines the hosting scene
  101271. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101272. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101273. * @returns a promise that will resolve to the new node material
  101274. */
  101275. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101276. /**
  101277. * Creates a new node material set to default basic configuration
  101278. * @param name defines the name of the material
  101279. * @param scene defines the hosting scene
  101280. * @returns a new NodeMaterial
  101281. */
  101282. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101283. }
  101284. }
  101285. declare module BABYLON {
  101286. /**
  101287. * Size options for a post process
  101288. */
  101289. export type PostProcessOptions = {
  101290. width: number;
  101291. height: number;
  101292. };
  101293. /**
  101294. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101295. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101296. */
  101297. export class PostProcess {
  101298. /** Name of the PostProcess. */
  101299. name: string;
  101300. /**
  101301. * Gets or sets the unique id of the post process
  101302. */
  101303. uniqueId: number;
  101304. /**
  101305. * Width of the texture to apply the post process on
  101306. */
  101307. width: number;
  101308. /**
  101309. * Height of the texture to apply the post process on
  101310. */
  101311. height: number;
  101312. /**
  101313. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101314. */
  101315. nodeMaterialSource: Nullable<NodeMaterial>;
  101316. /**
  101317. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101318. * @hidden
  101319. */
  101320. _outputTexture: Nullable<InternalTexture>;
  101321. /**
  101322. * Sampling mode used by the shader
  101323. * See https://doc.babylonjs.com/classes/3.1/texture
  101324. */
  101325. renderTargetSamplingMode: number;
  101326. /**
  101327. * Clear color to use when screen clearing
  101328. */
  101329. clearColor: Color4;
  101330. /**
  101331. * If the buffer needs to be cleared before applying the post process. (default: true)
  101332. * Should be set to false if shader will overwrite all previous pixels.
  101333. */
  101334. autoClear: boolean;
  101335. /**
  101336. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101337. */
  101338. alphaMode: number;
  101339. /**
  101340. * Sets the setAlphaBlendConstants of the babylon engine
  101341. */
  101342. alphaConstants: Color4;
  101343. /**
  101344. * Animations to be used for the post processing
  101345. */
  101346. animations: Animation[];
  101347. /**
  101348. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101349. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101350. */
  101351. enablePixelPerfectMode: boolean;
  101352. /**
  101353. * Force the postprocess to be applied without taking in account viewport
  101354. */
  101355. forceFullscreenViewport: boolean;
  101356. /**
  101357. * List of inspectable custom properties (used by the Inspector)
  101358. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101359. */
  101360. inspectableCustomProperties: IInspectable[];
  101361. /**
  101362. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101363. *
  101364. * | Value | Type | Description |
  101365. * | ----- | ----------------------------------- | ----------- |
  101366. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101367. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101368. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101369. *
  101370. */
  101371. scaleMode: number;
  101372. /**
  101373. * Force textures to be a power of two (default: false)
  101374. */
  101375. alwaysForcePOT: boolean;
  101376. private _samples;
  101377. /**
  101378. * Number of sample textures (default: 1)
  101379. */
  101380. get samples(): number;
  101381. set samples(n: number);
  101382. /**
  101383. * Modify the scale of the post process to be the same as the viewport (default: false)
  101384. */
  101385. adaptScaleToCurrentViewport: boolean;
  101386. private _camera;
  101387. protected _scene: Scene;
  101388. private _engine;
  101389. private _options;
  101390. private _reusable;
  101391. private _textureType;
  101392. private _textureFormat;
  101393. /**
  101394. * Smart array of input and output textures for the post process.
  101395. * @hidden
  101396. */
  101397. _textures: SmartArray<InternalTexture>;
  101398. /**
  101399. * The index in _textures that corresponds to the output texture.
  101400. * @hidden
  101401. */
  101402. _currentRenderTextureInd: number;
  101403. private _effect;
  101404. private _samplers;
  101405. private _fragmentUrl;
  101406. private _vertexUrl;
  101407. private _parameters;
  101408. private _scaleRatio;
  101409. protected _indexParameters: any;
  101410. private _shareOutputWithPostProcess;
  101411. private _texelSize;
  101412. private _forcedOutputTexture;
  101413. /**
  101414. * Returns the fragment url or shader name used in the post process.
  101415. * @returns the fragment url or name in the shader store.
  101416. */
  101417. getEffectName(): string;
  101418. /**
  101419. * An event triggered when the postprocess is activated.
  101420. */
  101421. onActivateObservable: Observable<Camera>;
  101422. private _onActivateObserver;
  101423. /**
  101424. * A function that is added to the onActivateObservable
  101425. */
  101426. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101427. /**
  101428. * An event triggered when the postprocess changes its size.
  101429. */
  101430. onSizeChangedObservable: Observable<PostProcess>;
  101431. private _onSizeChangedObserver;
  101432. /**
  101433. * A function that is added to the onSizeChangedObservable
  101434. */
  101435. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  101436. /**
  101437. * An event triggered when the postprocess applies its effect.
  101438. */
  101439. onApplyObservable: Observable<Effect>;
  101440. private _onApplyObserver;
  101441. /**
  101442. * A function that is added to the onApplyObservable
  101443. */
  101444. set onApply(callback: (effect: Effect) => void);
  101445. /**
  101446. * An event triggered before rendering the postprocess
  101447. */
  101448. onBeforeRenderObservable: Observable<Effect>;
  101449. private _onBeforeRenderObserver;
  101450. /**
  101451. * A function that is added to the onBeforeRenderObservable
  101452. */
  101453. set onBeforeRender(callback: (effect: Effect) => void);
  101454. /**
  101455. * An event triggered after rendering the postprocess
  101456. */
  101457. onAfterRenderObservable: Observable<Effect>;
  101458. private _onAfterRenderObserver;
  101459. /**
  101460. * A function that is added to the onAfterRenderObservable
  101461. */
  101462. set onAfterRender(callback: (efect: Effect) => void);
  101463. /**
  101464. * 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
  101465. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  101466. */
  101467. get inputTexture(): InternalTexture;
  101468. set inputTexture(value: InternalTexture);
  101469. /**
  101470. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  101471. * the only way to unset it is to use this function to restore its internal state
  101472. */
  101473. restoreDefaultInputTexture(): void;
  101474. /**
  101475. * Gets the camera which post process is applied to.
  101476. * @returns The camera the post process is applied to.
  101477. */
  101478. getCamera(): Camera;
  101479. /**
  101480. * Gets the texel size of the postprocess.
  101481. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101482. */
  101483. get texelSize(): Vector2;
  101484. /**
  101485. * Creates a new instance PostProcess
  101486. * @param name The name of the PostProcess.
  101487. * @param fragmentUrl The url of the fragment shader to be used.
  101488. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101489. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101490. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101491. * @param camera The camera to apply the render pass to.
  101492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101493. * @param engine The engine which the post process will be applied. (default: current engine)
  101494. * @param reusable If the post process can be reused on the same frame. (default: false)
  101495. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101496. * @param textureType Type of textures used when performing the post process. (default: 0)
  101497. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101498. * @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
  101499. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101500. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101501. */
  101502. constructor(
  101503. /** Name of the PostProcess. */
  101504. 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);
  101505. /**
  101506. * Gets a string idenfifying the name of the class
  101507. * @returns "PostProcess" string
  101508. */
  101509. getClassName(): string;
  101510. /**
  101511. * Gets the engine which this post process belongs to.
  101512. * @returns The engine the post process was enabled with.
  101513. */
  101514. getEngine(): Engine;
  101515. /**
  101516. * The effect that is created when initializing the post process.
  101517. * @returns The created effect corresponding the the postprocess.
  101518. */
  101519. getEffect(): Effect;
  101520. /**
  101521. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101522. * @param postProcess The post process to share the output with.
  101523. * @returns This post process.
  101524. */
  101525. shareOutputWith(postProcess: PostProcess): PostProcess;
  101526. /**
  101527. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101528. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101529. */
  101530. useOwnOutput(): void;
  101531. /**
  101532. * Updates the effect with the current post process compile time values and recompiles the shader.
  101533. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101534. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101535. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101536. * @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
  101537. * @param onCompiled Called when the shader has been compiled.
  101538. * @param onError Called if there is an error when compiling a shader.
  101539. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101540. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101541. */
  101542. 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;
  101543. /**
  101544. * The post process is reusable if it can be used multiple times within one frame.
  101545. * @returns If the post process is reusable
  101546. */
  101547. isReusable(): boolean;
  101548. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101549. markTextureDirty(): void;
  101550. /**
  101551. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101552. * 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.
  101553. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101554. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101555. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101556. * @returns The target texture that was bound to be written to.
  101557. */
  101558. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101559. /**
  101560. * If the post process is supported.
  101561. */
  101562. get isSupported(): boolean;
  101563. /**
  101564. * The aspect ratio of the output texture.
  101565. */
  101566. get aspectRatio(): number;
  101567. /**
  101568. * Get a value indicating if the post-process is ready to be used
  101569. * @returns true if the post-process is ready (shader is compiled)
  101570. */
  101571. isReady(): boolean;
  101572. /**
  101573. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101574. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101575. */
  101576. apply(): Nullable<Effect>;
  101577. private _disposeTextures;
  101578. /**
  101579. * Disposes the post process.
  101580. * @param camera The camera to dispose the post process on.
  101581. */
  101582. dispose(camera?: Camera): void;
  101583. }
  101584. }
  101585. declare module BABYLON {
  101586. /** @hidden */
  101587. export var kernelBlurVaryingDeclaration: {
  101588. name: string;
  101589. shader: string;
  101590. };
  101591. }
  101592. declare module BABYLON {
  101593. /** @hidden */
  101594. export var kernelBlurFragment: {
  101595. name: string;
  101596. shader: string;
  101597. };
  101598. }
  101599. declare module BABYLON {
  101600. /** @hidden */
  101601. export var kernelBlurFragment2: {
  101602. name: string;
  101603. shader: string;
  101604. };
  101605. }
  101606. declare module BABYLON {
  101607. /** @hidden */
  101608. export var kernelBlurPixelShader: {
  101609. name: string;
  101610. shader: string;
  101611. };
  101612. }
  101613. declare module BABYLON {
  101614. /** @hidden */
  101615. export var kernelBlurVertex: {
  101616. name: string;
  101617. shader: string;
  101618. };
  101619. }
  101620. declare module BABYLON {
  101621. /** @hidden */
  101622. export var kernelBlurVertexShader: {
  101623. name: string;
  101624. shader: string;
  101625. };
  101626. }
  101627. declare module BABYLON {
  101628. /**
  101629. * The Blur Post Process which blurs an image based on a kernel and direction.
  101630. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101631. */
  101632. export class BlurPostProcess extends PostProcess {
  101633. /** The direction in which to blur the image. */
  101634. direction: Vector2;
  101635. private blockCompilation;
  101636. protected _kernel: number;
  101637. protected _idealKernel: number;
  101638. protected _packedFloat: boolean;
  101639. private _staticDefines;
  101640. /**
  101641. * Sets the length in pixels of the blur sample region
  101642. */
  101643. set kernel(v: number);
  101644. /**
  101645. * Gets the length in pixels of the blur sample region
  101646. */
  101647. get kernel(): number;
  101648. /**
  101649. * Sets wether or not the blur needs to unpack/repack floats
  101650. */
  101651. set packedFloat(v: boolean);
  101652. /**
  101653. * Gets wether or not the blur is unpacking/repacking floats
  101654. */
  101655. get packedFloat(): boolean;
  101656. /**
  101657. * Creates a new instance BlurPostProcess
  101658. * @param name The name of the effect.
  101659. * @param direction The direction in which to blur the image.
  101660. * @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.
  101661. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101662. * @param camera The camera to apply the render pass to.
  101663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101664. * @param engine The engine which the post process will be applied. (default: current engine)
  101665. * @param reusable If the post process can be reused on the same frame. (default: false)
  101666. * @param textureType Type of textures used when performing the post process. (default: 0)
  101667. * @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)
  101668. */
  101669. constructor(name: string,
  101670. /** The direction in which to blur the image. */
  101671. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101672. /**
  101673. * Updates the effect with the current post process compile time values and recompiles the shader.
  101674. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101675. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101676. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101677. * @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
  101678. * @param onCompiled Called when the shader has been compiled.
  101679. * @param onError Called if there is an error when compiling a shader.
  101680. */
  101681. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101682. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101683. /**
  101684. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101685. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101686. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101687. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101688. * The gaps between physical kernels are compensated for in the weighting of the samples
  101689. * @param idealKernel Ideal blur kernel.
  101690. * @return Nearest best kernel.
  101691. */
  101692. protected _nearestBestKernel(idealKernel: number): number;
  101693. /**
  101694. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101695. * @param x The point on the Gaussian distribution to sample.
  101696. * @return the value of the Gaussian function at x.
  101697. */
  101698. protected _gaussianWeight(x: number): number;
  101699. /**
  101700. * Generates a string that can be used as a floating point number in GLSL.
  101701. * @param x Value to print.
  101702. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101703. * @return GLSL float string.
  101704. */
  101705. protected _glslFloat(x: number, decimalFigures?: number): string;
  101706. }
  101707. }
  101708. declare module BABYLON {
  101709. /**
  101710. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101711. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101712. * You can then easily use it as a reflectionTexture on a flat surface.
  101713. * In case the surface is not a plane, please consider relying on reflection probes.
  101714. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101715. */
  101716. export class MirrorTexture extends RenderTargetTexture {
  101717. private scene;
  101718. /**
  101719. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101720. * 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.
  101721. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101722. */
  101723. mirrorPlane: Plane;
  101724. /**
  101725. * Define the blur ratio used to blur the reflection if needed.
  101726. */
  101727. set blurRatio(value: number);
  101728. get blurRatio(): number;
  101729. /**
  101730. * Define the adaptive blur kernel used to blur the reflection if needed.
  101731. * This will autocompute the closest best match for the `blurKernel`
  101732. */
  101733. set adaptiveBlurKernel(value: number);
  101734. /**
  101735. * Define the blur kernel used to blur the reflection if needed.
  101736. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101737. */
  101738. set blurKernel(value: number);
  101739. /**
  101740. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101741. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101742. */
  101743. set blurKernelX(value: number);
  101744. get blurKernelX(): number;
  101745. /**
  101746. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101747. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101748. */
  101749. set blurKernelY(value: number);
  101750. get blurKernelY(): number;
  101751. private _autoComputeBlurKernel;
  101752. protected _onRatioRescale(): void;
  101753. private _updateGammaSpace;
  101754. private _imageProcessingConfigChangeObserver;
  101755. private _transformMatrix;
  101756. private _mirrorMatrix;
  101757. private _savedViewMatrix;
  101758. private _blurX;
  101759. private _blurY;
  101760. private _adaptiveBlurKernel;
  101761. private _blurKernelX;
  101762. private _blurKernelY;
  101763. private _blurRatio;
  101764. /**
  101765. * Instantiates a Mirror Texture.
  101766. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101767. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101768. * You can then easily use it as a reflectionTexture on a flat surface.
  101769. * In case the surface is not a plane, please consider relying on reflection probes.
  101770. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101771. * @param name
  101772. * @param size
  101773. * @param scene
  101774. * @param generateMipMaps
  101775. * @param type
  101776. * @param samplingMode
  101777. * @param generateDepthBuffer
  101778. */
  101779. constructor(name: string, size: number | {
  101780. width: number;
  101781. height: number;
  101782. } | {
  101783. ratio: number;
  101784. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101785. private _preparePostProcesses;
  101786. /**
  101787. * Clone the mirror texture.
  101788. * @returns the cloned texture
  101789. */
  101790. clone(): MirrorTexture;
  101791. /**
  101792. * Serialize the texture to a JSON representation you could use in Parse later on
  101793. * @returns the serialized JSON representation
  101794. */
  101795. serialize(): any;
  101796. /**
  101797. * Dispose the texture and release its associated resources.
  101798. */
  101799. dispose(): void;
  101800. }
  101801. }
  101802. declare module BABYLON {
  101803. /**
  101804. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101805. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101806. */
  101807. export class Texture extends BaseTexture {
  101808. /**
  101809. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101810. */
  101811. static SerializeBuffers: boolean;
  101812. /** @hidden */
  101813. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101814. /** @hidden */
  101815. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101816. /** @hidden */
  101817. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101818. /** nearest is mag = nearest and min = nearest and mip = linear */
  101819. static readonly NEAREST_SAMPLINGMODE: number;
  101820. /** nearest is mag = nearest and min = nearest and mip = linear */
  101821. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101822. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101823. static readonly BILINEAR_SAMPLINGMODE: number;
  101824. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101825. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101826. /** Trilinear is mag = linear and min = linear and mip = linear */
  101827. static readonly TRILINEAR_SAMPLINGMODE: number;
  101828. /** Trilinear is mag = linear and min = linear and mip = linear */
  101829. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101830. /** mag = nearest and min = nearest and mip = nearest */
  101831. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101832. /** mag = nearest and min = linear and mip = nearest */
  101833. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101834. /** mag = nearest and min = linear and mip = linear */
  101835. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101836. /** mag = nearest and min = linear and mip = none */
  101837. static readonly NEAREST_LINEAR: number;
  101838. /** mag = nearest and min = nearest and mip = none */
  101839. static readonly NEAREST_NEAREST: number;
  101840. /** mag = linear and min = nearest and mip = nearest */
  101841. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101842. /** mag = linear and min = nearest and mip = linear */
  101843. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101844. /** mag = linear and min = linear and mip = none */
  101845. static readonly LINEAR_LINEAR: number;
  101846. /** mag = linear and min = nearest and mip = none */
  101847. static readonly LINEAR_NEAREST: number;
  101848. /** Explicit coordinates mode */
  101849. static readonly EXPLICIT_MODE: number;
  101850. /** Spherical coordinates mode */
  101851. static readonly SPHERICAL_MODE: number;
  101852. /** Planar coordinates mode */
  101853. static readonly PLANAR_MODE: number;
  101854. /** Cubic coordinates mode */
  101855. static readonly CUBIC_MODE: number;
  101856. /** Projection coordinates mode */
  101857. static readonly PROJECTION_MODE: number;
  101858. /** Inverse Cubic coordinates mode */
  101859. static readonly SKYBOX_MODE: number;
  101860. /** Inverse Cubic coordinates mode */
  101861. static readonly INVCUBIC_MODE: number;
  101862. /** Equirectangular coordinates mode */
  101863. static readonly EQUIRECTANGULAR_MODE: number;
  101864. /** Equirectangular Fixed coordinates mode */
  101865. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101866. /** Equirectangular Fixed Mirrored coordinates mode */
  101867. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101868. /** Texture is not repeating outside of 0..1 UVs */
  101869. static readonly CLAMP_ADDRESSMODE: number;
  101870. /** Texture is repeating outside of 0..1 UVs */
  101871. static readonly WRAP_ADDRESSMODE: number;
  101872. /** Texture is repeating and mirrored */
  101873. static readonly MIRROR_ADDRESSMODE: number;
  101874. /**
  101875. * 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
  101876. */
  101877. static UseSerializedUrlIfAny: boolean;
  101878. /**
  101879. * Define the url of the texture.
  101880. */
  101881. url: Nullable<string>;
  101882. /**
  101883. * Define an offset on the texture to offset the u coordinates of the UVs
  101884. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101885. */
  101886. uOffset: number;
  101887. /**
  101888. * Define an offset on the texture to offset the v coordinates of the UVs
  101889. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101890. */
  101891. vOffset: number;
  101892. /**
  101893. * Define an offset on the texture to scale the u coordinates of the UVs
  101894. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101895. */
  101896. uScale: number;
  101897. /**
  101898. * Define an offset on the texture to scale the v coordinates of the UVs
  101899. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101900. */
  101901. vScale: number;
  101902. /**
  101903. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101904. * @see https://doc.babylonjs.com/how_to/more_materials
  101905. */
  101906. uAng: number;
  101907. /**
  101908. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101909. * @see https://doc.babylonjs.com/how_to/more_materials
  101910. */
  101911. vAng: number;
  101912. /**
  101913. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101914. * @see https://doc.babylonjs.com/how_to/more_materials
  101915. */
  101916. wAng: number;
  101917. /**
  101918. * Defines the center of rotation (U)
  101919. */
  101920. uRotationCenter: number;
  101921. /**
  101922. * Defines the center of rotation (V)
  101923. */
  101924. vRotationCenter: number;
  101925. /**
  101926. * Defines the center of rotation (W)
  101927. */
  101928. wRotationCenter: number;
  101929. /**
  101930. * Are mip maps generated for this texture or not.
  101931. */
  101932. get noMipmap(): boolean;
  101933. /**
  101934. * List of inspectable custom properties (used by the Inspector)
  101935. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101936. */
  101937. inspectableCustomProperties: Nullable<IInspectable[]>;
  101938. private _noMipmap;
  101939. /** @hidden */
  101940. _invertY: boolean;
  101941. private _rowGenerationMatrix;
  101942. private _cachedTextureMatrix;
  101943. private _projectionModeMatrix;
  101944. private _t0;
  101945. private _t1;
  101946. private _t2;
  101947. private _cachedUOffset;
  101948. private _cachedVOffset;
  101949. private _cachedUScale;
  101950. private _cachedVScale;
  101951. private _cachedUAng;
  101952. private _cachedVAng;
  101953. private _cachedWAng;
  101954. private _cachedProjectionMatrixId;
  101955. private _cachedCoordinatesMode;
  101956. /** @hidden */
  101957. protected _initialSamplingMode: number;
  101958. /** @hidden */
  101959. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101960. private _deleteBuffer;
  101961. protected _format: Nullable<number>;
  101962. private _delayedOnLoad;
  101963. private _delayedOnError;
  101964. private _mimeType?;
  101965. /**
  101966. * Observable triggered once the texture has been loaded.
  101967. */
  101968. onLoadObservable: Observable<Texture>;
  101969. protected _isBlocking: boolean;
  101970. /**
  101971. * Is the texture preventing material to render while loading.
  101972. * If false, a default texture will be used instead of the loading one during the preparation step.
  101973. */
  101974. set isBlocking(value: boolean);
  101975. get isBlocking(): boolean;
  101976. /**
  101977. * Get the current sampling mode associated with the texture.
  101978. */
  101979. get samplingMode(): number;
  101980. /**
  101981. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101982. */
  101983. get invertY(): boolean;
  101984. /**
  101985. * Instantiates a new texture.
  101986. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101987. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101988. * @param url defines the url of the picture to load as a texture
  101989. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101990. * @param noMipmap defines if the texture will require mip maps or not
  101991. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101992. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101993. * @param onLoad defines a callback triggered when the texture has been loaded
  101994. * @param onError defines a callback triggered when an error occurred during the loading session
  101995. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101996. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101997. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101998. * @param mimeType defines an optional mime type information
  101999. */
  102000. 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);
  102001. /**
  102002. * Update the url (and optional buffer) of this texture if url was null during construction.
  102003. * @param url the url of the texture
  102004. * @param buffer the buffer of the texture (defaults to null)
  102005. * @param onLoad callback called when the texture is loaded (defaults to null)
  102006. */
  102007. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102008. /**
  102009. * Finish the loading sequence of a texture flagged as delayed load.
  102010. * @hidden
  102011. */
  102012. delayLoad(): void;
  102013. private _prepareRowForTextureGeneration;
  102014. /**
  102015. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102016. * @returns the transform matrix of the texture.
  102017. */
  102018. getTextureMatrix(uBase?: number): Matrix;
  102019. /**
  102020. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102021. * @returns The reflection texture transform
  102022. */
  102023. getReflectionTextureMatrix(): Matrix;
  102024. /**
  102025. * Clones the texture.
  102026. * @returns the cloned texture
  102027. */
  102028. clone(): Texture;
  102029. /**
  102030. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102031. * @returns The JSON representation of the texture
  102032. */
  102033. serialize(): any;
  102034. /**
  102035. * Get the current class name of the texture useful for serialization or dynamic coding.
  102036. * @returns "Texture"
  102037. */
  102038. getClassName(): string;
  102039. /**
  102040. * Dispose the texture and release its associated resources.
  102041. */
  102042. dispose(): void;
  102043. /**
  102044. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102045. * @param parsedTexture Define the JSON representation of the texture
  102046. * @param scene Define the scene the parsed texture should be instantiated in
  102047. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102048. * @returns The parsed texture if successful
  102049. */
  102050. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102051. /**
  102052. * Creates a texture from its base 64 representation.
  102053. * @param data Define the base64 payload without the data: prefix
  102054. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102055. * @param scene Define the scene the texture should belong to
  102056. * @param noMipmap Forces the texture to not create mip map information if true
  102057. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102058. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102059. * @param onLoad define a callback triggered when the texture has been loaded
  102060. * @param onError define a callback triggered when an error occurred during the loading session
  102061. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102062. * @returns the created texture
  102063. */
  102064. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  102065. /**
  102066. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  102067. * @param data Define the base64 payload without the data: prefix
  102068. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102069. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  102070. * @param scene Define the scene the texture should belong to
  102071. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  102072. * @param noMipmap Forces the texture to not create mip map information if true
  102073. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102074. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102075. * @param onLoad define a callback triggered when the texture has been loaded
  102076. * @param onError define a callback triggered when an error occurred during the loading session
  102077. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102078. * @returns the created texture
  102079. */
  102080. 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;
  102081. }
  102082. }
  102083. declare module BABYLON {
  102084. /**
  102085. * PostProcessManager is used to manage one or more post processes or post process pipelines
  102086. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102087. */
  102088. export class PostProcessManager {
  102089. private _scene;
  102090. private _indexBuffer;
  102091. private _vertexBuffers;
  102092. /**
  102093. * Creates a new instance PostProcess
  102094. * @param scene The scene that the post process is associated with.
  102095. */
  102096. constructor(scene: Scene);
  102097. private _prepareBuffers;
  102098. private _buildIndexBuffer;
  102099. /**
  102100. * Rebuilds the vertex buffers of the manager.
  102101. * @hidden
  102102. */
  102103. _rebuild(): void;
  102104. /**
  102105. * Prepares a frame to be run through a post process.
  102106. * @param sourceTexture The input texture to the post procesess. (default: null)
  102107. * @param postProcesses An array of post processes to be run. (default: null)
  102108. * @returns True if the post processes were able to be run.
  102109. * @hidden
  102110. */
  102111. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  102112. /**
  102113. * Manually render a set of post processes to a texture.
  102114. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  102115. * @param postProcesses An array of post processes to be run.
  102116. * @param targetTexture The target texture to render to.
  102117. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  102118. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  102119. * @param lodLevel defines which lod of the texture to render to
  102120. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  102121. */
  102122. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  102123. /**
  102124. * Finalize the result of the output of the postprocesses.
  102125. * @param doNotPresent If true the result will not be displayed to the screen.
  102126. * @param targetTexture The target texture to render to.
  102127. * @param faceIndex The index of the face to bind the target texture to.
  102128. * @param postProcesses The array of post processes to render.
  102129. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  102130. * @hidden
  102131. */
  102132. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  102133. /**
  102134. * Disposes of the post process manager.
  102135. */
  102136. dispose(): void;
  102137. }
  102138. }
  102139. declare module BABYLON {
  102140. /**
  102141. * This Helps creating a texture that will be created from a camera in your scene.
  102142. * It is basically a dynamic texture that could be used to create special effects for instance.
  102143. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  102144. */
  102145. export class RenderTargetTexture extends Texture {
  102146. isCube: boolean;
  102147. /**
  102148. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  102149. */
  102150. static readonly REFRESHRATE_RENDER_ONCE: number;
  102151. /**
  102152. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  102153. */
  102154. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  102155. /**
  102156. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  102157. * the central point of your effect and can save a lot of performances.
  102158. */
  102159. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  102160. /**
  102161. * Use this predicate to dynamically define the list of mesh you want to render.
  102162. * If set, the renderList property will be overwritten.
  102163. */
  102164. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  102165. private _renderList;
  102166. /**
  102167. * Use this list to define the list of mesh you want to render.
  102168. */
  102169. get renderList(): Nullable<Array<AbstractMesh>>;
  102170. set renderList(value: Nullable<Array<AbstractMesh>>);
  102171. /**
  102172. * Use this function to overload the renderList array at rendering time.
  102173. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  102174. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  102175. * the cube (if the RTT is a cube, else layerOrFace=0).
  102176. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102177. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102178. * hold dummy elements!
  102179. */
  102180. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102181. private _hookArray;
  102182. /**
  102183. * Define if particles should be rendered in your texture.
  102184. */
  102185. renderParticles: boolean;
  102186. /**
  102187. * Define if sprites should be rendered in your texture.
  102188. */
  102189. renderSprites: boolean;
  102190. /**
  102191. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102192. */
  102193. coordinatesMode: number;
  102194. /**
  102195. * Define the camera used to render the texture.
  102196. */
  102197. activeCamera: Nullable<Camera>;
  102198. /**
  102199. * Override the mesh isReady function with your own one.
  102200. */
  102201. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102202. /**
  102203. * Override the render function of the texture with your own one.
  102204. */
  102205. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102206. /**
  102207. * Define if camera post processes should be use while rendering the texture.
  102208. */
  102209. useCameraPostProcesses: boolean;
  102210. /**
  102211. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102212. */
  102213. ignoreCameraViewport: boolean;
  102214. private _postProcessManager;
  102215. private _postProcesses;
  102216. private _resizeObserver;
  102217. /**
  102218. * An event triggered when the texture is unbind.
  102219. */
  102220. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102221. /**
  102222. * An event triggered when the texture is unbind.
  102223. */
  102224. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102225. private _onAfterUnbindObserver;
  102226. /**
  102227. * Set a after unbind callback in the texture.
  102228. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102229. */
  102230. set onAfterUnbind(callback: () => void);
  102231. /**
  102232. * An event triggered before rendering the texture
  102233. */
  102234. onBeforeRenderObservable: Observable<number>;
  102235. private _onBeforeRenderObserver;
  102236. /**
  102237. * Set a before render callback in the texture.
  102238. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102239. */
  102240. set onBeforeRender(callback: (faceIndex: number) => void);
  102241. /**
  102242. * An event triggered after rendering the texture
  102243. */
  102244. onAfterRenderObservable: Observable<number>;
  102245. private _onAfterRenderObserver;
  102246. /**
  102247. * Set a after render callback in the texture.
  102248. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102249. */
  102250. set onAfterRender(callback: (faceIndex: number) => void);
  102251. /**
  102252. * An event triggered after the texture clear
  102253. */
  102254. onClearObservable: Observable<Engine>;
  102255. private _onClearObserver;
  102256. /**
  102257. * Set a clear callback in the texture.
  102258. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102259. */
  102260. set onClear(callback: (Engine: Engine) => void);
  102261. /**
  102262. * An event triggered when the texture is resized.
  102263. */
  102264. onResizeObservable: Observable<RenderTargetTexture>;
  102265. /**
  102266. * Define the clear color of the Render Target if it should be different from the scene.
  102267. */
  102268. clearColor: Color4;
  102269. protected _size: number | {
  102270. width: number;
  102271. height: number;
  102272. layers?: number;
  102273. };
  102274. protected _initialSizeParameter: number | {
  102275. width: number;
  102276. height: number;
  102277. } | {
  102278. ratio: number;
  102279. };
  102280. protected _sizeRatio: Nullable<number>;
  102281. /** @hidden */
  102282. _generateMipMaps: boolean;
  102283. protected _renderingManager: RenderingManager;
  102284. /** @hidden */
  102285. _waitingRenderList: string[];
  102286. protected _doNotChangeAspectRatio: boolean;
  102287. protected _currentRefreshId: number;
  102288. protected _refreshRate: number;
  102289. protected _textureMatrix: Matrix;
  102290. protected _samples: number;
  102291. protected _renderTargetOptions: RenderTargetCreationOptions;
  102292. /**
  102293. * Gets render target creation options that were used.
  102294. */
  102295. get renderTargetOptions(): RenderTargetCreationOptions;
  102296. protected _onRatioRescale(): void;
  102297. /**
  102298. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102299. * It must define where the camera used to render the texture is set
  102300. */
  102301. boundingBoxPosition: Vector3;
  102302. private _boundingBoxSize;
  102303. /**
  102304. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102305. * When defined, the cubemap will switch to local mode
  102306. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102307. * @example https://www.babylonjs-playground.com/#RNASML
  102308. */
  102309. set boundingBoxSize(value: Vector3);
  102310. get boundingBoxSize(): Vector3;
  102311. /**
  102312. * In case the RTT has been created with a depth texture, get the associated
  102313. * depth texture.
  102314. * Otherwise, return null.
  102315. */
  102316. get depthStencilTexture(): Nullable<InternalTexture>;
  102317. /**
  102318. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102319. * or used a shadow, depth texture...
  102320. * @param name The friendly name of the texture
  102321. * @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)
  102322. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102323. * @param generateMipMaps True if mip maps need to be generated after render.
  102324. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102325. * @param type The type of the buffer in the RTT (int, half float, float...)
  102326. * @param isCube True if a cube texture needs to be created
  102327. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102328. * @param generateDepthBuffer True to generate a depth buffer
  102329. * @param generateStencilBuffer True to generate a stencil buffer
  102330. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102331. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102332. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102333. */
  102334. constructor(name: string, size: number | {
  102335. width: number;
  102336. height: number;
  102337. layers?: number;
  102338. } | {
  102339. ratio: number;
  102340. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102341. /**
  102342. * Creates a depth stencil texture.
  102343. * This is only available in WebGL 2 or with the depth texture extension available.
  102344. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102345. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102346. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102347. */
  102348. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102349. private _processSizeParameter;
  102350. /**
  102351. * Define the number of samples to use in case of MSAA.
  102352. * It defaults to one meaning no MSAA has been enabled.
  102353. */
  102354. get samples(): number;
  102355. set samples(value: number);
  102356. /**
  102357. * Resets the refresh counter of the texture and start bak from scratch.
  102358. * Could be useful to regenerate the texture if it is setup to render only once.
  102359. */
  102360. resetRefreshCounter(): void;
  102361. /**
  102362. * Define the refresh rate of the texture or the rendering frequency.
  102363. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102364. */
  102365. get refreshRate(): number;
  102366. set refreshRate(value: number);
  102367. /**
  102368. * Adds a post process to the render target rendering passes.
  102369. * @param postProcess define the post process to add
  102370. */
  102371. addPostProcess(postProcess: PostProcess): void;
  102372. /**
  102373. * Clear all the post processes attached to the render target
  102374. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102375. */
  102376. clearPostProcesses(dispose?: boolean): void;
  102377. /**
  102378. * Remove one of the post process from the list of attached post processes to the texture
  102379. * @param postProcess define the post process to remove from the list
  102380. */
  102381. removePostProcess(postProcess: PostProcess): void;
  102382. /** @hidden */
  102383. _shouldRender(): boolean;
  102384. /**
  102385. * Gets the actual render size of the texture.
  102386. * @returns the width of the render size
  102387. */
  102388. getRenderSize(): number;
  102389. /**
  102390. * Gets the actual render width of the texture.
  102391. * @returns the width of the render size
  102392. */
  102393. getRenderWidth(): number;
  102394. /**
  102395. * Gets the actual render height of the texture.
  102396. * @returns the height of the render size
  102397. */
  102398. getRenderHeight(): number;
  102399. /**
  102400. * Gets the actual number of layers of the texture.
  102401. * @returns the number of layers
  102402. */
  102403. getRenderLayers(): number;
  102404. /**
  102405. * Get if the texture can be rescaled or not.
  102406. */
  102407. get canRescale(): boolean;
  102408. /**
  102409. * Resize the texture using a ratio.
  102410. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102411. */
  102412. scale(ratio: number): void;
  102413. /**
  102414. * Get the texture reflection matrix used to rotate/transform the reflection.
  102415. * @returns the reflection matrix
  102416. */
  102417. getReflectionTextureMatrix(): Matrix;
  102418. /**
  102419. * Resize the texture to a new desired size.
  102420. * Be carrefull as it will recreate all the data in the new texture.
  102421. * @param size Define the new size. It can be:
  102422. * - a number for squared texture,
  102423. * - an object containing { width: number, height: number }
  102424. * - or an object containing a ratio { ratio: number }
  102425. */
  102426. resize(size: number | {
  102427. width: number;
  102428. height: number;
  102429. } | {
  102430. ratio: number;
  102431. }): void;
  102432. private _defaultRenderListPrepared;
  102433. /**
  102434. * Renders all the objects from the render list into the texture.
  102435. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  102436. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  102437. */
  102438. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  102439. private _bestReflectionRenderTargetDimension;
  102440. private _prepareRenderingManager;
  102441. /**
  102442. * @hidden
  102443. * @param faceIndex face index to bind to if this is a cubetexture
  102444. * @param layer defines the index of the texture to bind in the array
  102445. */
  102446. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  102447. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102448. private renderToTarget;
  102449. /**
  102450. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102451. * This allowed control for front to back rendering or reversly depending of the special needs.
  102452. *
  102453. * @param renderingGroupId The rendering group id corresponding to its index
  102454. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102455. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102456. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102457. */
  102458. 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;
  102459. /**
  102460. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102461. *
  102462. * @param renderingGroupId The rendering group id corresponding to its index
  102463. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102464. */
  102465. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102466. /**
  102467. * Clones the texture.
  102468. * @returns the cloned texture
  102469. */
  102470. clone(): RenderTargetTexture;
  102471. /**
  102472. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102473. * @returns The JSON representation of the texture
  102474. */
  102475. serialize(): any;
  102476. /**
  102477. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102478. */
  102479. disposeFramebufferObjects(): void;
  102480. /**
  102481. * Dispose the texture and release its associated resources.
  102482. */
  102483. dispose(): void;
  102484. /** @hidden */
  102485. _rebuild(): void;
  102486. /**
  102487. * Clear the info related to rendering groups preventing retention point in material dispose.
  102488. */
  102489. freeRenderingGroups(): void;
  102490. /**
  102491. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102492. * @returns the view count
  102493. */
  102494. getViewCount(): number;
  102495. }
  102496. }
  102497. declare module BABYLON {
  102498. /**
  102499. * Class used to manipulate GUIDs
  102500. */
  102501. export class GUID {
  102502. /**
  102503. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102504. * Be aware Math.random() could cause collisions, but:
  102505. * "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"
  102506. * @returns a pseudo random id
  102507. */
  102508. static RandomId(): string;
  102509. }
  102510. }
  102511. declare module BABYLON {
  102512. /**
  102513. * Options to be used when creating a shadow depth material
  102514. */
  102515. export interface IIOptionShadowDepthMaterial {
  102516. /** Variables in the vertex shader code that need to have their names remapped.
  102517. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102518. * "var_name" should be either: worldPos or vNormalW
  102519. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102520. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102521. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102522. */
  102523. remappedVariables?: string[];
  102524. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102525. standalone?: boolean;
  102526. }
  102527. /**
  102528. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102529. */
  102530. export class ShadowDepthWrapper {
  102531. private _scene;
  102532. private _options?;
  102533. private _baseMaterial;
  102534. private _onEffectCreatedObserver;
  102535. private _subMeshToEffect;
  102536. private _subMeshToDepthEffect;
  102537. private _meshes;
  102538. /** @hidden */
  102539. _matriceNames: any;
  102540. /** Gets the standalone status of the wrapper */
  102541. get standalone(): boolean;
  102542. /** Gets the base material the wrapper is built upon */
  102543. get baseMaterial(): Material;
  102544. /**
  102545. * Instantiate a new shadow depth wrapper.
  102546. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102547. * generate the shadow depth map. For more information, please refer to the documentation:
  102548. * https://doc.babylonjs.com/babylon101/shadows
  102549. * @param baseMaterial Material to wrap
  102550. * @param scene Define the scene the material belongs to
  102551. * @param options Options used to create the wrapper
  102552. */
  102553. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102554. /**
  102555. * Gets the effect to use to generate the depth map
  102556. * @param subMesh subMesh to get the effect for
  102557. * @param shadowGenerator shadow generator to get the effect for
  102558. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102559. */
  102560. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102561. /**
  102562. * Specifies that the submesh is ready to be used for depth rendering
  102563. * @param subMesh submesh to check
  102564. * @param defines the list of defines to take into account when checking the effect
  102565. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102566. * @param useInstances specifies that instances should be used
  102567. * @returns a boolean indicating that the submesh is ready or not
  102568. */
  102569. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102570. /**
  102571. * Disposes the resources
  102572. */
  102573. dispose(): void;
  102574. private _makeEffect;
  102575. }
  102576. }
  102577. declare module BABYLON {
  102578. interface ThinEngine {
  102579. /**
  102580. * Unbind a list of render target textures from the webGL context
  102581. * This is used only when drawBuffer extension or webGL2 are active
  102582. * @param textures defines the render target textures to unbind
  102583. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102584. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102585. */
  102586. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102587. /**
  102588. * Create a multi render target texture
  102589. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102590. * @param size defines the size of the texture
  102591. * @param options defines the creation options
  102592. * @returns the cube texture as an InternalTexture
  102593. */
  102594. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102595. /**
  102596. * Update the sample count for a given multiple render target texture
  102597. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102598. * @param textures defines the textures to update
  102599. * @param samples defines the sample count to set
  102600. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102601. */
  102602. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102603. /**
  102604. * Select a subsets of attachments to draw to.
  102605. * @param attachments gl attachments
  102606. */
  102607. bindAttachments(attachments: number[]): void;
  102608. }
  102609. }
  102610. declare module BABYLON {
  102611. /**
  102612. * Creation options of the multi render target texture.
  102613. */
  102614. export interface IMultiRenderTargetOptions {
  102615. /**
  102616. * Define if the texture needs to create mip maps after render.
  102617. */
  102618. generateMipMaps?: boolean;
  102619. /**
  102620. * Define the types of all the draw buffers we want to create
  102621. */
  102622. types?: number[];
  102623. /**
  102624. * Define the sampling modes of all the draw buffers we want to create
  102625. */
  102626. samplingModes?: number[];
  102627. /**
  102628. * Define if a depth buffer is required
  102629. */
  102630. generateDepthBuffer?: boolean;
  102631. /**
  102632. * Define if a stencil buffer is required
  102633. */
  102634. generateStencilBuffer?: boolean;
  102635. /**
  102636. * Define if a depth texture is required instead of a depth buffer
  102637. */
  102638. generateDepthTexture?: boolean;
  102639. /**
  102640. * Define the number of desired draw buffers
  102641. */
  102642. textureCount?: number;
  102643. /**
  102644. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102645. */
  102646. doNotChangeAspectRatio?: boolean;
  102647. /**
  102648. * Define the default type of the buffers we are creating
  102649. */
  102650. defaultType?: number;
  102651. }
  102652. /**
  102653. * A multi render target, like a render target provides the ability to render to a texture.
  102654. * Unlike the render target, it can render to several draw buffers in one draw.
  102655. * This is specially interesting in deferred rendering or for any effects requiring more than
  102656. * just one color from a single pass.
  102657. */
  102658. export class MultiRenderTarget extends RenderTargetTexture {
  102659. private _internalTextures;
  102660. private _textures;
  102661. private _multiRenderTargetOptions;
  102662. private _count;
  102663. /**
  102664. * Get if draw buffers are currently supported by the used hardware and browser.
  102665. */
  102666. get isSupported(): boolean;
  102667. /**
  102668. * Get the list of textures generated by the multi render target.
  102669. */
  102670. get textures(): Texture[];
  102671. /**
  102672. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102673. */
  102674. get count(): number;
  102675. /**
  102676. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102677. */
  102678. get depthTexture(): Texture;
  102679. /**
  102680. * Set the wrapping mode on U of all the textures we are rendering to.
  102681. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102682. */
  102683. set wrapU(wrap: number);
  102684. /**
  102685. * Set the wrapping mode on V of all the textures we are rendering to.
  102686. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102687. */
  102688. set wrapV(wrap: number);
  102689. /**
  102690. * Instantiate a new multi render target texture.
  102691. * A multi render target, like a render target provides the ability to render to a texture.
  102692. * Unlike the render target, it can render to several draw buffers in one draw.
  102693. * This is specially interesting in deferred rendering or for any effects requiring more than
  102694. * just one color from a single pass.
  102695. * @param name Define the name of the texture
  102696. * @param size Define the size of the buffers to render to
  102697. * @param count Define the number of target we are rendering into
  102698. * @param scene Define the scene the texture belongs to
  102699. * @param options Define the options used to create the multi render target
  102700. */
  102701. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102702. /** @hidden */
  102703. _rebuild(): void;
  102704. private _createInternalTextures;
  102705. private _createTextures;
  102706. /**
  102707. * Define the number of samples used if MSAA is enabled.
  102708. */
  102709. get samples(): number;
  102710. set samples(value: number);
  102711. /**
  102712. * Resize all the textures in the multi render target.
  102713. * Be carrefull as it will recreate all the data in the new texture.
  102714. * @param size Define the new size
  102715. */
  102716. resize(size: any): void;
  102717. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102718. /**
  102719. * Dispose the render targets and their associated resources
  102720. */
  102721. dispose(): void;
  102722. /**
  102723. * Release all the underlying texture used as draw buffers.
  102724. */
  102725. releaseInternalTextures(): void;
  102726. }
  102727. }
  102728. declare module BABYLON {
  102729. /** @hidden */
  102730. export var imageProcessingPixelShader: {
  102731. name: string;
  102732. shader: string;
  102733. };
  102734. }
  102735. declare module BABYLON {
  102736. /**
  102737. * ImageProcessingPostProcess
  102738. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102739. */
  102740. export class ImageProcessingPostProcess extends PostProcess {
  102741. /**
  102742. * Default configuration related to image processing available in the PBR Material.
  102743. */
  102744. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102745. /**
  102746. * Gets the image processing configuration used either in this material.
  102747. */
  102748. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102749. /**
  102750. * Sets the Default image processing configuration used either in the this material.
  102751. *
  102752. * If sets to null, the scene one is in use.
  102753. */
  102754. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102755. /**
  102756. * Keep track of the image processing observer to allow dispose and replace.
  102757. */
  102758. private _imageProcessingObserver;
  102759. /**
  102760. * Attaches a new image processing configuration to the PBR Material.
  102761. * @param configuration
  102762. */
  102763. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102764. /**
  102765. * If the post process is supported.
  102766. */
  102767. get isSupported(): boolean;
  102768. /**
  102769. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102770. */
  102771. get colorCurves(): Nullable<ColorCurves>;
  102772. /**
  102773. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102774. */
  102775. set colorCurves(value: Nullable<ColorCurves>);
  102776. /**
  102777. * Gets wether the color curves effect is enabled.
  102778. */
  102779. get colorCurvesEnabled(): boolean;
  102780. /**
  102781. * Sets wether the color curves effect is enabled.
  102782. */
  102783. set colorCurvesEnabled(value: boolean);
  102784. /**
  102785. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102786. */
  102787. get colorGradingTexture(): Nullable<BaseTexture>;
  102788. /**
  102789. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102790. */
  102791. set colorGradingTexture(value: Nullable<BaseTexture>);
  102792. /**
  102793. * Gets wether the color grading effect is enabled.
  102794. */
  102795. get colorGradingEnabled(): boolean;
  102796. /**
  102797. * Gets wether the color grading effect is enabled.
  102798. */
  102799. set colorGradingEnabled(value: boolean);
  102800. /**
  102801. * Gets exposure used in the effect.
  102802. */
  102803. get exposure(): number;
  102804. /**
  102805. * Sets exposure used in the effect.
  102806. */
  102807. set exposure(value: number);
  102808. /**
  102809. * Gets wether tonemapping is enabled or not.
  102810. */
  102811. get toneMappingEnabled(): boolean;
  102812. /**
  102813. * Sets wether tonemapping is enabled or not
  102814. */
  102815. set toneMappingEnabled(value: boolean);
  102816. /**
  102817. * Gets the type of tone mapping effect.
  102818. */
  102819. get toneMappingType(): number;
  102820. /**
  102821. * Sets the type of tone mapping effect.
  102822. */
  102823. set toneMappingType(value: number);
  102824. /**
  102825. * Gets contrast used in the effect.
  102826. */
  102827. get contrast(): number;
  102828. /**
  102829. * Sets contrast used in the effect.
  102830. */
  102831. set contrast(value: number);
  102832. /**
  102833. * Gets Vignette stretch size.
  102834. */
  102835. get vignetteStretch(): number;
  102836. /**
  102837. * Sets Vignette stretch size.
  102838. */
  102839. set vignetteStretch(value: number);
  102840. /**
  102841. * Gets Vignette centre X Offset.
  102842. */
  102843. get vignetteCentreX(): number;
  102844. /**
  102845. * Sets Vignette centre X Offset.
  102846. */
  102847. set vignetteCentreX(value: number);
  102848. /**
  102849. * Gets Vignette centre Y Offset.
  102850. */
  102851. get vignetteCentreY(): number;
  102852. /**
  102853. * Sets Vignette centre Y Offset.
  102854. */
  102855. set vignetteCentreY(value: number);
  102856. /**
  102857. * Gets Vignette weight or intensity of the vignette effect.
  102858. */
  102859. get vignetteWeight(): number;
  102860. /**
  102861. * Sets Vignette weight or intensity of the vignette effect.
  102862. */
  102863. set vignetteWeight(value: number);
  102864. /**
  102865. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102866. * if vignetteEnabled is set to true.
  102867. */
  102868. get vignetteColor(): Color4;
  102869. /**
  102870. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102871. * if vignetteEnabled is set to true.
  102872. */
  102873. set vignetteColor(value: Color4);
  102874. /**
  102875. * Gets Camera field of view used by the Vignette effect.
  102876. */
  102877. get vignetteCameraFov(): number;
  102878. /**
  102879. * Sets Camera field of view used by the Vignette effect.
  102880. */
  102881. set vignetteCameraFov(value: number);
  102882. /**
  102883. * Gets the vignette blend mode allowing different kind of effect.
  102884. */
  102885. get vignetteBlendMode(): number;
  102886. /**
  102887. * Sets the vignette blend mode allowing different kind of effect.
  102888. */
  102889. set vignetteBlendMode(value: number);
  102890. /**
  102891. * Gets wether the vignette effect is enabled.
  102892. */
  102893. get vignetteEnabled(): boolean;
  102894. /**
  102895. * Sets wether the vignette effect is enabled.
  102896. */
  102897. set vignetteEnabled(value: boolean);
  102898. private _fromLinearSpace;
  102899. /**
  102900. * Gets wether the input of the processing is in Gamma or Linear Space.
  102901. */
  102902. get fromLinearSpace(): boolean;
  102903. /**
  102904. * Sets wether the input of the processing is in Gamma or Linear Space.
  102905. */
  102906. set fromLinearSpace(value: boolean);
  102907. /**
  102908. * Defines cache preventing GC.
  102909. */
  102910. private _defines;
  102911. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102912. /**
  102913. * "ImageProcessingPostProcess"
  102914. * @returns "ImageProcessingPostProcess"
  102915. */
  102916. getClassName(): string;
  102917. /**
  102918. * @hidden
  102919. */
  102920. _updateParameters(): void;
  102921. dispose(camera?: Camera): void;
  102922. }
  102923. }
  102924. declare module BABYLON {
  102925. /** @hidden */
  102926. export var fibonacci: {
  102927. name: string;
  102928. shader: string;
  102929. };
  102930. }
  102931. declare module BABYLON {
  102932. /** @hidden */
  102933. export var subSurfaceScatteringFunctions: {
  102934. name: string;
  102935. shader: string;
  102936. };
  102937. }
  102938. declare module BABYLON {
  102939. /** @hidden */
  102940. export var diffusionProfile: {
  102941. name: string;
  102942. shader: string;
  102943. };
  102944. }
  102945. declare module BABYLON {
  102946. /** @hidden */
  102947. export var subSurfaceScatteringPixelShader: {
  102948. name: string;
  102949. shader: string;
  102950. };
  102951. }
  102952. declare module BABYLON {
  102953. /**
  102954. * Sub surface scattering post process
  102955. */
  102956. export class SubSurfaceScatteringPostProcess extends PostProcess {
  102957. /** @hidden */
  102958. texelWidth: number;
  102959. /** @hidden */
  102960. texelHeight: number;
  102961. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  102962. }
  102963. }
  102964. declare module BABYLON {
  102965. /**
  102966. * Interface for defining prepass effects in the prepass post-process pipeline
  102967. */
  102968. export interface PrePassEffectConfiguration {
  102969. /**
  102970. * Post process to attach for this effect
  102971. */
  102972. postProcess: PostProcess;
  102973. /**
  102974. * Is the effect enabled
  102975. */
  102976. enabled: boolean;
  102977. /**
  102978. * Disposes the effect configuration
  102979. */
  102980. dispose(): void;
  102981. /**
  102982. * Disposes the effect configuration
  102983. */
  102984. createPostProcess: () => PostProcess;
  102985. }
  102986. }
  102987. declare module BABYLON {
  102988. /**
  102989. * Contains all parameters needed for the prepass to perform
  102990. * screen space subsurface scattering
  102991. */
  102992. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  102993. private _ssDiffusionS;
  102994. private _ssFilterRadii;
  102995. private _ssDiffusionD;
  102996. /**
  102997. * Post process to attach for screen space subsurface scattering
  102998. */
  102999. postProcess: SubSurfaceScatteringPostProcess;
  103000. /**
  103001. * Diffusion profile color for subsurface scattering
  103002. */
  103003. get ssDiffusionS(): number[];
  103004. /**
  103005. * Diffusion profile max color channel value for subsurface scattering
  103006. */
  103007. get ssDiffusionD(): number[];
  103008. /**
  103009. * Diffusion profile filter radius for subsurface scattering
  103010. */
  103011. get ssFilterRadii(): number[];
  103012. /**
  103013. * Is subsurface enabled
  103014. */
  103015. enabled: boolean;
  103016. /**
  103017. * Diffusion profile colors for subsurface scattering
  103018. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103019. * See ...
  103020. * Note that you can only store up to 5 of them
  103021. */
  103022. ssDiffusionProfileColors: Color3[];
  103023. /**
  103024. * Defines the ratio real world => scene units.
  103025. * Used for subsurface scattering
  103026. */
  103027. metersPerUnit: number;
  103028. private _scene;
  103029. /**
  103030. * Builds a subsurface configuration object
  103031. * @param scene The scene
  103032. */
  103033. constructor(scene: Scene);
  103034. /**
  103035. * Adds a new diffusion profile.
  103036. * Useful for more realistic subsurface scattering on diverse materials.
  103037. * @param color The color of the diffusion profile. Should be the average color of the material.
  103038. * @return The index of the diffusion profile for the material subsurface configuration
  103039. */
  103040. addDiffusionProfile(color: Color3): number;
  103041. /**
  103042. * Creates the sss post process
  103043. * @return The created post process
  103044. */
  103045. createPostProcess(): SubSurfaceScatteringPostProcess;
  103046. /**
  103047. * Deletes all diffusion profiles.
  103048. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103049. */
  103050. clearAllDiffusionProfiles(): void;
  103051. /**
  103052. * Disposes this object
  103053. */
  103054. dispose(): void;
  103055. /**
  103056. * @hidden
  103057. * https://zero-radiance.github.io/post/sampling-diffusion/
  103058. *
  103059. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  103060. * ------------------------------------------------------------------------------------
  103061. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  103062. * PDF[r, phi, s] = r * R[r, phi, s]
  103063. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  103064. * ------------------------------------------------------------------------------------
  103065. * We importance sample the color channel with the widest scattering distance.
  103066. */
  103067. getDiffusionProfileParameters(color: Color3): number;
  103068. /**
  103069. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103070. * 'u' is the random number (the value of the CDF): [0, 1).
  103071. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  103072. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  103073. */
  103074. private _sampleBurleyDiffusionProfile;
  103075. }
  103076. }
  103077. declare module BABYLON {
  103078. /**
  103079. * Renders a pre pass of the scene
  103080. * This means every mesh in the scene will be rendered to a render target texture
  103081. * And then this texture will be composited to the rendering canvas with post processes
  103082. * It is necessary for effects like subsurface scattering or deferred shading
  103083. */
  103084. export class PrePassRenderer {
  103085. /** @hidden */
  103086. static _SceneComponentInitialization: (scene: Scene) => void;
  103087. private _scene;
  103088. private _engine;
  103089. private _isDirty;
  103090. /**
  103091. * Number of textures in the multi render target texture where the scene is directly rendered
  103092. */
  103093. readonly mrtCount: number;
  103094. /**
  103095. * The render target where the scene is directly rendered
  103096. */
  103097. prePassRT: MultiRenderTarget;
  103098. private _mrtTypes;
  103099. private _multiRenderAttachments;
  103100. private _defaultAttachments;
  103101. private _clearAttachments;
  103102. private _postProcesses;
  103103. private readonly _clearColor;
  103104. /**
  103105. * Image processing post process for composition
  103106. */
  103107. imageProcessingPostProcess: ImageProcessingPostProcess;
  103108. /**
  103109. * Configuration for sub surface scattering post process
  103110. */
  103111. subSurfaceConfiguration: SubSurfaceConfiguration;
  103112. /**
  103113. * Should materials render their geometry on the MRT
  103114. */
  103115. materialsShouldRenderGeometry: boolean;
  103116. /**
  103117. * Should materials render the irradiance information on the MRT
  103118. */
  103119. materialsShouldRenderIrradiance: boolean;
  103120. private _enabled;
  103121. /**
  103122. * Indicates if the prepass is enabled
  103123. */
  103124. get enabled(): boolean;
  103125. /**
  103126. * How many samples are used for MSAA of the scene render target
  103127. */
  103128. get samples(): number;
  103129. set samples(n: number);
  103130. /**
  103131. * Instanciates a prepass renderer
  103132. * @param scene The scene
  103133. */
  103134. constructor(scene: Scene);
  103135. private _initializeAttachments;
  103136. private _createCompositionEffect;
  103137. /**
  103138. * Indicates if rendering a prepass is supported
  103139. */
  103140. get isSupported(): boolean;
  103141. /**
  103142. * Sets the proper output textures to draw in the engine.
  103143. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103144. */
  103145. bindAttachmentsForEffect(effect: Effect): void;
  103146. /**
  103147. * @hidden
  103148. */
  103149. _beforeCameraDraw(): void;
  103150. /**
  103151. * @hidden
  103152. */
  103153. _afterCameraDraw(): void;
  103154. private _checkRTSize;
  103155. private _bindFrameBuffer;
  103156. /**
  103157. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103158. */
  103159. clear(): void;
  103160. private _setState;
  103161. private _enable;
  103162. private _disable;
  103163. private _resetPostProcessChain;
  103164. private _bindPostProcessChain;
  103165. /**
  103166. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103167. */
  103168. markAsDirty(): void;
  103169. private _update;
  103170. /**
  103171. * Disposes the prepass renderer.
  103172. */
  103173. dispose(): void;
  103174. }
  103175. }
  103176. declare module BABYLON {
  103177. /**
  103178. * Options for compiling materials.
  103179. */
  103180. export interface IMaterialCompilationOptions {
  103181. /**
  103182. * Defines whether clip planes are enabled.
  103183. */
  103184. clipPlane: boolean;
  103185. /**
  103186. * Defines whether instances are enabled.
  103187. */
  103188. useInstances: boolean;
  103189. }
  103190. /**
  103191. * Options passed when calling customShaderNameResolve
  103192. */
  103193. export interface ICustomShaderNameResolveOptions {
  103194. /**
  103195. * 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
  103196. */
  103197. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103198. }
  103199. /**
  103200. * Base class for the main features of a material in Babylon.js
  103201. */
  103202. export class Material implements IAnimatable {
  103203. /**
  103204. * Returns the triangle fill mode
  103205. */
  103206. static readonly TriangleFillMode: number;
  103207. /**
  103208. * Returns the wireframe mode
  103209. */
  103210. static readonly WireFrameFillMode: number;
  103211. /**
  103212. * Returns the point fill mode
  103213. */
  103214. static readonly PointFillMode: number;
  103215. /**
  103216. * Returns the point list draw mode
  103217. */
  103218. static readonly PointListDrawMode: number;
  103219. /**
  103220. * Returns the line list draw mode
  103221. */
  103222. static readonly LineListDrawMode: number;
  103223. /**
  103224. * Returns the line loop draw mode
  103225. */
  103226. static readonly LineLoopDrawMode: number;
  103227. /**
  103228. * Returns the line strip draw mode
  103229. */
  103230. static readonly LineStripDrawMode: number;
  103231. /**
  103232. * Returns the triangle strip draw mode
  103233. */
  103234. static readonly TriangleStripDrawMode: number;
  103235. /**
  103236. * Returns the triangle fan draw mode
  103237. */
  103238. static readonly TriangleFanDrawMode: number;
  103239. /**
  103240. * Stores the clock-wise side orientation
  103241. */
  103242. static readonly ClockWiseSideOrientation: number;
  103243. /**
  103244. * Stores the counter clock-wise side orientation
  103245. */
  103246. static readonly CounterClockWiseSideOrientation: number;
  103247. /**
  103248. * The dirty texture flag value
  103249. */
  103250. static readonly TextureDirtyFlag: number;
  103251. /**
  103252. * The dirty light flag value
  103253. */
  103254. static readonly LightDirtyFlag: number;
  103255. /**
  103256. * The dirty fresnel flag value
  103257. */
  103258. static readonly FresnelDirtyFlag: number;
  103259. /**
  103260. * The dirty attribute flag value
  103261. */
  103262. static readonly AttributesDirtyFlag: number;
  103263. /**
  103264. * The dirty misc flag value
  103265. */
  103266. static readonly MiscDirtyFlag: number;
  103267. /**
  103268. * The all dirty flag value
  103269. */
  103270. static readonly AllDirtyFlag: number;
  103271. /**
  103272. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103273. */
  103274. static readonly MATERIAL_OPAQUE: number;
  103275. /**
  103276. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103277. */
  103278. static readonly MATERIAL_ALPHATEST: number;
  103279. /**
  103280. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103281. */
  103282. static readonly MATERIAL_ALPHABLEND: number;
  103283. /**
  103284. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103285. * They are also discarded below the alpha cutoff threshold to improve performances.
  103286. */
  103287. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103288. /**
  103289. * The Whiteout method is used to blend normals.
  103290. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103291. */
  103292. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  103293. /**
  103294. * The Reoriented Normal Mapping method is used to blend normals.
  103295. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103296. */
  103297. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103298. /**
  103299. * Custom callback helping to override the default shader used in the material.
  103300. */
  103301. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103302. /**
  103303. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103304. */
  103305. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103306. /**
  103307. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103308. * This means that the material can keep using a previous shader while a new one is being compiled.
  103309. * This is mostly used when shader parallel compilation is supported (true by default)
  103310. */
  103311. allowShaderHotSwapping: boolean;
  103312. /**
  103313. * The ID of the material
  103314. */
  103315. id: string;
  103316. /**
  103317. * Gets or sets the unique id of the material
  103318. */
  103319. uniqueId: number;
  103320. /**
  103321. * The name of the material
  103322. */
  103323. name: string;
  103324. /**
  103325. * Gets or sets user defined metadata
  103326. */
  103327. metadata: any;
  103328. /**
  103329. * For internal use only. Please do not use.
  103330. */
  103331. reservedDataStore: any;
  103332. /**
  103333. * Specifies if the ready state should be checked on each call
  103334. */
  103335. checkReadyOnEveryCall: boolean;
  103336. /**
  103337. * Specifies if the ready state should be checked once
  103338. */
  103339. checkReadyOnlyOnce: boolean;
  103340. /**
  103341. * The state of the material
  103342. */
  103343. state: string;
  103344. /**
  103345. * If the material can be rendered to several textures with MRT extension
  103346. */
  103347. get canRenderToMRT(): boolean;
  103348. /**
  103349. * The alpha value of the material
  103350. */
  103351. protected _alpha: number;
  103352. /**
  103353. * List of inspectable custom properties (used by the Inspector)
  103354. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103355. */
  103356. inspectableCustomProperties: IInspectable[];
  103357. /**
  103358. * Sets the alpha value of the material
  103359. */
  103360. set alpha(value: number);
  103361. /**
  103362. * Gets the alpha value of the material
  103363. */
  103364. get alpha(): number;
  103365. /**
  103366. * Specifies if back face culling is enabled
  103367. */
  103368. protected _backFaceCulling: boolean;
  103369. /**
  103370. * Sets the back-face culling state
  103371. */
  103372. set backFaceCulling(value: boolean);
  103373. /**
  103374. * Gets the back-face culling state
  103375. */
  103376. get backFaceCulling(): boolean;
  103377. /**
  103378. * Stores the value for side orientation
  103379. */
  103380. sideOrientation: number;
  103381. /**
  103382. * Callback triggered when the material is compiled
  103383. */
  103384. onCompiled: Nullable<(effect: Effect) => void>;
  103385. /**
  103386. * Callback triggered when an error occurs
  103387. */
  103388. onError: Nullable<(effect: Effect, errors: string) => void>;
  103389. /**
  103390. * Callback triggered to get the render target textures
  103391. */
  103392. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103393. /**
  103394. * Gets a boolean indicating that current material needs to register RTT
  103395. */
  103396. get hasRenderTargetTextures(): boolean;
  103397. /**
  103398. * Specifies if the material should be serialized
  103399. */
  103400. doNotSerialize: boolean;
  103401. /**
  103402. * @hidden
  103403. */
  103404. _storeEffectOnSubMeshes: boolean;
  103405. /**
  103406. * Stores the animations for the material
  103407. */
  103408. animations: Nullable<Array<Animation>>;
  103409. /**
  103410. * An event triggered when the material is disposed
  103411. */
  103412. onDisposeObservable: Observable<Material>;
  103413. /**
  103414. * An observer which watches for dispose events
  103415. */
  103416. private _onDisposeObserver;
  103417. private _onUnBindObservable;
  103418. /**
  103419. * Called during a dispose event
  103420. */
  103421. set onDispose(callback: () => void);
  103422. private _onBindObservable;
  103423. /**
  103424. * An event triggered when the material is bound
  103425. */
  103426. get onBindObservable(): Observable<AbstractMesh>;
  103427. /**
  103428. * An observer which watches for bind events
  103429. */
  103430. private _onBindObserver;
  103431. /**
  103432. * Called during a bind event
  103433. */
  103434. set onBind(callback: (Mesh: AbstractMesh) => void);
  103435. /**
  103436. * An event triggered when the material is unbound
  103437. */
  103438. get onUnBindObservable(): Observable<Material>;
  103439. protected _onEffectCreatedObservable: Nullable<Observable<{
  103440. effect: Effect;
  103441. subMesh: Nullable<SubMesh>;
  103442. }>>;
  103443. /**
  103444. * An event triggered when the effect is (re)created
  103445. */
  103446. get onEffectCreatedObservable(): Observable<{
  103447. effect: Effect;
  103448. subMesh: Nullable<SubMesh>;
  103449. }>;
  103450. /**
  103451. * Stores the value of the alpha mode
  103452. */
  103453. private _alphaMode;
  103454. /**
  103455. * Sets the value of the alpha mode.
  103456. *
  103457. * | Value | Type | Description |
  103458. * | --- | --- | --- |
  103459. * | 0 | ALPHA_DISABLE | |
  103460. * | 1 | ALPHA_ADD | |
  103461. * | 2 | ALPHA_COMBINE | |
  103462. * | 3 | ALPHA_SUBTRACT | |
  103463. * | 4 | ALPHA_MULTIPLY | |
  103464. * | 5 | ALPHA_MAXIMIZED | |
  103465. * | 6 | ALPHA_ONEONE | |
  103466. * | 7 | ALPHA_PREMULTIPLIED | |
  103467. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  103468. * | 9 | ALPHA_INTERPOLATE | |
  103469. * | 10 | ALPHA_SCREENMODE | |
  103470. *
  103471. */
  103472. set alphaMode(value: number);
  103473. /**
  103474. * Gets the value of the alpha mode
  103475. */
  103476. get alphaMode(): number;
  103477. /**
  103478. * Stores the state of the need depth pre-pass value
  103479. */
  103480. private _needDepthPrePass;
  103481. /**
  103482. * Sets the need depth pre-pass value
  103483. */
  103484. set needDepthPrePass(value: boolean);
  103485. /**
  103486. * Gets the depth pre-pass value
  103487. */
  103488. get needDepthPrePass(): boolean;
  103489. /**
  103490. * Specifies if depth writing should be disabled
  103491. */
  103492. disableDepthWrite: boolean;
  103493. /**
  103494. * Specifies if color writing should be disabled
  103495. */
  103496. disableColorWrite: boolean;
  103497. /**
  103498. * Specifies if depth writing should be forced
  103499. */
  103500. forceDepthWrite: boolean;
  103501. /**
  103502. * Specifies the depth function that should be used. 0 means the default engine function
  103503. */
  103504. depthFunction: number;
  103505. /**
  103506. * Specifies if there should be a separate pass for culling
  103507. */
  103508. separateCullingPass: boolean;
  103509. /**
  103510. * Stores the state specifing if fog should be enabled
  103511. */
  103512. private _fogEnabled;
  103513. /**
  103514. * Sets the state for enabling fog
  103515. */
  103516. set fogEnabled(value: boolean);
  103517. /**
  103518. * Gets the value of the fog enabled state
  103519. */
  103520. get fogEnabled(): boolean;
  103521. /**
  103522. * Stores the size of points
  103523. */
  103524. pointSize: number;
  103525. /**
  103526. * Stores the z offset value
  103527. */
  103528. zOffset: number;
  103529. get wireframe(): boolean;
  103530. /**
  103531. * Sets the state of wireframe mode
  103532. */
  103533. set wireframe(value: boolean);
  103534. /**
  103535. * Gets the value specifying if point clouds are enabled
  103536. */
  103537. get pointsCloud(): boolean;
  103538. /**
  103539. * Sets the state of point cloud mode
  103540. */
  103541. set pointsCloud(value: boolean);
  103542. /**
  103543. * Gets the material fill mode
  103544. */
  103545. get fillMode(): number;
  103546. /**
  103547. * Sets the material fill mode
  103548. */
  103549. set fillMode(value: number);
  103550. /**
  103551. * @hidden
  103552. * Stores the effects for the material
  103553. */
  103554. _effect: Nullable<Effect>;
  103555. /**
  103556. * Specifies if uniform buffers should be used
  103557. */
  103558. private _useUBO;
  103559. /**
  103560. * Stores a reference to the scene
  103561. */
  103562. private _scene;
  103563. /**
  103564. * Stores the fill mode state
  103565. */
  103566. private _fillMode;
  103567. /**
  103568. * Specifies if the depth write state should be cached
  103569. */
  103570. private _cachedDepthWriteState;
  103571. /**
  103572. * Specifies if the color write state should be cached
  103573. */
  103574. private _cachedColorWriteState;
  103575. /**
  103576. * Specifies if the depth function state should be cached
  103577. */
  103578. private _cachedDepthFunctionState;
  103579. /**
  103580. * Stores the uniform buffer
  103581. */
  103582. protected _uniformBuffer: UniformBuffer;
  103583. /** @hidden */
  103584. _indexInSceneMaterialArray: number;
  103585. /** @hidden */
  103586. meshMap: Nullable<{
  103587. [id: string]: AbstractMesh | undefined;
  103588. }>;
  103589. /**
  103590. * Creates a material instance
  103591. * @param name defines the name of the material
  103592. * @param scene defines the scene to reference
  103593. * @param doNotAdd specifies if the material should be added to the scene
  103594. */
  103595. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  103596. /**
  103597. * Returns a string representation of the current material
  103598. * @param fullDetails defines a boolean indicating which levels of logging is desired
  103599. * @returns a string with material information
  103600. */
  103601. toString(fullDetails?: boolean): string;
  103602. /**
  103603. * Gets the class name of the material
  103604. * @returns a string with the class name of the material
  103605. */
  103606. getClassName(): string;
  103607. /**
  103608. * Specifies if updates for the material been locked
  103609. */
  103610. get isFrozen(): boolean;
  103611. /**
  103612. * Locks updates for the material
  103613. */
  103614. freeze(): void;
  103615. /**
  103616. * Unlocks updates for the material
  103617. */
  103618. unfreeze(): void;
  103619. /**
  103620. * Specifies if the material is ready to be used
  103621. * @param mesh defines the mesh to check
  103622. * @param useInstances specifies if instances should be used
  103623. * @returns a boolean indicating if the material is ready to be used
  103624. */
  103625. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103626. /**
  103627. * Specifies that the submesh is ready to be used
  103628. * @param mesh defines the mesh to check
  103629. * @param subMesh defines which submesh to check
  103630. * @param useInstances specifies that instances should be used
  103631. * @returns a boolean indicating that the submesh is ready or not
  103632. */
  103633. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103634. /**
  103635. * Returns the material effect
  103636. * @returns the effect associated with the material
  103637. */
  103638. getEffect(): Nullable<Effect>;
  103639. /**
  103640. * Returns the current scene
  103641. * @returns a Scene
  103642. */
  103643. getScene(): Scene;
  103644. /**
  103645. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103646. */
  103647. protected _forceAlphaTest: boolean;
  103648. /**
  103649. * The transparency mode of the material.
  103650. */
  103651. protected _transparencyMode: Nullable<number>;
  103652. /**
  103653. * Gets the current transparency mode.
  103654. */
  103655. get transparencyMode(): Nullable<number>;
  103656. /**
  103657. * Sets the transparency mode of the material.
  103658. *
  103659. * | Value | Type | Description |
  103660. * | ----- | ----------------------------------- | ----------- |
  103661. * | 0 | OPAQUE | |
  103662. * | 1 | ALPHATEST | |
  103663. * | 2 | ALPHABLEND | |
  103664. * | 3 | ALPHATESTANDBLEND | |
  103665. *
  103666. */
  103667. set transparencyMode(value: Nullable<number>);
  103668. /**
  103669. * Returns true if alpha blending should be disabled.
  103670. */
  103671. protected get _disableAlphaBlending(): boolean;
  103672. /**
  103673. * Specifies whether or not this material should be rendered in alpha blend mode.
  103674. * @returns a boolean specifying if alpha blending is needed
  103675. */
  103676. needAlphaBlending(): boolean;
  103677. /**
  103678. * Specifies if the mesh will require alpha blending
  103679. * @param mesh defines the mesh to check
  103680. * @returns a boolean specifying if alpha blending is needed for the mesh
  103681. */
  103682. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103683. /**
  103684. * Specifies whether or not this material should be rendered in alpha test mode.
  103685. * @returns a boolean specifying if an alpha test is needed.
  103686. */
  103687. needAlphaTesting(): boolean;
  103688. /**
  103689. * Specifies if material alpha testing should be turned on for the mesh
  103690. * @param mesh defines the mesh to check
  103691. */
  103692. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  103693. /**
  103694. * Gets the texture used for the alpha test
  103695. * @returns the texture to use for alpha testing
  103696. */
  103697. getAlphaTestTexture(): Nullable<BaseTexture>;
  103698. /**
  103699. * Marks the material to indicate that it needs to be re-calculated
  103700. */
  103701. markDirty(): void;
  103702. /** @hidden */
  103703. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  103704. /**
  103705. * Binds the material to the mesh
  103706. * @param world defines the world transformation matrix
  103707. * @param mesh defines the mesh to bind the material to
  103708. */
  103709. bind(world: Matrix, mesh?: Mesh): void;
  103710. /**
  103711. * Binds the submesh to the material
  103712. * @param world defines the world transformation matrix
  103713. * @param mesh defines the mesh containing the submesh
  103714. * @param subMesh defines the submesh to bind the material to
  103715. */
  103716. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103717. /**
  103718. * Binds the world matrix to the material
  103719. * @param world defines the world transformation matrix
  103720. */
  103721. bindOnlyWorldMatrix(world: Matrix): void;
  103722. /**
  103723. * Binds the scene's uniform buffer to the effect.
  103724. * @param effect defines the effect to bind to the scene uniform buffer
  103725. * @param sceneUbo defines the uniform buffer storing scene data
  103726. */
  103727. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  103728. /**
  103729. * Binds the view matrix to the effect
  103730. * @param effect defines the effect to bind the view matrix to
  103731. */
  103732. bindView(effect: Effect): void;
  103733. /**
  103734. * Binds the view projection matrix to the effect
  103735. * @param effect defines the effect to bind the view projection matrix to
  103736. */
  103737. bindViewProjection(effect: Effect): void;
  103738. /**
  103739. * Processes to execute after binding the material to a mesh
  103740. * @param mesh defines the rendered mesh
  103741. */
  103742. protected _afterBind(mesh?: Mesh): void;
  103743. /**
  103744. * Unbinds the material from the mesh
  103745. */
  103746. unbind(): void;
  103747. /**
  103748. * Gets the active textures from the material
  103749. * @returns an array of textures
  103750. */
  103751. getActiveTextures(): BaseTexture[];
  103752. /**
  103753. * Specifies if the material uses a texture
  103754. * @param texture defines the texture to check against the material
  103755. * @returns a boolean specifying if the material uses the texture
  103756. */
  103757. hasTexture(texture: BaseTexture): boolean;
  103758. /**
  103759. * Makes a duplicate of the material, and gives it a new name
  103760. * @param name defines the new name for the duplicated material
  103761. * @returns the cloned material
  103762. */
  103763. clone(name: string): Nullable<Material>;
  103764. /**
  103765. * Gets the meshes bound to the material
  103766. * @returns an array of meshes bound to the material
  103767. */
  103768. getBindedMeshes(): AbstractMesh[];
  103769. /**
  103770. * Force shader compilation
  103771. * @param mesh defines the mesh associated with this material
  103772. * @param onCompiled defines a function to execute once the material is compiled
  103773. * @param options defines the options to configure the compilation
  103774. * @param onError defines a function to execute if the material fails compiling
  103775. */
  103776. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  103777. /**
  103778. * Force shader compilation
  103779. * @param mesh defines the mesh that will use this material
  103780. * @param options defines additional options for compiling the shaders
  103781. * @returns a promise that resolves when the compilation completes
  103782. */
  103783. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  103784. private static readonly _AllDirtyCallBack;
  103785. private static readonly _ImageProcessingDirtyCallBack;
  103786. private static readonly _TextureDirtyCallBack;
  103787. private static readonly _FresnelDirtyCallBack;
  103788. private static readonly _MiscDirtyCallBack;
  103789. private static readonly _LightsDirtyCallBack;
  103790. private static readonly _AttributeDirtyCallBack;
  103791. private static _FresnelAndMiscDirtyCallBack;
  103792. private static _TextureAndMiscDirtyCallBack;
  103793. private static readonly _DirtyCallbackArray;
  103794. private static readonly _RunDirtyCallBacks;
  103795. /**
  103796. * Marks a define in the material to indicate that it needs to be re-computed
  103797. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  103798. */
  103799. markAsDirty(flag: number): void;
  103800. /**
  103801. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  103802. * @param func defines a function which checks material defines against the submeshes
  103803. */
  103804. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  103805. /**
  103806. * Indicates that the scene should check if the rendering now needs a prepass
  103807. */
  103808. protected _markScenePrePassDirty(): void;
  103809. /**
  103810. * Indicates that we need to re-calculated for all submeshes
  103811. */
  103812. protected _markAllSubMeshesAsAllDirty(): void;
  103813. /**
  103814. * Indicates that image processing needs to be re-calculated for all submeshes
  103815. */
  103816. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  103817. /**
  103818. * Indicates that textures need to be re-calculated for all submeshes
  103819. */
  103820. protected _markAllSubMeshesAsTexturesDirty(): void;
  103821. /**
  103822. * Indicates that fresnel needs to be re-calculated for all submeshes
  103823. */
  103824. protected _markAllSubMeshesAsFresnelDirty(): void;
  103825. /**
  103826. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  103827. */
  103828. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  103829. /**
  103830. * Indicates that lights need to be re-calculated for all submeshes
  103831. */
  103832. protected _markAllSubMeshesAsLightsDirty(): void;
  103833. /**
  103834. * Indicates that attributes need to be re-calculated for all submeshes
  103835. */
  103836. protected _markAllSubMeshesAsAttributesDirty(): void;
  103837. /**
  103838. * Indicates that misc needs to be re-calculated for all submeshes
  103839. */
  103840. protected _markAllSubMeshesAsMiscDirty(): void;
  103841. /**
  103842. * Indicates that textures and misc need to be re-calculated for all submeshes
  103843. */
  103844. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  103845. /**
  103846. * Sets the required values to the prepass renderer.
  103847. * @param prePassRenderer defines the prepass renderer to setup.
  103848. * @returns true if the pre pass is needed.
  103849. */
  103850. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103851. /**
  103852. * Disposes the material
  103853. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103854. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103855. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103856. */
  103857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103858. /** @hidden */
  103859. private releaseVertexArrayObject;
  103860. /**
  103861. * Serializes this material
  103862. * @returns the serialized material object
  103863. */
  103864. serialize(): any;
  103865. /**
  103866. * Creates a material from parsed material data
  103867. * @param parsedMaterial defines parsed material data
  103868. * @param scene defines the hosting scene
  103869. * @param rootUrl defines the root URL to use to load textures
  103870. * @returns a new material
  103871. */
  103872. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  103873. }
  103874. }
  103875. declare module BABYLON {
  103876. /**
  103877. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103878. * separate meshes. This can be use to improve performances.
  103879. * @see https://doc.babylonjs.com/how_to/multi_materials
  103880. */
  103881. export class MultiMaterial extends Material {
  103882. private _subMaterials;
  103883. /**
  103884. * Gets or Sets the list of Materials used within the multi material.
  103885. * They need to be ordered according to the submeshes order in the associated mesh
  103886. */
  103887. get subMaterials(): Nullable<Material>[];
  103888. set subMaterials(value: Nullable<Material>[]);
  103889. /**
  103890. * Function used to align with Node.getChildren()
  103891. * @returns the list of Materials used within the multi material
  103892. */
  103893. getChildren(): Nullable<Material>[];
  103894. /**
  103895. * Instantiates a new Multi Material
  103896. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103897. * separate meshes. This can be use to improve performances.
  103898. * @see https://doc.babylonjs.com/how_to/multi_materials
  103899. * @param name Define the name in the scene
  103900. * @param scene Define the scene the material belongs to
  103901. */
  103902. constructor(name: string, scene: Scene);
  103903. private _hookArray;
  103904. /**
  103905. * Get one of the submaterial by its index in the submaterials array
  103906. * @param index The index to look the sub material at
  103907. * @returns The Material if the index has been defined
  103908. */
  103909. getSubMaterial(index: number): Nullable<Material>;
  103910. /**
  103911. * Get the list of active textures for the whole sub materials list.
  103912. * @returns All the textures that will be used during the rendering
  103913. */
  103914. getActiveTextures(): BaseTexture[];
  103915. /**
  103916. * Gets the current class name of the material e.g. "MultiMaterial"
  103917. * Mainly use in serialization.
  103918. * @returns the class name
  103919. */
  103920. getClassName(): string;
  103921. /**
  103922. * Checks if the material is ready to render the requested sub mesh
  103923. * @param mesh Define the mesh the submesh belongs to
  103924. * @param subMesh Define the sub mesh to look readyness for
  103925. * @param useInstances Define whether or not the material is used with instances
  103926. * @returns true if ready, otherwise false
  103927. */
  103928. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103929. /**
  103930. * Clones the current material and its related sub materials
  103931. * @param name Define the name of the newly cloned material
  103932. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  103933. * @returns the cloned material
  103934. */
  103935. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  103936. /**
  103937. * Serializes the materials into a JSON representation.
  103938. * @returns the JSON representation
  103939. */
  103940. serialize(): any;
  103941. /**
  103942. * Dispose the material and release its associated resources
  103943. * @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)
  103944. * @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)
  103945. * @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)
  103946. */
  103947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  103948. /**
  103949. * Creates a MultiMaterial from parsed MultiMaterial data.
  103950. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  103951. * @param scene defines the hosting scene
  103952. * @returns a new MultiMaterial
  103953. */
  103954. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  103955. }
  103956. }
  103957. declare module BABYLON {
  103958. /**
  103959. * Defines a subdivision inside a mesh
  103960. */
  103961. export class SubMesh implements ICullable {
  103962. /** the material index to use */
  103963. materialIndex: number;
  103964. /** vertex index start */
  103965. verticesStart: number;
  103966. /** vertices count */
  103967. verticesCount: number;
  103968. /** index start */
  103969. indexStart: number;
  103970. /** indices count */
  103971. indexCount: number;
  103972. /** @hidden */
  103973. _materialDefines: Nullable<MaterialDefines>;
  103974. /** @hidden */
  103975. _materialEffect: Nullable<Effect>;
  103976. /** @hidden */
  103977. _effectOverride: Nullable<Effect>;
  103978. /**
  103979. * Gets material defines used by the effect associated to the sub mesh
  103980. */
  103981. get materialDefines(): Nullable<MaterialDefines>;
  103982. /**
  103983. * Sets material defines used by the effect associated to the sub mesh
  103984. */
  103985. set materialDefines(defines: Nullable<MaterialDefines>);
  103986. /**
  103987. * Gets associated effect
  103988. */
  103989. get effect(): Nullable<Effect>;
  103990. /**
  103991. * Sets associated effect (effect used to render this submesh)
  103992. * @param effect defines the effect to associate with
  103993. * @param defines defines the set of defines used to compile this effect
  103994. */
  103995. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  103996. /** @hidden */
  103997. _linesIndexCount: number;
  103998. private _mesh;
  103999. private _renderingMesh;
  104000. private _boundingInfo;
  104001. private _linesIndexBuffer;
  104002. /** @hidden */
  104003. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104004. /** @hidden */
  104005. _trianglePlanes: Plane[];
  104006. /** @hidden */
  104007. _lastColliderTransformMatrix: Nullable<Matrix>;
  104008. /** @hidden */
  104009. _renderId: number;
  104010. /** @hidden */
  104011. _alphaIndex: number;
  104012. /** @hidden */
  104013. _distanceToCamera: number;
  104014. /** @hidden */
  104015. _id: number;
  104016. private _currentMaterial;
  104017. /**
  104018. * Add a new submesh to a mesh
  104019. * @param materialIndex defines the material index to use
  104020. * @param verticesStart defines vertex index start
  104021. * @param verticesCount defines vertices count
  104022. * @param indexStart defines index start
  104023. * @param indexCount defines indices count
  104024. * @param mesh defines the parent mesh
  104025. * @param renderingMesh defines an optional rendering mesh
  104026. * @param createBoundingBox defines if bounding box should be created for this submesh
  104027. * @returns the new submesh
  104028. */
  104029. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104030. /**
  104031. * Creates a new submesh
  104032. * @param materialIndex defines the material index to use
  104033. * @param verticesStart defines vertex index start
  104034. * @param verticesCount defines vertices count
  104035. * @param indexStart defines index start
  104036. * @param indexCount defines indices count
  104037. * @param mesh defines the parent mesh
  104038. * @param renderingMesh defines an optional rendering mesh
  104039. * @param createBoundingBox defines if bounding box should be created for this submesh
  104040. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104041. */
  104042. constructor(
  104043. /** the material index to use */
  104044. materialIndex: number,
  104045. /** vertex index start */
  104046. verticesStart: number,
  104047. /** vertices count */
  104048. verticesCount: number,
  104049. /** index start */
  104050. indexStart: number,
  104051. /** indices count */
  104052. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104053. /**
  104054. * Returns true if this submesh covers the entire parent mesh
  104055. * @ignorenaming
  104056. */
  104057. get IsGlobal(): boolean;
  104058. /**
  104059. * Returns the submesh BoudingInfo object
  104060. * @returns current bounding info (or mesh's one if the submesh is global)
  104061. */
  104062. getBoundingInfo(): BoundingInfo;
  104063. /**
  104064. * Sets the submesh BoundingInfo
  104065. * @param boundingInfo defines the new bounding info to use
  104066. * @returns the SubMesh
  104067. */
  104068. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  104069. /**
  104070. * Returns the mesh of the current submesh
  104071. * @return the parent mesh
  104072. */
  104073. getMesh(): AbstractMesh;
  104074. /**
  104075. * Returns the rendering mesh of the submesh
  104076. * @returns the rendering mesh (could be different from parent mesh)
  104077. */
  104078. getRenderingMesh(): Mesh;
  104079. /**
  104080. * Returns the replacement mesh of the submesh
  104081. * @returns the replacement mesh (could be different from parent mesh)
  104082. */
  104083. getReplacementMesh(): Nullable<AbstractMesh>;
  104084. /**
  104085. * Returns the effective mesh of the submesh
  104086. * @returns the effective mesh (could be different from parent mesh)
  104087. */
  104088. getEffectiveMesh(): AbstractMesh;
  104089. /**
  104090. * Returns the submesh material
  104091. * @returns null or the current material
  104092. */
  104093. getMaterial(): Nullable<Material>;
  104094. private _IsMultiMaterial;
  104095. /**
  104096. * Sets a new updated BoundingInfo object to the submesh
  104097. * @param data defines an optional position array to use to determine the bounding info
  104098. * @returns the SubMesh
  104099. */
  104100. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  104101. /** @hidden */
  104102. _checkCollision(collider: Collider): boolean;
  104103. /**
  104104. * Updates the submesh BoundingInfo
  104105. * @param world defines the world matrix to use to update the bounding info
  104106. * @returns the submesh
  104107. */
  104108. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  104109. /**
  104110. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104111. * @param frustumPlanes defines the frustum planes
  104112. * @returns true if the submesh is intersecting with the frustum
  104113. */
  104114. isInFrustum(frustumPlanes: Plane[]): boolean;
  104115. /**
  104116. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104117. * @param frustumPlanes defines the frustum planes
  104118. * @returns true if the submesh is inside the frustum
  104119. */
  104120. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104121. /**
  104122. * Renders the submesh
  104123. * @param enableAlphaMode defines if alpha needs to be used
  104124. * @returns the submesh
  104125. */
  104126. render(enableAlphaMode: boolean): SubMesh;
  104127. /**
  104128. * @hidden
  104129. */
  104130. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  104131. /**
  104132. * Checks if the submesh intersects with a ray
  104133. * @param ray defines the ray to test
  104134. * @returns true is the passed ray intersects the submesh bounding box
  104135. */
  104136. canIntersects(ray: Ray): boolean;
  104137. /**
  104138. * Intersects current submesh with a ray
  104139. * @param ray defines the ray to test
  104140. * @param positions defines mesh's positions array
  104141. * @param indices defines mesh's indices array
  104142. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104143. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104144. * @returns intersection info or null if no intersection
  104145. */
  104146. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  104147. /** @hidden */
  104148. private _intersectLines;
  104149. /** @hidden */
  104150. private _intersectUnIndexedLines;
  104151. /** @hidden */
  104152. private _intersectTriangles;
  104153. /** @hidden */
  104154. private _intersectUnIndexedTriangles;
  104155. /** @hidden */
  104156. _rebuild(): void;
  104157. /**
  104158. * Creates a new submesh from the passed mesh
  104159. * @param newMesh defines the new hosting mesh
  104160. * @param newRenderingMesh defines an optional rendering mesh
  104161. * @returns the new submesh
  104162. */
  104163. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  104164. /**
  104165. * Release associated resources
  104166. */
  104167. dispose(): void;
  104168. /**
  104169. * Gets the class name
  104170. * @returns the string "SubMesh".
  104171. */
  104172. getClassName(): string;
  104173. /**
  104174. * Creates a new submesh from indices data
  104175. * @param materialIndex the index of the main mesh material
  104176. * @param startIndex the index where to start the copy in the mesh indices array
  104177. * @param indexCount the number of indices to copy then from the startIndex
  104178. * @param mesh the main mesh to create the submesh from
  104179. * @param renderingMesh the optional rendering mesh
  104180. * @returns a new submesh
  104181. */
  104182. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104183. }
  104184. }
  104185. declare module BABYLON {
  104186. /**
  104187. * Class used to represent data loading progression
  104188. */
  104189. export class SceneLoaderFlags {
  104190. private static _ForceFullSceneLoadingForIncremental;
  104191. private static _ShowLoadingScreen;
  104192. private static _CleanBoneMatrixWeights;
  104193. private static _loggingLevel;
  104194. /**
  104195. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104196. */
  104197. static get ForceFullSceneLoadingForIncremental(): boolean;
  104198. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104199. /**
  104200. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104201. */
  104202. static get ShowLoadingScreen(): boolean;
  104203. static set ShowLoadingScreen(value: boolean);
  104204. /**
  104205. * Defines the current logging level (while loading the scene)
  104206. * @ignorenaming
  104207. */
  104208. static get loggingLevel(): number;
  104209. static set loggingLevel(value: number);
  104210. /**
  104211. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104212. */
  104213. static get CleanBoneMatrixWeights(): boolean;
  104214. static set CleanBoneMatrixWeights(value: boolean);
  104215. }
  104216. }
  104217. declare module BABYLON {
  104218. /**
  104219. * Class used to store geometry data (vertex buffers + index buffer)
  104220. */
  104221. export class Geometry implements IGetSetVerticesData {
  104222. /**
  104223. * Gets or sets the ID of the geometry
  104224. */
  104225. id: string;
  104226. /**
  104227. * Gets or sets the unique ID of the geometry
  104228. */
  104229. uniqueId: number;
  104230. /**
  104231. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104232. */
  104233. delayLoadState: number;
  104234. /**
  104235. * Gets the file containing the data to load when running in delay load state
  104236. */
  104237. delayLoadingFile: Nullable<string>;
  104238. /**
  104239. * Callback called when the geometry is updated
  104240. */
  104241. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104242. private _scene;
  104243. private _engine;
  104244. private _meshes;
  104245. private _totalVertices;
  104246. /** @hidden */
  104247. _indices: IndicesArray;
  104248. /** @hidden */
  104249. _vertexBuffers: {
  104250. [key: string]: VertexBuffer;
  104251. };
  104252. private _isDisposed;
  104253. private _extend;
  104254. private _boundingBias;
  104255. /** @hidden */
  104256. _delayInfo: Array<string>;
  104257. private _indexBuffer;
  104258. private _indexBufferIsUpdatable;
  104259. /** @hidden */
  104260. _boundingInfo: Nullable<BoundingInfo>;
  104261. /** @hidden */
  104262. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104263. /** @hidden */
  104264. _softwareSkinningFrameId: number;
  104265. private _vertexArrayObjects;
  104266. private _updatable;
  104267. /** @hidden */
  104268. _positions: Nullable<Vector3[]>;
  104269. /**
  104270. * 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
  104271. */
  104272. get boundingBias(): Vector2;
  104273. /**
  104274. * 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
  104275. */
  104276. set boundingBias(value: Vector2);
  104277. /**
  104278. * Static function used to attach a new empty geometry to a mesh
  104279. * @param mesh defines the mesh to attach the geometry to
  104280. * @returns the new Geometry
  104281. */
  104282. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104283. /** Get the list of meshes using this geometry */
  104284. get meshes(): Mesh[];
  104285. /**
  104286. * 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
  104287. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104288. */
  104289. useBoundingInfoFromGeometry: boolean;
  104290. /**
  104291. * Creates a new geometry
  104292. * @param id defines the unique ID
  104293. * @param scene defines the hosting scene
  104294. * @param vertexData defines the VertexData used to get geometry data
  104295. * @param updatable defines if geometry must be updatable (false by default)
  104296. * @param mesh defines the mesh that will be associated with the geometry
  104297. */
  104298. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104299. /**
  104300. * Gets the current extend of the geometry
  104301. */
  104302. get extend(): {
  104303. minimum: Vector3;
  104304. maximum: Vector3;
  104305. };
  104306. /**
  104307. * Gets the hosting scene
  104308. * @returns the hosting Scene
  104309. */
  104310. getScene(): Scene;
  104311. /**
  104312. * Gets the hosting engine
  104313. * @returns the hosting Engine
  104314. */
  104315. getEngine(): Engine;
  104316. /**
  104317. * Defines if the geometry is ready to use
  104318. * @returns true if the geometry is ready to be used
  104319. */
  104320. isReady(): boolean;
  104321. /**
  104322. * Gets a value indicating that the geometry should not be serialized
  104323. */
  104324. get doNotSerialize(): boolean;
  104325. /** @hidden */
  104326. _rebuild(): void;
  104327. /**
  104328. * Affects all geometry data in one call
  104329. * @param vertexData defines the geometry data
  104330. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104331. */
  104332. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104333. /**
  104334. * Set specific vertex data
  104335. * @param kind defines the data kind (Position, normal, etc...)
  104336. * @param data defines the vertex data to use
  104337. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104338. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104339. */
  104340. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104341. /**
  104342. * Removes a specific vertex data
  104343. * @param kind defines the data kind (Position, normal, etc...)
  104344. */
  104345. removeVerticesData(kind: string): void;
  104346. /**
  104347. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104348. * @param buffer defines the vertex buffer to use
  104349. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104350. */
  104351. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104352. /**
  104353. * Update a specific vertex buffer
  104354. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104355. * It will do nothing if the buffer is not updatable
  104356. * @param kind defines the data kind (Position, normal, etc...)
  104357. * @param data defines the data to use
  104358. * @param offset defines the offset in the target buffer where to store the data
  104359. * @param useBytes set to true if the offset is in bytes
  104360. */
  104361. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104362. /**
  104363. * Update a specific vertex buffer
  104364. * This function will create a new buffer if the current one is not updatable
  104365. * @param kind defines the data kind (Position, normal, etc...)
  104366. * @param data defines the data to use
  104367. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104368. */
  104369. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104370. private _updateBoundingInfo;
  104371. /** @hidden */
  104372. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104373. /**
  104374. * Gets total number of vertices
  104375. * @returns the total number of vertices
  104376. */
  104377. getTotalVertices(): number;
  104378. /**
  104379. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104380. * @param kind defines the data kind (Position, normal, etc...)
  104381. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104382. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104383. * @returns a float array containing vertex data
  104384. */
  104385. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104386. /**
  104387. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104388. * @param kind defines the data kind (Position, normal, etc...)
  104389. * @returns true if the vertex buffer with the specified kind is updatable
  104390. */
  104391. isVertexBufferUpdatable(kind: string): boolean;
  104392. /**
  104393. * Gets a specific vertex buffer
  104394. * @param kind defines the data kind (Position, normal, etc...)
  104395. * @returns a VertexBuffer
  104396. */
  104397. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104398. /**
  104399. * Returns all vertex buffers
  104400. * @return an object holding all vertex buffers indexed by kind
  104401. */
  104402. getVertexBuffers(): Nullable<{
  104403. [key: string]: VertexBuffer;
  104404. }>;
  104405. /**
  104406. * Gets a boolean indicating if specific vertex buffer is present
  104407. * @param kind defines the data kind (Position, normal, etc...)
  104408. * @returns true if data is present
  104409. */
  104410. isVerticesDataPresent(kind: string): boolean;
  104411. /**
  104412. * Gets a list of all attached data kinds (Position, normal, etc...)
  104413. * @returns a list of string containing all kinds
  104414. */
  104415. getVerticesDataKinds(): string[];
  104416. /**
  104417. * Update index buffer
  104418. * @param indices defines the indices to store in the index buffer
  104419. * @param offset defines the offset in the target buffer where to store the data
  104420. * @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)
  104421. */
  104422. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  104423. /**
  104424. * Creates a new index buffer
  104425. * @param indices defines the indices to store in the index buffer
  104426. * @param totalVertices defines the total number of vertices (could be null)
  104427. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104428. */
  104429. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  104430. /**
  104431. * Return the total number of indices
  104432. * @returns the total number of indices
  104433. */
  104434. getTotalIndices(): number;
  104435. /**
  104436. * Gets the index buffer array
  104437. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104438. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104439. * @returns the index buffer array
  104440. */
  104441. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104442. /**
  104443. * Gets the index buffer
  104444. * @return the index buffer
  104445. */
  104446. getIndexBuffer(): Nullable<DataBuffer>;
  104447. /** @hidden */
  104448. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  104449. /**
  104450. * Release the associated resources for a specific mesh
  104451. * @param mesh defines the source mesh
  104452. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  104453. */
  104454. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  104455. /**
  104456. * Apply current geometry to a given mesh
  104457. * @param mesh defines the mesh to apply geometry to
  104458. */
  104459. applyToMesh(mesh: Mesh): void;
  104460. private _updateExtend;
  104461. private _applyToMesh;
  104462. private notifyUpdate;
  104463. /**
  104464. * Load the geometry if it was flagged as delay loaded
  104465. * @param scene defines the hosting scene
  104466. * @param onLoaded defines a callback called when the geometry is loaded
  104467. */
  104468. load(scene: Scene, onLoaded?: () => void): void;
  104469. private _queueLoad;
  104470. /**
  104471. * Invert the geometry to move from a right handed system to a left handed one.
  104472. */
  104473. toLeftHanded(): void;
  104474. /** @hidden */
  104475. _resetPointsArrayCache(): void;
  104476. /** @hidden */
  104477. _generatePointsArray(): boolean;
  104478. /**
  104479. * Gets a value indicating if the geometry is disposed
  104480. * @returns true if the geometry was disposed
  104481. */
  104482. isDisposed(): boolean;
  104483. private _disposeVertexArrayObjects;
  104484. /**
  104485. * Free all associated resources
  104486. */
  104487. dispose(): void;
  104488. /**
  104489. * Clone the current geometry into a new geometry
  104490. * @param id defines the unique ID of the new geometry
  104491. * @returns a new geometry object
  104492. */
  104493. copy(id: string): Geometry;
  104494. /**
  104495. * Serialize the current geometry info (and not the vertices data) into a JSON object
  104496. * @return a JSON representation of the current geometry data (without the vertices data)
  104497. */
  104498. serialize(): any;
  104499. private toNumberArray;
  104500. /**
  104501. * Serialize all vertices data into a JSON oject
  104502. * @returns a JSON representation of the current geometry data
  104503. */
  104504. serializeVerticeData(): any;
  104505. /**
  104506. * Extracts a clone of a mesh geometry
  104507. * @param mesh defines the source mesh
  104508. * @param id defines the unique ID of the new geometry object
  104509. * @returns the new geometry object
  104510. */
  104511. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  104512. /**
  104513. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  104514. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104515. * Be aware Math.random() could cause collisions, but:
  104516. * "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"
  104517. * @returns a string containing a new GUID
  104518. */
  104519. static RandomId(): string;
  104520. /** @hidden */
  104521. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  104522. private static _CleanMatricesWeights;
  104523. /**
  104524. * Create a new geometry from persisted data (Using .babylon file format)
  104525. * @param parsedVertexData defines the persisted data
  104526. * @param scene defines the hosting scene
  104527. * @param rootUrl defines the root url to use to load assets (like delayed data)
  104528. * @returns the new geometry object
  104529. */
  104530. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  104531. }
  104532. }
  104533. declare module BABYLON {
  104534. /**
  104535. * Define an interface for all classes that will get and set the data on vertices
  104536. */
  104537. export interface IGetSetVerticesData {
  104538. /**
  104539. * Gets a boolean indicating if specific vertex data is present
  104540. * @param kind defines the vertex data kind to use
  104541. * @returns true is data kind is present
  104542. */
  104543. isVerticesDataPresent(kind: string): boolean;
  104544. /**
  104545. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104546. * @param kind defines the data kind (Position, normal, etc...)
  104547. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104548. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104549. * @returns a float array containing vertex data
  104550. */
  104551. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104552. /**
  104553. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104554. * @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.
  104555. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104556. * @returns the indices array or an empty array if the mesh has no geometry
  104557. */
  104558. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104559. /**
  104560. * Set specific vertex data
  104561. * @param kind defines the data kind (Position, normal, etc...)
  104562. * @param data defines the vertex data to use
  104563. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104564. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104565. */
  104566. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  104567. /**
  104568. * Update a specific associated vertex buffer
  104569. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104570. * - VertexBuffer.PositionKind
  104571. * - VertexBuffer.UVKind
  104572. * - VertexBuffer.UV2Kind
  104573. * - VertexBuffer.UV3Kind
  104574. * - VertexBuffer.UV4Kind
  104575. * - VertexBuffer.UV5Kind
  104576. * - VertexBuffer.UV6Kind
  104577. * - VertexBuffer.ColorKind
  104578. * - VertexBuffer.MatricesIndicesKind
  104579. * - VertexBuffer.MatricesIndicesExtraKind
  104580. * - VertexBuffer.MatricesWeightsKind
  104581. * - VertexBuffer.MatricesWeightsExtraKind
  104582. * @param data defines the data source
  104583. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104584. * @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)
  104585. */
  104586. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  104587. /**
  104588. * Creates a new index buffer
  104589. * @param indices defines the indices to store in the index buffer
  104590. * @param totalVertices defines the total number of vertices (could be null)
  104591. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104592. */
  104593. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  104594. }
  104595. /**
  104596. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  104597. */
  104598. export class VertexData {
  104599. /**
  104600. * Mesh side orientation : usually the external or front surface
  104601. */
  104602. static readonly FRONTSIDE: number;
  104603. /**
  104604. * Mesh side orientation : usually the internal or back surface
  104605. */
  104606. static readonly BACKSIDE: number;
  104607. /**
  104608. * Mesh side orientation : both internal and external or front and back surfaces
  104609. */
  104610. static readonly DOUBLESIDE: number;
  104611. /**
  104612. * Mesh side orientation : by default, `FRONTSIDE`
  104613. */
  104614. static readonly DEFAULTSIDE: number;
  104615. /**
  104616. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  104617. */
  104618. positions: Nullable<FloatArray>;
  104619. /**
  104620. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  104621. */
  104622. normals: Nullable<FloatArray>;
  104623. /**
  104624. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  104625. */
  104626. tangents: Nullable<FloatArray>;
  104627. /**
  104628. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104629. */
  104630. uvs: Nullable<FloatArray>;
  104631. /**
  104632. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104633. */
  104634. uvs2: Nullable<FloatArray>;
  104635. /**
  104636. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104637. */
  104638. uvs3: Nullable<FloatArray>;
  104639. /**
  104640. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104641. */
  104642. uvs4: Nullable<FloatArray>;
  104643. /**
  104644. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104645. */
  104646. uvs5: Nullable<FloatArray>;
  104647. /**
  104648. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104649. */
  104650. uvs6: Nullable<FloatArray>;
  104651. /**
  104652. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  104653. */
  104654. colors: Nullable<FloatArray>;
  104655. /**
  104656. * 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).
  104657. */
  104658. matricesIndices: Nullable<FloatArray>;
  104659. /**
  104660. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  104661. */
  104662. matricesWeights: Nullable<FloatArray>;
  104663. /**
  104664. * An array extending the number of possible indices
  104665. */
  104666. matricesIndicesExtra: Nullable<FloatArray>;
  104667. /**
  104668. * An array extending the number of possible weights when the number of indices is extended
  104669. */
  104670. matricesWeightsExtra: Nullable<FloatArray>;
  104671. /**
  104672. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  104673. */
  104674. indices: Nullable<IndicesArray>;
  104675. /**
  104676. * Uses the passed data array to set the set the values for the specified kind of data
  104677. * @param data a linear array of floating numbers
  104678. * @param kind the type of data that is being set, eg positions, colors etc
  104679. */
  104680. set(data: FloatArray, kind: string): void;
  104681. /**
  104682. * Associates the vertexData to the passed Mesh.
  104683. * Sets it as updatable or not (default `false`)
  104684. * @param mesh the mesh the vertexData is applied to
  104685. * @param updatable when used and having the value true allows new data to update the vertexData
  104686. * @returns the VertexData
  104687. */
  104688. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  104689. /**
  104690. * Associates the vertexData to the passed Geometry.
  104691. * Sets it as updatable or not (default `false`)
  104692. * @param geometry the geometry the vertexData is applied to
  104693. * @param updatable when used and having the value true allows new data to update the vertexData
  104694. * @returns VertexData
  104695. */
  104696. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  104697. /**
  104698. * Updates the associated mesh
  104699. * @param mesh the mesh to be updated
  104700. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104701. * @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
  104702. * @returns VertexData
  104703. */
  104704. updateMesh(mesh: Mesh): VertexData;
  104705. /**
  104706. * Updates the associated geometry
  104707. * @param geometry the geometry to be updated
  104708. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104709. * @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
  104710. * @returns VertexData.
  104711. */
  104712. updateGeometry(geometry: Geometry): VertexData;
  104713. private _applyTo;
  104714. private _update;
  104715. /**
  104716. * Transforms each position and each normal of the vertexData according to the passed Matrix
  104717. * @param matrix the transforming matrix
  104718. * @returns the VertexData
  104719. */
  104720. transform(matrix: Matrix): VertexData;
  104721. /**
  104722. * Merges the passed VertexData into the current one
  104723. * @param other the VertexData to be merged into the current one
  104724. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  104725. * @returns the modified VertexData
  104726. */
  104727. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  104728. private _mergeElement;
  104729. private _validate;
  104730. /**
  104731. * Serializes the VertexData
  104732. * @returns a serialized object
  104733. */
  104734. serialize(): any;
  104735. /**
  104736. * Extracts the vertexData from a mesh
  104737. * @param mesh the mesh from which to extract the VertexData
  104738. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  104739. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104740. * @returns the object VertexData associated to the passed mesh
  104741. */
  104742. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104743. /**
  104744. * Extracts the vertexData from the geometry
  104745. * @param geometry the geometry from which to extract the VertexData
  104746. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  104747. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104748. * @returns the object VertexData associated to the passed mesh
  104749. */
  104750. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104751. private static _ExtractFrom;
  104752. /**
  104753. * Creates the VertexData for a Ribbon
  104754. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  104755. * * pathArray array of paths, each of which an array of successive Vector3
  104756. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  104757. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  104758. * * 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
  104759. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104760. * * 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)
  104761. * * 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)
  104762. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  104763. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  104764. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  104765. * @returns the VertexData of the ribbon
  104766. */
  104767. static CreateRibbon(options: {
  104768. pathArray: Vector3[][];
  104769. closeArray?: boolean;
  104770. closePath?: boolean;
  104771. offset?: number;
  104772. sideOrientation?: number;
  104773. frontUVs?: Vector4;
  104774. backUVs?: Vector4;
  104775. invertUV?: boolean;
  104776. uvs?: Vector2[];
  104777. colors?: Color4[];
  104778. }): VertexData;
  104779. /**
  104780. * Creates the VertexData for a box
  104781. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104782. * * size sets the width, height and depth of the box to the value of size, optional default 1
  104783. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  104784. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  104785. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  104786. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104787. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104789. * * 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)
  104790. * * 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)
  104791. * @returns the VertexData of the box
  104792. */
  104793. static CreateBox(options: {
  104794. size?: number;
  104795. width?: number;
  104796. height?: number;
  104797. depth?: number;
  104798. faceUV?: Vector4[];
  104799. faceColors?: Color4[];
  104800. sideOrientation?: number;
  104801. frontUVs?: Vector4;
  104802. backUVs?: Vector4;
  104803. }): VertexData;
  104804. /**
  104805. * Creates the VertexData for a tiled box
  104806. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104807. * * faceTiles sets the pattern, tile size and number of tiles for a face
  104808. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104809. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104811. * @returns the VertexData of the box
  104812. */
  104813. static CreateTiledBox(options: {
  104814. pattern?: number;
  104815. width?: number;
  104816. height?: number;
  104817. depth?: number;
  104818. tileSize?: number;
  104819. tileWidth?: number;
  104820. tileHeight?: number;
  104821. alignHorizontal?: number;
  104822. alignVertical?: number;
  104823. faceUV?: Vector4[];
  104824. faceColors?: Color4[];
  104825. sideOrientation?: number;
  104826. }): VertexData;
  104827. /**
  104828. * Creates the VertexData for a tiled plane
  104829. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104830. * * pattern a limited pattern arrangement depending on the number
  104831. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  104832. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  104833. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  104834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104835. * * 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)
  104836. * * 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)
  104837. * @returns the VertexData of the tiled plane
  104838. */
  104839. static CreateTiledPlane(options: {
  104840. pattern?: number;
  104841. tileSize?: number;
  104842. tileWidth?: number;
  104843. tileHeight?: number;
  104844. size?: number;
  104845. width?: number;
  104846. height?: number;
  104847. alignHorizontal?: number;
  104848. alignVertical?: number;
  104849. sideOrientation?: number;
  104850. frontUVs?: Vector4;
  104851. backUVs?: Vector4;
  104852. }): VertexData;
  104853. /**
  104854. * Creates the VertexData for an ellipsoid, defaults to a sphere
  104855. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104856. * * segments sets the number of horizontal strips optional, default 32
  104857. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  104858. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  104859. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  104860. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  104861. * * 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
  104862. * * 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
  104863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104864. * * 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)
  104865. * * 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)
  104866. * @returns the VertexData of the ellipsoid
  104867. */
  104868. static CreateSphere(options: {
  104869. segments?: number;
  104870. diameter?: number;
  104871. diameterX?: number;
  104872. diameterY?: number;
  104873. diameterZ?: number;
  104874. arc?: number;
  104875. slice?: number;
  104876. sideOrientation?: number;
  104877. frontUVs?: Vector4;
  104878. backUVs?: Vector4;
  104879. }): VertexData;
  104880. /**
  104881. * Creates the VertexData for a cylinder, cone or prism
  104882. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104883. * * height sets the height (y direction) of the cylinder, optional, default 2
  104884. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  104885. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  104886. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  104887. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104888. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  104889. * * 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
  104890. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104891. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104892. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  104893. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  104894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104895. * * 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)
  104896. * * 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)
  104897. * @returns the VertexData of the cylinder, cone or prism
  104898. */
  104899. static CreateCylinder(options: {
  104900. height?: number;
  104901. diameterTop?: number;
  104902. diameterBottom?: number;
  104903. diameter?: number;
  104904. tessellation?: number;
  104905. subdivisions?: number;
  104906. arc?: number;
  104907. faceColors?: Color4[];
  104908. faceUV?: Vector4[];
  104909. hasRings?: boolean;
  104910. enclose?: boolean;
  104911. sideOrientation?: number;
  104912. frontUVs?: Vector4;
  104913. backUVs?: Vector4;
  104914. }): VertexData;
  104915. /**
  104916. * Creates the VertexData for a torus
  104917. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104918. * * diameter the diameter of the torus, optional default 1
  104919. * * thickness the diameter of the tube forming the torus, optional default 0.5
  104920. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104922. * * 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)
  104923. * * 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)
  104924. * @returns the VertexData of the torus
  104925. */
  104926. static CreateTorus(options: {
  104927. diameter?: number;
  104928. thickness?: number;
  104929. tessellation?: number;
  104930. sideOrientation?: number;
  104931. frontUVs?: Vector4;
  104932. backUVs?: Vector4;
  104933. }): VertexData;
  104934. /**
  104935. * Creates the VertexData of the LineSystem
  104936. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  104937. * - lines an array of lines, each line being an array of successive Vector3
  104938. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  104939. * @returns the VertexData of the LineSystem
  104940. */
  104941. static CreateLineSystem(options: {
  104942. lines: Vector3[][];
  104943. colors?: Nullable<Color4[][]>;
  104944. }): VertexData;
  104945. /**
  104946. * Create the VertexData for a DashedLines
  104947. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  104948. * - points an array successive Vector3
  104949. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  104950. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  104951. * - dashNb the intended total number of dashes, optional, default 200
  104952. * @returns the VertexData for the DashedLines
  104953. */
  104954. static CreateDashedLines(options: {
  104955. points: Vector3[];
  104956. dashSize?: number;
  104957. gapSize?: number;
  104958. dashNb?: number;
  104959. }): VertexData;
  104960. /**
  104961. * Creates the VertexData for a Ground
  104962. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104963. * - width the width (x direction) of the ground, optional, default 1
  104964. * - height the height (z direction) of the ground, optional, default 1
  104965. * - subdivisions the number of subdivisions per side, optional, default 1
  104966. * @returns the VertexData of the Ground
  104967. */
  104968. static CreateGround(options: {
  104969. width?: number;
  104970. height?: number;
  104971. subdivisions?: number;
  104972. subdivisionsX?: number;
  104973. subdivisionsY?: number;
  104974. }): VertexData;
  104975. /**
  104976. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  104977. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104978. * * xmin the ground minimum X coordinate, optional, default -1
  104979. * * zmin the ground minimum Z coordinate, optional, default -1
  104980. * * xmax the ground maximum X coordinate, optional, default 1
  104981. * * zmax the ground maximum Z coordinate, optional, default 1
  104982. * * 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}
  104983. * * 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}
  104984. * @returns the VertexData of the TiledGround
  104985. */
  104986. static CreateTiledGround(options: {
  104987. xmin: number;
  104988. zmin: number;
  104989. xmax: number;
  104990. zmax: number;
  104991. subdivisions?: {
  104992. w: number;
  104993. h: number;
  104994. };
  104995. precision?: {
  104996. w: number;
  104997. h: number;
  104998. };
  104999. }): VertexData;
  105000. /**
  105001. * Creates the VertexData of the Ground designed from a heightmap
  105002. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105003. * * width the width (x direction) of the ground
  105004. * * height the height (z direction) of the ground
  105005. * * subdivisions the number of subdivisions per side
  105006. * * minHeight the minimum altitude on the ground, optional, default 0
  105007. * * maxHeight the maximum altitude on the ground, optional default 1
  105008. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105009. * * buffer the array holding the image color data
  105010. * * bufferWidth the width of image
  105011. * * bufferHeight the height of image
  105012. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105013. * @returns the VertexData of the Ground designed from a heightmap
  105014. */
  105015. static CreateGroundFromHeightMap(options: {
  105016. width: number;
  105017. height: number;
  105018. subdivisions: number;
  105019. minHeight: number;
  105020. maxHeight: number;
  105021. colorFilter: Color3;
  105022. buffer: Uint8Array;
  105023. bufferWidth: number;
  105024. bufferHeight: number;
  105025. alphaFilter: number;
  105026. }): VertexData;
  105027. /**
  105028. * Creates the VertexData for a Plane
  105029. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105030. * * size sets the width and height of the plane to the value of size, optional default 1
  105031. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105032. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105034. * * 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)
  105035. * * 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)
  105036. * @returns the VertexData of the box
  105037. */
  105038. static CreatePlane(options: {
  105039. size?: number;
  105040. width?: number;
  105041. height?: number;
  105042. sideOrientation?: number;
  105043. frontUVs?: Vector4;
  105044. backUVs?: Vector4;
  105045. }): VertexData;
  105046. /**
  105047. * Creates the VertexData of the Disc or regular Polygon
  105048. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105049. * * radius the radius of the disc, optional default 0.5
  105050. * * tessellation the number of polygon sides, optional, default 64
  105051. * * 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
  105052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105053. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  105054. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  105055. * @returns the VertexData of the box
  105056. */
  105057. static CreateDisc(options: {
  105058. radius?: number;
  105059. tessellation?: number;
  105060. arc?: number;
  105061. sideOrientation?: number;
  105062. frontUVs?: Vector4;
  105063. backUVs?: Vector4;
  105064. }): VertexData;
  105065. /**
  105066. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  105067. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  105068. * @param polygon a mesh built from polygonTriangulation.build()
  105069. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105070. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105071. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105072. * @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)
  105073. * @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)
  105074. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  105075. * @returns the VertexData of the Polygon
  105076. */
  105077. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  105078. /**
  105079. * Creates the VertexData of the IcoSphere
  105080. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  105081. * * radius the radius of the IcoSphere, optional default 1
  105082. * * radiusX allows stretching in the x direction, optional, default radius
  105083. * * radiusY allows stretching in the y direction, optional, default radius
  105084. * * radiusZ allows stretching in the z direction, optional, default radius
  105085. * * flat when true creates a flat shaded mesh, optional, default true
  105086. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105088. * * 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)
  105089. * * 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)
  105090. * @returns the VertexData of the IcoSphere
  105091. */
  105092. static CreateIcoSphere(options: {
  105093. radius?: number;
  105094. radiusX?: number;
  105095. radiusY?: number;
  105096. radiusZ?: number;
  105097. flat?: boolean;
  105098. subdivisions?: number;
  105099. sideOrientation?: number;
  105100. frontUVs?: Vector4;
  105101. backUVs?: Vector4;
  105102. }): VertexData;
  105103. /**
  105104. * Creates the VertexData for a Polyhedron
  105105. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  105106. * * type provided types are:
  105107. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  105108. * * 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)
  105109. * * size the size of the IcoSphere, optional default 1
  105110. * * sizeX allows stretching in the x direction, optional, default size
  105111. * * sizeY allows stretching in the y direction, optional, default size
  105112. * * sizeZ allows stretching in the z direction, optional, default size
  105113. * * 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
  105114. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105115. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105116. * * flat when true creates a flat shaded mesh, optional, default true
  105117. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105119. * * 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)
  105120. * * 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)
  105121. * @returns the VertexData of the Polyhedron
  105122. */
  105123. static CreatePolyhedron(options: {
  105124. type?: number;
  105125. size?: number;
  105126. sizeX?: number;
  105127. sizeY?: number;
  105128. sizeZ?: number;
  105129. custom?: any;
  105130. faceUV?: Vector4[];
  105131. faceColors?: Color4[];
  105132. flat?: boolean;
  105133. sideOrientation?: number;
  105134. frontUVs?: Vector4;
  105135. backUVs?: Vector4;
  105136. }): VertexData;
  105137. /**
  105138. * Creates the VertexData for a TorusKnot
  105139. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  105140. * * radius the radius of the torus knot, optional, default 2
  105141. * * tube the thickness of the tube, optional, default 0.5
  105142. * * radialSegments the number of sides on each tube segments, optional, default 32
  105143. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  105144. * * p the number of windings around the z axis, optional, default 2
  105145. * * q the number of windings around the x axis, optional, default 3
  105146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105147. * * 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)
  105148. * * 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)
  105149. * @returns the VertexData of the Torus Knot
  105150. */
  105151. static CreateTorusKnot(options: {
  105152. radius?: number;
  105153. tube?: number;
  105154. radialSegments?: number;
  105155. tubularSegments?: number;
  105156. p?: number;
  105157. q?: number;
  105158. sideOrientation?: number;
  105159. frontUVs?: Vector4;
  105160. backUVs?: Vector4;
  105161. }): VertexData;
  105162. /**
  105163. * Compute normals for given positions and indices
  105164. * @param positions an array of vertex positions, [...., x, y, z, ......]
  105165. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  105166. * @param normals an array of vertex normals, [...., x, y, z, ......]
  105167. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  105168. * * facetNormals : optional array of facet normals (vector3)
  105169. * * facetPositions : optional array of facet positions (vector3)
  105170. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  105171. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  105172. * * bInfo : optional bounding info, required for facetPartitioning computation
  105173. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  105174. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  105175. * * useRightHandedSystem: optional boolean to for right handed system computation
  105176. * * depthSort : optional boolean to enable the facet depth sort computation
  105177. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105178. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105179. */
  105180. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105181. facetNormals?: any;
  105182. facetPositions?: any;
  105183. facetPartitioning?: any;
  105184. ratio?: number;
  105185. bInfo?: any;
  105186. bbSize?: Vector3;
  105187. subDiv?: any;
  105188. useRightHandedSystem?: boolean;
  105189. depthSort?: boolean;
  105190. distanceTo?: Vector3;
  105191. depthSortedFacets?: any;
  105192. }): void;
  105193. /** @hidden */
  105194. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105195. /**
  105196. * Applies VertexData created from the imported parameters to the geometry
  105197. * @param parsedVertexData the parsed data from an imported file
  105198. * @param geometry the geometry to apply the VertexData to
  105199. */
  105200. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105201. }
  105202. }
  105203. declare module BABYLON {
  105204. /**
  105205. * Defines a target to use with MorphTargetManager
  105206. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105207. */
  105208. export class MorphTarget implements IAnimatable {
  105209. /** defines the name of the target */
  105210. name: string;
  105211. /**
  105212. * Gets or sets the list of animations
  105213. */
  105214. animations: Animation[];
  105215. private _scene;
  105216. private _positions;
  105217. private _normals;
  105218. private _tangents;
  105219. private _uvs;
  105220. private _influence;
  105221. private _uniqueId;
  105222. /**
  105223. * Observable raised when the influence changes
  105224. */
  105225. onInfluenceChanged: Observable<boolean>;
  105226. /** @hidden */
  105227. _onDataLayoutChanged: Observable<void>;
  105228. /**
  105229. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105230. */
  105231. get influence(): number;
  105232. set influence(influence: number);
  105233. /**
  105234. * Gets or sets the id of the morph Target
  105235. */
  105236. id: string;
  105237. private _animationPropertiesOverride;
  105238. /**
  105239. * Gets or sets the animation properties override
  105240. */
  105241. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105242. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105243. /**
  105244. * Creates a new MorphTarget
  105245. * @param name defines the name of the target
  105246. * @param influence defines the influence to use
  105247. * @param scene defines the scene the morphtarget belongs to
  105248. */
  105249. constructor(
  105250. /** defines the name of the target */
  105251. name: string, influence?: number, scene?: Nullable<Scene>);
  105252. /**
  105253. * Gets the unique ID of this manager
  105254. */
  105255. get uniqueId(): number;
  105256. /**
  105257. * Gets a boolean defining if the target contains position data
  105258. */
  105259. get hasPositions(): boolean;
  105260. /**
  105261. * Gets a boolean defining if the target contains normal data
  105262. */
  105263. get hasNormals(): boolean;
  105264. /**
  105265. * Gets a boolean defining if the target contains tangent data
  105266. */
  105267. get hasTangents(): boolean;
  105268. /**
  105269. * Gets a boolean defining if the target contains texture coordinates data
  105270. */
  105271. get hasUVs(): boolean;
  105272. /**
  105273. * Affects position data to this target
  105274. * @param data defines the position data to use
  105275. */
  105276. setPositions(data: Nullable<FloatArray>): void;
  105277. /**
  105278. * Gets the position data stored in this target
  105279. * @returns a FloatArray containing the position data (or null if not present)
  105280. */
  105281. getPositions(): Nullable<FloatArray>;
  105282. /**
  105283. * Affects normal data to this target
  105284. * @param data defines the normal data to use
  105285. */
  105286. setNormals(data: Nullable<FloatArray>): void;
  105287. /**
  105288. * Gets the normal data stored in this target
  105289. * @returns a FloatArray containing the normal data (or null if not present)
  105290. */
  105291. getNormals(): Nullable<FloatArray>;
  105292. /**
  105293. * Affects tangent data to this target
  105294. * @param data defines the tangent data to use
  105295. */
  105296. setTangents(data: Nullable<FloatArray>): void;
  105297. /**
  105298. * Gets the tangent data stored in this target
  105299. * @returns a FloatArray containing the tangent data (or null if not present)
  105300. */
  105301. getTangents(): Nullable<FloatArray>;
  105302. /**
  105303. * Affects texture coordinates data to this target
  105304. * @param data defines the texture coordinates data to use
  105305. */
  105306. setUVs(data: Nullable<FloatArray>): void;
  105307. /**
  105308. * Gets the texture coordinates data stored in this target
  105309. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105310. */
  105311. getUVs(): Nullable<FloatArray>;
  105312. /**
  105313. * Clone the current target
  105314. * @returns a new MorphTarget
  105315. */
  105316. clone(): MorphTarget;
  105317. /**
  105318. * Serializes the current target into a Serialization object
  105319. * @returns the serialized object
  105320. */
  105321. serialize(): any;
  105322. /**
  105323. * Returns the string "MorphTarget"
  105324. * @returns "MorphTarget"
  105325. */
  105326. getClassName(): string;
  105327. /**
  105328. * Creates a new target from serialized data
  105329. * @param serializationObject defines the serialized data to use
  105330. * @returns a new MorphTarget
  105331. */
  105332. static Parse(serializationObject: any): MorphTarget;
  105333. /**
  105334. * Creates a MorphTarget from mesh data
  105335. * @param mesh defines the source mesh
  105336. * @param name defines the name to use for the new target
  105337. * @param influence defines the influence to attach to the target
  105338. * @returns a new MorphTarget
  105339. */
  105340. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105341. }
  105342. }
  105343. declare module BABYLON {
  105344. /**
  105345. * This class is used to deform meshes using morphing between different targets
  105346. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105347. */
  105348. export class MorphTargetManager {
  105349. private _targets;
  105350. private _targetInfluenceChangedObservers;
  105351. private _targetDataLayoutChangedObservers;
  105352. private _activeTargets;
  105353. private _scene;
  105354. private _influences;
  105355. private _supportsNormals;
  105356. private _supportsTangents;
  105357. private _supportsUVs;
  105358. private _vertexCount;
  105359. private _uniqueId;
  105360. private _tempInfluences;
  105361. /**
  105362. * Gets or sets a boolean indicating if normals must be morphed
  105363. */
  105364. enableNormalMorphing: boolean;
  105365. /**
  105366. * Gets or sets a boolean indicating if tangents must be morphed
  105367. */
  105368. enableTangentMorphing: boolean;
  105369. /**
  105370. * Gets or sets a boolean indicating if UV must be morphed
  105371. */
  105372. enableUVMorphing: boolean;
  105373. /**
  105374. * Creates a new MorphTargetManager
  105375. * @param scene defines the current scene
  105376. */
  105377. constructor(scene?: Nullable<Scene>);
  105378. /**
  105379. * Gets the unique ID of this manager
  105380. */
  105381. get uniqueId(): number;
  105382. /**
  105383. * Gets the number of vertices handled by this manager
  105384. */
  105385. get vertexCount(): number;
  105386. /**
  105387. * Gets a boolean indicating if this manager supports morphing of normals
  105388. */
  105389. get supportsNormals(): boolean;
  105390. /**
  105391. * Gets a boolean indicating if this manager supports morphing of tangents
  105392. */
  105393. get supportsTangents(): boolean;
  105394. /**
  105395. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105396. */
  105397. get supportsUVs(): boolean;
  105398. /**
  105399. * Gets the number of targets stored in this manager
  105400. */
  105401. get numTargets(): number;
  105402. /**
  105403. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105404. */
  105405. get numInfluencers(): number;
  105406. /**
  105407. * Gets the list of influences (one per target)
  105408. */
  105409. get influences(): Float32Array;
  105410. /**
  105411. * Gets the active target at specified index. An active target is a target with an influence > 0
  105412. * @param index defines the index to check
  105413. * @returns the requested target
  105414. */
  105415. getActiveTarget(index: number): MorphTarget;
  105416. /**
  105417. * Gets the target at specified index
  105418. * @param index defines the index to check
  105419. * @returns the requested target
  105420. */
  105421. getTarget(index: number): MorphTarget;
  105422. /**
  105423. * Add a new target to this manager
  105424. * @param target defines the target to add
  105425. */
  105426. addTarget(target: MorphTarget): void;
  105427. /**
  105428. * Removes a target from the manager
  105429. * @param target defines the target to remove
  105430. */
  105431. removeTarget(target: MorphTarget): void;
  105432. /**
  105433. * Clone the current manager
  105434. * @returns a new MorphTargetManager
  105435. */
  105436. clone(): MorphTargetManager;
  105437. /**
  105438. * Serializes the current manager into a Serialization object
  105439. * @returns the serialized object
  105440. */
  105441. serialize(): any;
  105442. private _syncActiveTargets;
  105443. /**
  105444. * Syncrhonize the targets with all the meshes using this morph target manager
  105445. */
  105446. synchronize(): void;
  105447. /**
  105448. * Creates a new MorphTargetManager from serialized data
  105449. * @param serializationObject defines the serialized data
  105450. * @param scene defines the hosting scene
  105451. * @returns the new MorphTargetManager
  105452. */
  105453. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  105454. }
  105455. }
  105456. declare module BABYLON {
  105457. /**
  105458. * Class used to represent a specific level of detail of a mesh
  105459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105460. */
  105461. export class MeshLODLevel {
  105462. /** Defines the distance where this level should start being displayed */
  105463. distance: number;
  105464. /** Defines the mesh to use to render this level */
  105465. mesh: Nullable<Mesh>;
  105466. /**
  105467. * Creates a new LOD level
  105468. * @param distance defines the distance where this level should star being displayed
  105469. * @param mesh defines the mesh to use to render this level
  105470. */
  105471. constructor(
  105472. /** Defines the distance where this level should start being displayed */
  105473. distance: number,
  105474. /** Defines the mesh to use to render this level */
  105475. mesh: Nullable<Mesh>);
  105476. }
  105477. }
  105478. declare module BABYLON {
  105479. /**
  105480. * Helper class used to generate a canvas to manipulate images
  105481. */
  105482. export class CanvasGenerator {
  105483. /**
  105484. * Create a new canvas (or offscreen canvas depending on the context)
  105485. * @param width defines the expected width
  105486. * @param height defines the expected height
  105487. * @return a new canvas or offscreen canvas
  105488. */
  105489. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  105490. }
  105491. }
  105492. declare module BABYLON {
  105493. /**
  105494. * Mesh representing the gorund
  105495. */
  105496. export class GroundMesh extends Mesh {
  105497. /** If octree should be generated */
  105498. generateOctree: boolean;
  105499. private _heightQuads;
  105500. /** @hidden */
  105501. _subdivisionsX: number;
  105502. /** @hidden */
  105503. _subdivisionsY: number;
  105504. /** @hidden */
  105505. _width: number;
  105506. /** @hidden */
  105507. _height: number;
  105508. /** @hidden */
  105509. _minX: number;
  105510. /** @hidden */
  105511. _maxX: number;
  105512. /** @hidden */
  105513. _minZ: number;
  105514. /** @hidden */
  105515. _maxZ: number;
  105516. constructor(name: string, scene: Scene);
  105517. /**
  105518. * "GroundMesh"
  105519. * @returns "GroundMesh"
  105520. */
  105521. getClassName(): string;
  105522. /**
  105523. * The minimum of x and y subdivisions
  105524. */
  105525. get subdivisions(): number;
  105526. /**
  105527. * X subdivisions
  105528. */
  105529. get subdivisionsX(): number;
  105530. /**
  105531. * Y subdivisions
  105532. */
  105533. get subdivisionsY(): number;
  105534. /**
  105535. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  105536. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105537. * @param chunksCount the number of subdivisions for x and y
  105538. * @param octreeBlocksSize (Default: 32)
  105539. */
  105540. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  105541. /**
  105542. * Returns a height (y) value in the Worl system :
  105543. * the ground altitude at the coordinates (x, z) expressed in the World system.
  105544. * @param x x coordinate
  105545. * @param z z coordinate
  105546. * @returns the ground y position if (x, z) are outside the ground surface.
  105547. */
  105548. getHeightAtCoordinates(x: number, z: number): number;
  105549. /**
  105550. * Returns a normalized vector (Vector3) orthogonal to the ground
  105551. * at the ground coordinates (x, z) expressed in the World system.
  105552. * @param x x coordinate
  105553. * @param z z coordinate
  105554. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  105555. */
  105556. getNormalAtCoordinates(x: number, z: number): Vector3;
  105557. /**
  105558. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  105559. * at the ground coordinates (x, z) expressed in the World system.
  105560. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  105561. * @param x x coordinate
  105562. * @param z z coordinate
  105563. * @param ref vector to store the result
  105564. * @returns the GroundMesh.
  105565. */
  105566. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  105567. /**
  105568. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  105569. * if the ground has been updated.
  105570. * This can be used in the render loop.
  105571. * @returns the GroundMesh.
  105572. */
  105573. updateCoordinateHeights(): GroundMesh;
  105574. private _getFacetAt;
  105575. private _initHeightQuads;
  105576. private _computeHeightQuads;
  105577. /**
  105578. * Serializes this ground mesh
  105579. * @param serializationObject object to write serialization to
  105580. */
  105581. serialize(serializationObject: any): void;
  105582. /**
  105583. * Parses a serialized ground mesh
  105584. * @param parsedMesh the serialized mesh
  105585. * @param scene the scene to create the ground mesh in
  105586. * @returns the created ground mesh
  105587. */
  105588. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  105589. }
  105590. }
  105591. declare module BABYLON {
  105592. /**
  105593. * Interface for Physics-Joint data
  105594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105595. */
  105596. export interface PhysicsJointData {
  105597. /**
  105598. * The main pivot of the joint
  105599. */
  105600. mainPivot?: Vector3;
  105601. /**
  105602. * The connected pivot of the joint
  105603. */
  105604. connectedPivot?: Vector3;
  105605. /**
  105606. * The main axis of the joint
  105607. */
  105608. mainAxis?: Vector3;
  105609. /**
  105610. * The connected axis of the joint
  105611. */
  105612. connectedAxis?: Vector3;
  105613. /**
  105614. * The collision of the joint
  105615. */
  105616. collision?: boolean;
  105617. /**
  105618. * Native Oimo/Cannon/Energy data
  105619. */
  105620. nativeParams?: any;
  105621. }
  105622. /**
  105623. * This is a holder class for the physics joint created by the physics plugin
  105624. * It holds a set of functions to control the underlying joint
  105625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105626. */
  105627. export class PhysicsJoint {
  105628. /**
  105629. * The type of the physics joint
  105630. */
  105631. type: number;
  105632. /**
  105633. * The data for the physics joint
  105634. */
  105635. jointData: PhysicsJointData;
  105636. private _physicsJoint;
  105637. protected _physicsPlugin: IPhysicsEnginePlugin;
  105638. /**
  105639. * Initializes the physics joint
  105640. * @param type The type of the physics joint
  105641. * @param jointData The data for the physics joint
  105642. */
  105643. constructor(
  105644. /**
  105645. * The type of the physics joint
  105646. */
  105647. type: number,
  105648. /**
  105649. * The data for the physics joint
  105650. */
  105651. jointData: PhysicsJointData);
  105652. /**
  105653. * Gets the physics joint
  105654. */
  105655. get physicsJoint(): any;
  105656. /**
  105657. * Sets the physics joint
  105658. */
  105659. set physicsJoint(newJoint: any);
  105660. /**
  105661. * Sets the physics plugin
  105662. */
  105663. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  105664. /**
  105665. * Execute a function that is physics-plugin specific.
  105666. * @param {Function} func the function that will be executed.
  105667. * It accepts two parameters: the physics world and the physics joint
  105668. */
  105669. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  105670. /**
  105671. * Distance-Joint type
  105672. */
  105673. static DistanceJoint: number;
  105674. /**
  105675. * Hinge-Joint type
  105676. */
  105677. static HingeJoint: number;
  105678. /**
  105679. * Ball-and-Socket joint type
  105680. */
  105681. static BallAndSocketJoint: number;
  105682. /**
  105683. * Wheel-Joint type
  105684. */
  105685. static WheelJoint: number;
  105686. /**
  105687. * Slider-Joint type
  105688. */
  105689. static SliderJoint: number;
  105690. /**
  105691. * Prismatic-Joint type
  105692. */
  105693. static PrismaticJoint: number;
  105694. /**
  105695. * Universal-Joint type
  105696. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  105697. */
  105698. static UniversalJoint: number;
  105699. /**
  105700. * Hinge-Joint 2 type
  105701. */
  105702. static Hinge2Joint: number;
  105703. /**
  105704. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  105705. */
  105706. static PointToPointJoint: number;
  105707. /**
  105708. * Spring-Joint type
  105709. */
  105710. static SpringJoint: number;
  105711. /**
  105712. * Lock-Joint type
  105713. */
  105714. static LockJoint: number;
  105715. }
  105716. /**
  105717. * A class representing a physics distance joint
  105718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105719. */
  105720. export class DistanceJoint extends PhysicsJoint {
  105721. /**
  105722. *
  105723. * @param jointData The data for the Distance-Joint
  105724. */
  105725. constructor(jointData: DistanceJointData);
  105726. /**
  105727. * Update the predefined distance.
  105728. * @param maxDistance The maximum preferred distance
  105729. * @param minDistance The minimum preferred distance
  105730. */
  105731. updateDistance(maxDistance: number, minDistance?: number): void;
  105732. }
  105733. /**
  105734. * Represents a Motor-Enabled Joint
  105735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105736. */
  105737. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  105738. /**
  105739. * Initializes the Motor-Enabled Joint
  105740. * @param type The type of the joint
  105741. * @param jointData The physica joint data for the joint
  105742. */
  105743. constructor(type: number, jointData: PhysicsJointData);
  105744. /**
  105745. * Set the motor values.
  105746. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105747. * @param force the force to apply
  105748. * @param maxForce max force for this motor.
  105749. */
  105750. setMotor(force?: number, maxForce?: number): void;
  105751. /**
  105752. * Set the motor's limits.
  105753. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105754. * @param upperLimit The upper limit of the motor
  105755. * @param lowerLimit The lower limit of the motor
  105756. */
  105757. setLimit(upperLimit: number, lowerLimit?: number): void;
  105758. }
  105759. /**
  105760. * This class represents a single physics Hinge-Joint
  105761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105762. */
  105763. export class HingeJoint extends MotorEnabledJoint {
  105764. /**
  105765. * Initializes the Hinge-Joint
  105766. * @param jointData The joint data for the Hinge-Joint
  105767. */
  105768. constructor(jointData: PhysicsJointData);
  105769. /**
  105770. * Set the motor values.
  105771. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105772. * @param {number} force the force to apply
  105773. * @param {number} maxForce max force for this motor.
  105774. */
  105775. setMotor(force?: number, maxForce?: number): void;
  105776. /**
  105777. * Set the motor's limits.
  105778. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105779. * @param upperLimit The upper limit of the motor
  105780. * @param lowerLimit The lower limit of the motor
  105781. */
  105782. setLimit(upperLimit: number, lowerLimit?: number): void;
  105783. }
  105784. /**
  105785. * This class represents a dual hinge physics joint (same as wheel joint)
  105786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105787. */
  105788. export class Hinge2Joint extends MotorEnabledJoint {
  105789. /**
  105790. * Initializes the Hinge2-Joint
  105791. * @param jointData The joint data for the Hinge2-Joint
  105792. */
  105793. constructor(jointData: PhysicsJointData);
  105794. /**
  105795. * Set the motor values.
  105796. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105797. * @param {number} targetSpeed the speed the motor is to reach
  105798. * @param {number} maxForce max force for this motor.
  105799. * @param {motorIndex} the motor's index, 0 or 1.
  105800. */
  105801. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  105802. /**
  105803. * Set the motor limits.
  105804. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105805. * @param {number} upperLimit the upper limit
  105806. * @param {number} lowerLimit lower limit
  105807. * @param {motorIndex} the motor's index, 0 or 1.
  105808. */
  105809. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105810. }
  105811. /**
  105812. * Interface for a motor enabled joint
  105813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105814. */
  105815. export interface IMotorEnabledJoint {
  105816. /**
  105817. * Physics joint
  105818. */
  105819. physicsJoint: any;
  105820. /**
  105821. * Sets the motor of the motor-enabled joint
  105822. * @param force The force of the motor
  105823. * @param maxForce The maximum force of the motor
  105824. * @param motorIndex The index of the motor
  105825. */
  105826. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  105827. /**
  105828. * Sets the limit of the motor
  105829. * @param upperLimit The upper limit of the motor
  105830. * @param lowerLimit The lower limit of the motor
  105831. * @param motorIndex The index of the motor
  105832. */
  105833. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105834. }
  105835. /**
  105836. * Joint data for a Distance-Joint
  105837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105838. */
  105839. export interface DistanceJointData extends PhysicsJointData {
  105840. /**
  105841. * Max distance the 2 joint objects can be apart
  105842. */
  105843. maxDistance: number;
  105844. }
  105845. /**
  105846. * Joint data from a spring joint
  105847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105848. */
  105849. export interface SpringJointData extends PhysicsJointData {
  105850. /**
  105851. * Length of the spring
  105852. */
  105853. length: number;
  105854. /**
  105855. * Stiffness of the spring
  105856. */
  105857. stiffness: number;
  105858. /**
  105859. * Damping of the spring
  105860. */
  105861. damping: number;
  105862. /** this callback will be called when applying the force to the impostors. */
  105863. forceApplicationCallback: () => void;
  105864. }
  105865. }
  105866. declare module BABYLON {
  105867. /**
  105868. * Holds the data for the raycast result
  105869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105870. */
  105871. export class PhysicsRaycastResult {
  105872. private _hasHit;
  105873. private _hitDistance;
  105874. private _hitNormalWorld;
  105875. private _hitPointWorld;
  105876. private _rayFromWorld;
  105877. private _rayToWorld;
  105878. /**
  105879. * Gets if there was a hit
  105880. */
  105881. get hasHit(): boolean;
  105882. /**
  105883. * Gets the distance from the hit
  105884. */
  105885. get hitDistance(): number;
  105886. /**
  105887. * Gets the hit normal/direction in the world
  105888. */
  105889. get hitNormalWorld(): Vector3;
  105890. /**
  105891. * Gets the hit point in the world
  105892. */
  105893. get hitPointWorld(): Vector3;
  105894. /**
  105895. * Gets the ray "start point" of the ray in the world
  105896. */
  105897. get rayFromWorld(): Vector3;
  105898. /**
  105899. * Gets the ray "end point" of the ray in the world
  105900. */
  105901. get rayToWorld(): Vector3;
  105902. /**
  105903. * Sets the hit data (normal & point in world space)
  105904. * @param hitNormalWorld defines the normal in world space
  105905. * @param hitPointWorld defines the point in world space
  105906. */
  105907. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  105908. /**
  105909. * Sets the distance from the start point to the hit point
  105910. * @param distance
  105911. */
  105912. setHitDistance(distance: number): void;
  105913. /**
  105914. * Calculates the distance manually
  105915. */
  105916. calculateHitDistance(): void;
  105917. /**
  105918. * Resets all the values to default
  105919. * @param from The from point on world space
  105920. * @param to The to point on world space
  105921. */
  105922. reset(from?: Vector3, to?: Vector3): void;
  105923. }
  105924. /**
  105925. * Interface for the size containing width and height
  105926. */
  105927. interface IXYZ {
  105928. /**
  105929. * X
  105930. */
  105931. x: number;
  105932. /**
  105933. * Y
  105934. */
  105935. y: number;
  105936. /**
  105937. * Z
  105938. */
  105939. z: number;
  105940. }
  105941. }
  105942. declare module BABYLON {
  105943. /**
  105944. * Interface used to describe a physics joint
  105945. */
  105946. export interface PhysicsImpostorJoint {
  105947. /** Defines the main impostor to which the joint is linked */
  105948. mainImpostor: PhysicsImpostor;
  105949. /** Defines the impostor that is connected to the main impostor using this joint */
  105950. connectedImpostor: PhysicsImpostor;
  105951. /** Defines the joint itself */
  105952. joint: PhysicsJoint;
  105953. }
  105954. /** @hidden */
  105955. export interface IPhysicsEnginePlugin {
  105956. world: any;
  105957. name: string;
  105958. setGravity(gravity: Vector3): void;
  105959. setTimeStep(timeStep: number): void;
  105960. getTimeStep(): number;
  105961. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105962. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105963. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105964. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105965. removePhysicsBody(impostor: PhysicsImpostor): void;
  105966. generateJoint(joint: PhysicsImpostorJoint): void;
  105967. removeJoint(joint: PhysicsImpostorJoint): void;
  105968. isSupported(): boolean;
  105969. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105970. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105971. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105972. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105973. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105974. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105975. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105976. getBodyMass(impostor: PhysicsImpostor): number;
  105977. getBodyFriction(impostor: PhysicsImpostor): number;
  105978. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105979. getBodyRestitution(impostor: PhysicsImpostor): number;
  105980. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105981. getBodyPressure?(impostor: PhysicsImpostor): number;
  105982. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  105983. getBodyStiffness?(impostor: PhysicsImpostor): number;
  105984. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  105985. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  105986. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  105987. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  105988. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  105989. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  105990. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  105991. sleepBody(impostor: PhysicsImpostor): void;
  105992. wakeUpBody(impostor: PhysicsImpostor): void;
  105993. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105994. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105995. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  105996. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105997. getRadius(impostor: PhysicsImpostor): number;
  105998. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105999. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106000. dispose(): void;
  106001. }
  106002. /**
  106003. * Interface used to define a physics engine
  106004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106005. */
  106006. export interface IPhysicsEngine {
  106007. /**
  106008. * Gets the gravity vector used by the simulation
  106009. */
  106010. gravity: Vector3;
  106011. /**
  106012. * Sets the gravity vector used by the simulation
  106013. * @param gravity defines the gravity vector to use
  106014. */
  106015. setGravity(gravity: Vector3): void;
  106016. /**
  106017. * Set the time step of the physics engine.
  106018. * Default is 1/60.
  106019. * To slow it down, enter 1/600 for example.
  106020. * To speed it up, 1/30
  106021. * @param newTimeStep the new timestep to apply to this world.
  106022. */
  106023. setTimeStep(newTimeStep: number): void;
  106024. /**
  106025. * Get the time step of the physics engine.
  106026. * @returns the current time step
  106027. */
  106028. getTimeStep(): number;
  106029. /**
  106030. * Set the sub time step of the physics engine.
  106031. * Default is 0 meaning there is no sub steps
  106032. * To increase physics resolution precision, set a small value (like 1 ms)
  106033. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106034. */
  106035. setSubTimeStep(subTimeStep: number): void;
  106036. /**
  106037. * Get the sub time step of the physics engine.
  106038. * @returns the current sub time step
  106039. */
  106040. getSubTimeStep(): number;
  106041. /**
  106042. * Release all resources
  106043. */
  106044. dispose(): void;
  106045. /**
  106046. * Gets the name of the current physics plugin
  106047. * @returns the name of the plugin
  106048. */
  106049. getPhysicsPluginName(): string;
  106050. /**
  106051. * Adding a new impostor for the impostor tracking.
  106052. * This will be done by the impostor itself.
  106053. * @param impostor the impostor to add
  106054. */
  106055. addImpostor(impostor: PhysicsImpostor): void;
  106056. /**
  106057. * Remove an impostor from the engine.
  106058. * This impostor and its mesh will not longer be updated by the physics engine.
  106059. * @param impostor the impostor to remove
  106060. */
  106061. removeImpostor(impostor: PhysicsImpostor): void;
  106062. /**
  106063. * Add a joint to the physics engine
  106064. * @param mainImpostor defines the main impostor to which the joint is added.
  106065. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106066. * @param joint defines the joint that will connect both impostors.
  106067. */
  106068. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106069. /**
  106070. * Removes a joint from the simulation
  106071. * @param mainImpostor defines the impostor used with the joint
  106072. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106073. * @param joint defines the joint to remove
  106074. */
  106075. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106076. /**
  106077. * Gets the current plugin used to run the simulation
  106078. * @returns current plugin
  106079. */
  106080. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106081. /**
  106082. * Gets the list of physic impostors
  106083. * @returns an array of PhysicsImpostor
  106084. */
  106085. getImpostors(): Array<PhysicsImpostor>;
  106086. /**
  106087. * Gets the impostor for a physics enabled object
  106088. * @param object defines the object impersonated by the impostor
  106089. * @returns the PhysicsImpostor or null if not found
  106090. */
  106091. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106092. /**
  106093. * Gets the impostor for a physics body object
  106094. * @param body defines physics body used by the impostor
  106095. * @returns the PhysicsImpostor or null if not found
  106096. */
  106097. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106098. /**
  106099. * Does a raycast in the physics world
  106100. * @param from when should the ray start?
  106101. * @param to when should the ray end?
  106102. * @returns PhysicsRaycastResult
  106103. */
  106104. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106105. /**
  106106. * Called by the scene. No need to call it.
  106107. * @param delta defines the timespam between frames
  106108. */
  106109. _step(delta: number): void;
  106110. }
  106111. }
  106112. declare module BABYLON {
  106113. /**
  106114. * The interface for the physics imposter parameters
  106115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106116. */
  106117. export interface PhysicsImpostorParameters {
  106118. /**
  106119. * The mass of the physics imposter
  106120. */
  106121. mass: number;
  106122. /**
  106123. * The friction of the physics imposter
  106124. */
  106125. friction?: number;
  106126. /**
  106127. * The coefficient of restitution of the physics imposter
  106128. */
  106129. restitution?: number;
  106130. /**
  106131. * The native options of the physics imposter
  106132. */
  106133. nativeOptions?: any;
  106134. /**
  106135. * Specifies if the parent should be ignored
  106136. */
  106137. ignoreParent?: boolean;
  106138. /**
  106139. * Specifies if bi-directional transformations should be disabled
  106140. */
  106141. disableBidirectionalTransformation?: boolean;
  106142. /**
  106143. * The pressure inside the physics imposter, soft object only
  106144. */
  106145. pressure?: number;
  106146. /**
  106147. * The stiffness the physics imposter, soft object only
  106148. */
  106149. stiffness?: number;
  106150. /**
  106151. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  106152. */
  106153. velocityIterations?: number;
  106154. /**
  106155. * The number of iterations used in maintaining consistent vertex positions, soft object only
  106156. */
  106157. positionIterations?: number;
  106158. /**
  106159. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  106160. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  106161. * Add to fix multiple points
  106162. */
  106163. fixedPoints?: number;
  106164. /**
  106165. * The collision margin around a soft object
  106166. */
  106167. margin?: number;
  106168. /**
  106169. * The collision margin around a soft object
  106170. */
  106171. damping?: number;
  106172. /**
  106173. * The path for a rope based on an extrusion
  106174. */
  106175. path?: any;
  106176. /**
  106177. * The shape of an extrusion used for a rope based on an extrusion
  106178. */
  106179. shape?: any;
  106180. }
  106181. /**
  106182. * Interface for a physics-enabled object
  106183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106184. */
  106185. export interface IPhysicsEnabledObject {
  106186. /**
  106187. * The position of the physics-enabled object
  106188. */
  106189. position: Vector3;
  106190. /**
  106191. * The rotation of the physics-enabled object
  106192. */
  106193. rotationQuaternion: Nullable<Quaternion>;
  106194. /**
  106195. * The scale of the physics-enabled object
  106196. */
  106197. scaling: Vector3;
  106198. /**
  106199. * The rotation of the physics-enabled object
  106200. */
  106201. rotation?: Vector3;
  106202. /**
  106203. * The parent of the physics-enabled object
  106204. */
  106205. parent?: any;
  106206. /**
  106207. * The bounding info of the physics-enabled object
  106208. * @returns The bounding info of the physics-enabled object
  106209. */
  106210. getBoundingInfo(): BoundingInfo;
  106211. /**
  106212. * Computes the world matrix
  106213. * @param force Specifies if the world matrix should be computed by force
  106214. * @returns A world matrix
  106215. */
  106216. computeWorldMatrix(force: boolean): Matrix;
  106217. /**
  106218. * Gets the world matrix
  106219. * @returns A world matrix
  106220. */
  106221. getWorldMatrix?(): Matrix;
  106222. /**
  106223. * Gets the child meshes
  106224. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106225. * @returns An array of abstract meshes
  106226. */
  106227. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106228. /**
  106229. * Gets the vertex data
  106230. * @param kind The type of vertex data
  106231. * @returns A nullable array of numbers, or a float32 array
  106232. */
  106233. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106234. /**
  106235. * Gets the indices from the mesh
  106236. * @returns A nullable array of index arrays
  106237. */
  106238. getIndices?(): Nullable<IndicesArray>;
  106239. /**
  106240. * Gets the scene from the mesh
  106241. * @returns the indices array or null
  106242. */
  106243. getScene?(): Scene;
  106244. /**
  106245. * Gets the absolute position from the mesh
  106246. * @returns the absolute position
  106247. */
  106248. getAbsolutePosition(): Vector3;
  106249. /**
  106250. * Gets the absolute pivot point from the mesh
  106251. * @returns the absolute pivot point
  106252. */
  106253. getAbsolutePivotPoint(): Vector3;
  106254. /**
  106255. * Rotates the mesh
  106256. * @param axis The axis of rotation
  106257. * @param amount The amount of rotation
  106258. * @param space The space of the rotation
  106259. * @returns The rotation transform node
  106260. */
  106261. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106262. /**
  106263. * Translates the mesh
  106264. * @param axis The axis of translation
  106265. * @param distance The distance of translation
  106266. * @param space The space of the translation
  106267. * @returns The transform node
  106268. */
  106269. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106270. /**
  106271. * Sets the absolute position of the mesh
  106272. * @param absolutePosition The absolute position of the mesh
  106273. * @returns The transform node
  106274. */
  106275. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106276. /**
  106277. * Gets the class name of the mesh
  106278. * @returns The class name
  106279. */
  106280. getClassName(): string;
  106281. }
  106282. /**
  106283. * Represents a physics imposter
  106284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106285. */
  106286. export class PhysicsImpostor {
  106287. /**
  106288. * The physics-enabled object used as the physics imposter
  106289. */
  106290. object: IPhysicsEnabledObject;
  106291. /**
  106292. * The type of the physics imposter
  106293. */
  106294. type: number;
  106295. private _options;
  106296. private _scene?;
  106297. /**
  106298. * The default object size of the imposter
  106299. */
  106300. static DEFAULT_OBJECT_SIZE: Vector3;
  106301. /**
  106302. * The identity quaternion of the imposter
  106303. */
  106304. static IDENTITY_QUATERNION: Quaternion;
  106305. /** @hidden */
  106306. _pluginData: any;
  106307. private _physicsEngine;
  106308. private _physicsBody;
  106309. private _bodyUpdateRequired;
  106310. private _onBeforePhysicsStepCallbacks;
  106311. private _onAfterPhysicsStepCallbacks;
  106312. /** @hidden */
  106313. _onPhysicsCollideCallbacks: Array<{
  106314. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106315. otherImpostors: Array<PhysicsImpostor>;
  106316. }>;
  106317. private _deltaPosition;
  106318. private _deltaRotation;
  106319. private _deltaRotationConjugated;
  106320. /** @hidden */
  106321. _isFromLine: boolean;
  106322. private _parent;
  106323. private _isDisposed;
  106324. private static _tmpVecs;
  106325. private static _tmpQuat;
  106326. /**
  106327. * Specifies if the physics imposter is disposed
  106328. */
  106329. get isDisposed(): boolean;
  106330. /**
  106331. * Gets the mass of the physics imposter
  106332. */
  106333. get mass(): number;
  106334. set mass(value: number);
  106335. /**
  106336. * Gets the coefficient of friction
  106337. */
  106338. get friction(): number;
  106339. /**
  106340. * Sets the coefficient of friction
  106341. */
  106342. set friction(value: number);
  106343. /**
  106344. * Gets the coefficient of restitution
  106345. */
  106346. get restitution(): number;
  106347. /**
  106348. * Sets the coefficient of restitution
  106349. */
  106350. set restitution(value: number);
  106351. /**
  106352. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106353. */
  106354. get pressure(): number;
  106355. /**
  106356. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106357. */
  106358. set pressure(value: number);
  106359. /**
  106360. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106361. */
  106362. get stiffness(): number;
  106363. /**
  106364. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106365. */
  106366. set stiffness(value: number);
  106367. /**
  106368. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106369. */
  106370. get velocityIterations(): number;
  106371. /**
  106372. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106373. */
  106374. set velocityIterations(value: number);
  106375. /**
  106376. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106377. */
  106378. get positionIterations(): number;
  106379. /**
  106380. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106381. */
  106382. set positionIterations(value: number);
  106383. /**
  106384. * The unique id of the physics imposter
  106385. * set by the physics engine when adding this impostor to the array
  106386. */
  106387. uniqueId: number;
  106388. /**
  106389. * @hidden
  106390. */
  106391. soft: boolean;
  106392. /**
  106393. * @hidden
  106394. */
  106395. segments: number;
  106396. private _joints;
  106397. /**
  106398. * Initializes the physics imposter
  106399. * @param object The physics-enabled object used as the physics imposter
  106400. * @param type The type of the physics imposter
  106401. * @param _options The options for the physics imposter
  106402. * @param _scene The Babylon scene
  106403. */
  106404. constructor(
  106405. /**
  106406. * The physics-enabled object used as the physics imposter
  106407. */
  106408. object: IPhysicsEnabledObject,
  106409. /**
  106410. * The type of the physics imposter
  106411. */
  106412. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106413. /**
  106414. * This function will completly initialize this impostor.
  106415. * It will create a new body - but only if this mesh has no parent.
  106416. * If it has, this impostor will not be used other than to define the impostor
  106417. * of the child mesh.
  106418. * @hidden
  106419. */
  106420. _init(): void;
  106421. private _getPhysicsParent;
  106422. /**
  106423. * Should a new body be generated.
  106424. * @returns boolean specifying if body initialization is required
  106425. */
  106426. isBodyInitRequired(): boolean;
  106427. /**
  106428. * Sets the updated scaling
  106429. * @param updated Specifies if the scaling is updated
  106430. */
  106431. setScalingUpdated(): void;
  106432. /**
  106433. * Force a regeneration of this or the parent's impostor's body.
  106434. * Use under cautious - This will remove all joints already implemented.
  106435. */
  106436. forceUpdate(): void;
  106437. /**
  106438. * Gets the body that holds this impostor. Either its own, or its parent.
  106439. */
  106440. get physicsBody(): any;
  106441. /**
  106442. * Get the parent of the physics imposter
  106443. * @returns Physics imposter or null
  106444. */
  106445. get parent(): Nullable<PhysicsImpostor>;
  106446. /**
  106447. * Sets the parent of the physics imposter
  106448. */
  106449. set parent(value: Nullable<PhysicsImpostor>);
  106450. /**
  106451. * Set the physics body. Used mainly by the physics engine/plugin
  106452. */
  106453. set physicsBody(physicsBody: any);
  106454. /**
  106455. * Resets the update flags
  106456. */
  106457. resetUpdateFlags(): void;
  106458. /**
  106459. * Gets the object extend size
  106460. * @returns the object extend size
  106461. */
  106462. getObjectExtendSize(): Vector3;
  106463. /**
  106464. * Gets the object center
  106465. * @returns The object center
  106466. */
  106467. getObjectCenter(): Vector3;
  106468. /**
  106469. * Get a specific parameter from the options parameters
  106470. * @param paramName The object parameter name
  106471. * @returns The object parameter
  106472. */
  106473. getParam(paramName: string): any;
  106474. /**
  106475. * Sets a specific parameter in the options given to the physics plugin
  106476. * @param paramName The parameter name
  106477. * @param value The value of the parameter
  106478. */
  106479. setParam(paramName: string, value: number): void;
  106480. /**
  106481. * Specifically change the body's mass option. Won't recreate the physics body object
  106482. * @param mass The mass of the physics imposter
  106483. */
  106484. setMass(mass: number): void;
  106485. /**
  106486. * Gets the linear velocity
  106487. * @returns linear velocity or null
  106488. */
  106489. getLinearVelocity(): Nullable<Vector3>;
  106490. /**
  106491. * Sets the linear velocity
  106492. * @param velocity linear velocity or null
  106493. */
  106494. setLinearVelocity(velocity: Nullable<Vector3>): void;
  106495. /**
  106496. * Gets the angular velocity
  106497. * @returns angular velocity or null
  106498. */
  106499. getAngularVelocity(): Nullable<Vector3>;
  106500. /**
  106501. * Sets the angular velocity
  106502. * @param velocity The velocity or null
  106503. */
  106504. setAngularVelocity(velocity: Nullable<Vector3>): void;
  106505. /**
  106506. * Execute a function with the physics plugin native code
  106507. * Provide a function the will have two variables - the world object and the physics body object
  106508. * @param func The function to execute with the physics plugin native code
  106509. */
  106510. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  106511. /**
  106512. * Register a function that will be executed before the physics world is stepping forward
  106513. * @param func The function to execute before the physics world is stepped forward
  106514. */
  106515. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106516. /**
  106517. * Unregister a function that will be executed before the physics world is stepping forward
  106518. * @param func The function to execute before the physics world is stepped forward
  106519. */
  106520. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106521. /**
  106522. * Register a function that will be executed after the physics step
  106523. * @param func The function to execute after physics step
  106524. */
  106525. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106526. /**
  106527. * Unregisters a function that will be executed after the physics step
  106528. * @param func The function to execute after physics step
  106529. */
  106530. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106531. /**
  106532. * register a function that will be executed when this impostor collides against a different body
  106533. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  106534. * @param func Callback that is executed on collision
  106535. */
  106536. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  106537. /**
  106538. * Unregisters the physics imposter on contact
  106539. * @param collideAgainst The physics object to collide against
  106540. * @param func Callback to execute on collision
  106541. */
  106542. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  106543. private _tmpQuat;
  106544. private _tmpQuat2;
  106545. /**
  106546. * Get the parent rotation
  106547. * @returns The parent rotation
  106548. */
  106549. getParentsRotation(): Quaternion;
  106550. /**
  106551. * this function is executed by the physics engine.
  106552. */
  106553. beforeStep: () => void;
  106554. /**
  106555. * this function is executed by the physics engine
  106556. */
  106557. afterStep: () => void;
  106558. /**
  106559. * Legacy collision detection event support
  106560. */
  106561. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  106562. /**
  106563. * event and body object due to cannon's event-based architecture.
  106564. */
  106565. onCollide: (e: {
  106566. body: any;
  106567. }) => void;
  106568. /**
  106569. * Apply a force
  106570. * @param force The force to apply
  106571. * @param contactPoint The contact point for the force
  106572. * @returns The physics imposter
  106573. */
  106574. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106575. /**
  106576. * Apply an impulse
  106577. * @param force The impulse force
  106578. * @param contactPoint The contact point for the impulse force
  106579. * @returns The physics imposter
  106580. */
  106581. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106582. /**
  106583. * A help function to create a joint
  106584. * @param otherImpostor A physics imposter used to create a joint
  106585. * @param jointType The type of joint
  106586. * @param jointData The data for the joint
  106587. * @returns The physics imposter
  106588. */
  106589. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  106590. /**
  106591. * Add a joint to this impostor with a different impostor
  106592. * @param otherImpostor A physics imposter used to add a joint
  106593. * @param joint The joint to add
  106594. * @returns The physics imposter
  106595. */
  106596. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  106597. /**
  106598. * Add an anchor to a cloth impostor
  106599. * @param otherImpostor rigid impostor to anchor to
  106600. * @param width ratio across width from 0 to 1
  106601. * @param height ratio up height from 0 to 1
  106602. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  106603. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  106604. * @returns impostor the soft imposter
  106605. */
  106606. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106607. /**
  106608. * Add a hook to a rope impostor
  106609. * @param otherImpostor rigid impostor to anchor to
  106610. * @param length ratio across rope from 0 to 1
  106611. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  106612. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  106613. * @returns impostor the rope imposter
  106614. */
  106615. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106616. /**
  106617. * Will keep this body still, in a sleep mode.
  106618. * @returns the physics imposter
  106619. */
  106620. sleep(): PhysicsImpostor;
  106621. /**
  106622. * Wake the body up.
  106623. * @returns The physics imposter
  106624. */
  106625. wakeUp(): PhysicsImpostor;
  106626. /**
  106627. * Clones the physics imposter
  106628. * @param newObject The physics imposter clones to this physics-enabled object
  106629. * @returns A nullable physics imposter
  106630. */
  106631. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106632. /**
  106633. * Disposes the physics imposter
  106634. */
  106635. dispose(): void;
  106636. /**
  106637. * Sets the delta position
  106638. * @param position The delta position amount
  106639. */
  106640. setDeltaPosition(position: Vector3): void;
  106641. /**
  106642. * Sets the delta rotation
  106643. * @param rotation The delta rotation amount
  106644. */
  106645. setDeltaRotation(rotation: Quaternion): void;
  106646. /**
  106647. * Gets the box size of the physics imposter and stores the result in the input parameter
  106648. * @param result Stores the box size
  106649. * @returns The physics imposter
  106650. */
  106651. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  106652. /**
  106653. * Gets the radius of the physics imposter
  106654. * @returns Radius of the physics imposter
  106655. */
  106656. getRadius(): number;
  106657. /**
  106658. * Sync a bone with this impostor
  106659. * @param bone The bone to sync to the impostor.
  106660. * @param boneMesh The mesh that the bone is influencing.
  106661. * @param jointPivot The pivot of the joint / bone in local space.
  106662. * @param distToJoint Optional distance from the impostor to the joint.
  106663. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106664. */
  106665. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  106666. /**
  106667. * Sync impostor to a bone
  106668. * @param bone The bone that the impostor will be synced to.
  106669. * @param boneMesh The mesh that the bone is influencing.
  106670. * @param jointPivot The pivot of the joint / bone in local space.
  106671. * @param distToJoint Optional distance from the impostor to the joint.
  106672. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106673. * @param boneAxis Optional vector3 axis the bone is aligned with
  106674. */
  106675. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  106676. /**
  106677. * No-Imposter type
  106678. */
  106679. static NoImpostor: number;
  106680. /**
  106681. * Sphere-Imposter type
  106682. */
  106683. static SphereImpostor: number;
  106684. /**
  106685. * Box-Imposter type
  106686. */
  106687. static BoxImpostor: number;
  106688. /**
  106689. * Plane-Imposter type
  106690. */
  106691. static PlaneImpostor: number;
  106692. /**
  106693. * Mesh-imposter type
  106694. */
  106695. static MeshImpostor: number;
  106696. /**
  106697. * Capsule-Impostor type (Ammo.js plugin only)
  106698. */
  106699. static CapsuleImpostor: number;
  106700. /**
  106701. * Cylinder-Imposter type
  106702. */
  106703. static CylinderImpostor: number;
  106704. /**
  106705. * Particle-Imposter type
  106706. */
  106707. static ParticleImpostor: number;
  106708. /**
  106709. * Heightmap-Imposter type
  106710. */
  106711. static HeightmapImpostor: number;
  106712. /**
  106713. * ConvexHull-Impostor type (Ammo.js plugin only)
  106714. */
  106715. static ConvexHullImpostor: number;
  106716. /**
  106717. * Custom-Imposter type (Ammo.js plugin only)
  106718. */
  106719. static CustomImpostor: number;
  106720. /**
  106721. * Rope-Imposter type
  106722. */
  106723. static RopeImpostor: number;
  106724. /**
  106725. * Cloth-Imposter type
  106726. */
  106727. static ClothImpostor: number;
  106728. /**
  106729. * Softbody-Imposter type
  106730. */
  106731. static SoftbodyImpostor: number;
  106732. }
  106733. }
  106734. declare module BABYLON {
  106735. /**
  106736. * @hidden
  106737. **/
  106738. export class _CreationDataStorage {
  106739. closePath?: boolean;
  106740. closeArray?: boolean;
  106741. idx: number[];
  106742. dashSize: number;
  106743. gapSize: number;
  106744. path3D: Path3D;
  106745. pathArray: Vector3[][];
  106746. arc: number;
  106747. radius: number;
  106748. cap: number;
  106749. tessellation: number;
  106750. }
  106751. /**
  106752. * @hidden
  106753. **/
  106754. class _InstanceDataStorage {
  106755. visibleInstances: any;
  106756. batchCache: _InstancesBatch;
  106757. instancesBufferSize: number;
  106758. instancesBuffer: Nullable<Buffer>;
  106759. instancesData: Float32Array;
  106760. overridenInstanceCount: number;
  106761. isFrozen: boolean;
  106762. previousBatch: Nullable<_InstancesBatch>;
  106763. hardwareInstancedRendering: boolean;
  106764. sideOrientation: number;
  106765. manualUpdate: boolean;
  106766. }
  106767. /**
  106768. * @hidden
  106769. **/
  106770. export class _InstancesBatch {
  106771. mustReturn: boolean;
  106772. visibleInstances: Nullable<InstancedMesh[]>[];
  106773. renderSelf: boolean[];
  106774. hardwareInstancedRendering: boolean[];
  106775. }
  106776. /**
  106777. * @hidden
  106778. **/
  106779. class _ThinInstanceDataStorage {
  106780. instancesCount: number;
  106781. matrixBuffer: Nullable<Buffer>;
  106782. matrixBufferSize: number;
  106783. matrixData: Nullable<Float32Array>;
  106784. boundingVectors: Array<Vector3>;
  106785. }
  106786. /**
  106787. * Class used to represent renderable models
  106788. */
  106789. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  106790. /**
  106791. * Mesh side orientation : usually the external or front surface
  106792. */
  106793. static readonly FRONTSIDE: number;
  106794. /**
  106795. * Mesh side orientation : usually the internal or back surface
  106796. */
  106797. static readonly BACKSIDE: number;
  106798. /**
  106799. * Mesh side orientation : both internal and external or front and back surfaces
  106800. */
  106801. static readonly DOUBLESIDE: number;
  106802. /**
  106803. * Mesh side orientation : by default, `FRONTSIDE`
  106804. */
  106805. static readonly DEFAULTSIDE: number;
  106806. /**
  106807. * Mesh cap setting : no cap
  106808. */
  106809. static readonly NO_CAP: number;
  106810. /**
  106811. * Mesh cap setting : one cap at the beginning of the mesh
  106812. */
  106813. static readonly CAP_START: number;
  106814. /**
  106815. * Mesh cap setting : one cap at the end of the mesh
  106816. */
  106817. static readonly CAP_END: number;
  106818. /**
  106819. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  106820. */
  106821. static readonly CAP_ALL: number;
  106822. /**
  106823. * Mesh pattern setting : no flip or rotate
  106824. */
  106825. static readonly NO_FLIP: number;
  106826. /**
  106827. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  106828. */
  106829. static readonly FLIP_TILE: number;
  106830. /**
  106831. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  106832. */
  106833. static readonly ROTATE_TILE: number;
  106834. /**
  106835. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  106836. */
  106837. static readonly FLIP_ROW: number;
  106838. /**
  106839. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  106840. */
  106841. static readonly ROTATE_ROW: number;
  106842. /**
  106843. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  106844. */
  106845. static readonly FLIP_N_ROTATE_TILE: number;
  106846. /**
  106847. * Mesh pattern setting : rotate pattern and rotate
  106848. */
  106849. static readonly FLIP_N_ROTATE_ROW: number;
  106850. /**
  106851. * Mesh tile positioning : part tiles same on left/right or top/bottom
  106852. */
  106853. static readonly CENTER: number;
  106854. /**
  106855. * Mesh tile positioning : part tiles on left
  106856. */
  106857. static readonly LEFT: number;
  106858. /**
  106859. * Mesh tile positioning : part tiles on right
  106860. */
  106861. static readonly RIGHT: number;
  106862. /**
  106863. * Mesh tile positioning : part tiles on top
  106864. */
  106865. static readonly TOP: number;
  106866. /**
  106867. * Mesh tile positioning : part tiles on bottom
  106868. */
  106869. static readonly BOTTOM: number;
  106870. /**
  106871. * Gets the default side orientation.
  106872. * @param orientation the orientation to value to attempt to get
  106873. * @returns the default orientation
  106874. * @hidden
  106875. */
  106876. static _GetDefaultSideOrientation(orientation?: number): number;
  106877. private _internalMeshDataInfo;
  106878. get computeBonesUsingShaders(): boolean;
  106879. set computeBonesUsingShaders(value: boolean);
  106880. /**
  106881. * An event triggered before rendering the mesh
  106882. */
  106883. get onBeforeRenderObservable(): Observable<Mesh>;
  106884. /**
  106885. * An event triggered before binding the mesh
  106886. */
  106887. get onBeforeBindObservable(): Observable<Mesh>;
  106888. /**
  106889. * An event triggered after rendering the mesh
  106890. */
  106891. get onAfterRenderObservable(): Observable<Mesh>;
  106892. /**
  106893. * An event triggered before drawing the mesh
  106894. */
  106895. get onBeforeDrawObservable(): Observable<Mesh>;
  106896. private _onBeforeDrawObserver;
  106897. /**
  106898. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  106899. */
  106900. set onBeforeDraw(callback: () => void);
  106901. get hasInstances(): boolean;
  106902. get hasThinInstances(): boolean;
  106903. /**
  106904. * Gets the delay loading state of the mesh (when delay loading is turned on)
  106905. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  106906. */
  106907. delayLoadState: number;
  106908. /**
  106909. * Gets the list of instances created from this mesh
  106910. * it is not supposed to be modified manually.
  106911. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  106912. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106913. */
  106914. instances: InstancedMesh[];
  106915. /**
  106916. * Gets the file containing delay loading data for this mesh
  106917. */
  106918. delayLoadingFile: string;
  106919. /** @hidden */
  106920. _binaryInfo: any;
  106921. /**
  106922. * User defined function used to change how LOD level selection is done
  106923. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106924. */
  106925. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  106926. /**
  106927. * Gets or sets the morph target manager
  106928. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106929. */
  106930. get morphTargetManager(): Nullable<MorphTargetManager>;
  106931. set morphTargetManager(value: Nullable<MorphTargetManager>);
  106932. /** @hidden */
  106933. _creationDataStorage: Nullable<_CreationDataStorage>;
  106934. /** @hidden */
  106935. _geometry: Nullable<Geometry>;
  106936. /** @hidden */
  106937. _delayInfo: Array<string>;
  106938. /** @hidden */
  106939. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  106940. /** @hidden */
  106941. _instanceDataStorage: _InstanceDataStorage;
  106942. /** @hidden */
  106943. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  106944. private _effectiveMaterial;
  106945. /** @hidden */
  106946. _shouldGenerateFlatShading: boolean;
  106947. /** @hidden */
  106948. _originalBuilderSideOrientation: number;
  106949. /**
  106950. * Use this property to change the original side orientation defined at construction time
  106951. */
  106952. overrideMaterialSideOrientation: Nullable<number>;
  106953. /**
  106954. * Gets the source mesh (the one used to clone this one from)
  106955. */
  106956. get source(): Nullable<Mesh>;
  106957. /**
  106958. * Gets or sets a boolean indicating that this mesh does not use index buffer
  106959. */
  106960. get isUnIndexed(): boolean;
  106961. set isUnIndexed(value: boolean);
  106962. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  106963. get worldMatrixInstancedBuffer(): Float32Array;
  106964. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  106965. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  106966. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  106967. /**
  106968. * @constructor
  106969. * @param name The value used by scene.getMeshByName() to do a lookup.
  106970. * @param scene The scene to add this mesh to.
  106971. * @param parent The parent of this mesh, if it has one
  106972. * @param source An optional Mesh from which geometry is shared, cloned.
  106973. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  106974. * When false, achieved by calling a clone(), also passing False.
  106975. * This will make creation of children, recursive.
  106976. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  106977. */
  106978. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  106979. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  106980. doNotInstantiate: boolean;
  106981. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  106982. /**
  106983. * Gets the class name
  106984. * @returns the string "Mesh".
  106985. */
  106986. getClassName(): string;
  106987. /** @hidden */
  106988. get _isMesh(): boolean;
  106989. /**
  106990. * Returns a description of this mesh
  106991. * @param fullDetails define if full details about this mesh must be used
  106992. * @returns a descriptive string representing this mesh
  106993. */
  106994. toString(fullDetails?: boolean): string;
  106995. /** @hidden */
  106996. _unBindEffect(): void;
  106997. /**
  106998. * Gets a boolean indicating if this mesh has LOD
  106999. */
  107000. get hasLODLevels(): boolean;
  107001. /**
  107002. * Gets the list of MeshLODLevel associated with the current mesh
  107003. * @returns an array of MeshLODLevel
  107004. */
  107005. getLODLevels(): MeshLODLevel[];
  107006. private _sortLODLevels;
  107007. /**
  107008. * Add a mesh as LOD level triggered at the given distance.
  107009. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107010. * @param distance The distance from the center of the object to show this level
  107011. * @param mesh The mesh to be added as LOD level (can be null)
  107012. * @return This mesh (for chaining)
  107013. */
  107014. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107015. /**
  107016. * Returns the LOD level mesh at the passed distance or null if not found.
  107017. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107018. * @param distance The distance from the center of the object to show this level
  107019. * @returns a Mesh or `null`
  107020. */
  107021. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107022. /**
  107023. * Remove a mesh from the LOD array
  107024. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107025. * @param mesh defines the mesh to be removed
  107026. * @return This mesh (for chaining)
  107027. */
  107028. removeLODLevel(mesh: Mesh): Mesh;
  107029. /**
  107030. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107031. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107032. * @param camera defines the camera to use to compute distance
  107033. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107034. * @return This mesh (for chaining)
  107035. */
  107036. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107037. /**
  107038. * Gets the mesh internal Geometry object
  107039. */
  107040. get geometry(): Nullable<Geometry>;
  107041. /**
  107042. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107043. * @returns the total number of vertices
  107044. */
  107045. getTotalVertices(): number;
  107046. /**
  107047. * Returns the content of an associated vertex buffer
  107048. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107049. * - VertexBuffer.PositionKind
  107050. * - VertexBuffer.UVKind
  107051. * - VertexBuffer.UV2Kind
  107052. * - VertexBuffer.UV3Kind
  107053. * - VertexBuffer.UV4Kind
  107054. * - VertexBuffer.UV5Kind
  107055. * - VertexBuffer.UV6Kind
  107056. * - VertexBuffer.ColorKind
  107057. * - VertexBuffer.MatricesIndicesKind
  107058. * - VertexBuffer.MatricesIndicesExtraKind
  107059. * - VertexBuffer.MatricesWeightsKind
  107060. * - VertexBuffer.MatricesWeightsExtraKind
  107061. * @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
  107062. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  107063. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  107064. */
  107065. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  107066. /**
  107067. * Returns the mesh VertexBuffer object from the requested `kind`
  107068. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107069. * - VertexBuffer.PositionKind
  107070. * - VertexBuffer.NormalKind
  107071. * - VertexBuffer.UVKind
  107072. * - VertexBuffer.UV2Kind
  107073. * - VertexBuffer.UV3Kind
  107074. * - VertexBuffer.UV4Kind
  107075. * - VertexBuffer.UV5Kind
  107076. * - VertexBuffer.UV6Kind
  107077. * - VertexBuffer.ColorKind
  107078. * - VertexBuffer.MatricesIndicesKind
  107079. * - VertexBuffer.MatricesIndicesExtraKind
  107080. * - VertexBuffer.MatricesWeightsKind
  107081. * - VertexBuffer.MatricesWeightsExtraKind
  107082. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  107083. */
  107084. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  107085. /**
  107086. * Tests if a specific vertex buffer is associated with this mesh
  107087. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107088. * - VertexBuffer.PositionKind
  107089. * - VertexBuffer.NormalKind
  107090. * - VertexBuffer.UVKind
  107091. * - VertexBuffer.UV2Kind
  107092. * - VertexBuffer.UV3Kind
  107093. * - VertexBuffer.UV4Kind
  107094. * - VertexBuffer.UV5Kind
  107095. * - VertexBuffer.UV6Kind
  107096. * - VertexBuffer.ColorKind
  107097. * - VertexBuffer.MatricesIndicesKind
  107098. * - VertexBuffer.MatricesIndicesExtraKind
  107099. * - VertexBuffer.MatricesWeightsKind
  107100. * - VertexBuffer.MatricesWeightsExtraKind
  107101. * @returns a boolean
  107102. */
  107103. isVerticesDataPresent(kind: string): boolean;
  107104. /**
  107105. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  107106. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107107. * - VertexBuffer.PositionKind
  107108. * - VertexBuffer.UVKind
  107109. * - VertexBuffer.UV2Kind
  107110. * - VertexBuffer.UV3Kind
  107111. * - VertexBuffer.UV4Kind
  107112. * - VertexBuffer.UV5Kind
  107113. * - VertexBuffer.UV6Kind
  107114. * - VertexBuffer.ColorKind
  107115. * - VertexBuffer.MatricesIndicesKind
  107116. * - VertexBuffer.MatricesIndicesExtraKind
  107117. * - VertexBuffer.MatricesWeightsKind
  107118. * - VertexBuffer.MatricesWeightsExtraKind
  107119. * @returns a boolean
  107120. */
  107121. isVertexBufferUpdatable(kind: string): boolean;
  107122. /**
  107123. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  107124. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107125. * - VertexBuffer.PositionKind
  107126. * - VertexBuffer.NormalKind
  107127. * - VertexBuffer.UVKind
  107128. * - VertexBuffer.UV2Kind
  107129. * - VertexBuffer.UV3Kind
  107130. * - VertexBuffer.UV4Kind
  107131. * - VertexBuffer.UV5Kind
  107132. * - VertexBuffer.UV6Kind
  107133. * - VertexBuffer.ColorKind
  107134. * - VertexBuffer.MatricesIndicesKind
  107135. * - VertexBuffer.MatricesIndicesExtraKind
  107136. * - VertexBuffer.MatricesWeightsKind
  107137. * - VertexBuffer.MatricesWeightsExtraKind
  107138. * @returns an array of strings
  107139. */
  107140. getVerticesDataKinds(): string[];
  107141. /**
  107142. * Returns a positive integer : the total number of indices in this mesh geometry.
  107143. * @returns the numner of indices or zero if the mesh has no geometry.
  107144. */
  107145. getTotalIndices(): number;
  107146. /**
  107147. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  107148. * @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.
  107149. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  107150. * @returns the indices array or an empty array if the mesh has no geometry
  107151. */
  107152. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  107153. get isBlocked(): boolean;
  107154. /**
  107155. * Determine if the current mesh is ready to be rendered
  107156. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  107157. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  107158. * @returns true if all associated assets are ready (material, textures, shaders)
  107159. */
  107160. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  107161. /**
  107162. * 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.
  107163. */
  107164. get areNormalsFrozen(): boolean;
  107165. /**
  107166. * 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.
  107167. * @returns the current mesh
  107168. */
  107169. freezeNormals(): Mesh;
  107170. /**
  107171. * 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
  107172. * @returns the current mesh
  107173. */
  107174. unfreezeNormals(): Mesh;
  107175. /**
  107176. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107177. */
  107178. set overridenInstanceCount(count: number);
  107179. /** @hidden */
  107180. _preActivate(): Mesh;
  107181. /** @hidden */
  107182. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107183. /** @hidden */
  107184. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107185. protected _afterComputeWorldMatrix(): void;
  107186. /** @hidden */
  107187. _postActivate(): void;
  107188. /**
  107189. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107190. * This means the mesh underlying bounding box and sphere are recomputed.
  107191. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107192. * @returns the current mesh
  107193. */
  107194. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107195. /** @hidden */
  107196. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107197. /**
  107198. * This function will subdivide the mesh into multiple submeshes
  107199. * @param count defines the expected number of submeshes
  107200. */
  107201. subdivide(count: number): void;
  107202. /**
  107203. * Copy a FloatArray into a specific associated vertex buffer
  107204. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107205. * - VertexBuffer.PositionKind
  107206. * - VertexBuffer.UVKind
  107207. * - VertexBuffer.UV2Kind
  107208. * - VertexBuffer.UV3Kind
  107209. * - VertexBuffer.UV4Kind
  107210. * - VertexBuffer.UV5Kind
  107211. * - VertexBuffer.UV6Kind
  107212. * - VertexBuffer.ColorKind
  107213. * - VertexBuffer.MatricesIndicesKind
  107214. * - VertexBuffer.MatricesIndicesExtraKind
  107215. * - VertexBuffer.MatricesWeightsKind
  107216. * - VertexBuffer.MatricesWeightsExtraKind
  107217. * @param data defines the data source
  107218. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107219. * @param stride defines the data stride size (can be null)
  107220. * @returns the current mesh
  107221. */
  107222. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107223. /**
  107224. * Delete a vertex buffer associated with this mesh
  107225. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107226. * - VertexBuffer.PositionKind
  107227. * - VertexBuffer.UVKind
  107228. * - VertexBuffer.UV2Kind
  107229. * - VertexBuffer.UV3Kind
  107230. * - VertexBuffer.UV4Kind
  107231. * - VertexBuffer.UV5Kind
  107232. * - VertexBuffer.UV6Kind
  107233. * - VertexBuffer.ColorKind
  107234. * - VertexBuffer.MatricesIndicesKind
  107235. * - VertexBuffer.MatricesIndicesExtraKind
  107236. * - VertexBuffer.MatricesWeightsKind
  107237. * - VertexBuffer.MatricesWeightsExtraKind
  107238. */
  107239. removeVerticesData(kind: string): void;
  107240. /**
  107241. * Flags an associated vertex buffer as updatable
  107242. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107243. * - VertexBuffer.PositionKind
  107244. * - VertexBuffer.UVKind
  107245. * - VertexBuffer.UV2Kind
  107246. * - VertexBuffer.UV3Kind
  107247. * - VertexBuffer.UV4Kind
  107248. * - VertexBuffer.UV5Kind
  107249. * - VertexBuffer.UV6Kind
  107250. * - VertexBuffer.ColorKind
  107251. * - VertexBuffer.MatricesIndicesKind
  107252. * - VertexBuffer.MatricesIndicesExtraKind
  107253. * - VertexBuffer.MatricesWeightsKind
  107254. * - VertexBuffer.MatricesWeightsExtraKind
  107255. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107256. */
  107257. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107258. /**
  107259. * Sets the mesh global Vertex Buffer
  107260. * @param buffer defines the buffer to use
  107261. * @returns the current mesh
  107262. */
  107263. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107264. /**
  107265. * Update a specific associated vertex buffer
  107266. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107267. * - VertexBuffer.PositionKind
  107268. * - VertexBuffer.UVKind
  107269. * - VertexBuffer.UV2Kind
  107270. * - VertexBuffer.UV3Kind
  107271. * - VertexBuffer.UV4Kind
  107272. * - VertexBuffer.UV5Kind
  107273. * - VertexBuffer.UV6Kind
  107274. * - VertexBuffer.ColorKind
  107275. * - VertexBuffer.MatricesIndicesKind
  107276. * - VertexBuffer.MatricesIndicesExtraKind
  107277. * - VertexBuffer.MatricesWeightsKind
  107278. * - VertexBuffer.MatricesWeightsExtraKind
  107279. * @param data defines the data source
  107280. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107281. * @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)
  107282. * @returns the current mesh
  107283. */
  107284. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107285. /**
  107286. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107287. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107288. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107289. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107290. * @returns the current mesh
  107291. */
  107292. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107293. /**
  107294. * Creates a un-shared specific occurence of the geometry for the mesh.
  107295. * @returns the current mesh
  107296. */
  107297. makeGeometryUnique(): Mesh;
  107298. /**
  107299. * Set the index buffer of this mesh
  107300. * @param indices defines the source data
  107301. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107302. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107303. * @returns the current mesh
  107304. */
  107305. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107306. /**
  107307. * Update the current index buffer
  107308. * @param indices defines the source data
  107309. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107310. * @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)
  107311. * @returns the current mesh
  107312. */
  107313. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107314. /**
  107315. * Invert the geometry to move from a right handed system to a left handed one.
  107316. * @returns the current mesh
  107317. */
  107318. toLeftHanded(): Mesh;
  107319. /** @hidden */
  107320. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107321. /** @hidden */
  107322. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107323. /**
  107324. * Registers for this mesh a javascript function called just before the rendering process
  107325. * @param func defines the function to call before rendering this mesh
  107326. * @returns the current mesh
  107327. */
  107328. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107329. /**
  107330. * Disposes a previously registered javascript function called before the rendering
  107331. * @param func defines the function to remove
  107332. * @returns the current mesh
  107333. */
  107334. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107335. /**
  107336. * Registers for this mesh a javascript function called just after the rendering is complete
  107337. * @param func defines the function to call after rendering this mesh
  107338. * @returns the current mesh
  107339. */
  107340. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107341. /**
  107342. * Disposes a previously registered javascript function called after the rendering.
  107343. * @param func defines the function to remove
  107344. * @returns the current mesh
  107345. */
  107346. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107347. /** @hidden */
  107348. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107349. /** @hidden */
  107350. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107351. /** @hidden */
  107352. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107353. /** @hidden */
  107354. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107355. /** @hidden */
  107356. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107357. /** @hidden */
  107358. _rebuild(): void;
  107359. /** @hidden */
  107360. _freeze(): void;
  107361. /** @hidden */
  107362. _unFreeze(): void;
  107363. /**
  107364. * 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
  107365. * @param subMesh defines the subMesh to render
  107366. * @param enableAlphaMode defines if alpha mode can be changed
  107367. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107368. * @returns the current mesh
  107369. */
  107370. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107371. private _onBeforeDraw;
  107372. /**
  107373. * Renormalize the mesh and patch it up if there are no weights
  107374. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107375. * However in the case of zero weights then we set just a single influence to 1.
  107376. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107377. */
  107378. cleanMatrixWeights(): void;
  107379. private normalizeSkinFourWeights;
  107380. private normalizeSkinWeightsAndExtra;
  107381. /**
  107382. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107383. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107384. * the user know there was an issue with importing the mesh
  107385. * @returns a validation object with skinned, valid and report string
  107386. */
  107387. validateSkinning(): {
  107388. skinned: boolean;
  107389. valid: boolean;
  107390. report: string;
  107391. };
  107392. /** @hidden */
  107393. _checkDelayState(): Mesh;
  107394. private _queueLoad;
  107395. /**
  107396. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107397. * A mesh is in the frustum if its bounding box intersects the frustum
  107398. * @param frustumPlanes defines the frustum to test
  107399. * @returns true if the mesh is in the frustum planes
  107400. */
  107401. isInFrustum(frustumPlanes: Plane[]): boolean;
  107402. /**
  107403. * Sets the mesh material by the material or multiMaterial `id` property
  107404. * @param id is a string identifying the material or the multiMaterial
  107405. * @returns the current mesh
  107406. */
  107407. setMaterialByID(id: string): Mesh;
  107408. /**
  107409. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107410. * @returns an array of IAnimatable
  107411. */
  107412. getAnimatables(): IAnimatable[];
  107413. /**
  107414. * Modifies the mesh geometry according to the passed transformation matrix.
  107415. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107416. * The mesh normals are modified using the same transformation.
  107417. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107418. * @param transform defines the transform matrix to use
  107419. * @see https://doc.babylonjs.com/resources/baking_transformations
  107420. * @returns the current mesh
  107421. */
  107422. bakeTransformIntoVertices(transform: Matrix): Mesh;
  107423. /**
  107424. * Modifies the mesh geometry according to its own current World Matrix.
  107425. * The mesh World Matrix is then reset.
  107426. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  107427. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107428. * @see https://doc.babylonjs.com/resources/baking_transformations
  107429. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  107430. * @returns the current mesh
  107431. */
  107432. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  107433. /** @hidden */
  107434. get _positions(): Nullable<Vector3[]>;
  107435. /** @hidden */
  107436. _resetPointsArrayCache(): Mesh;
  107437. /** @hidden */
  107438. _generatePointsArray(): boolean;
  107439. /**
  107440. * Returns a new Mesh object generated from the current mesh properties.
  107441. * This method must not get confused with createInstance()
  107442. * @param name is a string, the name given to the new mesh
  107443. * @param newParent can be any Node object (default `null`)
  107444. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  107445. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  107446. * @returns a new mesh
  107447. */
  107448. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  107449. /**
  107450. * Releases resources associated with this mesh.
  107451. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107452. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107453. */
  107454. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107455. /** @hidden */
  107456. _disposeInstanceSpecificData(): void;
  107457. /** @hidden */
  107458. _disposeThinInstanceSpecificData(): void;
  107459. /**
  107460. * Modifies the mesh geometry according to a displacement map.
  107461. * 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.
  107462. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107463. * @param url is a string, the URL from the image file is to be downloaded.
  107464. * @param minHeight is the lower limit of the displacement.
  107465. * @param maxHeight is the upper limit of the displacement.
  107466. * @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.
  107467. * @param uvOffset is an optional vector2 used to offset UV.
  107468. * @param uvScale is an optional vector2 used to scale UV.
  107469. * @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.
  107470. * @returns the Mesh.
  107471. */
  107472. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107473. /**
  107474. * Modifies the mesh geometry according to a displacementMap buffer.
  107475. * 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.
  107476. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107477. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  107478. * @param heightMapWidth is the width of the buffer image.
  107479. * @param heightMapHeight is the height of the buffer image.
  107480. * @param minHeight is the lower limit of the displacement.
  107481. * @param maxHeight is the upper limit of the displacement.
  107482. * @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.
  107483. * @param uvOffset is an optional vector2 used to offset UV.
  107484. * @param uvScale is an optional vector2 used to scale UV.
  107485. * @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.
  107486. * @returns the Mesh.
  107487. */
  107488. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107489. /**
  107490. * Modify the mesh to get a flat shading rendering.
  107491. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  107492. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  107493. * @returns current mesh
  107494. */
  107495. convertToFlatShadedMesh(): Mesh;
  107496. /**
  107497. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  107498. * In other words, more vertices, no more indices and a single bigger VBO.
  107499. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  107500. * @returns current mesh
  107501. */
  107502. convertToUnIndexedMesh(): Mesh;
  107503. /**
  107504. * Inverses facet orientations.
  107505. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107506. * @param flipNormals will also inverts the normals
  107507. * @returns current mesh
  107508. */
  107509. flipFaces(flipNormals?: boolean): Mesh;
  107510. /**
  107511. * Increase the number of facets and hence vertices in a mesh
  107512. * Vertex normals are interpolated from existing vertex normals
  107513. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107514. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  107515. */
  107516. increaseVertices(numberPerEdge: number): void;
  107517. /**
  107518. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  107519. * This will undo any application of covertToFlatShadedMesh
  107520. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107521. */
  107522. forceSharedVertices(): void;
  107523. /** @hidden */
  107524. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  107525. /** @hidden */
  107526. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  107527. /**
  107528. * Creates a new InstancedMesh object from the mesh model.
  107529. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107530. * @param name defines the name of the new instance
  107531. * @returns a new InstancedMesh
  107532. */
  107533. createInstance(name: string): InstancedMesh;
  107534. /**
  107535. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  107536. * After this call, all the mesh instances have the same submeshes than the current mesh.
  107537. * @returns the current mesh
  107538. */
  107539. synchronizeInstances(): Mesh;
  107540. /**
  107541. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  107542. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  107543. * This should be used together with the simplification to avoid disappearing triangles.
  107544. * @param successCallback an optional success callback to be called after the optimization finished.
  107545. * @returns the current mesh
  107546. */
  107547. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  107548. /**
  107549. * Serialize current mesh
  107550. * @param serializationObject defines the object which will receive the serialization data
  107551. */
  107552. serialize(serializationObject: any): void;
  107553. /** @hidden */
  107554. _syncGeometryWithMorphTargetManager(): void;
  107555. /** @hidden */
  107556. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  107557. /**
  107558. * Returns a new Mesh object parsed from the source provided.
  107559. * @param parsedMesh is the source
  107560. * @param scene defines the hosting scene
  107561. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  107562. * @returns a new Mesh
  107563. */
  107564. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  107565. /**
  107566. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  107567. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107568. * @param name defines the name of the mesh to create
  107569. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  107570. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  107571. * @param closePath creates a seam between the first and the last points of each path of the path array
  107572. * @param offset is taken in account only if the `pathArray` is containing a single path
  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 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)
  107577. * @returns a new Mesh
  107578. */
  107579. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107580. /**
  107581. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  107582. * @param name defines the name of the mesh to create
  107583. * @param radius sets the radius size (float) of the polygon (default 0.5)
  107584. * @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
  107585. * @param scene defines the hosting scene
  107586. * @param updatable defines if the mesh must be flagged as updatable
  107587. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107588. * @returns a new Mesh
  107589. */
  107590. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107591. /**
  107592. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  107593. * @param name defines the name of the mesh to create
  107594. * @param size sets the size (float) of each box side (default 1)
  107595. * @param scene defines the hosting scene
  107596. * @param updatable defines if the mesh must be flagged as updatable
  107597. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107598. * @returns a new Mesh
  107599. */
  107600. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107601. /**
  107602. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  107603. * @param name defines the name of the mesh to create
  107604. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107605. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107606. * @param scene defines the hosting scene
  107607. * @param updatable defines if the mesh must be flagged as updatable
  107608. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107609. * @returns a new Mesh
  107610. */
  107611. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107612. /**
  107613. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  107614. * @param name defines the name of the mesh to create
  107615. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107616. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107617. * @param scene defines the hosting scene
  107618. * @returns a new Mesh
  107619. */
  107620. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  107621. /**
  107622. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  107623. * @param name defines the name of the mesh to create
  107624. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  107625. * @param diameterTop set the top cap diameter (floats, default 1)
  107626. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  107627. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  107628. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  107629. * @param scene defines the hosting scene
  107630. * @param updatable defines if the mesh must be flagged as updatable
  107631. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107632. * @returns a new Mesh
  107633. */
  107634. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  107635. /**
  107636. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  107637. * @param name defines the name of the mesh to create
  107638. * @param diameter sets the diameter size (float) of the torus (default 1)
  107639. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  107640. * @param tessellation sets the number of torus sides (postive integer, default 16)
  107641. * @param scene defines the hosting scene
  107642. * @param updatable defines if the mesh must be flagged as updatable
  107643. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107644. * @returns a new Mesh
  107645. */
  107646. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107647. /**
  107648. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  107649. * @param name defines the name of the mesh to create
  107650. * @param radius sets the global radius size (float) of the torus knot (default 2)
  107651. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  107652. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  107653. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  107654. * @param p the number of windings on X axis (positive integers, default 2)
  107655. * @param q the number of windings on Y axis (positive integers, default 3)
  107656. * @param scene defines the hosting scene
  107657. * @param updatable defines if the mesh must be flagged as updatable
  107658. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107659. * @returns a new Mesh
  107660. */
  107661. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107662. /**
  107663. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  107664. * @param name defines the name of the mesh to create
  107665. * @param points is an array successive Vector3
  107666. * @param scene defines the hosting scene
  107667. * @param updatable defines if the mesh must be flagged as updatable
  107668. * @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).
  107669. * @returns a new Mesh
  107670. */
  107671. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  107672. /**
  107673. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  107674. * @param name defines the name of the mesh to create
  107675. * @param points is an array successive Vector3
  107676. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  107677. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107678. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  107679. * @param scene defines the hosting scene
  107680. * @param updatable defines if the mesh must be flagged as updatable
  107681. * @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)
  107682. * @returns a new Mesh
  107683. */
  107684. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  107685. /**
  107686. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  107687. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  107688. * 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.
  107689. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107690. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107691. * Remember you can only change the shape positions, not their number when updating a polygon.
  107692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107693. * @param name defines the name of the mesh to create
  107694. * @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
  107695. * @param scene defines the hosting scene
  107696. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107697. * @param updatable defines if the mesh must be flagged as updatable
  107698. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107699. * @param earcutInjection can be used to inject your own earcut reference
  107700. * @returns a new Mesh
  107701. */
  107702. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107703. /**
  107704. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  107705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  107706. * @param name defines the name of the mesh to create
  107707. * @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
  107708. * @param depth defines the height of extrusion
  107709. * @param scene defines the hosting scene
  107710. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107711. * @param updatable defines if the mesh must be flagged as updatable
  107712. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107713. * @param earcutInjection can be used to inject your own earcut reference
  107714. * @returns a new Mesh
  107715. */
  107716. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107717. /**
  107718. * Creates an extruded shape mesh.
  107719. * 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
  107720. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107722. * @param name defines the name of the mesh to create
  107723. * @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
  107724. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107725. * @param scale is the value to scale the shape
  107726. * @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
  107727. * @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
  107728. * @param scene defines the hosting scene
  107729. * @param updatable defines if the mesh must be flagged as updatable
  107730. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107731. * @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)
  107732. * @returns a new Mesh
  107733. */
  107734. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107735. /**
  107736. * Creates an custom extruded shape mesh.
  107737. * The custom extrusion is a parametric shape.
  107738. * It has no predefined shape. Its final shape will depend on the input parameters.
  107739. * Please consider using the same method from the MeshBuilder class instead
  107740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107741. * @param name defines the name of the mesh to create
  107742. * @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
  107743. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107744. * @param scaleFunction is a custom Javascript function called on each path point
  107745. * @param rotationFunction is a custom Javascript function called on each path point
  107746. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107747. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  107748. * @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
  107749. * @param scene defines the hosting scene
  107750. * @param updatable defines if the mesh must be flagged as updatable
  107751. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107752. * @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)
  107753. * @returns a new Mesh
  107754. */
  107755. 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;
  107756. /**
  107757. * Creates lathe mesh.
  107758. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  107759. * Please consider using the same method from the MeshBuilder class instead
  107760. * @param name defines the name of the mesh to create
  107761. * @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
  107762. * @param radius is the radius value of the lathe
  107763. * @param tessellation is the side number of the lathe.
  107764. * @param scene defines the hosting scene
  107765. * @param updatable defines if the mesh must be flagged as updatable
  107766. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107767. * @returns a new Mesh
  107768. */
  107769. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107770. /**
  107771. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  107772. * @param name defines the name of the mesh to create
  107773. * @param size sets the size (float) of both sides of the plane at once (default 1)
  107774. * @param scene defines the hosting scene
  107775. * @param updatable defines if the mesh must be flagged as updatable
  107776. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107777. * @returns a new Mesh
  107778. */
  107779. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107780. /**
  107781. * Creates a ground mesh.
  107782. * Please consider using the same method from the MeshBuilder class instead
  107783. * @param name defines the name of the mesh to create
  107784. * @param width set the width of the ground
  107785. * @param height set the height of the ground
  107786. * @param subdivisions sets the number of subdivisions per side
  107787. * @param scene defines the hosting scene
  107788. * @param updatable defines if the mesh must be flagged as updatable
  107789. * @returns a new Mesh
  107790. */
  107791. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  107792. /**
  107793. * Creates a tiled ground mesh.
  107794. * Please consider using the same method from the MeshBuilder class instead
  107795. * @param name defines the name of the mesh to create
  107796. * @param xmin set the ground minimum X coordinate
  107797. * @param zmin set the ground minimum Y coordinate
  107798. * @param xmax set the ground maximum X coordinate
  107799. * @param zmax set the ground maximum Z coordinate
  107800. * @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
  107801. * @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
  107802. * @param scene defines the hosting scene
  107803. * @param updatable defines if the mesh must be flagged as updatable
  107804. * @returns a new Mesh
  107805. */
  107806. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  107807. w: number;
  107808. h: number;
  107809. }, precision: {
  107810. w: number;
  107811. h: number;
  107812. }, scene: Scene, updatable?: boolean): Mesh;
  107813. /**
  107814. * Creates a ground mesh from a height map.
  107815. * Please consider using the same method from the MeshBuilder class instead
  107816. * @see https://doc.babylonjs.com/babylon101/height_map
  107817. * @param name defines the name of the mesh to create
  107818. * @param url sets the URL of the height map image resource
  107819. * @param width set the ground width size
  107820. * @param height set the ground height size
  107821. * @param subdivisions sets the number of subdivision per side
  107822. * @param minHeight is the minimum altitude on the ground
  107823. * @param maxHeight is the maximum altitude on the ground
  107824. * @param scene defines the hosting scene
  107825. * @param updatable defines if the mesh must be flagged as updatable
  107826. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  107827. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107828. * @returns a new Mesh
  107829. */
  107830. 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;
  107831. /**
  107832. * Creates a tube mesh.
  107833. * The tube is a parametric shape.
  107834. * It has no predefined shape. Its final shape will depend on the input parameters.
  107835. * Please consider using the same method from the MeshBuilder class instead
  107836. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107837. * @param name defines the name of the mesh to create
  107838. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  107839. * @param radius sets the tube radius size
  107840. * @param tessellation is the number of sides on the tubular surface
  107841. * @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
  107842. * @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
  107843. * @param scene defines the hosting scene
  107844. * @param updatable defines if the mesh must be flagged as updatable
  107845. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107846. * @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)
  107847. * @returns a new Mesh
  107848. */
  107849. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  107850. (i: number, distance: number): number;
  107851. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107852. /**
  107853. * Creates a polyhedron mesh.
  107854. * Please consider using the same method from the MeshBuilder class instead.
  107855. * * 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
  107856. * * The parameter `size` (positive float, default 1) sets the polygon size
  107857. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107858. * * 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`
  107859. * * 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
  107860. * * 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)`)
  107861. * * 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
  107862. * * 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
  107863. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107866. * @param name defines the name of the mesh to create
  107867. * @param options defines the options used to create the mesh
  107868. * @param scene defines the hosting scene
  107869. * @returns a new Mesh
  107870. */
  107871. static CreatePolyhedron(name: string, options: {
  107872. type?: number;
  107873. size?: number;
  107874. sizeX?: number;
  107875. sizeY?: number;
  107876. sizeZ?: number;
  107877. custom?: any;
  107878. faceUV?: Vector4[];
  107879. faceColors?: Color4[];
  107880. updatable?: boolean;
  107881. sideOrientation?: number;
  107882. }, scene: Scene): Mesh;
  107883. /**
  107884. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107885. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107886. * * 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`)
  107887. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107888. * * 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
  107889. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107892. * @param name defines the name of the mesh
  107893. * @param options defines the options used to create the mesh
  107894. * @param scene defines the hosting scene
  107895. * @returns a new Mesh
  107896. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107897. */
  107898. static CreateIcoSphere(name: string, options: {
  107899. radius?: number;
  107900. flat?: boolean;
  107901. subdivisions?: number;
  107902. sideOrientation?: number;
  107903. updatable?: boolean;
  107904. }, scene: Scene): Mesh;
  107905. /**
  107906. * Creates a decal mesh.
  107907. * Please consider using the same method from the MeshBuilder class instead.
  107908. * A decal is a mesh usually applied as a model onto the surface of another mesh
  107909. * @param name defines the name of the mesh
  107910. * @param sourceMesh defines the mesh receiving the decal
  107911. * @param position sets the position of the decal in world coordinates
  107912. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  107913. * @param size sets the decal scaling
  107914. * @param angle sets the angle to rotate the decal
  107915. * @returns a new Mesh
  107916. */
  107917. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  107918. /**
  107919. * Prepare internal position array for software CPU skinning
  107920. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  107921. */
  107922. setPositionsForCPUSkinning(): Float32Array;
  107923. /**
  107924. * Prepare internal normal array for software CPU skinning
  107925. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  107926. */
  107927. setNormalsForCPUSkinning(): Float32Array;
  107928. /**
  107929. * Updates the vertex buffer by applying transformation from the bones
  107930. * @param skeleton defines the skeleton to apply to current mesh
  107931. * @returns the current mesh
  107932. */
  107933. applySkeleton(skeleton: Skeleton): Mesh;
  107934. /**
  107935. * 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
  107936. * @param meshes defines the list of meshes to scan
  107937. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  107938. */
  107939. static MinMax(meshes: AbstractMesh[]): {
  107940. min: Vector3;
  107941. max: Vector3;
  107942. };
  107943. /**
  107944. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  107945. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  107946. * @returns a vector3
  107947. */
  107948. static Center(meshesOrMinMaxVector: {
  107949. min: Vector3;
  107950. max: Vector3;
  107951. } | AbstractMesh[]): Vector3;
  107952. /**
  107953. * Merge the array of meshes into a single mesh for performance reasons.
  107954. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  107955. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  107956. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  107957. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  107958. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  107959. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  107960. * @returns a new mesh
  107961. */
  107962. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  107963. /** @hidden */
  107964. addInstance(instance: InstancedMesh): void;
  107965. /** @hidden */
  107966. removeInstance(instance: InstancedMesh): void;
  107967. }
  107968. }
  107969. declare module BABYLON {
  107970. /**
  107971. * This is the base class of all the camera used in the application.
  107972. * @see https://doc.babylonjs.com/features/cameras
  107973. */
  107974. export class Camera extends Node {
  107975. /** @hidden */
  107976. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  107977. /**
  107978. * This is the default projection mode used by the cameras.
  107979. * It helps recreating a feeling of perspective and better appreciate depth.
  107980. * This is the best way to simulate real life cameras.
  107981. */
  107982. static readonly PERSPECTIVE_CAMERA: number;
  107983. /**
  107984. * This helps creating camera with an orthographic mode.
  107985. * 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.
  107986. */
  107987. static readonly ORTHOGRAPHIC_CAMERA: number;
  107988. /**
  107989. * This is the default FOV mode for perspective cameras.
  107990. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  107991. */
  107992. static readonly FOVMODE_VERTICAL_FIXED: number;
  107993. /**
  107994. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  107995. */
  107996. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  107997. /**
  107998. * This specifies ther is no need for a camera rig.
  107999. * Basically only one eye is rendered corresponding to the camera.
  108000. */
  108001. static readonly RIG_MODE_NONE: number;
  108002. /**
  108003. * Simulates a camera Rig with one blue eye and one red eye.
  108004. * This can be use with 3d blue and red glasses.
  108005. */
  108006. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108007. /**
  108008. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108009. */
  108010. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108011. /**
  108012. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108013. */
  108014. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108015. /**
  108016. * Defines that both eyes of the camera will be rendered over under each other.
  108017. */
  108018. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108019. /**
  108020. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108021. */
  108022. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108023. /**
  108024. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108025. */
  108026. static readonly RIG_MODE_VR: number;
  108027. /**
  108028. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108029. */
  108030. static readonly RIG_MODE_WEBVR: number;
  108031. /**
  108032. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108033. */
  108034. static readonly RIG_MODE_CUSTOM: number;
  108035. /**
  108036. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108037. */
  108038. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108039. /**
  108040. * Define the input manager associated with the camera.
  108041. */
  108042. inputs: CameraInputsManager<Camera>;
  108043. /** @hidden */
  108044. _position: Vector3;
  108045. /**
  108046. * Define the current local position of the camera in the scene
  108047. */
  108048. get position(): Vector3;
  108049. set position(newPosition: Vector3);
  108050. /**
  108051. * The vector the camera should consider as up.
  108052. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108053. */
  108054. upVector: Vector3;
  108055. /**
  108056. * Define the current limit on the left side for an orthographic camera
  108057. * In scene unit
  108058. */
  108059. orthoLeft: Nullable<number>;
  108060. /**
  108061. * Define the current limit on the right side for an orthographic camera
  108062. * In scene unit
  108063. */
  108064. orthoRight: Nullable<number>;
  108065. /**
  108066. * Define the current limit on the bottom side for an orthographic camera
  108067. * In scene unit
  108068. */
  108069. orthoBottom: Nullable<number>;
  108070. /**
  108071. * Define the current limit on the top side for an orthographic camera
  108072. * In scene unit
  108073. */
  108074. orthoTop: Nullable<number>;
  108075. /**
  108076. * Field Of View is set in Radians. (default is 0.8)
  108077. */
  108078. fov: number;
  108079. /**
  108080. * Define the minimum distance the camera can see from.
  108081. * This is important to note that the depth buffer are not infinite and the closer it starts
  108082. * the more your scene might encounter depth fighting issue.
  108083. */
  108084. minZ: number;
  108085. /**
  108086. * Define the maximum distance the camera can see to.
  108087. * This is important to note that the depth buffer are not infinite and the further it end
  108088. * the more your scene might encounter depth fighting issue.
  108089. */
  108090. maxZ: number;
  108091. /**
  108092. * Define the default inertia of the camera.
  108093. * This helps giving a smooth feeling to the camera movement.
  108094. */
  108095. inertia: number;
  108096. /**
  108097. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  108098. */
  108099. mode: number;
  108100. /**
  108101. * Define whether the camera is intermediate.
  108102. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  108103. */
  108104. isIntermediate: boolean;
  108105. /**
  108106. * Define the viewport of the camera.
  108107. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  108108. */
  108109. viewport: Viewport;
  108110. /**
  108111. * Restricts the camera to viewing objects with the same layerMask.
  108112. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  108113. */
  108114. layerMask: number;
  108115. /**
  108116. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  108117. */
  108118. fovMode: number;
  108119. /**
  108120. * Rig mode of the camera.
  108121. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  108122. * This is normally controlled byt the camera themselves as internal use.
  108123. */
  108124. cameraRigMode: number;
  108125. /**
  108126. * Defines the distance between both "eyes" in case of a RIG
  108127. */
  108128. interaxialDistance: number;
  108129. /**
  108130. * Defines if stereoscopic rendering is done side by side or over under.
  108131. */
  108132. isStereoscopicSideBySide: boolean;
  108133. /**
  108134. * 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
  108135. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  108136. * else in the scene. (Eg. security camera)
  108137. *
  108138. * 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)
  108139. */
  108140. customRenderTargets: RenderTargetTexture[];
  108141. /**
  108142. * When set, the camera will render to this render target instead of the default canvas
  108143. *
  108144. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  108145. */
  108146. outputRenderTarget: Nullable<RenderTargetTexture>;
  108147. /**
  108148. * Observable triggered when the camera view matrix has changed.
  108149. */
  108150. onViewMatrixChangedObservable: Observable<Camera>;
  108151. /**
  108152. * Observable triggered when the camera Projection matrix has changed.
  108153. */
  108154. onProjectionMatrixChangedObservable: Observable<Camera>;
  108155. /**
  108156. * Observable triggered when the inputs have been processed.
  108157. */
  108158. onAfterCheckInputsObservable: Observable<Camera>;
  108159. /**
  108160. * Observable triggered when reset has been called and applied to the camera.
  108161. */
  108162. onRestoreStateObservable: Observable<Camera>;
  108163. /**
  108164. * Is this camera a part of a rig system?
  108165. */
  108166. isRigCamera: boolean;
  108167. /**
  108168. * If isRigCamera set to true this will be set with the parent camera.
  108169. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  108170. */
  108171. rigParent?: Camera;
  108172. /** @hidden */
  108173. _cameraRigParams: any;
  108174. /** @hidden */
  108175. _rigCameras: Camera[];
  108176. /** @hidden */
  108177. _rigPostProcess: Nullable<PostProcess>;
  108178. protected _webvrViewMatrix: Matrix;
  108179. /** @hidden */
  108180. _skipRendering: boolean;
  108181. /** @hidden */
  108182. _projectionMatrix: Matrix;
  108183. /** @hidden */
  108184. _postProcesses: Nullable<PostProcess>[];
  108185. /** @hidden */
  108186. _activeMeshes: SmartArray<AbstractMesh>;
  108187. protected _globalPosition: Vector3;
  108188. /** @hidden */
  108189. _computedViewMatrix: Matrix;
  108190. private _doNotComputeProjectionMatrix;
  108191. private _transformMatrix;
  108192. private _frustumPlanes;
  108193. private _refreshFrustumPlanes;
  108194. private _storedFov;
  108195. private _stateStored;
  108196. /**
  108197. * Instantiates a new camera object.
  108198. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108199. * @see https://doc.babylonjs.com/features/cameras
  108200. * @param name Defines the name of the camera in the scene
  108201. * @param position Defines the position of the camera
  108202. * @param scene Defines the scene the camera belongs too
  108203. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108204. */
  108205. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108206. /**
  108207. * Store current camera state (fov, position, etc..)
  108208. * @returns the camera
  108209. */
  108210. storeState(): Camera;
  108211. /**
  108212. * Restores the camera state values if it has been stored. You must call storeState() first
  108213. */
  108214. protected _restoreStateValues(): boolean;
  108215. /**
  108216. * Restored camera state. You must call storeState() first.
  108217. * @returns true if restored and false otherwise
  108218. */
  108219. restoreState(): boolean;
  108220. /**
  108221. * Gets the class name of the camera.
  108222. * @returns the class name
  108223. */
  108224. getClassName(): string;
  108225. /** @hidden */
  108226. readonly _isCamera: boolean;
  108227. /**
  108228. * Gets a string representation of the camera useful for debug purpose.
  108229. * @param fullDetails Defines that a more verboe level of logging is required
  108230. * @returns the string representation
  108231. */
  108232. toString(fullDetails?: boolean): string;
  108233. /**
  108234. * Gets the current world space position of the camera.
  108235. */
  108236. get globalPosition(): Vector3;
  108237. /**
  108238. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108239. * @returns the active meshe list
  108240. */
  108241. getActiveMeshes(): SmartArray<AbstractMesh>;
  108242. /**
  108243. * Check whether a mesh is part of the current active mesh list of the camera
  108244. * @param mesh Defines the mesh to check
  108245. * @returns true if active, false otherwise
  108246. */
  108247. isActiveMesh(mesh: Mesh): boolean;
  108248. /**
  108249. * Is this camera ready to be used/rendered
  108250. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108251. * @return true if the camera is ready
  108252. */
  108253. isReady(completeCheck?: boolean): boolean;
  108254. /** @hidden */
  108255. _initCache(): void;
  108256. /** @hidden */
  108257. _updateCache(ignoreParentClass?: boolean): void;
  108258. /** @hidden */
  108259. _isSynchronized(): boolean;
  108260. /** @hidden */
  108261. _isSynchronizedViewMatrix(): boolean;
  108262. /** @hidden */
  108263. _isSynchronizedProjectionMatrix(): boolean;
  108264. /**
  108265. * Attach the input controls to a specific dom element to get the input from.
  108266. * @param element Defines the element the controls should be listened from
  108267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108268. */
  108269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108270. /**
  108271. * Detach the current controls from the specified dom element.
  108272. * @param element Defines the element to stop listening the inputs from
  108273. */
  108274. detachControl(element: HTMLElement): void;
  108275. /**
  108276. * Update the camera state according to the different inputs gathered during the frame.
  108277. */
  108278. update(): void;
  108279. /** @hidden */
  108280. _checkInputs(): void;
  108281. /** @hidden */
  108282. get rigCameras(): Camera[];
  108283. /**
  108284. * Gets the post process used by the rig cameras
  108285. */
  108286. get rigPostProcess(): Nullable<PostProcess>;
  108287. /**
  108288. * Internal, gets the first post proces.
  108289. * @returns the first post process to be run on this camera.
  108290. */
  108291. _getFirstPostProcess(): Nullable<PostProcess>;
  108292. private _cascadePostProcessesToRigCams;
  108293. /**
  108294. * Attach a post process to the camera.
  108295. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108296. * @param postProcess The post process to attach to the camera
  108297. * @param insertAt The position of the post process in case several of them are in use in the scene
  108298. * @returns the position the post process has been inserted at
  108299. */
  108300. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108301. /**
  108302. * Detach a post process to the camera.
  108303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108304. * @param postProcess The post process to detach from the camera
  108305. */
  108306. detachPostProcess(postProcess: PostProcess): void;
  108307. /**
  108308. * Gets the current world matrix of the camera
  108309. */
  108310. getWorldMatrix(): Matrix;
  108311. /** @hidden */
  108312. _getViewMatrix(): Matrix;
  108313. /**
  108314. * Gets the current view matrix of the camera.
  108315. * @param force forces the camera to recompute the matrix without looking at the cached state
  108316. * @returns the view matrix
  108317. */
  108318. getViewMatrix(force?: boolean): Matrix;
  108319. /**
  108320. * Freeze the projection matrix.
  108321. * It will prevent the cache check of the camera projection compute and can speed up perf
  108322. * if no parameter of the camera are meant to change
  108323. * @param projection Defines manually a projection if necessary
  108324. */
  108325. freezeProjectionMatrix(projection?: Matrix): void;
  108326. /**
  108327. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108328. */
  108329. unfreezeProjectionMatrix(): void;
  108330. /**
  108331. * Gets the current projection matrix of the camera.
  108332. * @param force forces the camera to recompute the matrix without looking at the cached state
  108333. * @returns the projection matrix
  108334. */
  108335. getProjectionMatrix(force?: boolean): Matrix;
  108336. /**
  108337. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108338. * @returns a Matrix
  108339. */
  108340. getTransformationMatrix(): Matrix;
  108341. private _updateFrustumPlanes;
  108342. /**
  108343. * Checks if a cullable object (mesh...) is in the camera frustum
  108344. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108345. * @param target The object to check
  108346. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108347. * @returns true if the object is in frustum otherwise false
  108348. */
  108349. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108350. /**
  108351. * Checks if a cullable object (mesh...) is in the camera frustum
  108352. * Unlike isInFrustum this cheks the full bounding box
  108353. * @param target The object to check
  108354. * @returns true if the object is in frustum otherwise false
  108355. */
  108356. isCompletelyInFrustum(target: ICullable): boolean;
  108357. /**
  108358. * Gets a ray in the forward direction from the camera.
  108359. * @param length Defines the length of the ray to create
  108360. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108361. * @param origin Defines the start point of the ray which defaults to the camera position
  108362. * @returns the forward ray
  108363. */
  108364. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108365. /**
  108366. * Gets a ray in the forward direction from the camera.
  108367. * @param refRay the ray to (re)use when setting the values
  108368. * @param length Defines the length of the ray to create
  108369. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108370. * @param origin Defines the start point of the ray which defaults to the camera position
  108371. * @returns the forward ray
  108372. */
  108373. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108374. /**
  108375. * Releases resources associated with this node.
  108376. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108377. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108378. */
  108379. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108380. /** @hidden */
  108381. _isLeftCamera: boolean;
  108382. /**
  108383. * Gets the left camera of a rig setup in case of Rigged Camera
  108384. */
  108385. get isLeftCamera(): boolean;
  108386. /** @hidden */
  108387. _isRightCamera: boolean;
  108388. /**
  108389. * Gets the right camera of a rig setup in case of Rigged Camera
  108390. */
  108391. get isRightCamera(): boolean;
  108392. /**
  108393. * Gets the left camera of a rig setup in case of Rigged Camera
  108394. */
  108395. get leftCamera(): Nullable<FreeCamera>;
  108396. /**
  108397. * Gets the right camera of a rig setup in case of Rigged Camera
  108398. */
  108399. get rightCamera(): Nullable<FreeCamera>;
  108400. /**
  108401. * Gets the left camera target of a rig setup in case of Rigged Camera
  108402. * @returns the target position
  108403. */
  108404. getLeftTarget(): Nullable<Vector3>;
  108405. /**
  108406. * Gets the right camera target of a rig setup in case of Rigged Camera
  108407. * @returns the target position
  108408. */
  108409. getRightTarget(): Nullable<Vector3>;
  108410. /**
  108411. * @hidden
  108412. */
  108413. setCameraRigMode(mode: number, rigParams: any): void;
  108414. /** @hidden */
  108415. static _setStereoscopicRigMode(camera: Camera): void;
  108416. /** @hidden */
  108417. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  108418. /** @hidden */
  108419. static _setVRRigMode(camera: Camera, rigParams: any): void;
  108420. /** @hidden */
  108421. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  108422. /** @hidden */
  108423. _getVRProjectionMatrix(): Matrix;
  108424. protected _updateCameraRotationMatrix(): void;
  108425. protected _updateWebVRCameraRotationMatrix(): void;
  108426. /**
  108427. * This function MUST be overwritten by the different WebVR cameras available.
  108428. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108429. * @hidden
  108430. */
  108431. _getWebVRProjectionMatrix(): Matrix;
  108432. /**
  108433. * This function MUST be overwritten by the different WebVR cameras available.
  108434. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108435. * @hidden
  108436. */
  108437. _getWebVRViewMatrix(): Matrix;
  108438. /** @hidden */
  108439. setCameraRigParameter(name: string, value: any): void;
  108440. /**
  108441. * needs to be overridden by children so sub has required properties to be copied
  108442. * @hidden
  108443. */
  108444. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  108445. /**
  108446. * May need to be overridden by children
  108447. * @hidden
  108448. */
  108449. _updateRigCameras(): void;
  108450. /** @hidden */
  108451. _setupInputs(): void;
  108452. /**
  108453. * Serialiaze the camera setup to a json represention
  108454. * @returns the JSON representation
  108455. */
  108456. serialize(): any;
  108457. /**
  108458. * Clones the current camera.
  108459. * @param name The cloned camera name
  108460. * @returns the cloned camera
  108461. */
  108462. clone(name: string): Camera;
  108463. /**
  108464. * Gets the direction of the camera relative to a given local axis.
  108465. * @param localAxis Defines the reference axis to provide a relative direction.
  108466. * @return the direction
  108467. */
  108468. getDirection(localAxis: Vector3): Vector3;
  108469. /**
  108470. * Returns the current camera absolute rotation
  108471. */
  108472. get absoluteRotation(): Quaternion;
  108473. /**
  108474. * Gets the direction of the camera relative to a given local axis into a passed vector.
  108475. * @param localAxis Defines the reference axis to provide a relative direction.
  108476. * @param result Defines the vector to store the result in
  108477. */
  108478. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  108479. /**
  108480. * Gets a camera constructor for a given camera type
  108481. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  108482. * @param name The name of the camera the result will be able to instantiate
  108483. * @param scene The scene the result will construct the camera in
  108484. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  108485. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  108486. * @returns a factory method to construc the camera
  108487. */
  108488. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  108489. /**
  108490. * Compute the world matrix of the camera.
  108491. * @returns the camera world matrix
  108492. */
  108493. computeWorldMatrix(): Matrix;
  108494. /**
  108495. * Parse a JSON and creates the camera from the parsed information
  108496. * @param parsedCamera The JSON to parse
  108497. * @param scene The scene to instantiate the camera in
  108498. * @returns the newly constructed camera
  108499. */
  108500. static Parse(parsedCamera: any, scene: Scene): Camera;
  108501. }
  108502. }
  108503. declare module BABYLON {
  108504. /**
  108505. * Class containing static functions to help procedurally build meshes
  108506. */
  108507. export class DiscBuilder {
  108508. /**
  108509. * Creates a plane polygonal mesh. By default, this is a disc
  108510. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108511. * * 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
  108512. * * 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
  108513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108516. * @param name defines the name of the mesh
  108517. * @param options defines the options used to create the mesh
  108518. * @param scene defines the hosting scene
  108519. * @returns the plane polygonal mesh
  108520. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108521. */
  108522. static CreateDisc(name: string, options: {
  108523. radius?: number;
  108524. tessellation?: number;
  108525. arc?: number;
  108526. updatable?: boolean;
  108527. sideOrientation?: number;
  108528. frontUVs?: Vector4;
  108529. backUVs?: Vector4;
  108530. }, scene?: Nullable<Scene>): Mesh;
  108531. }
  108532. }
  108533. declare module BABYLON {
  108534. /**
  108535. * Options to be used when creating a FresnelParameters.
  108536. */
  108537. export type IFresnelParametersCreationOptions = {
  108538. /**
  108539. * Define the color used on edges (grazing angle)
  108540. */
  108541. leftColor?: Color3;
  108542. /**
  108543. * Define the color used on center
  108544. */
  108545. rightColor?: Color3;
  108546. /**
  108547. * Define bias applied to computed fresnel term
  108548. */
  108549. bias?: number;
  108550. /**
  108551. * Defined the power exponent applied to fresnel term
  108552. */
  108553. power?: number;
  108554. /**
  108555. * Define if the fresnel effect is enable or not.
  108556. */
  108557. isEnabled?: boolean;
  108558. };
  108559. /**
  108560. * Serialized format for FresnelParameters.
  108561. */
  108562. export type IFresnelParametersSerialized = {
  108563. /**
  108564. * Define the color used on edges (grazing angle) [as an array]
  108565. */
  108566. leftColor: number[];
  108567. /**
  108568. * Define the color used on center [as an array]
  108569. */
  108570. rightColor: number[];
  108571. /**
  108572. * Define bias applied to computed fresnel term
  108573. */
  108574. bias: number;
  108575. /**
  108576. * Defined the power exponent applied to fresnel term
  108577. */
  108578. power?: number;
  108579. /**
  108580. * Define if the fresnel effect is enable or not.
  108581. */
  108582. isEnabled: boolean;
  108583. };
  108584. /**
  108585. * This represents all the required information to add a fresnel effect on a material:
  108586. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108587. */
  108588. export class FresnelParameters {
  108589. private _isEnabled;
  108590. /**
  108591. * Define if the fresnel effect is enable or not.
  108592. */
  108593. get isEnabled(): boolean;
  108594. set isEnabled(value: boolean);
  108595. /**
  108596. * Define the color used on edges (grazing angle)
  108597. */
  108598. leftColor: Color3;
  108599. /**
  108600. * Define the color used on center
  108601. */
  108602. rightColor: Color3;
  108603. /**
  108604. * Define bias applied to computed fresnel term
  108605. */
  108606. bias: number;
  108607. /**
  108608. * Defined the power exponent applied to fresnel term
  108609. */
  108610. power: number;
  108611. /**
  108612. * Creates a new FresnelParameters object.
  108613. *
  108614. * @param options provide your own settings to optionally to override defaults
  108615. */
  108616. constructor(options?: IFresnelParametersCreationOptions);
  108617. /**
  108618. * Clones the current fresnel and its valuues
  108619. * @returns a clone fresnel configuration
  108620. */
  108621. clone(): FresnelParameters;
  108622. /**
  108623. * Determines equality between FresnelParameters objects
  108624. * @param otherFresnelParameters defines the second operand
  108625. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  108626. */
  108627. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  108628. /**
  108629. * Serializes the current fresnel parameters to a JSON representation.
  108630. * @return the JSON serialization
  108631. */
  108632. serialize(): IFresnelParametersSerialized;
  108633. /**
  108634. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  108635. * @param parsedFresnelParameters Define the JSON representation
  108636. * @returns the parsed parameters
  108637. */
  108638. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  108639. }
  108640. }
  108641. declare module BABYLON {
  108642. /**
  108643. * This groups all the flags used to control the materials channel.
  108644. */
  108645. export class MaterialFlags {
  108646. private static _DiffuseTextureEnabled;
  108647. /**
  108648. * Are diffuse textures enabled in the application.
  108649. */
  108650. static get DiffuseTextureEnabled(): boolean;
  108651. static set DiffuseTextureEnabled(value: boolean);
  108652. private static _DetailTextureEnabled;
  108653. /**
  108654. * Are detail textures enabled in the application.
  108655. */
  108656. static get DetailTextureEnabled(): boolean;
  108657. static set DetailTextureEnabled(value: boolean);
  108658. private static _AmbientTextureEnabled;
  108659. /**
  108660. * Are ambient textures enabled in the application.
  108661. */
  108662. static get AmbientTextureEnabled(): boolean;
  108663. static set AmbientTextureEnabled(value: boolean);
  108664. private static _OpacityTextureEnabled;
  108665. /**
  108666. * Are opacity textures enabled in the application.
  108667. */
  108668. static get OpacityTextureEnabled(): boolean;
  108669. static set OpacityTextureEnabled(value: boolean);
  108670. private static _ReflectionTextureEnabled;
  108671. /**
  108672. * Are reflection textures enabled in the application.
  108673. */
  108674. static get ReflectionTextureEnabled(): boolean;
  108675. static set ReflectionTextureEnabled(value: boolean);
  108676. private static _EmissiveTextureEnabled;
  108677. /**
  108678. * Are emissive textures enabled in the application.
  108679. */
  108680. static get EmissiveTextureEnabled(): boolean;
  108681. static set EmissiveTextureEnabled(value: boolean);
  108682. private static _SpecularTextureEnabled;
  108683. /**
  108684. * Are specular textures enabled in the application.
  108685. */
  108686. static get SpecularTextureEnabled(): boolean;
  108687. static set SpecularTextureEnabled(value: boolean);
  108688. private static _BumpTextureEnabled;
  108689. /**
  108690. * Are bump textures enabled in the application.
  108691. */
  108692. static get BumpTextureEnabled(): boolean;
  108693. static set BumpTextureEnabled(value: boolean);
  108694. private static _LightmapTextureEnabled;
  108695. /**
  108696. * Are lightmap textures enabled in the application.
  108697. */
  108698. static get LightmapTextureEnabled(): boolean;
  108699. static set LightmapTextureEnabled(value: boolean);
  108700. private static _RefractionTextureEnabled;
  108701. /**
  108702. * Are refraction textures enabled in the application.
  108703. */
  108704. static get RefractionTextureEnabled(): boolean;
  108705. static set RefractionTextureEnabled(value: boolean);
  108706. private static _ColorGradingTextureEnabled;
  108707. /**
  108708. * Are color grading textures enabled in the application.
  108709. */
  108710. static get ColorGradingTextureEnabled(): boolean;
  108711. static set ColorGradingTextureEnabled(value: boolean);
  108712. private static _FresnelEnabled;
  108713. /**
  108714. * Are fresnels enabled in the application.
  108715. */
  108716. static get FresnelEnabled(): boolean;
  108717. static set FresnelEnabled(value: boolean);
  108718. private static _ClearCoatTextureEnabled;
  108719. /**
  108720. * Are clear coat textures enabled in the application.
  108721. */
  108722. static get ClearCoatTextureEnabled(): boolean;
  108723. static set ClearCoatTextureEnabled(value: boolean);
  108724. private static _ClearCoatBumpTextureEnabled;
  108725. /**
  108726. * Are clear coat bump textures enabled in the application.
  108727. */
  108728. static get ClearCoatBumpTextureEnabled(): boolean;
  108729. static set ClearCoatBumpTextureEnabled(value: boolean);
  108730. private static _ClearCoatTintTextureEnabled;
  108731. /**
  108732. * Are clear coat tint textures enabled in the application.
  108733. */
  108734. static get ClearCoatTintTextureEnabled(): boolean;
  108735. static set ClearCoatTintTextureEnabled(value: boolean);
  108736. private static _SheenTextureEnabled;
  108737. /**
  108738. * Are sheen textures enabled in the application.
  108739. */
  108740. static get SheenTextureEnabled(): boolean;
  108741. static set SheenTextureEnabled(value: boolean);
  108742. private static _AnisotropicTextureEnabled;
  108743. /**
  108744. * Are anisotropic textures enabled in the application.
  108745. */
  108746. static get AnisotropicTextureEnabled(): boolean;
  108747. static set AnisotropicTextureEnabled(value: boolean);
  108748. private static _ThicknessTextureEnabled;
  108749. /**
  108750. * Are thickness textures enabled in the application.
  108751. */
  108752. static get ThicknessTextureEnabled(): boolean;
  108753. static set ThicknessTextureEnabled(value: boolean);
  108754. }
  108755. }
  108756. declare module BABYLON {
  108757. /** @hidden */
  108758. export var defaultFragmentDeclaration: {
  108759. name: string;
  108760. shader: string;
  108761. };
  108762. }
  108763. declare module BABYLON {
  108764. /** @hidden */
  108765. export var defaultUboDeclaration: {
  108766. name: string;
  108767. shader: string;
  108768. };
  108769. }
  108770. declare module BABYLON {
  108771. /** @hidden */
  108772. export var prePassDeclaration: {
  108773. name: string;
  108774. shader: string;
  108775. };
  108776. }
  108777. declare module BABYLON {
  108778. /** @hidden */
  108779. export var lightFragmentDeclaration: {
  108780. name: string;
  108781. shader: string;
  108782. };
  108783. }
  108784. declare module BABYLON {
  108785. /** @hidden */
  108786. export var lightUboDeclaration: {
  108787. name: string;
  108788. shader: string;
  108789. };
  108790. }
  108791. declare module BABYLON {
  108792. /** @hidden */
  108793. export var lightsFragmentFunctions: {
  108794. name: string;
  108795. shader: string;
  108796. };
  108797. }
  108798. declare module BABYLON {
  108799. /** @hidden */
  108800. export var shadowsFragmentFunctions: {
  108801. name: string;
  108802. shader: string;
  108803. };
  108804. }
  108805. declare module BABYLON {
  108806. /** @hidden */
  108807. export var fresnelFunction: {
  108808. name: string;
  108809. shader: string;
  108810. };
  108811. }
  108812. declare module BABYLON {
  108813. /** @hidden */
  108814. export var bumpFragmentMainFunctions: {
  108815. name: string;
  108816. shader: string;
  108817. };
  108818. }
  108819. declare module BABYLON {
  108820. /** @hidden */
  108821. export var bumpFragmentFunctions: {
  108822. name: string;
  108823. shader: string;
  108824. };
  108825. }
  108826. declare module BABYLON {
  108827. /** @hidden */
  108828. export var logDepthDeclaration: {
  108829. name: string;
  108830. shader: string;
  108831. };
  108832. }
  108833. declare module BABYLON {
  108834. /** @hidden */
  108835. export var bumpFragment: {
  108836. name: string;
  108837. shader: string;
  108838. };
  108839. }
  108840. declare module BABYLON {
  108841. /** @hidden */
  108842. export var depthPrePass: {
  108843. name: string;
  108844. shader: string;
  108845. };
  108846. }
  108847. declare module BABYLON {
  108848. /** @hidden */
  108849. export var lightFragment: {
  108850. name: string;
  108851. shader: string;
  108852. };
  108853. }
  108854. declare module BABYLON {
  108855. /** @hidden */
  108856. export var logDepthFragment: {
  108857. name: string;
  108858. shader: string;
  108859. };
  108860. }
  108861. declare module BABYLON {
  108862. /** @hidden */
  108863. export var defaultPixelShader: {
  108864. name: string;
  108865. shader: string;
  108866. };
  108867. }
  108868. declare module BABYLON {
  108869. /** @hidden */
  108870. export var defaultVertexDeclaration: {
  108871. name: string;
  108872. shader: string;
  108873. };
  108874. }
  108875. declare module BABYLON {
  108876. /** @hidden */
  108877. export var bumpVertexDeclaration: {
  108878. name: string;
  108879. shader: string;
  108880. };
  108881. }
  108882. declare module BABYLON {
  108883. /** @hidden */
  108884. export var bumpVertex: {
  108885. name: string;
  108886. shader: string;
  108887. };
  108888. }
  108889. declare module BABYLON {
  108890. /** @hidden */
  108891. export var fogVertex: {
  108892. name: string;
  108893. shader: string;
  108894. };
  108895. }
  108896. declare module BABYLON {
  108897. /** @hidden */
  108898. export var shadowsVertex: {
  108899. name: string;
  108900. shader: string;
  108901. };
  108902. }
  108903. declare module BABYLON {
  108904. /** @hidden */
  108905. export var pointCloudVertex: {
  108906. name: string;
  108907. shader: string;
  108908. };
  108909. }
  108910. declare module BABYLON {
  108911. /** @hidden */
  108912. export var logDepthVertex: {
  108913. name: string;
  108914. shader: string;
  108915. };
  108916. }
  108917. declare module BABYLON {
  108918. /** @hidden */
  108919. export var defaultVertexShader: {
  108920. name: string;
  108921. shader: string;
  108922. };
  108923. }
  108924. declare module BABYLON {
  108925. /**
  108926. * @hidden
  108927. */
  108928. export interface IMaterialDetailMapDefines {
  108929. DETAIL: boolean;
  108930. DETAILDIRECTUV: number;
  108931. DETAIL_NORMALBLENDMETHOD: number;
  108932. /** @hidden */
  108933. _areTexturesDirty: boolean;
  108934. }
  108935. /**
  108936. * Define the code related to the detail map parameters of a material
  108937. *
  108938. * Inspired from:
  108939. * 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
  108940. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  108941. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  108942. */
  108943. export class DetailMapConfiguration {
  108944. private _texture;
  108945. /**
  108946. * The detail texture of the material.
  108947. */
  108948. texture: Nullable<BaseTexture>;
  108949. /**
  108950. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  108951. * Bigger values mean stronger blending
  108952. */
  108953. diffuseBlendLevel: number;
  108954. /**
  108955. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  108956. * Bigger values mean stronger blending. Only used with PBR materials
  108957. */
  108958. roughnessBlendLevel: number;
  108959. /**
  108960. * Defines how strong the bump effect from the detail map is
  108961. * Bigger values mean stronger effect
  108962. */
  108963. bumpLevel: number;
  108964. private _normalBlendMethod;
  108965. /**
  108966. * The method used to blend the bump and detail normals together
  108967. */
  108968. normalBlendMethod: number;
  108969. private _isEnabled;
  108970. /**
  108971. * Enable or disable the detail map on this material
  108972. */
  108973. isEnabled: boolean;
  108974. /** @hidden */
  108975. private _internalMarkAllSubMeshesAsTexturesDirty;
  108976. /** @hidden */
  108977. _markAllSubMeshesAsTexturesDirty(): void;
  108978. /**
  108979. * Instantiate a new detail map
  108980. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108981. */
  108982. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108983. /**
  108984. * Gets whether the submesh is ready to be used or not.
  108985. * @param defines the list of "defines" to update.
  108986. * @param scene defines the scene the material belongs to.
  108987. * @returns - boolean indicating that the submesh is ready or not.
  108988. */
  108989. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  108990. /**
  108991. * Update the defines for detail map usage
  108992. * @param defines the list of "defines" to update.
  108993. * @param scene defines the scene the material belongs to.
  108994. */
  108995. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  108996. /**
  108997. * Binds the material data.
  108998. * @param uniformBuffer defines the Uniform buffer to fill in.
  108999. * @param scene defines the scene the material belongs to.
  109000. * @param isFrozen defines whether the material is frozen or not.
  109001. */
  109002. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109003. /**
  109004. * Checks to see if a texture is used in the material.
  109005. * @param texture - Base texture to use.
  109006. * @returns - Boolean specifying if a texture is used in the material.
  109007. */
  109008. hasTexture(texture: BaseTexture): boolean;
  109009. /**
  109010. * Returns an array of the actively used textures.
  109011. * @param activeTextures Array of BaseTextures
  109012. */
  109013. getActiveTextures(activeTextures: BaseTexture[]): void;
  109014. /**
  109015. * Returns the animatable textures.
  109016. * @param animatables Array of animatable textures.
  109017. */
  109018. getAnimatables(animatables: IAnimatable[]): void;
  109019. /**
  109020. * Disposes the resources of the material.
  109021. * @param forceDisposeTextures - Forces the disposal of all textures.
  109022. */
  109023. dispose(forceDisposeTextures?: boolean): void;
  109024. /**
  109025. * Get the current class name useful for serialization or dynamic coding.
  109026. * @returns "DetailMap"
  109027. */
  109028. getClassName(): string;
  109029. /**
  109030. * Add the required uniforms to the current list.
  109031. * @param uniforms defines the current uniform list.
  109032. */
  109033. static AddUniforms(uniforms: string[]): void;
  109034. /**
  109035. * Add the required samplers to the current list.
  109036. * @param samplers defines the current sampler list.
  109037. */
  109038. static AddSamplers(samplers: string[]): void;
  109039. /**
  109040. * Add the required uniforms to the current buffer.
  109041. * @param uniformBuffer defines the current uniform buffer.
  109042. */
  109043. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109044. /**
  109045. * Makes a duplicate of the current instance into another one.
  109046. * @param detailMap define the instance where to copy the info
  109047. */
  109048. copyTo(detailMap: DetailMapConfiguration): void;
  109049. /**
  109050. * Serializes this detail map instance
  109051. * @returns - An object with the serialized instance.
  109052. */
  109053. serialize(): any;
  109054. /**
  109055. * Parses a detail map setting from a serialized object.
  109056. * @param source - Serialized object.
  109057. * @param scene Defines the scene we are parsing for
  109058. * @param rootUrl Defines the rootUrl to load from
  109059. */
  109060. parse(source: any, scene: Scene, rootUrl: string): void;
  109061. }
  109062. }
  109063. declare module BABYLON {
  109064. /** @hidden */
  109065. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  109066. MAINUV1: boolean;
  109067. MAINUV2: boolean;
  109068. DIFFUSE: boolean;
  109069. DIFFUSEDIRECTUV: number;
  109070. DETAIL: boolean;
  109071. DETAILDIRECTUV: number;
  109072. DETAIL_NORMALBLENDMETHOD: number;
  109073. AMBIENT: boolean;
  109074. AMBIENTDIRECTUV: number;
  109075. OPACITY: boolean;
  109076. OPACITYDIRECTUV: number;
  109077. OPACITYRGB: boolean;
  109078. REFLECTION: boolean;
  109079. EMISSIVE: boolean;
  109080. EMISSIVEDIRECTUV: number;
  109081. SPECULAR: boolean;
  109082. SPECULARDIRECTUV: number;
  109083. BUMP: boolean;
  109084. BUMPDIRECTUV: number;
  109085. PARALLAX: boolean;
  109086. PARALLAXOCCLUSION: boolean;
  109087. SPECULAROVERALPHA: boolean;
  109088. CLIPPLANE: boolean;
  109089. CLIPPLANE2: boolean;
  109090. CLIPPLANE3: boolean;
  109091. CLIPPLANE4: boolean;
  109092. CLIPPLANE5: boolean;
  109093. CLIPPLANE6: boolean;
  109094. ALPHATEST: boolean;
  109095. DEPTHPREPASS: boolean;
  109096. ALPHAFROMDIFFUSE: boolean;
  109097. POINTSIZE: boolean;
  109098. FOG: boolean;
  109099. SPECULARTERM: boolean;
  109100. DIFFUSEFRESNEL: boolean;
  109101. OPACITYFRESNEL: boolean;
  109102. REFLECTIONFRESNEL: boolean;
  109103. REFRACTIONFRESNEL: boolean;
  109104. EMISSIVEFRESNEL: boolean;
  109105. FRESNEL: boolean;
  109106. NORMAL: boolean;
  109107. UV1: boolean;
  109108. UV2: boolean;
  109109. VERTEXCOLOR: boolean;
  109110. VERTEXALPHA: boolean;
  109111. NUM_BONE_INFLUENCERS: number;
  109112. BonesPerMesh: number;
  109113. BONETEXTURE: boolean;
  109114. INSTANCES: boolean;
  109115. THIN_INSTANCES: boolean;
  109116. GLOSSINESS: boolean;
  109117. ROUGHNESS: boolean;
  109118. EMISSIVEASILLUMINATION: boolean;
  109119. LINKEMISSIVEWITHDIFFUSE: boolean;
  109120. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109121. LIGHTMAP: boolean;
  109122. LIGHTMAPDIRECTUV: number;
  109123. OBJECTSPACE_NORMALMAP: boolean;
  109124. USELIGHTMAPASSHADOWMAP: boolean;
  109125. REFLECTIONMAP_3D: boolean;
  109126. REFLECTIONMAP_SPHERICAL: boolean;
  109127. REFLECTIONMAP_PLANAR: boolean;
  109128. REFLECTIONMAP_CUBIC: boolean;
  109129. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109130. REFLECTIONMAP_PROJECTION: boolean;
  109131. REFLECTIONMAP_SKYBOX: boolean;
  109132. REFLECTIONMAP_EXPLICIT: boolean;
  109133. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109134. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109135. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109136. INVERTCUBICMAP: boolean;
  109137. LOGARITHMICDEPTH: boolean;
  109138. REFRACTION: boolean;
  109139. REFRACTIONMAP_3D: boolean;
  109140. REFLECTIONOVERALPHA: boolean;
  109141. TWOSIDEDLIGHTING: boolean;
  109142. SHADOWFLOAT: boolean;
  109143. MORPHTARGETS: boolean;
  109144. MORPHTARGETS_NORMAL: boolean;
  109145. MORPHTARGETS_TANGENT: boolean;
  109146. MORPHTARGETS_UV: boolean;
  109147. NUM_MORPH_INFLUENCERS: number;
  109148. NONUNIFORMSCALING: boolean;
  109149. PREMULTIPLYALPHA: boolean;
  109150. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  109151. ALPHABLEND: boolean;
  109152. PREPASS: boolean;
  109153. SCENE_MRT_COUNT: number;
  109154. RGBDLIGHTMAP: boolean;
  109155. RGBDREFLECTION: boolean;
  109156. RGBDREFRACTION: boolean;
  109157. IMAGEPROCESSING: boolean;
  109158. VIGNETTE: boolean;
  109159. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109160. VIGNETTEBLENDMODEOPAQUE: boolean;
  109161. TONEMAPPING: boolean;
  109162. TONEMAPPING_ACES: boolean;
  109163. CONTRAST: boolean;
  109164. COLORCURVES: boolean;
  109165. COLORGRADING: boolean;
  109166. COLORGRADING3D: boolean;
  109167. SAMPLER3DGREENDEPTH: boolean;
  109168. SAMPLER3DBGRMAP: boolean;
  109169. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109170. MULTIVIEW: boolean;
  109171. /**
  109172. * If the reflection texture on this material is in linear color space
  109173. * @hidden
  109174. */
  109175. IS_REFLECTION_LINEAR: boolean;
  109176. /**
  109177. * If the refraction texture on this material is in linear color space
  109178. * @hidden
  109179. */
  109180. IS_REFRACTION_LINEAR: boolean;
  109181. EXPOSURE: boolean;
  109182. constructor();
  109183. setReflectionMode(modeToEnable: string): void;
  109184. }
  109185. /**
  109186. * This is the default material used in Babylon. It is the best trade off between quality
  109187. * and performances.
  109188. * @see https://doc.babylonjs.com/babylon101/materials
  109189. */
  109190. export class StandardMaterial extends PushMaterial {
  109191. private _diffuseTexture;
  109192. /**
  109193. * The basic texture of the material as viewed under a light.
  109194. */
  109195. diffuseTexture: Nullable<BaseTexture>;
  109196. private _ambientTexture;
  109197. /**
  109198. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109199. */
  109200. ambientTexture: Nullable<BaseTexture>;
  109201. private _opacityTexture;
  109202. /**
  109203. * Define the transparency of the material from a texture.
  109204. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109205. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109206. */
  109207. opacityTexture: Nullable<BaseTexture>;
  109208. private _reflectionTexture;
  109209. /**
  109210. * Define the texture used to display the reflection.
  109211. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109212. */
  109213. reflectionTexture: Nullable<BaseTexture>;
  109214. private _emissiveTexture;
  109215. /**
  109216. * Define texture of the material as if self lit.
  109217. * This will be mixed in the final result even in the absence of light.
  109218. */
  109219. emissiveTexture: Nullable<BaseTexture>;
  109220. private _specularTexture;
  109221. /**
  109222. * Define how the color and intensity of the highlight given by the light in the material.
  109223. */
  109224. specularTexture: Nullable<BaseTexture>;
  109225. private _bumpTexture;
  109226. /**
  109227. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109228. * 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.
  109229. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109230. */
  109231. bumpTexture: Nullable<BaseTexture>;
  109232. private _lightmapTexture;
  109233. /**
  109234. * Complex lighting can be computationally expensive to compute at runtime.
  109235. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109236. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109237. */
  109238. lightmapTexture: Nullable<BaseTexture>;
  109239. private _refractionTexture;
  109240. /**
  109241. * Define the texture used to display the refraction.
  109242. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109243. */
  109244. refractionTexture: Nullable<BaseTexture>;
  109245. /**
  109246. * The color of the material lit by the environmental background lighting.
  109247. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109248. */
  109249. ambientColor: Color3;
  109250. /**
  109251. * The basic color of the material as viewed under a light.
  109252. */
  109253. diffuseColor: Color3;
  109254. /**
  109255. * Define how the color and intensity of the highlight given by the light in the material.
  109256. */
  109257. specularColor: Color3;
  109258. /**
  109259. * Define the color of the material as if self lit.
  109260. * This will be mixed in the final result even in the absence of light.
  109261. */
  109262. emissiveColor: Color3;
  109263. /**
  109264. * Defines how sharp are the highlights in the material.
  109265. * The bigger the value the sharper giving a more glossy feeling to the result.
  109266. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109267. */
  109268. specularPower: number;
  109269. private _useAlphaFromDiffuseTexture;
  109270. /**
  109271. * Does the transparency come from the diffuse texture alpha channel.
  109272. */
  109273. useAlphaFromDiffuseTexture: boolean;
  109274. private _useEmissiveAsIllumination;
  109275. /**
  109276. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109277. */
  109278. useEmissiveAsIllumination: boolean;
  109279. private _linkEmissiveWithDiffuse;
  109280. /**
  109281. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109282. * the emissive level when the final color is close to one.
  109283. */
  109284. linkEmissiveWithDiffuse: boolean;
  109285. private _useSpecularOverAlpha;
  109286. /**
  109287. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109288. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109289. */
  109290. useSpecularOverAlpha: boolean;
  109291. private _useReflectionOverAlpha;
  109292. /**
  109293. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109294. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109295. */
  109296. useReflectionOverAlpha: boolean;
  109297. private _disableLighting;
  109298. /**
  109299. * Does lights from the scene impacts this material.
  109300. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109301. */
  109302. disableLighting: boolean;
  109303. private _useObjectSpaceNormalMap;
  109304. /**
  109305. * Allows using an object space normal map (instead of tangent space).
  109306. */
  109307. useObjectSpaceNormalMap: boolean;
  109308. private _useParallax;
  109309. /**
  109310. * Is parallax enabled or not.
  109311. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109312. */
  109313. useParallax: boolean;
  109314. private _useParallaxOcclusion;
  109315. /**
  109316. * Is parallax occlusion enabled or not.
  109317. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109318. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109319. */
  109320. useParallaxOcclusion: boolean;
  109321. /**
  109322. * 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.
  109323. */
  109324. parallaxScaleBias: number;
  109325. private _roughness;
  109326. /**
  109327. * Helps to define how blurry the reflections should appears in the material.
  109328. */
  109329. roughness: number;
  109330. /**
  109331. * In case of refraction, define the value of the index of refraction.
  109332. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109333. */
  109334. indexOfRefraction: number;
  109335. /**
  109336. * Invert the refraction texture alongside the y axis.
  109337. * It can be useful with procedural textures or probe for instance.
  109338. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109339. */
  109340. invertRefractionY: boolean;
  109341. /**
  109342. * Defines the alpha limits in alpha test mode.
  109343. */
  109344. alphaCutOff: number;
  109345. private _useLightmapAsShadowmap;
  109346. /**
  109347. * In case of light mapping, define whether the map contains light or shadow informations.
  109348. */
  109349. useLightmapAsShadowmap: boolean;
  109350. private _diffuseFresnelParameters;
  109351. /**
  109352. * Define the diffuse fresnel parameters of the material.
  109353. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109354. */
  109355. diffuseFresnelParameters: FresnelParameters;
  109356. private _opacityFresnelParameters;
  109357. /**
  109358. * Define the opacity fresnel parameters of the material.
  109359. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109360. */
  109361. opacityFresnelParameters: FresnelParameters;
  109362. private _reflectionFresnelParameters;
  109363. /**
  109364. * Define the reflection fresnel parameters of the material.
  109365. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109366. */
  109367. reflectionFresnelParameters: FresnelParameters;
  109368. private _refractionFresnelParameters;
  109369. /**
  109370. * Define the refraction fresnel parameters of the material.
  109371. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109372. */
  109373. refractionFresnelParameters: FresnelParameters;
  109374. private _emissiveFresnelParameters;
  109375. /**
  109376. * Define the emissive fresnel parameters of the material.
  109377. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109378. */
  109379. emissiveFresnelParameters: FresnelParameters;
  109380. private _useReflectionFresnelFromSpecular;
  109381. /**
  109382. * If true automatically deducts the fresnels values from the material specularity.
  109383. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109384. */
  109385. useReflectionFresnelFromSpecular: boolean;
  109386. private _useGlossinessFromSpecularMapAlpha;
  109387. /**
  109388. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109389. */
  109390. useGlossinessFromSpecularMapAlpha: boolean;
  109391. private _maxSimultaneousLights;
  109392. /**
  109393. * Defines the maximum number of lights that can be used in the material
  109394. */
  109395. maxSimultaneousLights: number;
  109396. private _invertNormalMapX;
  109397. /**
  109398. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109399. */
  109400. invertNormalMapX: boolean;
  109401. private _invertNormalMapY;
  109402. /**
  109403. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109404. */
  109405. invertNormalMapY: boolean;
  109406. private _twoSidedLighting;
  109407. /**
  109408. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109409. */
  109410. twoSidedLighting: boolean;
  109411. /**
  109412. * Default configuration related to image processing available in the standard Material.
  109413. */
  109414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109415. /**
  109416. * Gets the image processing configuration used either in this material.
  109417. */
  109418. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109419. /**
  109420. * Sets the Default image processing configuration used either in the this material.
  109421. *
  109422. * If sets to null, the scene one is in use.
  109423. */
  109424. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  109425. /**
  109426. * Keep track of the image processing observer to allow dispose and replace.
  109427. */
  109428. private _imageProcessingObserver;
  109429. /**
  109430. * Attaches a new image processing configuration to the Standard Material.
  109431. * @param configuration
  109432. */
  109433. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109434. /**
  109435. * Gets wether the color curves effect is enabled.
  109436. */
  109437. get cameraColorCurvesEnabled(): boolean;
  109438. /**
  109439. * Sets wether the color curves effect is enabled.
  109440. */
  109441. set cameraColorCurvesEnabled(value: boolean);
  109442. /**
  109443. * Gets wether the color grading effect is enabled.
  109444. */
  109445. get cameraColorGradingEnabled(): boolean;
  109446. /**
  109447. * Gets wether the color grading effect is enabled.
  109448. */
  109449. set cameraColorGradingEnabled(value: boolean);
  109450. /**
  109451. * Gets wether tonemapping is enabled or not.
  109452. */
  109453. get cameraToneMappingEnabled(): boolean;
  109454. /**
  109455. * Sets wether tonemapping is enabled or not
  109456. */
  109457. set cameraToneMappingEnabled(value: boolean);
  109458. /**
  109459. * The camera exposure used on this material.
  109460. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109461. * This corresponds to a photographic exposure.
  109462. */
  109463. get cameraExposure(): number;
  109464. /**
  109465. * The camera exposure used on this material.
  109466. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109467. * This corresponds to a photographic exposure.
  109468. */
  109469. set cameraExposure(value: number);
  109470. /**
  109471. * Gets The camera contrast used on this material.
  109472. */
  109473. get cameraContrast(): number;
  109474. /**
  109475. * Sets The camera contrast used on this material.
  109476. */
  109477. set cameraContrast(value: number);
  109478. /**
  109479. * Gets the Color Grading 2D Lookup Texture.
  109480. */
  109481. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  109482. /**
  109483. * Sets the Color Grading 2D Lookup Texture.
  109484. */
  109485. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  109486. /**
  109487. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109488. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109489. * 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;
  109490. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109491. */
  109492. get cameraColorCurves(): Nullable<ColorCurves>;
  109493. /**
  109494. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109495. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109496. * 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;
  109497. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109498. */
  109499. set cameraColorCurves(value: Nullable<ColorCurves>);
  109500. /**
  109501. * Can this material render to several textures at once
  109502. */
  109503. get canRenderToMRT(): boolean;
  109504. /**
  109505. * Defines the detail map parameters for the material.
  109506. */
  109507. readonly detailMap: DetailMapConfiguration;
  109508. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109509. protected _worldViewProjectionMatrix: Matrix;
  109510. protected _globalAmbientColor: Color3;
  109511. protected _useLogarithmicDepth: boolean;
  109512. protected _rebuildInParallel: boolean;
  109513. /**
  109514. * Instantiates a new standard material.
  109515. * This is the default material used in Babylon. It is the best trade off between quality
  109516. * and performances.
  109517. * @see https://doc.babylonjs.com/babylon101/materials
  109518. * @param name Define the name of the material in the scene
  109519. * @param scene Define the scene the material belong to
  109520. */
  109521. constructor(name: string, scene: Scene);
  109522. /**
  109523. * Gets a boolean indicating that current material needs to register RTT
  109524. */
  109525. get hasRenderTargetTextures(): boolean;
  109526. /**
  109527. * Gets the current class name of the material e.g. "StandardMaterial"
  109528. * Mainly use in serialization.
  109529. * @returns the class name
  109530. */
  109531. getClassName(): string;
  109532. /**
  109533. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109534. * You can try switching to logarithmic depth.
  109535. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109536. */
  109537. get useLogarithmicDepth(): boolean;
  109538. set useLogarithmicDepth(value: boolean);
  109539. /**
  109540. * Specifies if the material will require alpha blending
  109541. * @returns a boolean specifying if alpha blending is needed
  109542. */
  109543. needAlphaBlending(): boolean;
  109544. /**
  109545. * Specifies if this material should be rendered in alpha test mode
  109546. * @returns a boolean specifying if an alpha test is needed.
  109547. */
  109548. needAlphaTesting(): boolean;
  109549. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109550. /**
  109551. * Get the texture used for alpha test purpose.
  109552. * @returns the diffuse texture in case of the standard material.
  109553. */
  109554. getAlphaTestTexture(): Nullable<BaseTexture>;
  109555. /**
  109556. * Get if the submesh is ready to be used and all its information available.
  109557. * Child classes can use it to update shaders
  109558. * @param mesh defines the mesh to check
  109559. * @param subMesh defines which submesh to check
  109560. * @param useInstances specifies that instances should be used
  109561. * @returns a boolean indicating that the submesh is ready or not
  109562. */
  109563. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109564. /**
  109565. * Builds the material UBO layouts.
  109566. * Used internally during the effect preparation.
  109567. */
  109568. buildUniformLayout(): void;
  109569. /**
  109570. * Unbinds the material from the mesh
  109571. */
  109572. unbind(): void;
  109573. /**
  109574. * Binds the submesh to this material by preparing the effect and shader to draw
  109575. * @param world defines the world transformation matrix
  109576. * @param mesh defines the mesh containing the submesh
  109577. * @param subMesh defines the submesh to bind the material to
  109578. */
  109579. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109580. /**
  109581. * Get the list of animatables in the material.
  109582. * @returns the list of animatables object used in the material
  109583. */
  109584. getAnimatables(): IAnimatable[];
  109585. /**
  109586. * Gets the active textures from the material
  109587. * @returns an array of textures
  109588. */
  109589. getActiveTextures(): BaseTexture[];
  109590. /**
  109591. * Specifies if the material uses a texture
  109592. * @param texture defines the texture to check against the material
  109593. * @returns a boolean specifying if the material uses the texture
  109594. */
  109595. hasTexture(texture: BaseTexture): boolean;
  109596. /**
  109597. * Disposes the material
  109598. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109599. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109600. */
  109601. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109602. /**
  109603. * Makes a duplicate of the material, and gives it a new name
  109604. * @param name defines the new name for the duplicated material
  109605. * @returns the cloned material
  109606. */
  109607. clone(name: string): StandardMaterial;
  109608. /**
  109609. * Serializes this material in a JSON representation
  109610. * @returns the serialized material object
  109611. */
  109612. serialize(): any;
  109613. /**
  109614. * Creates a standard material from parsed material data
  109615. * @param source defines the JSON representation of the material
  109616. * @param scene defines the hosting scene
  109617. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109618. * @returns a new standard material
  109619. */
  109620. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109621. /**
  109622. * Are diffuse textures enabled in the application.
  109623. */
  109624. static get DiffuseTextureEnabled(): boolean;
  109625. static set DiffuseTextureEnabled(value: boolean);
  109626. /**
  109627. * Are detail textures enabled in the application.
  109628. */
  109629. static get DetailTextureEnabled(): boolean;
  109630. static set DetailTextureEnabled(value: boolean);
  109631. /**
  109632. * Are ambient textures enabled in the application.
  109633. */
  109634. static get AmbientTextureEnabled(): boolean;
  109635. static set AmbientTextureEnabled(value: boolean);
  109636. /**
  109637. * Are opacity textures enabled in the application.
  109638. */
  109639. static get OpacityTextureEnabled(): boolean;
  109640. static set OpacityTextureEnabled(value: boolean);
  109641. /**
  109642. * Are reflection textures enabled in the application.
  109643. */
  109644. static get ReflectionTextureEnabled(): boolean;
  109645. static set ReflectionTextureEnabled(value: boolean);
  109646. /**
  109647. * Are emissive textures enabled in the application.
  109648. */
  109649. static get EmissiveTextureEnabled(): boolean;
  109650. static set EmissiveTextureEnabled(value: boolean);
  109651. /**
  109652. * Are specular textures enabled in the application.
  109653. */
  109654. static get SpecularTextureEnabled(): boolean;
  109655. static set SpecularTextureEnabled(value: boolean);
  109656. /**
  109657. * Are bump textures enabled in the application.
  109658. */
  109659. static get BumpTextureEnabled(): boolean;
  109660. static set BumpTextureEnabled(value: boolean);
  109661. /**
  109662. * Are lightmap textures enabled in the application.
  109663. */
  109664. static get LightmapTextureEnabled(): boolean;
  109665. static set LightmapTextureEnabled(value: boolean);
  109666. /**
  109667. * Are refraction textures enabled in the application.
  109668. */
  109669. static get RefractionTextureEnabled(): boolean;
  109670. static set RefractionTextureEnabled(value: boolean);
  109671. /**
  109672. * Are color grading textures enabled in the application.
  109673. */
  109674. static get ColorGradingTextureEnabled(): boolean;
  109675. static set ColorGradingTextureEnabled(value: boolean);
  109676. /**
  109677. * Are fresnels enabled in the application.
  109678. */
  109679. static get FresnelEnabled(): boolean;
  109680. static set FresnelEnabled(value: boolean);
  109681. }
  109682. }
  109683. declare module BABYLON {
  109684. /**
  109685. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109686. *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.
  109687. * The SPS is also a particle system. It provides some methods to manage the particles.
  109688. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109689. *
  109690. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  109691. */
  109692. export class SolidParticleSystem implements IDisposable {
  109693. /**
  109694. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109695. * Example : var p = SPS.particles[i];
  109696. */
  109697. particles: SolidParticle[];
  109698. /**
  109699. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109700. */
  109701. nbParticles: number;
  109702. /**
  109703. * If the particles must ever face the camera (default false). Useful for planar particles.
  109704. */
  109705. billboard: boolean;
  109706. /**
  109707. * Recompute normals when adding a shape
  109708. */
  109709. recomputeNormals: boolean;
  109710. /**
  109711. * This a counter ofr your own usage. It's not set by any SPS functions.
  109712. */
  109713. counter: number;
  109714. /**
  109715. * The SPS name. This name is also given to the underlying mesh.
  109716. */
  109717. name: string;
  109718. /**
  109719. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  109720. */
  109721. mesh: Mesh;
  109722. /**
  109723. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109724. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  109725. */
  109726. vars: any;
  109727. /**
  109728. * This array is populated when the SPS is set as 'pickable'.
  109729. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  109730. * Each element of this array is an object `{idx: int, faceId: int}`.
  109731. * `idx` is the picked particle index in the `SPS.particles` array
  109732. * `faceId` is the picked face index counted within this particle.
  109733. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  109734. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  109735. * Use the method SPS.pickedParticle(pickingInfo) instead.
  109736. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109737. */
  109738. pickedParticles: {
  109739. idx: number;
  109740. faceId: number;
  109741. }[];
  109742. /**
  109743. * This array is populated when the SPS is set as 'pickable'
  109744. * Each key of this array is a submesh index.
  109745. * Each element of this array is a second array defined like this :
  109746. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  109747. * Each element of this second array is an object `{idx: int, faceId: int}`.
  109748. * `idx` is the picked particle index in the `SPS.particles` array
  109749. * `faceId` is the picked face index counted within this particle.
  109750. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  109751. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109752. */
  109753. pickedBySubMesh: {
  109754. idx: number;
  109755. faceId: number;
  109756. }[][];
  109757. /**
  109758. * This array is populated when `enableDepthSort` is set to true.
  109759. * Each element of this array is an instance of the class DepthSortedParticle.
  109760. */
  109761. depthSortedParticles: DepthSortedParticle[];
  109762. /**
  109763. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109764. * @hidden
  109765. */
  109766. _bSphereOnly: boolean;
  109767. /**
  109768. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109769. * @hidden
  109770. */
  109771. _bSphereRadiusFactor: number;
  109772. private _scene;
  109773. private _positions;
  109774. private _indices;
  109775. private _normals;
  109776. private _colors;
  109777. private _uvs;
  109778. private _indices32;
  109779. private _positions32;
  109780. private _normals32;
  109781. private _fixedNormal32;
  109782. private _colors32;
  109783. private _uvs32;
  109784. private _index;
  109785. private _updatable;
  109786. private _pickable;
  109787. private _isVisibilityBoxLocked;
  109788. private _alwaysVisible;
  109789. private _depthSort;
  109790. private _expandable;
  109791. private _shapeCounter;
  109792. private _copy;
  109793. private _color;
  109794. private _computeParticleColor;
  109795. private _computeParticleTexture;
  109796. private _computeParticleRotation;
  109797. private _computeParticleVertex;
  109798. private _computeBoundingBox;
  109799. private _depthSortParticles;
  109800. private _camera;
  109801. private _mustUnrotateFixedNormals;
  109802. private _particlesIntersect;
  109803. private _needs32Bits;
  109804. private _isNotBuilt;
  109805. private _lastParticleId;
  109806. private _idxOfId;
  109807. private _multimaterialEnabled;
  109808. private _useModelMaterial;
  109809. private _indicesByMaterial;
  109810. private _materialIndexes;
  109811. private _depthSortFunction;
  109812. private _materialSortFunction;
  109813. private _materials;
  109814. private _multimaterial;
  109815. private _materialIndexesById;
  109816. private _defaultMaterial;
  109817. private _autoUpdateSubMeshes;
  109818. private _tmpVertex;
  109819. /**
  109820. * Creates a SPS (Solid Particle System) object.
  109821. * @param name (String) is the SPS name, this will be the underlying mesh name.
  109822. * @param scene (Scene) is the scene in which the SPS is added.
  109823. * @param options defines the options of the sps e.g.
  109824. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  109825. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  109826. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  109827. * * 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.
  109828. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  109829. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  109830. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  109831. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  109832. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  109833. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  109834. */
  109835. constructor(name: string, scene: Scene, options?: {
  109836. updatable?: boolean;
  109837. isPickable?: boolean;
  109838. enableDepthSort?: boolean;
  109839. particleIntersection?: boolean;
  109840. boundingSphereOnly?: boolean;
  109841. bSphereRadiusFactor?: number;
  109842. expandable?: boolean;
  109843. useModelMaterial?: boolean;
  109844. enableMultiMaterial?: boolean;
  109845. });
  109846. /**
  109847. * Builds the SPS underlying mesh. Returns a standard Mesh.
  109848. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  109849. * @returns the created mesh
  109850. */
  109851. buildMesh(): Mesh;
  109852. /**
  109853. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  109854. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  109855. * Thus the particles generated from `digest()` have their property `position` set yet.
  109856. * @param mesh ( Mesh ) is the mesh to be digested
  109857. * @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
  109858. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  109859. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  109860. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109861. * @returns the current SPS
  109862. */
  109863. digest(mesh: Mesh, options?: {
  109864. facetNb?: number;
  109865. number?: number;
  109866. delta?: number;
  109867. storage?: [];
  109868. }): SolidParticleSystem;
  109869. /**
  109870. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  109871. * @hidden
  109872. */
  109873. private _unrotateFixedNormals;
  109874. /**
  109875. * Resets the temporary working copy particle
  109876. * @hidden
  109877. */
  109878. private _resetCopy;
  109879. /**
  109880. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  109881. * @param p the current index in the positions array to be updated
  109882. * @param ind the current index in the indices array
  109883. * @param shape a Vector3 array, the shape geometry
  109884. * @param positions the positions array to be updated
  109885. * @param meshInd the shape indices array
  109886. * @param indices the indices array to be updated
  109887. * @param meshUV the shape uv array
  109888. * @param uvs the uv array to be updated
  109889. * @param meshCol the shape color array
  109890. * @param colors the color array to be updated
  109891. * @param meshNor the shape normals array
  109892. * @param normals the normals array to be updated
  109893. * @param idx the particle index
  109894. * @param idxInShape the particle index in its shape
  109895. * @param options the addShape() method passed options
  109896. * @model the particle model
  109897. * @hidden
  109898. */
  109899. private _meshBuilder;
  109900. /**
  109901. * Returns a shape Vector3 array from positions float array
  109902. * @param positions float array
  109903. * @returns a vector3 array
  109904. * @hidden
  109905. */
  109906. private _posToShape;
  109907. /**
  109908. * Returns a shapeUV array from a float uvs (array deep copy)
  109909. * @param uvs as a float array
  109910. * @returns a shapeUV array
  109911. * @hidden
  109912. */
  109913. private _uvsToShapeUV;
  109914. /**
  109915. * Adds a new particle object in the particles array
  109916. * @param idx particle index in particles array
  109917. * @param id particle id
  109918. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  109919. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  109920. * @param model particle ModelShape object
  109921. * @param shapeId model shape identifier
  109922. * @param idxInShape index of the particle in the current model
  109923. * @param bInfo model bounding info object
  109924. * @param storage target storage array, if any
  109925. * @hidden
  109926. */
  109927. private _addParticle;
  109928. /**
  109929. * Adds some particles to the SPS from the model shape. Returns the shape id.
  109930. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  109931. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  109932. * @param nb (positive integer) the number of particles to be created from this model
  109933. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  109934. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  109935. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109936. * @returns the number of shapes in the system
  109937. */
  109938. addShape(mesh: Mesh, nb: number, options?: {
  109939. positionFunction?: any;
  109940. vertexFunction?: any;
  109941. storage?: [];
  109942. }): number;
  109943. /**
  109944. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  109945. * @hidden
  109946. */
  109947. private _rebuildParticle;
  109948. /**
  109949. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  109950. * @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.
  109951. * @returns the SPS.
  109952. */
  109953. rebuildMesh(reset?: boolean): SolidParticleSystem;
  109954. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  109955. * Returns an array with the removed particles.
  109956. * 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.
  109957. * The SPS can't be empty so at least one particle needs to remain in place.
  109958. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  109959. * @param start index of the first particle to remove
  109960. * @param end index of the last particle to remove (included)
  109961. * @returns an array populated with the removed particles
  109962. */
  109963. removeParticles(start: number, end: number): SolidParticle[];
  109964. /**
  109965. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  109966. * @param solidParticleArray an array populated with Solid Particles objects
  109967. * @returns the SPS
  109968. */
  109969. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  109970. /**
  109971. * Creates a new particle and modifies the SPS mesh geometry :
  109972. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  109973. * - calls _addParticle() to populate the particle array
  109974. * factorized code from addShape() and insertParticlesFromArray()
  109975. * @param idx particle index in the particles array
  109976. * @param i particle index in its shape
  109977. * @param modelShape particle ModelShape object
  109978. * @param shape shape vertex array
  109979. * @param meshInd shape indices array
  109980. * @param meshUV shape uv array
  109981. * @param meshCol shape color array
  109982. * @param meshNor shape normals array
  109983. * @param bbInfo shape bounding info
  109984. * @param storage target particle storage
  109985. * @options addShape() passed options
  109986. * @hidden
  109987. */
  109988. private _insertNewParticle;
  109989. /**
  109990. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  109991. * This method calls `updateParticle()` for each particle of the SPS.
  109992. * For an animated SPS, it is usually called within the render loop.
  109993. * 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.
  109994. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  109995. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  109996. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  109997. * @returns the SPS.
  109998. */
  109999. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110000. /**
  110001. * Disposes the SPS.
  110002. */
  110003. dispose(): void;
  110004. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110005. * idx is the particle index in the SPS
  110006. * faceId is the picked face index counted within this particle.
  110007. * Returns null if the pickInfo can't identify a picked particle.
  110008. * @param pickingInfo (PickingInfo object)
  110009. * @returns {idx: number, faceId: number} or null
  110010. */
  110011. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110012. idx: number;
  110013. faceId: number;
  110014. }>;
  110015. /**
  110016. * Returns a SolidParticle object from its identifier : particle.id
  110017. * @param id (integer) the particle Id
  110018. * @returns the searched particle or null if not found in the SPS.
  110019. */
  110020. getParticleById(id: number): Nullable<SolidParticle>;
  110021. /**
  110022. * Returns a new array populated with the particles having the passed shapeId.
  110023. * @param shapeId (integer) the shape identifier
  110024. * @returns a new solid particle array
  110025. */
  110026. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110027. /**
  110028. * Populates the passed array "ref" with the particles having the passed shapeId.
  110029. * @param shapeId the shape identifier
  110030. * @returns the SPS
  110031. * @param ref
  110032. */
  110033. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110034. /**
  110035. * Computes the required SubMeshes according the materials assigned to the particles.
  110036. * @returns the solid particle system.
  110037. * Does nothing if called before the SPS mesh is built.
  110038. */
  110039. computeSubMeshes(): SolidParticleSystem;
  110040. /**
  110041. * Sorts the solid particles by material when MultiMaterial is enabled.
  110042. * Updates the indices32 array.
  110043. * Updates the indicesByMaterial array.
  110044. * Updates the mesh indices array.
  110045. * @returns the SPS
  110046. * @hidden
  110047. */
  110048. private _sortParticlesByMaterial;
  110049. /**
  110050. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110051. * @hidden
  110052. */
  110053. private _setMaterialIndexesById;
  110054. /**
  110055. * Returns an array with unique values of Materials from the passed array
  110056. * @param array the material array to be checked and filtered
  110057. * @hidden
  110058. */
  110059. private _filterUniqueMaterialId;
  110060. /**
  110061. * Sets a new Standard Material as _defaultMaterial if not already set.
  110062. * @hidden
  110063. */
  110064. private _setDefaultMaterial;
  110065. /**
  110066. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110067. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110068. * @returns the SPS.
  110069. */
  110070. refreshVisibleSize(): SolidParticleSystem;
  110071. /**
  110072. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110073. * @param size the size (float) of the visibility box
  110074. * note : this doesn't lock the SPS mesh bounding box.
  110075. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110076. */
  110077. setVisibilityBox(size: number): void;
  110078. /**
  110079. * Gets whether the SPS as always visible or not
  110080. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110081. */
  110082. get isAlwaysVisible(): boolean;
  110083. /**
  110084. * Sets the SPS as always visible or not
  110085. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110086. */
  110087. set isAlwaysVisible(val: boolean);
  110088. /**
  110089. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110090. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110091. */
  110092. set isVisibilityBoxLocked(val: boolean);
  110093. /**
  110094. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110095. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110096. */
  110097. get isVisibilityBoxLocked(): boolean;
  110098. /**
  110099. * Tells to `setParticles()` to compute the particle rotations or not.
  110100. * Default value : true. The SPS is faster when it's set to false.
  110101. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110102. */
  110103. set computeParticleRotation(val: boolean);
  110104. /**
  110105. * Tells to `setParticles()` to compute the particle colors or not.
  110106. * Default value : true. The SPS is faster when it's set to false.
  110107. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110108. */
  110109. set computeParticleColor(val: boolean);
  110110. set computeParticleTexture(val: boolean);
  110111. /**
  110112. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110113. * Default value : false. The SPS is faster when it's set to false.
  110114. * Note : the particle custom vertex positions aren't stored values.
  110115. */
  110116. set computeParticleVertex(val: boolean);
  110117. /**
  110118. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110119. */
  110120. set computeBoundingBox(val: boolean);
  110121. /**
  110122. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110123. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110124. * Default : `true`
  110125. */
  110126. set depthSortParticles(val: boolean);
  110127. /**
  110128. * Gets if `setParticles()` computes the particle rotations or not.
  110129. * Default value : true. The SPS is faster when it's set to false.
  110130. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110131. */
  110132. get computeParticleRotation(): boolean;
  110133. /**
  110134. * Gets if `setParticles()` computes the particle colors or not.
  110135. * Default value : true. The SPS is faster when it's set to false.
  110136. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110137. */
  110138. get computeParticleColor(): boolean;
  110139. /**
  110140. * Gets if `setParticles()` computes the particle textures or not.
  110141. * Default value : true. The SPS is faster when it's set to false.
  110142. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110143. */
  110144. get computeParticleTexture(): boolean;
  110145. /**
  110146. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110147. * Default value : false. The SPS is faster when it's set to false.
  110148. * Note : the particle custom vertex positions aren't stored values.
  110149. */
  110150. get computeParticleVertex(): boolean;
  110151. /**
  110152. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110153. */
  110154. get computeBoundingBox(): boolean;
  110155. /**
  110156. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110157. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110158. * Default : `true`
  110159. */
  110160. get depthSortParticles(): boolean;
  110161. /**
  110162. * Gets if the SPS is created as expandable at construction time.
  110163. * Default : `false`
  110164. */
  110165. get expandable(): boolean;
  110166. /**
  110167. * Gets if the SPS supports the Multi Materials
  110168. */
  110169. get multimaterialEnabled(): boolean;
  110170. /**
  110171. * Gets if the SPS uses the model materials for its own multimaterial.
  110172. */
  110173. get useModelMaterial(): boolean;
  110174. /**
  110175. * The SPS used material array.
  110176. */
  110177. get materials(): Material[];
  110178. /**
  110179. * Sets the SPS MultiMaterial from the passed materials.
  110180. * Note : the passed array is internally copied and not used then by reference.
  110181. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110182. */
  110183. setMultiMaterial(materials: Material[]): void;
  110184. /**
  110185. * The SPS computed multimaterial object
  110186. */
  110187. get multimaterial(): MultiMaterial;
  110188. set multimaterial(mm: MultiMaterial);
  110189. /**
  110190. * If the subMeshes must be updated on the next call to setParticles()
  110191. */
  110192. get autoUpdateSubMeshes(): boolean;
  110193. set autoUpdateSubMeshes(val: boolean);
  110194. /**
  110195. * This function does nothing. It may be overwritten to set all the particle first values.
  110196. * The SPS doesn't call this function, you may have to call it by your own.
  110197. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110198. */
  110199. initParticles(): void;
  110200. /**
  110201. * This function does nothing. It may be overwritten to recycle a particle.
  110202. * The SPS doesn't call this function, you may have to call it by your own.
  110203. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110204. * @param particle The particle to recycle
  110205. * @returns the recycled particle
  110206. */
  110207. recycleParticle(particle: SolidParticle): SolidParticle;
  110208. /**
  110209. * Updates a particle : this function should be overwritten by the user.
  110210. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110211. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110212. * @example : just set a particle position or velocity and recycle conditions
  110213. * @param particle The particle to update
  110214. * @returns the updated particle
  110215. */
  110216. updateParticle(particle: SolidParticle): SolidParticle;
  110217. /**
  110218. * Updates a vertex of a particle : it can be overwritten by the user.
  110219. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110220. * @param particle the current particle
  110221. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110222. * @param pt the index of the current vertex in the particle shape
  110223. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110224. * @example : just set a vertex particle position or color
  110225. * @returns the sps
  110226. */
  110227. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110228. /**
  110229. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110230. * This does nothing and may be overwritten by the user.
  110231. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110232. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110233. * @param update the boolean update value actually passed to setParticles()
  110234. */
  110235. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110236. /**
  110237. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110238. * This will be passed three parameters.
  110239. * This does nothing and may be overwritten by the user.
  110240. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110241. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110242. * @param update the boolean update value actually passed to setParticles()
  110243. */
  110244. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Represents one particle of a solid particle system.
  110250. */
  110251. export class SolidParticle {
  110252. /**
  110253. * particle global index
  110254. */
  110255. idx: number;
  110256. /**
  110257. * particle identifier
  110258. */
  110259. id: number;
  110260. /**
  110261. * The color of the particle
  110262. */
  110263. color: Nullable<Color4>;
  110264. /**
  110265. * The world space position of the particle.
  110266. */
  110267. position: Vector3;
  110268. /**
  110269. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110270. */
  110271. rotation: Vector3;
  110272. /**
  110273. * The world space rotation quaternion of the particle.
  110274. */
  110275. rotationQuaternion: Nullable<Quaternion>;
  110276. /**
  110277. * The scaling of the particle.
  110278. */
  110279. scaling: Vector3;
  110280. /**
  110281. * The uvs of the particle.
  110282. */
  110283. uvs: Vector4;
  110284. /**
  110285. * The current speed of the particle.
  110286. */
  110287. velocity: Vector3;
  110288. /**
  110289. * The pivot point in the particle local space.
  110290. */
  110291. pivot: Vector3;
  110292. /**
  110293. * Must the particle be translated from its pivot point in its local space ?
  110294. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110295. * Default : false
  110296. */
  110297. translateFromPivot: boolean;
  110298. /**
  110299. * Is the particle active or not ?
  110300. */
  110301. alive: boolean;
  110302. /**
  110303. * Is the particle visible or not ?
  110304. */
  110305. isVisible: boolean;
  110306. /**
  110307. * Index of this particle in the global "positions" array (Internal use)
  110308. * @hidden
  110309. */
  110310. _pos: number;
  110311. /**
  110312. * @hidden Index of this particle in the global "indices" array (Internal use)
  110313. */
  110314. _ind: number;
  110315. /**
  110316. * @hidden ModelShape of this particle (Internal use)
  110317. */
  110318. _model: ModelShape;
  110319. /**
  110320. * ModelShape id of this particle
  110321. */
  110322. shapeId: number;
  110323. /**
  110324. * Index of the particle in its shape id
  110325. */
  110326. idxInShape: number;
  110327. /**
  110328. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110329. */
  110330. _modelBoundingInfo: BoundingInfo;
  110331. /**
  110332. * @hidden Particle BoundingInfo object (Internal use)
  110333. */
  110334. _boundingInfo: BoundingInfo;
  110335. /**
  110336. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110337. */
  110338. _sps: SolidParticleSystem;
  110339. /**
  110340. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110341. */
  110342. _stillInvisible: boolean;
  110343. /**
  110344. * @hidden Last computed particle rotation matrix
  110345. */
  110346. _rotationMatrix: number[];
  110347. /**
  110348. * Parent particle Id, if any.
  110349. * Default null.
  110350. */
  110351. parentId: Nullable<number>;
  110352. /**
  110353. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110354. */
  110355. materialIndex: Nullable<number>;
  110356. /**
  110357. * Custom object or properties.
  110358. */
  110359. props: Nullable<any>;
  110360. /**
  110361. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110362. * The possible values are :
  110363. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110364. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110365. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110366. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110367. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110368. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110369. * */
  110370. cullingStrategy: number;
  110371. /**
  110372. * @hidden Internal global position in the SPS.
  110373. */
  110374. _globalPosition: Vector3;
  110375. /**
  110376. * Creates a Solid Particle object.
  110377. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110378. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110379. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110380. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110381. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110382. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110383. * @param shapeId (integer) is the model shape identifier in the SPS.
  110384. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110385. * @param sps defines the sps it is associated to
  110386. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110387. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110388. */
  110389. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110390. /**
  110391. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110392. * @param target the particle target
  110393. * @returns the current particle
  110394. */
  110395. copyToRef(target: SolidParticle): SolidParticle;
  110396. /**
  110397. * Legacy support, changed scale to scaling
  110398. */
  110399. get scale(): Vector3;
  110400. /**
  110401. * Legacy support, changed scale to scaling
  110402. */
  110403. set scale(scale: Vector3);
  110404. /**
  110405. * Legacy support, changed quaternion to rotationQuaternion
  110406. */
  110407. get quaternion(): Nullable<Quaternion>;
  110408. /**
  110409. * Legacy support, changed quaternion to rotationQuaternion
  110410. */
  110411. set quaternion(q: Nullable<Quaternion>);
  110412. /**
  110413. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110414. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110415. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110416. * @returns true if it intersects
  110417. */
  110418. intersectsMesh(target: Mesh | SolidParticle): boolean;
  110419. /**
  110420. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110421. * A particle is in the frustum if its bounding box intersects the frustum
  110422. * @param frustumPlanes defines the frustum to test
  110423. * @returns true if the particle is in the frustum planes
  110424. */
  110425. isInFrustum(frustumPlanes: Plane[]): boolean;
  110426. /**
  110427. * get the rotation matrix of the particle
  110428. * @hidden
  110429. */
  110430. getRotationMatrix(m: Matrix): void;
  110431. }
  110432. /**
  110433. * Represents the shape of the model used by one particle of a solid particle system.
  110434. * SPS internal tool, don't use it manually.
  110435. */
  110436. export class ModelShape {
  110437. /**
  110438. * The shape id
  110439. * @hidden
  110440. */
  110441. shapeID: number;
  110442. /**
  110443. * flat array of model positions (internal use)
  110444. * @hidden
  110445. */
  110446. _shape: Vector3[];
  110447. /**
  110448. * flat array of model UVs (internal use)
  110449. * @hidden
  110450. */
  110451. _shapeUV: number[];
  110452. /**
  110453. * color array of the model
  110454. * @hidden
  110455. */
  110456. _shapeColors: number[];
  110457. /**
  110458. * indices array of the model
  110459. * @hidden
  110460. */
  110461. _indices: number[];
  110462. /**
  110463. * normals array of the model
  110464. * @hidden
  110465. */
  110466. _normals: number[];
  110467. /**
  110468. * length of the shape in the model indices array (internal use)
  110469. * @hidden
  110470. */
  110471. _indicesLength: number;
  110472. /**
  110473. * Custom position function (internal use)
  110474. * @hidden
  110475. */
  110476. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  110477. /**
  110478. * Custom vertex function (internal use)
  110479. * @hidden
  110480. */
  110481. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  110482. /**
  110483. * Model material (internal use)
  110484. * @hidden
  110485. */
  110486. _material: Nullable<Material>;
  110487. /**
  110488. * 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.
  110489. * SPS internal tool, don't use it manually.
  110490. * @hidden
  110491. */
  110492. 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>);
  110493. }
  110494. /**
  110495. * Represents a Depth Sorted Particle in the solid particle system.
  110496. * @hidden
  110497. */
  110498. export class DepthSortedParticle {
  110499. /**
  110500. * Particle index
  110501. */
  110502. idx: number;
  110503. /**
  110504. * Index of the particle in the "indices" array
  110505. */
  110506. ind: number;
  110507. /**
  110508. * Length of the particle shape in the "indices" array
  110509. */
  110510. indicesLength: number;
  110511. /**
  110512. * Squared distance from the particle to the camera
  110513. */
  110514. sqDistance: number;
  110515. /**
  110516. * Material index when used with MultiMaterials
  110517. */
  110518. materialIndex: number;
  110519. /**
  110520. * Creates a new sorted particle
  110521. * @param materialIndex
  110522. */
  110523. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  110524. }
  110525. /**
  110526. * Represents a solid particle vertex
  110527. */
  110528. export class SolidParticleVertex {
  110529. /**
  110530. * Vertex position
  110531. */
  110532. position: Vector3;
  110533. /**
  110534. * Vertex color
  110535. */
  110536. color: Color4;
  110537. /**
  110538. * Vertex UV
  110539. */
  110540. uv: Vector2;
  110541. /**
  110542. * Creates a new solid particle vertex
  110543. */
  110544. constructor();
  110545. /** Vertex x coordinate */
  110546. get x(): number;
  110547. set x(val: number);
  110548. /** Vertex y coordinate */
  110549. get y(): number;
  110550. set y(val: number);
  110551. /** Vertex z coordinate */
  110552. get z(): number;
  110553. set z(val: number);
  110554. }
  110555. }
  110556. declare module BABYLON {
  110557. /**
  110558. * @hidden
  110559. */
  110560. export class _MeshCollisionData {
  110561. _checkCollisions: boolean;
  110562. _collisionMask: number;
  110563. _collisionGroup: number;
  110564. _surroundingMeshes: Nullable<AbstractMesh[]>;
  110565. _collider: Nullable<Collider>;
  110566. _oldPositionForCollisions: Vector3;
  110567. _diffPositionForCollisions: Vector3;
  110568. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  110569. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  110570. }
  110571. }
  110572. declare module BABYLON {
  110573. /** @hidden */
  110574. class _FacetDataStorage {
  110575. facetPositions: Vector3[];
  110576. facetNormals: Vector3[];
  110577. facetPartitioning: number[][];
  110578. facetNb: number;
  110579. partitioningSubdivisions: number;
  110580. partitioningBBoxRatio: number;
  110581. facetDataEnabled: boolean;
  110582. facetParameters: any;
  110583. bbSize: Vector3;
  110584. subDiv: {
  110585. max: number;
  110586. X: number;
  110587. Y: number;
  110588. Z: number;
  110589. };
  110590. facetDepthSort: boolean;
  110591. facetDepthSortEnabled: boolean;
  110592. depthSortedIndices: IndicesArray;
  110593. depthSortedFacets: {
  110594. ind: number;
  110595. sqDistance: number;
  110596. }[];
  110597. facetDepthSortFunction: (f1: {
  110598. ind: number;
  110599. sqDistance: number;
  110600. }, f2: {
  110601. ind: number;
  110602. sqDistance: number;
  110603. }) => number;
  110604. facetDepthSortFrom: Vector3;
  110605. facetDepthSortOrigin: Vector3;
  110606. invertedMatrix: Matrix;
  110607. }
  110608. /**
  110609. * @hidden
  110610. **/
  110611. class _InternalAbstractMeshDataInfo {
  110612. _hasVertexAlpha: boolean;
  110613. _useVertexColors: boolean;
  110614. _numBoneInfluencers: number;
  110615. _applyFog: boolean;
  110616. _receiveShadows: boolean;
  110617. _facetData: _FacetDataStorage;
  110618. _visibility: number;
  110619. _skeleton: Nullable<Skeleton>;
  110620. _layerMask: number;
  110621. _computeBonesUsingShaders: boolean;
  110622. _isActive: boolean;
  110623. _onlyForInstances: boolean;
  110624. _isActiveIntermediate: boolean;
  110625. _onlyForInstancesIntermediate: boolean;
  110626. _actAsRegularMesh: boolean;
  110627. }
  110628. /**
  110629. * Class used to store all common mesh properties
  110630. */
  110631. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  110632. /** No occlusion */
  110633. static OCCLUSION_TYPE_NONE: number;
  110634. /** Occlusion set to optimisitic */
  110635. static OCCLUSION_TYPE_OPTIMISTIC: number;
  110636. /** Occlusion set to strict */
  110637. static OCCLUSION_TYPE_STRICT: number;
  110638. /** Use an accurante occlusion algorithm */
  110639. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  110640. /** Use a conservative occlusion algorithm */
  110641. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  110642. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  110643. * Test order :
  110644. * Is the bounding sphere outside the frustum ?
  110645. * If not, are the bounding box vertices outside the frustum ?
  110646. * It not, then the cullable object is in the frustum.
  110647. */
  110648. static readonly CULLINGSTRATEGY_STANDARD: number;
  110649. /** Culling strategy : Bounding Sphere Only.
  110650. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  110651. * It's also less accurate than the standard because some not visible objects can still be selected.
  110652. * Test : is the bounding sphere outside the frustum ?
  110653. * If not, then the cullable object is in the frustum.
  110654. */
  110655. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  110656. /** Culling strategy : Optimistic Inclusion.
  110657. * This in an inclusion test first, then the standard exclusion test.
  110658. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  110659. * 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.
  110660. * Anyway, it's as accurate as the standard strategy.
  110661. * Test :
  110662. * Is the cullable object bounding sphere center in the frustum ?
  110663. * If not, apply the default culling strategy.
  110664. */
  110665. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  110666. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  110667. * This in an inclusion test first, then the bounding sphere only exclusion test.
  110668. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  110669. * 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.
  110670. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  110671. * Test :
  110672. * Is the cullable object bounding sphere center in the frustum ?
  110673. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  110674. */
  110675. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  110676. /**
  110677. * No billboard
  110678. */
  110679. static get BILLBOARDMODE_NONE(): number;
  110680. /** Billboard on X axis */
  110681. static get BILLBOARDMODE_X(): number;
  110682. /** Billboard on Y axis */
  110683. static get BILLBOARDMODE_Y(): number;
  110684. /** Billboard on Z axis */
  110685. static get BILLBOARDMODE_Z(): number;
  110686. /** Billboard on all axes */
  110687. static get BILLBOARDMODE_ALL(): number;
  110688. /** Billboard on using position instead of orientation */
  110689. static get BILLBOARDMODE_USE_POSITION(): number;
  110690. /** @hidden */
  110691. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  110692. /**
  110693. * The culling strategy to use to check whether the mesh must be rendered or not.
  110694. * This value can be changed at any time and will be used on the next render mesh selection.
  110695. * The possible values are :
  110696. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110697. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110699. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110700. * Please read each static variable documentation to get details about the culling process.
  110701. * */
  110702. cullingStrategy: number;
  110703. /**
  110704. * Gets the number of facets in the mesh
  110705. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110706. */
  110707. get facetNb(): number;
  110708. /**
  110709. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  110710. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110711. */
  110712. get partitioningSubdivisions(): number;
  110713. set partitioningSubdivisions(nb: number);
  110714. /**
  110715. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  110716. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  110717. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110718. */
  110719. get partitioningBBoxRatio(): number;
  110720. set partitioningBBoxRatio(ratio: number);
  110721. /**
  110722. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  110723. * Works only for updatable meshes.
  110724. * Doesn't work with multi-materials
  110725. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110726. */
  110727. get mustDepthSortFacets(): boolean;
  110728. set mustDepthSortFacets(sort: boolean);
  110729. /**
  110730. * The location (Vector3) where the facet depth sort must be computed from.
  110731. * By default, the active camera position.
  110732. * Used only when facet depth sort is enabled
  110733. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110734. */
  110735. get facetDepthSortFrom(): Vector3;
  110736. set facetDepthSortFrom(location: Vector3);
  110737. /**
  110738. * gets a boolean indicating if facetData is enabled
  110739. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110740. */
  110741. get isFacetDataEnabled(): boolean;
  110742. /** @hidden */
  110743. _updateNonUniformScalingState(value: boolean): boolean;
  110744. /**
  110745. * An event triggered when this mesh collides with another one
  110746. */
  110747. onCollideObservable: Observable<AbstractMesh>;
  110748. /** Set a function to call when this mesh collides with another one */
  110749. set onCollide(callback: () => void);
  110750. /**
  110751. * An event triggered when the collision's position changes
  110752. */
  110753. onCollisionPositionChangeObservable: Observable<Vector3>;
  110754. /** Set a function to call when the collision's position changes */
  110755. set onCollisionPositionChange(callback: () => void);
  110756. /**
  110757. * An event triggered when material is changed
  110758. */
  110759. onMaterialChangedObservable: Observable<AbstractMesh>;
  110760. /**
  110761. * Gets or sets the orientation for POV movement & rotation
  110762. */
  110763. definedFacingForward: boolean;
  110764. /** @hidden */
  110765. _occlusionQuery: Nullable<WebGLQuery>;
  110766. /** @hidden */
  110767. _renderingGroup: Nullable<RenderingGroup>;
  110768. /**
  110769. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110770. */
  110771. get visibility(): number;
  110772. /**
  110773. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110774. */
  110775. set visibility(value: number);
  110776. /** Gets or sets the alpha index used to sort transparent meshes
  110777. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  110778. */
  110779. alphaIndex: number;
  110780. /**
  110781. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  110782. */
  110783. isVisible: boolean;
  110784. /**
  110785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  110786. */
  110787. isPickable: boolean;
  110788. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  110789. showSubMeshesBoundingBox: boolean;
  110790. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  110791. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110792. */
  110793. isBlocker: boolean;
  110794. /**
  110795. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  110796. */
  110797. enablePointerMoveEvents: boolean;
  110798. /**
  110799. * Specifies the rendering group id for this mesh (0 by default)
  110800. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  110801. */
  110802. renderingGroupId: number;
  110803. private _material;
  110804. /** Gets or sets current material */
  110805. get material(): Nullable<Material>;
  110806. set material(value: Nullable<Material>);
  110807. /**
  110808. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  110809. * @see https://doc.babylonjs.com/babylon101/shadows
  110810. */
  110811. get receiveShadows(): boolean;
  110812. set receiveShadows(value: boolean);
  110813. /** Defines color to use when rendering outline */
  110814. outlineColor: Color3;
  110815. /** Define width to use when rendering outline */
  110816. outlineWidth: number;
  110817. /** Defines color to use when rendering overlay */
  110818. overlayColor: Color3;
  110819. /** Defines alpha to use when rendering overlay */
  110820. overlayAlpha: number;
  110821. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  110822. get hasVertexAlpha(): boolean;
  110823. set hasVertexAlpha(value: boolean);
  110824. /** 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) */
  110825. get useVertexColors(): boolean;
  110826. set useVertexColors(value: boolean);
  110827. /**
  110828. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  110829. */
  110830. get computeBonesUsingShaders(): boolean;
  110831. set computeBonesUsingShaders(value: boolean);
  110832. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  110833. get numBoneInfluencers(): number;
  110834. set numBoneInfluencers(value: number);
  110835. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  110836. get applyFog(): boolean;
  110837. set applyFog(value: boolean);
  110838. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  110839. useOctreeForRenderingSelection: boolean;
  110840. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  110841. useOctreeForPicking: boolean;
  110842. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  110843. useOctreeForCollisions: boolean;
  110844. /**
  110845. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  110846. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  110847. */
  110848. get layerMask(): number;
  110849. set layerMask(value: number);
  110850. /**
  110851. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  110852. */
  110853. alwaysSelectAsActiveMesh: boolean;
  110854. /**
  110855. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  110856. */
  110857. doNotSyncBoundingInfo: boolean;
  110858. /**
  110859. * Gets or sets the current action manager
  110860. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110861. */
  110862. actionManager: Nullable<AbstractActionManager>;
  110863. private _meshCollisionData;
  110864. /**
  110865. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  110866. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110867. */
  110868. ellipsoid: Vector3;
  110869. /**
  110870. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  110871. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110872. */
  110873. ellipsoidOffset: Vector3;
  110874. /**
  110875. * Gets or sets a collision mask used to mask collisions (default is -1).
  110876. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110877. */
  110878. get collisionMask(): number;
  110879. set collisionMask(mask: number);
  110880. /**
  110881. * Gets or sets the current collision group mask (-1 by default).
  110882. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110883. */
  110884. get collisionGroup(): number;
  110885. set collisionGroup(mask: number);
  110886. /**
  110887. * Gets or sets current surrounding meshes (null by default).
  110888. *
  110889. * By default collision detection is tested against every mesh in the scene.
  110890. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  110891. * meshes will be tested for the collision.
  110892. *
  110893. * Note: if set to an empty array no collision will happen when this mesh is moved.
  110894. */
  110895. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  110896. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  110897. /**
  110898. * Defines edge width used when edgesRenderer is enabled
  110899. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110900. */
  110901. edgesWidth: number;
  110902. /**
  110903. * Defines edge color used when edgesRenderer is enabled
  110904. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110905. */
  110906. edgesColor: Color4;
  110907. /** @hidden */
  110908. _edgesRenderer: Nullable<IEdgesRenderer>;
  110909. /** @hidden */
  110910. _masterMesh: Nullable<AbstractMesh>;
  110911. /** @hidden */
  110912. _boundingInfo: Nullable<BoundingInfo>;
  110913. /** @hidden */
  110914. _renderId: number;
  110915. /**
  110916. * Gets or sets the list of subMeshes
  110917. * @see https://doc.babylonjs.com/how_to/multi_materials
  110918. */
  110919. subMeshes: SubMesh[];
  110920. /** @hidden */
  110921. _intersectionsInProgress: AbstractMesh[];
  110922. /** @hidden */
  110923. _unIndexed: boolean;
  110924. /** @hidden */
  110925. _lightSources: Light[];
  110926. /** Gets the list of lights affecting that mesh */
  110927. get lightSources(): Light[];
  110928. /** @hidden */
  110929. get _positions(): Nullable<Vector3[]>;
  110930. /** @hidden */
  110931. _waitingData: {
  110932. lods: Nullable<any>;
  110933. actions: Nullable<any>;
  110934. freezeWorldMatrix: Nullable<boolean>;
  110935. };
  110936. /** @hidden */
  110937. _bonesTransformMatrices: Nullable<Float32Array>;
  110938. /** @hidden */
  110939. _transformMatrixTexture: Nullable<RawTexture>;
  110940. /**
  110941. * Gets or sets a skeleton to apply skining transformations
  110942. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110943. */
  110944. set skeleton(value: Nullable<Skeleton>);
  110945. get skeleton(): Nullable<Skeleton>;
  110946. /**
  110947. * An event triggered when the mesh is rebuilt.
  110948. */
  110949. onRebuildObservable: Observable<AbstractMesh>;
  110950. /**
  110951. * Creates a new AbstractMesh
  110952. * @param name defines the name of the mesh
  110953. * @param scene defines the hosting scene
  110954. */
  110955. constructor(name: string, scene?: Nullable<Scene>);
  110956. /**
  110957. * Returns the string "AbstractMesh"
  110958. * @returns "AbstractMesh"
  110959. */
  110960. getClassName(): string;
  110961. /**
  110962. * Gets a string representation of the current mesh
  110963. * @param fullDetails defines a boolean indicating if full details must be included
  110964. * @returns a string representation of the current mesh
  110965. */
  110966. toString(fullDetails?: boolean): string;
  110967. /**
  110968. * @hidden
  110969. */
  110970. protected _getEffectiveParent(): Nullable<Node>;
  110971. /** @hidden */
  110972. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110973. /** @hidden */
  110974. _rebuild(): void;
  110975. /** @hidden */
  110976. _resyncLightSources(): void;
  110977. /** @hidden */
  110978. _resyncLightSource(light: Light): void;
  110979. /** @hidden */
  110980. _unBindEffect(): void;
  110981. /** @hidden */
  110982. _removeLightSource(light: Light, dispose: boolean): void;
  110983. private _markSubMeshesAsDirty;
  110984. /** @hidden */
  110985. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  110986. /** @hidden */
  110987. _markSubMeshesAsAttributesDirty(): void;
  110988. /** @hidden */
  110989. _markSubMeshesAsMiscDirty(): void;
  110990. /**
  110991. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  110992. */
  110993. get scaling(): Vector3;
  110994. set scaling(newScaling: Vector3);
  110995. /**
  110996. * Returns true if the mesh is blocked. Implemented by child classes
  110997. */
  110998. get isBlocked(): boolean;
  110999. /**
  111000. * Returns the mesh itself by default. Implemented by child classes
  111001. * @param camera defines the camera to use to pick the right LOD level
  111002. * @returns the currentAbstractMesh
  111003. */
  111004. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111005. /**
  111006. * Returns 0 by default. Implemented by child classes
  111007. * @returns an integer
  111008. */
  111009. getTotalVertices(): number;
  111010. /**
  111011. * Returns a positive integer : the total number of indices in this mesh geometry.
  111012. * @returns the numner of indices or zero if the mesh has no geometry.
  111013. */
  111014. getTotalIndices(): number;
  111015. /**
  111016. * Returns null by default. Implemented by child classes
  111017. * @returns null
  111018. */
  111019. getIndices(): Nullable<IndicesArray>;
  111020. /**
  111021. * Returns the array of the requested vertex data kind. Implemented by child classes
  111022. * @param kind defines the vertex data kind to use
  111023. * @returns null
  111024. */
  111025. getVerticesData(kind: string): Nullable<FloatArray>;
  111026. /**
  111027. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111028. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111029. * Note that a new underlying VertexBuffer object is created each call.
  111030. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111031. * @param kind defines vertex data kind:
  111032. * * VertexBuffer.PositionKind
  111033. * * VertexBuffer.UVKind
  111034. * * VertexBuffer.UV2Kind
  111035. * * VertexBuffer.UV3Kind
  111036. * * VertexBuffer.UV4Kind
  111037. * * VertexBuffer.UV5Kind
  111038. * * VertexBuffer.UV6Kind
  111039. * * VertexBuffer.ColorKind
  111040. * * VertexBuffer.MatricesIndicesKind
  111041. * * VertexBuffer.MatricesIndicesExtraKind
  111042. * * VertexBuffer.MatricesWeightsKind
  111043. * * VertexBuffer.MatricesWeightsExtraKind
  111044. * @param data defines the data source
  111045. * @param updatable defines if the data must be flagged as updatable (or static)
  111046. * @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
  111047. * @returns the current mesh
  111048. */
  111049. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111050. /**
  111051. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111052. * If the mesh has no geometry, it is simply returned as it is.
  111053. * @param kind defines vertex data kind:
  111054. * * VertexBuffer.PositionKind
  111055. * * VertexBuffer.UVKind
  111056. * * VertexBuffer.UV2Kind
  111057. * * VertexBuffer.UV3Kind
  111058. * * VertexBuffer.UV4Kind
  111059. * * VertexBuffer.UV5Kind
  111060. * * VertexBuffer.UV6Kind
  111061. * * VertexBuffer.ColorKind
  111062. * * VertexBuffer.MatricesIndicesKind
  111063. * * VertexBuffer.MatricesIndicesExtraKind
  111064. * * VertexBuffer.MatricesWeightsKind
  111065. * * VertexBuffer.MatricesWeightsExtraKind
  111066. * @param data defines the data source
  111067. * @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
  111068. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  111069. * @returns the current mesh
  111070. */
  111071. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  111072. /**
  111073. * Sets the mesh indices,
  111074. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  111075. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  111076. * @param totalVertices Defines the total number of vertices
  111077. * @returns the current mesh
  111078. */
  111079. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  111080. /**
  111081. * Gets a boolean indicating if specific vertex data is present
  111082. * @param kind defines the vertex data kind to use
  111083. * @returns true is data kind is present
  111084. */
  111085. isVerticesDataPresent(kind: string): boolean;
  111086. /**
  111087. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  111088. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  111089. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  111090. * @returns a BoundingInfo
  111091. */
  111092. getBoundingInfo(): BoundingInfo;
  111093. /**
  111094. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111095. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111096. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111097. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111098. * @returns the current mesh
  111099. */
  111100. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  111101. /**
  111102. * Overwrite the current bounding info
  111103. * @param boundingInfo defines the new bounding info
  111104. * @returns the current mesh
  111105. */
  111106. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  111107. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  111108. get useBones(): boolean;
  111109. /** @hidden */
  111110. _preActivate(): void;
  111111. /** @hidden */
  111112. _preActivateForIntermediateRendering(renderId: number): void;
  111113. /** @hidden */
  111114. _activate(renderId: number, intermediateRendering: boolean): boolean;
  111115. /** @hidden */
  111116. _postActivate(): void;
  111117. /** @hidden */
  111118. _freeze(): void;
  111119. /** @hidden */
  111120. _unFreeze(): void;
  111121. /**
  111122. * Gets the current world matrix
  111123. * @returns a Matrix
  111124. */
  111125. getWorldMatrix(): Matrix;
  111126. /** @hidden */
  111127. _getWorldMatrixDeterminant(): number;
  111128. /**
  111129. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  111130. */
  111131. get isAnInstance(): boolean;
  111132. /**
  111133. * Gets a boolean indicating if this mesh has instances
  111134. */
  111135. get hasInstances(): boolean;
  111136. /**
  111137. * Gets a boolean indicating if this mesh has thin instances
  111138. */
  111139. get hasThinInstances(): boolean;
  111140. /**
  111141. * Perform relative position change from the point of view of behind the front of the mesh.
  111142. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111143. * Supports definition of mesh facing forward or backward
  111144. * @param amountRight defines the distance on the right axis
  111145. * @param amountUp defines the distance on the up axis
  111146. * @param amountForward defines the distance on the forward axis
  111147. * @returns the current mesh
  111148. */
  111149. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  111150. /**
  111151. * Calculate relative position change from the point of view of behind the front of the mesh.
  111152. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111153. * Supports definition of mesh facing forward or backward
  111154. * @param amountRight defines the distance on the right axis
  111155. * @param amountUp defines the distance on the up axis
  111156. * @param amountForward defines the distance on the forward axis
  111157. * @returns the new displacement vector
  111158. */
  111159. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  111160. /**
  111161. * Perform relative rotation change from the point of view of behind the front of the mesh.
  111162. * Supports definition of mesh facing forward or backward
  111163. * @param flipBack defines the flip
  111164. * @param twirlClockwise defines the twirl
  111165. * @param tiltRight defines the tilt
  111166. * @returns the current mesh
  111167. */
  111168. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  111169. /**
  111170. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  111171. * Supports definition of mesh facing forward or backward.
  111172. * @param flipBack defines the flip
  111173. * @param twirlClockwise defines the twirl
  111174. * @param tiltRight defines the tilt
  111175. * @returns the new rotation vector
  111176. */
  111177. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111178. /**
  111179. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111180. * This means the mesh underlying bounding box and sphere are recomputed.
  111181. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111182. * @returns the current mesh
  111183. */
  111184. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111185. /** @hidden */
  111186. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111187. /** @hidden */
  111188. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111189. /** @hidden */
  111190. _updateBoundingInfo(): AbstractMesh;
  111191. /** @hidden */
  111192. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111193. /** @hidden */
  111194. protected _afterComputeWorldMatrix(): void;
  111195. /** @hidden */
  111196. get _effectiveMesh(): AbstractMesh;
  111197. /**
  111198. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111199. * A mesh is in the frustum if its bounding box intersects the frustum
  111200. * @param frustumPlanes defines the frustum to test
  111201. * @returns true if the mesh is in the frustum planes
  111202. */
  111203. isInFrustum(frustumPlanes: Plane[]): boolean;
  111204. /**
  111205. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111206. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111207. * @param frustumPlanes defines the frustum to test
  111208. * @returns true if the mesh is completely in the frustum planes
  111209. */
  111210. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111211. /**
  111212. * True if the mesh intersects another mesh or a SolidParticle object
  111213. * @param mesh defines a target mesh or SolidParticle to test
  111214. * @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)
  111215. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111216. * @returns true if there is an intersection
  111217. */
  111218. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111219. /**
  111220. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111221. * @param point defines the point to test
  111222. * @returns true if there is an intersection
  111223. */
  111224. intersectsPoint(point: Vector3): boolean;
  111225. /**
  111226. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111227. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111228. */
  111229. get checkCollisions(): boolean;
  111230. set checkCollisions(collisionEnabled: boolean);
  111231. /**
  111232. * Gets Collider object used to compute collisions (not physics)
  111233. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111234. */
  111235. get collider(): Nullable<Collider>;
  111236. /**
  111237. * Move the mesh using collision engine
  111238. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111239. * @param displacement defines the requested displacement vector
  111240. * @returns the current mesh
  111241. */
  111242. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111243. private _onCollisionPositionChange;
  111244. /** @hidden */
  111245. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111246. /** @hidden */
  111247. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111248. /** @hidden */
  111249. _checkCollision(collider: Collider): AbstractMesh;
  111250. /** @hidden */
  111251. _generatePointsArray(): boolean;
  111252. /**
  111253. * Checks if the passed Ray intersects with the mesh
  111254. * @param ray defines the ray to use
  111255. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111257. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111258. * @returns the picking info
  111259. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111260. */
  111261. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  111262. /**
  111263. * Clones the current mesh
  111264. * @param name defines the mesh name
  111265. * @param newParent defines the new mesh parent
  111266. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111267. * @returns the new mesh
  111268. */
  111269. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111270. /**
  111271. * Disposes all the submeshes of the current meshnp
  111272. * @returns the current mesh
  111273. */
  111274. releaseSubMeshes(): AbstractMesh;
  111275. /**
  111276. * Releases resources associated with this abstract mesh.
  111277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111279. */
  111280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111281. /**
  111282. * Adds the passed mesh as a child to the current mesh
  111283. * @param mesh defines the child mesh
  111284. * @returns the current mesh
  111285. */
  111286. addChild(mesh: AbstractMesh): AbstractMesh;
  111287. /**
  111288. * Removes the passed mesh from the current mesh children list
  111289. * @param mesh defines the child mesh
  111290. * @returns the current mesh
  111291. */
  111292. removeChild(mesh: AbstractMesh): AbstractMesh;
  111293. /** @hidden */
  111294. private _initFacetData;
  111295. /**
  111296. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111297. * This method can be called within the render loop.
  111298. * 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
  111299. * @returns the current mesh
  111300. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111301. */
  111302. updateFacetData(): AbstractMesh;
  111303. /**
  111304. * Returns the facetLocalNormals array.
  111305. * The normals are expressed in the mesh local spac
  111306. * @returns an array of Vector3
  111307. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111308. */
  111309. getFacetLocalNormals(): Vector3[];
  111310. /**
  111311. * Returns the facetLocalPositions array.
  111312. * The facet positions are expressed in the mesh local space
  111313. * @returns an array of Vector3
  111314. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111315. */
  111316. getFacetLocalPositions(): Vector3[];
  111317. /**
  111318. * Returns the facetLocalPartioning array
  111319. * @returns an array of array of numbers
  111320. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111321. */
  111322. getFacetLocalPartitioning(): number[][];
  111323. /**
  111324. * Returns the i-th facet position in the world system.
  111325. * This method allocates a new Vector3 per call
  111326. * @param i defines the facet index
  111327. * @returns a new Vector3
  111328. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111329. */
  111330. getFacetPosition(i: number): Vector3;
  111331. /**
  111332. * Sets the reference Vector3 with the i-th facet position in the world system
  111333. * @param i defines the facet index
  111334. * @param ref defines the target vector
  111335. * @returns the current mesh
  111336. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111337. */
  111338. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111339. /**
  111340. * Returns the i-th facet normal in the world system.
  111341. * This method allocates a new Vector3 per call
  111342. * @param i defines the facet index
  111343. * @returns a new Vector3
  111344. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111345. */
  111346. getFacetNormal(i: number): Vector3;
  111347. /**
  111348. * Sets the reference Vector3 with the i-th facet normal in the world system
  111349. * @param i defines the facet index
  111350. * @param ref defines the target vector
  111351. * @returns the current mesh
  111352. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111353. */
  111354. getFacetNormalToRef(i: number, ref: Vector3): this;
  111355. /**
  111356. * 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)
  111357. * @param x defines x coordinate
  111358. * @param y defines y coordinate
  111359. * @param z defines z coordinate
  111360. * @returns the array of facet indexes
  111361. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111362. */
  111363. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111364. /**
  111365. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111366. * @param projected sets as the (x,y,z) world projection on the facet
  111367. * @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
  111368. * @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
  111369. * @param x defines x coordinate
  111370. * @param y defines y coordinate
  111371. * @param z defines z coordinate
  111372. * @returns the face index if found (or null instead)
  111373. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111374. */
  111375. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111376. /**
  111377. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111378. * @param projected sets as the (x,y,z) local projection on the facet
  111379. * @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
  111380. * @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
  111381. * @param x defines x coordinate
  111382. * @param y defines y coordinate
  111383. * @param z defines z coordinate
  111384. * @returns the face index if found (or null instead)
  111385. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111386. */
  111387. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111388. /**
  111389. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111390. * @returns the parameters
  111391. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111392. */
  111393. getFacetDataParameters(): any;
  111394. /**
  111395. * Disables the feature FacetData and frees the related memory
  111396. * @returns the current mesh
  111397. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111398. */
  111399. disableFacetData(): AbstractMesh;
  111400. /**
  111401. * Updates the AbstractMesh indices array
  111402. * @param indices defines the data source
  111403. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111404. * @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)
  111405. * @returns the current mesh
  111406. */
  111407. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111408. /**
  111409. * Creates new normals data for the mesh
  111410. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111411. * @returns the current mesh
  111412. */
  111413. createNormals(updatable: boolean): AbstractMesh;
  111414. /**
  111415. * Align the mesh with a normal
  111416. * @param normal defines the normal to use
  111417. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  111418. * @returns the current mesh
  111419. */
  111420. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  111421. /** @hidden */
  111422. _checkOcclusionQuery(): boolean;
  111423. /**
  111424. * Disables the mesh edge rendering mode
  111425. * @returns the currentAbstractMesh
  111426. */
  111427. disableEdgesRendering(): AbstractMesh;
  111428. /**
  111429. * Enables the edge rendering mode on the mesh.
  111430. * This mode makes the mesh edges visible
  111431. * @param epsilon defines the maximal distance between two angles to detect a face
  111432. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  111433. * @returns the currentAbstractMesh
  111434. * @see https://www.babylonjs-playground.com/#19O9TU#0
  111435. */
  111436. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  111437. /**
  111438. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  111439. * @returns an array of particle systems in the scene that use the mesh as an emitter
  111440. */
  111441. getConnectedParticleSystems(): IParticleSystem[];
  111442. }
  111443. }
  111444. declare module BABYLON {
  111445. /**
  111446. * Interface used to define ActionEvent
  111447. */
  111448. export interface IActionEvent {
  111449. /** The mesh or sprite that triggered the action */
  111450. source: any;
  111451. /** The X mouse cursor position at the time of the event */
  111452. pointerX: number;
  111453. /** The Y mouse cursor position at the time of the event */
  111454. pointerY: number;
  111455. /** The mesh that is currently pointed at (can be null) */
  111456. meshUnderPointer: Nullable<AbstractMesh>;
  111457. /** the original (browser) event that triggered the ActionEvent */
  111458. sourceEvent?: any;
  111459. /** additional data for the event */
  111460. additionalData?: any;
  111461. }
  111462. /**
  111463. * ActionEvent is the event being sent when an action is triggered.
  111464. */
  111465. export class ActionEvent implements IActionEvent {
  111466. /** The mesh or sprite that triggered the action */
  111467. source: any;
  111468. /** The X mouse cursor position at the time of the event */
  111469. pointerX: number;
  111470. /** The Y mouse cursor position at the time of the event */
  111471. pointerY: number;
  111472. /** The mesh that is currently pointed at (can be null) */
  111473. meshUnderPointer: Nullable<AbstractMesh>;
  111474. /** the original (browser) event that triggered the ActionEvent */
  111475. sourceEvent?: any;
  111476. /** additional data for the event */
  111477. additionalData?: any;
  111478. /**
  111479. * Creates a new ActionEvent
  111480. * @param source The mesh or sprite that triggered the action
  111481. * @param pointerX The X mouse cursor position at the time of the event
  111482. * @param pointerY The Y mouse cursor position at the time of the event
  111483. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  111484. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  111485. * @param additionalData additional data for the event
  111486. */
  111487. constructor(
  111488. /** The mesh or sprite that triggered the action */
  111489. source: any,
  111490. /** The X mouse cursor position at the time of the event */
  111491. pointerX: number,
  111492. /** The Y mouse cursor position at the time of the event */
  111493. pointerY: number,
  111494. /** The mesh that is currently pointed at (can be null) */
  111495. meshUnderPointer: Nullable<AbstractMesh>,
  111496. /** the original (browser) event that triggered the ActionEvent */
  111497. sourceEvent?: any,
  111498. /** additional data for the event */
  111499. additionalData?: any);
  111500. /**
  111501. * Helper function to auto-create an ActionEvent from a source mesh.
  111502. * @param source The source mesh that triggered the event
  111503. * @param evt The original (browser) event
  111504. * @param additionalData additional data for the event
  111505. * @returns the new ActionEvent
  111506. */
  111507. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  111508. /**
  111509. * Helper function to auto-create an ActionEvent from a source sprite
  111510. * @param source The source sprite that triggered the event
  111511. * @param scene Scene associated with the sprite
  111512. * @param evt The original (browser) event
  111513. * @param additionalData additional data for the event
  111514. * @returns the new ActionEvent
  111515. */
  111516. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  111517. /**
  111518. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  111519. * @param scene the scene where the event occurred
  111520. * @param evt The original (browser) event
  111521. * @returns the new ActionEvent
  111522. */
  111523. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  111524. /**
  111525. * Helper function to auto-create an ActionEvent from a primitive
  111526. * @param prim defines the target primitive
  111527. * @param pointerPos defines the pointer position
  111528. * @param evt The original (browser) event
  111529. * @param additionalData additional data for the event
  111530. * @returns the new ActionEvent
  111531. */
  111532. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  111533. }
  111534. }
  111535. declare module BABYLON {
  111536. /**
  111537. * Abstract class used to decouple action Manager from scene and meshes.
  111538. * Do not instantiate.
  111539. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111540. */
  111541. export abstract class AbstractActionManager implements IDisposable {
  111542. /** Gets the list of active triggers */
  111543. static Triggers: {
  111544. [key: string]: number;
  111545. };
  111546. /** Gets the cursor to use when hovering items */
  111547. hoverCursor: string;
  111548. /** Gets the list of actions */
  111549. actions: IAction[];
  111550. /**
  111551. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  111552. */
  111553. isRecursive: boolean;
  111554. /**
  111555. * Releases all associated resources
  111556. */
  111557. abstract dispose(): void;
  111558. /**
  111559. * Does this action manager has pointer triggers
  111560. */
  111561. abstract get hasPointerTriggers(): boolean;
  111562. /**
  111563. * Does this action manager has pick triggers
  111564. */
  111565. abstract get hasPickTriggers(): boolean;
  111566. /**
  111567. * Process a specific trigger
  111568. * @param trigger defines the trigger to process
  111569. * @param evt defines the event details to be processed
  111570. */
  111571. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  111572. /**
  111573. * Does this action manager handles actions of any of the given triggers
  111574. * @param triggers defines the triggers to be tested
  111575. * @return a boolean indicating whether one (or more) of the triggers is handled
  111576. */
  111577. abstract hasSpecificTriggers(triggers: number[]): boolean;
  111578. /**
  111579. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  111580. * speed.
  111581. * @param triggerA defines the trigger to be tested
  111582. * @param triggerB defines the trigger to be tested
  111583. * @return a boolean indicating whether one (or more) of the triggers is handled
  111584. */
  111585. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  111586. /**
  111587. * Does this action manager handles actions of a given trigger
  111588. * @param trigger defines the trigger to be tested
  111589. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  111590. * @return whether the trigger is handled
  111591. */
  111592. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  111593. /**
  111594. * Serialize this manager to a JSON object
  111595. * @param name defines the property name to store this manager
  111596. * @returns a JSON representation of this manager
  111597. */
  111598. abstract serialize(name: string): any;
  111599. /**
  111600. * Registers an action to this action manager
  111601. * @param action defines the action to be registered
  111602. * @return the action amended (prepared) after registration
  111603. */
  111604. abstract registerAction(action: IAction): Nullable<IAction>;
  111605. /**
  111606. * Unregisters an action to this action manager
  111607. * @param action defines the action to be unregistered
  111608. * @return a boolean indicating whether the action has been unregistered
  111609. */
  111610. abstract unregisterAction(action: IAction): Boolean;
  111611. /**
  111612. * Does exist one action manager with at least one trigger
  111613. **/
  111614. static get HasTriggers(): boolean;
  111615. /**
  111616. * Does exist one action manager with at least one pick trigger
  111617. **/
  111618. static get HasPickTriggers(): boolean;
  111619. /**
  111620. * Does exist one action manager that handles actions of a given trigger
  111621. * @param trigger defines the trigger to be tested
  111622. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  111623. **/
  111624. static HasSpecificTrigger(trigger: number): boolean;
  111625. }
  111626. }
  111627. declare module BABYLON {
  111628. /**
  111629. * Defines how a node can be built from a string name.
  111630. */
  111631. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  111632. /**
  111633. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  111634. */
  111635. export class Node implements IBehaviorAware<Node> {
  111636. /** @hidden */
  111637. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  111638. private static _NodeConstructors;
  111639. /**
  111640. * Add a new node constructor
  111641. * @param type defines the type name of the node to construct
  111642. * @param constructorFunc defines the constructor function
  111643. */
  111644. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  111645. /**
  111646. * Returns a node constructor based on type name
  111647. * @param type defines the type name
  111648. * @param name defines the new node name
  111649. * @param scene defines the hosting scene
  111650. * @param options defines optional options to transmit to constructors
  111651. * @returns the new constructor or null
  111652. */
  111653. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  111654. /**
  111655. * Gets or sets the name of the node
  111656. */
  111657. name: string;
  111658. /**
  111659. * Gets or sets the id of the node
  111660. */
  111661. id: string;
  111662. /**
  111663. * Gets or sets the unique id of the node
  111664. */
  111665. uniqueId: number;
  111666. /**
  111667. * Gets or sets a string used to store user defined state for the node
  111668. */
  111669. state: string;
  111670. /**
  111671. * Gets or sets an object used to store user defined information for the node
  111672. */
  111673. metadata: any;
  111674. /**
  111675. * For internal use only. Please do not use.
  111676. */
  111677. reservedDataStore: any;
  111678. /**
  111679. * List of inspectable custom properties (used by the Inspector)
  111680. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111681. */
  111682. inspectableCustomProperties: IInspectable[];
  111683. private _doNotSerialize;
  111684. /**
  111685. * Gets or sets a boolean used to define if the node must be serialized
  111686. */
  111687. get doNotSerialize(): boolean;
  111688. set doNotSerialize(value: boolean);
  111689. /** @hidden */
  111690. _isDisposed: boolean;
  111691. /**
  111692. * Gets a list of Animations associated with the node
  111693. */
  111694. animations: Animation[];
  111695. protected _ranges: {
  111696. [name: string]: Nullable<AnimationRange>;
  111697. };
  111698. /**
  111699. * Callback raised when the node is ready to be used
  111700. */
  111701. onReady: Nullable<(node: Node) => void>;
  111702. private _isEnabled;
  111703. private _isParentEnabled;
  111704. private _isReady;
  111705. /** @hidden */
  111706. _currentRenderId: number;
  111707. private _parentUpdateId;
  111708. /** @hidden */
  111709. _childUpdateId: number;
  111710. /** @hidden */
  111711. _waitingParentId: Nullable<string>;
  111712. /** @hidden */
  111713. _scene: Scene;
  111714. /** @hidden */
  111715. _cache: any;
  111716. private _parentNode;
  111717. private _children;
  111718. /** @hidden */
  111719. _worldMatrix: Matrix;
  111720. /** @hidden */
  111721. _worldMatrixDeterminant: number;
  111722. /** @hidden */
  111723. _worldMatrixDeterminantIsDirty: boolean;
  111724. /** @hidden */
  111725. private _sceneRootNodesIndex;
  111726. /**
  111727. * Gets a boolean indicating if the node has been disposed
  111728. * @returns true if the node was disposed
  111729. */
  111730. isDisposed(): boolean;
  111731. /**
  111732. * Gets or sets the parent of the node (without keeping the current position in the scene)
  111733. * @see https://doc.babylonjs.com/how_to/parenting
  111734. */
  111735. set parent(parent: Nullable<Node>);
  111736. get parent(): Nullable<Node>;
  111737. /** @hidden */
  111738. _addToSceneRootNodes(): void;
  111739. /** @hidden */
  111740. _removeFromSceneRootNodes(): void;
  111741. private _animationPropertiesOverride;
  111742. /**
  111743. * Gets or sets the animation properties override
  111744. */
  111745. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111746. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111747. /**
  111748. * Gets a string idenfifying the name of the class
  111749. * @returns "Node" string
  111750. */
  111751. getClassName(): string;
  111752. /** @hidden */
  111753. readonly _isNode: boolean;
  111754. /**
  111755. * An event triggered when the mesh is disposed
  111756. */
  111757. onDisposeObservable: Observable<Node>;
  111758. private _onDisposeObserver;
  111759. /**
  111760. * Sets a callback that will be raised when the node will be disposed
  111761. */
  111762. set onDispose(callback: () => void);
  111763. /**
  111764. * Creates a new Node
  111765. * @param name the name and id to be given to this node
  111766. * @param scene the scene this node will be added to
  111767. */
  111768. constructor(name: string, scene?: Nullable<Scene>);
  111769. /**
  111770. * Gets the scene of the node
  111771. * @returns a scene
  111772. */
  111773. getScene(): Scene;
  111774. /**
  111775. * Gets the engine of the node
  111776. * @returns a Engine
  111777. */
  111778. getEngine(): Engine;
  111779. private _behaviors;
  111780. /**
  111781. * Attach a behavior to the node
  111782. * @see https://doc.babylonjs.com/features/behaviour
  111783. * @param behavior defines the behavior to attach
  111784. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  111785. * @returns the current Node
  111786. */
  111787. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  111788. /**
  111789. * Remove an attached behavior
  111790. * @see https://doc.babylonjs.com/features/behaviour
  111791. * @param behavior defines the behavior to attach
  111792. * @returns the current Node
  111793. */
  111794. removeBehavior(behavior: Behavior<Node>): Node;
  111795. /**
  111796. * Gets the list of attached behaviors
  111797. * @see https://doc.babylonjs.com/features/behaviour
  111798. */
  111799. get behaviors(): Behavior<Node>[];
  111800. /**
  111801. * Gets an attached behavior by name
  111802. * @param name defines the name of the behavior to look for
  111803. * @see https://doc.babylonjs.com/features/behaviour
  111804. * @returns null if behavior was not found else the requested behavior
  111805. */
  111806. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  111807. /**
  111808. * Returns the latest update of the World matrix
  111809. * @returns a Matrix
  111810. */
  111811. getWorldMatrix(): Matrix;
  111812. /** @hidden */
  111813. _getWorldMatrixDeterminant(): number;
  111814. /**
  111815. * Returns directly the latest state of the mesh World matrix.
  111816. * A Matrix is returned.
  111817. */
  111818. get worldMatrixFromCache(): Matrix;
  111819. /** @hidden */
  111820. _initCache(): void;
  111821. /** @hidden */
  111822. updateCache(force?: boolean): void;
  111823. /** @hidden */
  111824. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111825. /** @hidden */
  111826. _updateCache(ignoreParentClass?: boolean): void;
  111827. /** @hidden */
  111828. _isSynchronized(): boolean;
  111829. /** @hidden */
  111830. _markSyncedWithParent(): void;
  111831. /** @hidden */
  111832. isSynchronizedWithParent(): boolean;
  111833. /** @hidden */
  111834. isSynchronized(): boolean;
  111835. /**
  111836. * Is this node ready to be used/rendered
  111837. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  111838. * @return true if the node is ready
  111839. */
  111840. isReady(completeCheck?: boolean): boolean;
  111841. /**
  111842. * Is this node enabled?
  111843. * 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
  111844. * @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
  111845. * @return whether this node (and its parent) is enabled
  111846. */
  111847. isEnabled(checkAncestors?: boolean): boolean;
  111848. /** @hidden */
  111849. protected _syncParentEnabledState(): void;
  111850. /**
  111851. * Set the enabled state of this node
  111852. * @param value defines the new enabled state
  111853. */
  111854. setEnabled(value: boolean): void;
  111855. /**
  111856. * Is this node a descendant of the given node?
  111857. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  111858. * @param ancestor defines the parent node to inspect
  111859. * @returns a boolean indicating if this node is a descendant of the given node
  111860. */
  111861. isDescendantOf(ancestor: Node): boolean;
  111862. /** @hidden */
  111863. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  111864. /**
  111865. * Will return all nodes that have this node as ascendant
  111866. * @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
  111867. * @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
  111868. * @return all children nodes of all types
  111869. */
  111870. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  111871. /**
  111872. * Get all child-meshes of this node
  111873. * @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)
  111874. * @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
  111875. * @returns an array of AbstractMesh
  111876. */
  111877. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  111878. /**
  111879. * Get all direct children of this node
  111880. * @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
  111881. * @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)
  111882. * @returns an array of Node
  111883. */
  111884. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  111885. /** @hidden */
  111886. _setReady(state: boolean): void;
  111887. /**
  111888. * Get an animation by name
  111889. * @param name defines the name of the animation to look for
  111890. * @returns null if not found else the requested animation
  111891. */
  111892. getAnimationByName(name: string): Nullable<Animation>;
  111893. /**
  111894. * Creates an animation range for this node
  111895. * @param name defines the name of the range
  111896. * @param from defines the starting key
  111897. * @param to defines the end key
  111898. */
  111899. createAnimationRange(name: string, from: number, to: number): void;
  111900. /**
  111901. * Delete a specific animation range
  111902. * @param name defines the name of the range to delete
  111903. * @param deleteFrames defines if animation frames from the range must be deleted as well
  111904. */
  111905. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  111906. /**
  111907. * Get an animation range by name
  111908. * @param name defines the name of the animation range to look for
  111909. * @returns null if not found else the requested animation range
  111910. */
  111911. getAnimationRange(name: string): Nullable<AnimationRange>;
  111912. /**
  111913. * Gets the list of all animation ranges defined on this node
  111914. * @returns an array
  111915. */
  111916. getAnimationRanges(): Nullable<AnimationRange>[];
  111917. /**
  111918. * Will start the animation sequence
  111919. * @param name defines the range frames for animation sequence
  111920. * @param loop defines if the animation should loop (false by default)
  111921. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  111922. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  111923. * @returns the object created for this animation. If range does not exist, it will return null
  111924. */
  111925. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  111926. /**
  111927. * Serialize animation ranges into a JSON compatible object
  111928. * @returns serialization object
  111929. */
  111930. serializeAnimationRanges(): any;
  111931. /**
  111932. * Computes the world matrix of the node
  111933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111934. * @returns the world matrix
  111935. */
  111936. computeWorldMatrix(force?: boolean): Matrix;
  111937. /**
  111938. * Releases resources associated with this node.
  111939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111941. */
  111942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111943. /**
  111944. * Parse animation range data from a serialization object and store them into a given node
  111945. * @param node defines where to store the animation ranges
  111946. * @param parsedNode defines the serialization object to read data from
  111947. * @param scene defines the hosting scene
  111948. */
  111949. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  111950. /**
  111951. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  111952. * @param includeDescendants Include bounding info from descendants as well (true by default)
  111953. * @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
  111954. * @returns the new bounding vectors
  111955. */
  111956. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  111957. min: Vector3;
  111958. max: Vector3;
  111959. };
  111960. }
  111961. }
  111962. declare module BABYLON {
  111963. /**
  111964. * @hidden
  111965. */
  111966. export class _IAnimationState {
  111967. key: number;
  111968. repeatCount: number;
  111969. workValue?: any;
  111970. loopMode?: number;
  111971. offsetValue?: any;
  111972. highLimitValue?: any;
  111973. }
  111974. /**
  111975. * Class used to store any kind of animation
  111976. */
  111977. export class Animation {
  111978. /**Name of the animation */
  111979. name: string;
  111980. /**Property to animate */
  111981. targetProperty: string;
  111982. /**The frames per second of the animation */
  111983. framePerSecond: number;
  111984. /**The data type of the animation */
  111985. dataType: number;
  111986. /**The loop mode of the animation */
  111987. loopMode?: number | undefined;
  111988. /**Specifies if blending should be enabled */
  111989. enableBlending?: boolean | undefined;
  111990. /**
  111991. * Use matrix interpolation instead of using direct key value when animating matrices
  111992. */
  111993. static AllowMatricesInterpolation: boolean;
  111994. /**
  111995. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  111996. */
  111997. static AllowMatrixDecomposeForInterpolation: boolean;
  111998. /** Define the Url to load snippets */
  111999. static SnippetUrl: string;
  112000. /** Snippet ID if the animation was created from the snippet server */
  112001. snippetId: string;
  112002. /**
  112003. * Stores the key frames of the animation
  112004. */
  112005. private _keys;
  112006. /**
  112007. * Stores the easing function of the animation
  112008. */
  112009. private _easingFunction;
  112010. /**
  112011. * @hidden Internal use only
  112012. */
  112013. _runtimeAnimations: RuntimeAnimation[];
  112014. /**
  112015. * The set of event that will be linked to this animation
  112016. */
  112017. private _events;
  112018. /**
  112019. * Stores an array of target property paths
  112020. */
  112021. targetPropertyPath: string[];
  112022. /**
  112023. * Stores the blending speed of the animation
  112024. */
  112025. blendingSpeed: number;
  112026. /**
  112027. * Stores the animation ranges for the animation
  112028. */
  112029. private _ranges;
  112030. /**
  112031. * @hidden Internal use
  112032. */
  112033. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112034. /**
  112035. * Sets up an animation
  112036. * @param property The property to animate
  112037. * @param animationType The animation type to apply
  112038. * @param framePerSecond The frames per second of the animation
  112039. * @param easingFunction The easing function used in the animation
  112040. * @returns The created animation
  112041. */
  112042. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112043. /**
  112044. * Create and start an animation on a node
  112045. * @param name defines the name of the global animation that will be run on all nodes
  112046. * @param node defines the root node where the animation will take place
  112047. * @param targetProperty defines property to animate
  112048. * @param framePerSecond defines the number of frame per second yo use
  112049. * @param totalFrame defines the number of frames in total
  112050. * @param from defines the initial value
  112051. * @param to defines the final value
  112052. * @param loopMode defines which loop mode you want to use (off by default)
  112053. * @param easingFunction defines the easing function to use (linear by default)
  112054. * @param onAnimationEnd defines the callback to call when animation end
  112055. * @returns the animatable created for this animation
  112056. */
  112057. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112058. /**
  112059. * Create and start an animation on a node and its descendants
  112060. * @param name defines the name of the global animation that will be run on all nodes
  112061. * @param node defines the root node where the animation will take place
  112062. * @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
  112063. * @param targetProperty defines property to animate
  112064. * @param framePerSecond defines the number of frame per second to use
  112065. * @param totalFrame defines the number of frames in total
  112066. * @param from defines the initial value
  112067. * @param to defines the final value
  112068. * @param loopMode defines which loop mode you want to use (off by default)
  112069. * @param easingFunction defines the easing function to use (linear by default)
  112070. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  112071. * @returns the list of animatables created for all nodes
  112072. * @example https://www.babylonjs-playground.com/#MH0VLI
  112073. */
  112074. 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[]>;
  112075. /**
  112076. * Creates a new animation, merges it with the existing animations and starts it
  112077. * @param name Name of the animation
  112078. * @param node Node which contains the scene that begins the animations
  112079. * @param targetProperty Specifies which property to animate
  112080. * @param framePerSecond The frames per second of the animation
  112081. * @param totalFrame The total number of frames
  112082. * @param from The frame at the beginning of the animation
  112083. * @param to The frame at the end of the animation
  112084. * @param loopMode Specifies the loop mode of the animation
  112085. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  112086. * @param onAnimationEnd Callback to run once the animation is complete
  112087. * @returns Nullable animation
  112088. */
  112089. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112090. /**
  112091. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  112092. * @param sourceAnimation defines the Animation containing keyframes to convert
  112093. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  112094. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  112095. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  112096. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  112097. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  112098. */
  112099. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  112100. /**
  112101. * Transition property of an host to the target Value
  112102. * @param property The property to transition
  112103. * @param targetValue The target Value of the property
  112104. * @param host The object where the property to animate belongs
  112105. * @param scene Scene used to run the animation
  112106. * @param frameRate Framerate (in frame/s) to use
  112107. * @param transition The transition type we want to use
  112108. * @param duration The duration of the animation, in milliseconds
  112109. * @param onAnimationEnd Callback trigger at the end of the animation
  112110. * @returns Nullable animation
  112111. */
  112112. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  112113. /**
  112114. * Return the array of runtime animations currently using this animation
  112115. */
  112116. get runtimeAnimations(): RuntimeAnimation[];
  112117. /**
  112118. * Specifies if any of the runtime animations are currently running
  112119. */
  112120. get hasRunningRuntimeAnimations(): boolean;
  112121. /**
  112122. * Initializes the animation
  112123. * @param name Name of the animation
  112124. * @param targetProperty Property to animate
  112125. * @param framePerSecond The frames per second of the animation
  112126. * @param dataType The data type of the animation
  112127. * @param loopMode The loop mode of the animation
  112128. * @param enableBlending Specifies if blending should be enabled
  112129. */
  112130. constructor(
  112131. /**Name of the animation */
  112132. name: string,
  112133. /**Property to animate */
  112134. targetProperty: string,
  112135. /**The frames per second of the animation */
  112136. framePerSecond: number,
  112137. /**The data type of the animation */
  112138. dataType: number,
  112139. /**The loop mode of the animation */
  112140. loopMode?: number | undefined,
  112141. /**Specifies if blending should be enabled */
  112142. enableBlending?: boolean | undefined);
  112143. /**
  112144. * Converts the animation to a string
  112145. * @param fullDetails support for multiple levels of logging within scene loading
  112146. * @returns String form of the animation
  112147. */
  112148. toString(fullDetails?: boolean): string;
  112149. /**
  112150. * Add an event to this animation
  112151. * @param event Event to add
  112152. */
  112153. addEvent(event: AnimationEvent): void;
  112154. /**
  112155. * Remove all events found at the given frame
  112156. * @param frame The frame to remove events from
  112157. */
  112158. removeEvents(frame: number): void;
  112159. /**
  112160. * Retrieves all the events from the animation
  112161. * @returns Events from the animation
  112162. */
  112163. getEvents(): AnimationEvent[];
  112164. /**
  112165. * Creates an animation range
  112166. * @param name Name of the animation range
  112167. * @param from Starting frame of the animation range
  112168. * @param to Ending frame of the animation
  112169. */
  112170. createRange(name: string, from: number, to: number): void;
  112171. /**
  112172. * Deletes an animation range by name
  112173. * @param name Name of the animation range to delete
  112174. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  112175. */
  112176. deleteRange(name: string, deleteFrames?: boolean): void;
  112177. /**
  112178. * Gets the animation range by name, or null if not defined
  112179. * @param name Name of the animation range
  112180. * @returns Nullable animation range
  112181. */
  112182. getRange(name: string): Nullable<AnimationRange>;
  112183. /**
  112184. * Gets the key frames from the animation
  112185. * @returns The key frames of the animation
  112186. */
  112187. getKeys(): Array<IAnimationKey>;
  112188. /**
  112189. * Gets the highest frame rate of the animation
  112190. * @returns Highest frame rate of the animation
  112191. */
  112192. getHighestFrame(): number;
  112193. /**
  112194. * Gets the easing function of the animation
  112195. * @returns Easing function of the animation
  112196. */
  112197. getEasingFunction(): IEasingFunction;
  112198. /**
  112199. * Sets the easing function of the animation
  112200. * @param easingFunction A custom mathematical formula for animation
  112201. */
  112202. setEasingFunction(easingFunction: EasingFunction): void;
  112203. /**
  112204. * Interpolates a scalar linearly
  112205. * @param startValue Start value of the animation curve
  112206. * @param endValue End value of the animation curve
  112207. * @param gradient Scalar amount to interpolate
  112208. * @returns Interpolated scalar value
  112209. */
  112210. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112211. /**
  112212. * Interpolates a scalar cubically
  112213. * @param startValue Start value of the animation curve
  112214. * @param outTangent End tangent of the animation
  112215. * @param endValue End value of the animation curve
  112216. * @param inTangent Start tangent of the animation curve
  112217. * @param gradient Scalar amount to interpolate
  112218. * @returns Interpolated scalar value
  112219. */
  112220. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112221. /**
  112222. * Interpolates a quaternion using a spherical linear interpolation
  112223. * @param startValue Start value of the animation curve
  112224. * @param endValue End value of the animation curve
  112225. * @param gradient Scalar amount to interpolate
  112226. * @returns Interpolated quaternion value
  112227. */
  112228. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112229. /**
  112230. * Interpolates a quaternion cubically
  112231. * @param startValue Start value of the animation curve
  112232. * @param outTangent End tangent of the animation curve
  112233. * @param endValue End value of the animation curve
  112234. * @param inTangent Start tangent of the animation curve
  112235. * @param gradient Scalar amount to interpolate
  112236. * @returns Interpolated quaternion value
  112237. */
  112238. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112239. /**
  112240. * Interpolates a Vector3 linearl
  112241. * @param startValue Start value of the animation curve
  112242. * @param endValue End value of the animation curve
  112243. * @param gradient Scalar amount to interpolate
  112244. * @returns Interpolated scalar value
  112245. */
  112246. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112247. /**
  112248. * Interpolates a Vector3 cubically
  112249. * @param startValue Start value of the animation curve
  112250. * @param outTangent End tangent of the animation
  112251. * @param endValue End value of the animation curve
  112252. * @param inTangent Start tangent of the animation curve
  112253. * @param gradient Scalar amount to interpolate
  112254. * @returns InterpolatedVector3 value
  112255. */
  112256. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112257. /**
  112258. * Interpolates a Vector2 linearly
  112259. * @param startValue Start value of the animation curve
  112260. * @param endValue End value of the animation curve
  112261. * @param gradient Scalar amount to interpolate
  112262. * @returns Interpolated Vector2 value
  112263. */
  112264. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112265. /**
  112266. * Interpolates a Vector2 cubically
  112267. * @param startValue Start value of the animation curve
  112268. * @param outTangent End tangent of the animation
  112269. * @param endValue End value of the animation curve
  112270. * @param inTangent Start tangent of the animation curve
  112271. * @param gradient Scalar amount to interpolate
  112272. * @returns Interpolated Vector2 value
  112273. */
  112274. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112275. /**
  112276. * Interpolates a size linearly
  112277. * @param startValue Start value of the animation curve
  112278. * @param endValue End value of the animation curve
  112279. * @param gradient Scalar amount to interpolate
  112280. * @returns Interpolated Size value
  112281. */
  112282. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112283. /**
  112284. * Interpolates a Color3 linearly
  112285. * @param startValue Start value of the animation curve
  112286. * @param endValue End value of the animation curve
  112287. * @param gradient Scalar amount to interpolate
  112288. * @returns Interpolated Color3 value
  112289. */
  112290. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112291. /**
  112292. * Interpolates a Color4 linearly
  112293. * @param startValue Start value of the animation curve
  112294. * @param endValue End value of the animation curve
  112295. * @param gradient Scalar amount to interpolate
  112296. * @returns Interpolated Color3 value
  112297. */
  112298. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112299. /**
  112300. * @hidden Internal use only
  112301. */
  112302. _getKeyValue(value: any): any;
  112303. /**
  112304. * @hidden Internal use only
  112305. */
  112306. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112307. /**
  112308. * Defines the function to use to interpolate matrices
  112309. * @param startValue defines the start matrix
  112310. * @param endValue defines the end matrix
  112311. * @param gradient defines the gradient between both matrices
  112312. * @param result defines an optional target matrix where to store the interpolation
  112313. * @returns the interpolated matrix
  112314. */
  112315. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112316. /**
  112317. * Makes a copy of the animation
  112318. * @returns Cloned animation
  112319. */
  112320. clone(): Animation;
  112321. /**
  112322. * Sets the key frames of the animation
  112323. * @param values The animation key frames to set
  112324. */
  112325. setKeys(values: Array<IAnimationKey>): void;
  112326. /**
  112327. * Serializes the animation to an object
  112328. * @returns Serialized object
  112329. */
  112330. serialize(): any;
  112331. /**
  112332. * Float animation type
  112333. */
  112334. static readonly ANIMATIONTYPE_FLOAT: number;
  112335. /**
  112336. * Vector3 animation type
  112337. */
  112338. static readonly ANIMATIONTYPE_VECTOR3: number;
  112339. /**
  112340. * Quaternion animation type
  112341. */
  112342. static readonly ANIMATIONTYPE_QUATERNION: number;
  112343. /**
  112344. * Matrix animation type
  112345. */
  112346. static readonly ANIMATIONTYPE_MATRIX: number;
  112347. /**
  112348. * Color3 animation type
  112349. */
  112350. static readonly ANIMATIONTYPE_COLOR3: number;
  112351. /**
  112352. * Color3 animation type
  112353. */
  112354. static readonly ANIMATIONTYPE_COLOR4: number;
  112355. /**
  112356. * Vector2 animation type
  112357. */
  112358. static readonly ANIMATIONTYPE_VECTOR2: number;
  112359. /**
  112360. * Size animation type
  112361. */
  112362. static readonly ANIMATIONTYPE_SIZE: number;
  112363. /**
  112364. * Relative Loop Mode
  112365. */
  112366. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112367. /**
  112368. * Cycle Loop Mode
  112369. */
  112370. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112371. /**
  112372. * Constant Loop Mode
  112373. */
  112374. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112375. /** @hidden */
  112376. static _UniversalLerp(left: any, right: any, amount: number): any;
  112377. /**
  112378. * Parses an animation object and creates an animation
  112379. * @param parsedAnimation Parsed animation object
  112380. * @returns Animation object
  112381. */
  112382. static Parse(parsedAnimation: any): Animation;
  112383. /**
  112384. * Appends the serialized animations from the source animations
  112385. * @param source Source containing the animations
  112386. * @param destination Target to store the animations
  112387. */
  112388. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112389. /**
  112390. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112391. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112392. * @param url defines the url to load from
  112393. * @returns a promise that will resolve to the new animation or an array of animations
  112394. */
  112395. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112396. /**
  112397. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112398. * @param snippetId defines the snippet to load
  112399. * @returns a promise that will resolve to the new animation or a new array of animations
  112400. */
  112401. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112402. }
  112403. }
  112404. declare module BABYLON {
  112405. /**
  112406. * Interface containing an array of animations
  112407. */
  112408. export interface IAnimatable {
  112409. /**
  112410. * Array of animations
  112411. */
  112412. animations: Nullable<Array<Animation>>;
  112413. }
  112414. }
  112415. declare module BABYLON {
  112416. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  112417. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112418. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112419. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112420. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112421. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112422. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112423. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112424. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112425. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112426. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112427. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112428. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112429. /**
  112430. * Decorator used to define property that can be serialized as reference to a camera
  112431. * @param sourceName defines the name of the property to decorate
  112432. */
  112433. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112434. /**
  112435. * Class used to help serialization objects
  112436. */
  112437. export class SerializationHelper {
  112438. /** @hidden */
  112439. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  112440. /** @hidden */
  112441. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  112442. /** @hidden */
  112443. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  112444. /** @hidden */
  112445. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  112446. /**
  112447. * Appends the serialized animations from the source animations
  112448. * @param source Source containing the animations
  112449. * @param destination Target to store the animations
  112450. */
  112451. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112452. /**
  112453. * Static function used to serialized a specific entity
  112454. * @param entity defines the entity to serialize
  112455. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  112456. * @returns a JSON compatible object representing the serialization of the entity
  112457. */
  112458. static Serialize<T>(entity: T, serializationObject?: any): any;
  112459. /**
  112460. * Creates a new entity from a serialization data object
  112461. * @param creationFunction defines a function used to instanciated the new entity
  112462. * @param source defines the source serialization data
  112463. * @param scene defines the hosting scene
  112464. * @param rootUrl defines the root url for resources
  112465. * @returns a new entity
  112466. */
  112467. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  112468. /**
  112469. * Clones an object
  112470. * @param creationFunction defines the function used to instanciate the new object
  112471. * @param source defines the source object
  112472. * @returns the cloned object
  112473. */
  112474. static Clone<T>(creationFunction: () => T, source: T): T;
  112475. /**
  112476. * Instanciates a new object based on a source one (some data will be shared between both object)
  112477. * @param creationFunction defines the function used to instanciate the new object
  112478. * @param source defines the source object
  112479. * @returns the new object
  112480. */
  112481. static Instanciate<T>(creationFunction: () => T, source: T): T;
  112482. }
  112483. }
  112484. declare module BABYLON {
  112485. /**
  112486. * Base class of all the textures in babylon.
  112487. * It groups all the common properties the materials, post process, lights... might need
  112488. * in order to make a correct use of the texture.
  112489. */
  112490. export class BaseTexture implements IAnimatable {
  112491. /**
  112492. * Default anisotropic filtering level for the application.
  112493. * It is set to 4 as a good tradeoff between perf and quality.
  112494. */
  112495. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  112496. /**
  112497. * Gets or sets the unique id of the texture
  112498. */
  112499. uniqueId: number;
  112500. /**
  112501. * Define the name of the texture.
  112502. */
  112503. name: string;
  112504. /**
  112505. * Gets or sets an object used to store user defined information.
  112506. */
  112507. metadata: any;
  112508. /**
  112509. * For internal use only. Please do not use.
  112510. */
  112511. reservedDataStore: any;
  112512. private _hasAlpha;
  112513. /**
  112514. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  112515. */
  112516. set hasAlpha(value: boolean);
  112517. get hasAlpha(): boolean;
  112518. /**
  112519. * Defines if the alpha value should be determined via the rgb values.
  112520. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  112521. */
  112522. getAlphaFromRGB: boolean;
  112523. /**
  112524. * Intensity or strength of the texture.
  112525. * It is commonly used by materials to fine tune the intensity of the texture
  112526. */
  112527. level: number;
  112528. /**
  112529. * Define the UV chanel to use starting from 0 and defaulting to 0.
  112530. * This is part of the texture as textures usually maps to one uv set.
  112531. */
  112532. coordinatesIndex: number;
  112533. private _coordinatesMode;
  112534. /**
  112535. * How a texture is mapped.
  112536. *
  112537. * | Value | Type | Description |
  112538. * | ----- | ----------------------------------- | ----------- |
  112539. * | 0 | EXPLICIT_MODE | |
  112540. * | 1 | SPHERICAL_MODE | |
  112541. * | 2 | PLANAR_MODE | |
  112542. * | 3 | CUBIC_MODE | |
  112543. * | 4 | PROJECTION_MODE | |
  112544. * | 5 | SKYBOX_MODE | |
  112545. * | 6 | INVCUBIC_MODE | |
  112546. * | 7 | EQUIRECTANGULAR_MODE | |
  112547. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  112548. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  112549. */
  112550. set coordinatesMode(value: number);
  112551. get coordinatesMode(): number;
  112552. /**
  112553. * | Value | Type | Description |
  112554. * | ----- | ------------------ | ----------- |
  112555. * | 0 | CLAMP_ADDRESSMODE | |
  112556. * | 1 | WRAP_ADDRESSMODE | |
  112557. * | 2 | MIRROR_ADDRESSMODE | |
  112558. */
  112559. wrapU: number;
  112560. /**
  112561. * | Value | Type | Description |
  112562. * | ----- | ------------------ | ----------- |
  112563. * | 0 | CLAMP_ADDRESSMODE | |
  112564. * | 1 | WRAP_ADDRESSMODE | |
  112565. * | 2 | MIRROR_ADDRESSMODE | |
  112566. */
  112567. wrapV: number;
  112568. /**
  112569. * | Value | Type | Description |
  112570. * | ----- | ------------------ | ----------- |
  112571. * | 0 | CLAMP_ADDRESSMODE | |
  112572. * | 1 | WRAP_ADDRESSMODE | |
  112573. * | 2 | MIRROR_ADDRESSMODE | |
  112574. */
  112575. wrapR: number;
  112576. /**
  112577. * With compliant hardware and browser (supporting anisotropic filtering)
  112578. * this defines the level of anisotropic filtering in the texture.
  112579. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  112580. */
  112581. anisotropicFilteringLevel: number;
  112582. /**
  112583. * Define if the texture is a cube texture or if false a 2d texture.
  112584. */
  112585. get isCube(): boolean;
  112586. set isCube(value: boolean);
  112587. /**
  112588. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  112589. */
  112590. get is3D(): boolean;
  112591. set is3D(value: boolean);
  112592. /**
  112593. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  112594. */
  112595. get is2DArray(): boolean;
  112596. set is2DArray(value: boolean);
  112597. /**
  112598. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  112599. * HDR texture are usually stored in linear space.
  112600. * This only impacts the PBR and Background materials
  112601. */
  112602. gammaSpace: boolean;
  112603. /**
  112604. * Gets or sets whether or not the texture contains RGBD data.
  112605. */
  112606. get isRGBD(): boolean;
  112607. set isRGBD(value: boolean);
  112608. /**
  112609. * Is Z inverted in the texture (useful in a cube texture).
  112610. */
  112611. invertZ: boolean;
  112612. /**
  112613. * Are mip maps generated for this texture or not.
  112614. */
  112615. get noMipmap(): boolean;
  112616. /**
  112617. * @hidden
  112618. */
  112619. lodLevelInAlpha: boolean;
  112620. /**
  112621. * With prefiltered texture, defined the offset used during the prefiltering steps.
  112622. */
  112623. get lodGenerationOffset(): number;
  112624. set lodGenerationOffset(value: number);
  112625. /**
  112626. * With prefiltered texture, defined the scale used during the prefiltering steps.
  112627. */
  112628. get lodGenerationScale(): number;
  112629. set lodGenerationScale(value: number);
  112630. /**
  112631. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  112632. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  112633. * average roughness values.
  112634. */
  112635. get linearSpecularLOD(): boolean;
  112636. set linearSpecularLOD(value: boolean);
  112637. /**
  112638. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  112639. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  112640. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  112641. */
  112642. get irradianceTexture(): Nullable<BaseTexture>;
  112643. set irradianceTexture(value: Nullable<BaseTexture>);
  112644. /**
  112645. * Define if the texture is a render target.
  112646. */
  112647. isRenderTarget: boolean;
  112648. /**
  112649. * Define the unique id of the texture in the scene.
  112650. */
  112651. get uid(): string;
  112652. /** @hidden */
  112653. _prefiltered: boolean;
  112654. /**
  112655. * Return a string representation of the texture.
  112656. * @returns the texture as a string
  112657. */
  112658. toString(): string;
  112659. /**
  112660. * Get the class name of the texture.
  112661. * @returns "BaseTexture"
  112662. */
  112663. getClassName(): string;
  112664. /**
  112665. * Define the list of animation attached to the texture.
  112666. */
  112667. animations: Animation[];
  112668. /**
  112669. * An event triggered when the texture is disposed.
  112670. */
  112671. onDisposeObservable: Observable<BaseTexture>;
  112672. private _onDisposeObserver;
  112673. /**
  112674. * Callback triggered when the texture has been disposed.
  112675. * Kept for back compatibility, you can use the onDisposeObservable instead.
  112676. */
  112677. set onDispose(callback: () => void);
  112678. /**
  112679. * Define the current state of the loading sequence when in delayed load mode.
  112680. */
  112681. delayLoadState: number;
  112682. private _scene;
  112683. private _engine;
  112684. /** @hidden */
  112685. _texture: Nullable<InternalTexture>;
  112686. private _uid;
  112687. /**
  112688. * Define if the texture is preventinga material to render or not.
  112689. * If not and the texture is not ready, the engine will use a default black texture instead.
  112690. */
  112691. get isBlocking(): boolean;
  112692. /**
  112693. * Instantiates a new BaseTexture.
  112694. * Base class of all the textures in babylon.
  112695. * It groups all the common properties the materials, post process, lights... might need
  112696. * in order to make a correct use of the texture.
  112697. * @param sceneOrEngine Define the scene or engine the texture blongs to
  112698. */
  112699. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  112700. /**
  112701. * Get the scene the texture belongs to.
  112702. * @returns the scene or null if undefined
  112703. */
  112704. getScene(): Nullable<Scene>;
  112705. /** @hidden */
  112706. protected _getEngine(): Nullable<ThinEngine>;
  112707. /**
  112708. * Get the texture transform matrix used to offset tile the texture for istance.
  112709. * @returns the transformation matrix
  112710. */
  112711. getTextureMatrix(): Matrix;
  112712. /**
  112713. * Get the texture reflection matrix used to rotate/transform the reflection.
  112714. * @returns the reflection matrix
  112715. */
  112716. getReflectionTextureMatrix(): Matrix;
  112717. /**
  112718. * Get the underlying lower level texture from Babylon.
  112719. * @returns the insternal texture
  112720. */
  112721. getInternalTexture(): Nullable<InternalTexture>;
  112722. /**
  112723. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  112724. * @returns true if ready or not blocking
  112725. */
  112726. isReadyOrNotBlocking(): boolean;
  112727. /**
  112728. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  112729. * @returns true if fully ready
  112730. */
  112731. isReady(): boolean;
  112732. private _cachedSize;
  112733. /**
  112734. * Get the size of the texture.
  112735. * @returns the texture size.
  112736. */
  112737. getSize(): ISize;
  112738. /**
  112739. * Get the base size of the texture.
  112740. * It can be different from the size if the texture has been resized for POT for instance
  112741. * @returns the base size
  112742. */
  112743. getBaseSize(): ISize;
  112744. /**
  112745. * Update the sampling mode of the texture.
  112746. * Default is Trilinear mode.
  112747. *
  112748. * | Value | Type | Description |
  112749. * | ----- | ------------------ | ----------- |
  112750. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  112751. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  112752. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  112753. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  112754. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  112755. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  112756. * | 7 | NEAREST_LINEAR | |
  112757. * | 8 | NEAREST_NEAREST | |
  112758. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  112759. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  112760. * | 11 | LINEAR_LINEAR | |
  112761. * | 12 | LINEAR_NEAREST | |
  112762. *
  112763. * > _mag_: magnification filter (close to the viewer)
  112764. * > _min_: minification filter (far from the viewer)
  112765. * > _mip_: filter used between mip map levels
  112766. *@param samplingMode Define the new sampling mode of the texture
  112767. */
  112768. updateSamplingMode(samplingMode: number): void;
  112769. /**
  112770. * Scales the texture if is `canRescale()`
  112771. * @param ratio the resize factor we want to use to rescale
  112772. */
  112773. scale(ratio: number): void;
  112774. /**
  112775. * Get if the texture can rescale.
  112776. */
  112777. get canRescale(): boolean;
  112778. /** @hidden */
  112779. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  112780. /** @hidden */
  112781. _rebuild(): void;
  112782. /**
  112783. * Triggers the load sequence in delayed load mode.
  112784. */
  112785. delayLoad(): void;
  112786. /**
  112787. * Clones the texture.
  112788. * @returns the cloned texture
  112789. */
  112790. clone(): Nullable<BaseTexture>;
  112791. /**
  112792. * Get the texture underlying type (INT, FLOAT...)
  112793. */
  112794. get textureType(): number;
  112795. /**
  112796. * Get the texture underlying format (RGB, RGBA...)
  112797. */
  112798. get textureFormat(): number;
  112799. /**
  112800. * Indicates that textures need to be re-calculated for all materials
  112801. */
  112802. protected _markAllSubMeshesAsTexturesDirty(): void;
  112803. /**
  112804. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  112805. * This will returns an RGBA array buffer containing either in values (0-255) or
  112806. * float values (0-1) depending of the underlying buffer type.
  112807. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  112808. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  112809. * @param buffer defines a user defined buffer to fill with data (can be null)
  112810. * @returns The Array buffer containing the pixels data.
  112811. */
  112812. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  112813. /**
  112814. * Release and destroy the underlying lower level texture aka internalTexture.
  112815. */
  112816. releaseInternalTexture(): void;
  112817. /** @hidden */
  112818. get _lodTextureHigh(): Nullable<BaseTexture>;
  112819. /** @hidden */
  112820. get _lodTextureMid(): Nullable<BaseTexture>;
  112821. /** @hidden */
  112822. get _lodTextureLow(): Nullable<BaseTexture>;
  112823. /**
  112824. * Dispose the texture and release its associated resources.
  112825. */
  112826. dispose(): void;
  112827. /**
  112828. * Serialize the texture into a JSON representation that can be parsed later on.
  112829. * @returns the JSON representation of the texture
  112830. */
  112831. serialize(): any;
  112832. /**
  112833. * Helper function to be called back once a list of texture contains only ready textures.
  112834. * @param textures Define the list of textures to wait for
  112835. * @param callback Define the callback triggered once the entire list will be ready
  112836. */
  112837. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  112838. private static _isScene;
  112839. }
  112840. }
  112841. declare module BABYLON {
  112842. /**
  112843. * Options to be used when creating an effect.
  112844. */
  112845. export interface IEffectCreationOptions {
  112846. /**
  112847. * Atrributes that will be used in the shader.
  112848. */
  112849. attributes: string[];
  112850. /**
  112851. * Uniform varible names that will be set in the shader.
  112852. */
  112853. uniformsNames: string[];
  112854. /**
  112855. * Uniform buffer variable names that will be set in the shader.
  112856. */
  112857. uniformBuffersNames: string[];
  112858. /**
  112859. * Sampler texture variable names that will be set in the shader.
  112860. */
  112861. samplers: string[];
  112862. /**
  112863. * Define statements that will be set in the shader.
  112864. */
  112865. defines: any;
  112866. /**
  112867. * Possible fallbacks for this effect to improve performance when needed.
  112868. */
  112869. fallbacks: Nullable<IEffectFallbacks>;
  112870. /**
  112871. * Callback that will be called when the shader is compiled.
  112872. */
  112873. onCompiled: Nullable<(effect: Effect) => void>;
  112874. /**
  112875. * Callback that will be called if an error occurs during shader compilation.
  112876. */
  112877. onError: Nullable<(effect: Effect, errors: string) => void>;
  112878. /**
  112879. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  112880. */
  112881. indexParameters?: any;
  112882. /**
  112883. * Max number of lights that can be used in the shader.
  112884. */
  112885. maxSimultaneousLights?: number;
  112886. /**
  112887. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  112888. */
  112889. transformFeedbackVaryings?: Nullable<string[]>;
  112890. /**
  112891. * 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
  112892. */
  112893. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  112894. /**
  112895. * Is this effect rendering to several color attachments ?
  112896. */
  112897. multiTarget?: boolean;
  112898. }
  112899. /**
  112900. * Effect containing vertex and fragment shader that can be executed on an object.
  112901. */
  112902. export class Effect implements IDisposable {
  112903. /**
  112904. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112905. */
  112906. static ShadersRepository: string;
  112907. /**
  112908. * Enable logging of the shader code when a compilation error occurs
  112909. */
  112910. static LogShaderCodeOnCompilationError: boolean;
  112911. /**
  112912. * Name of the effect.
  112913. */
  112914. name: any;
  112915. /**
  112916. * String container all the define statements that should be set on the shader.
  112917. */
  112918. defines: string;
  112919. /**
  112920. * Callback that will be called when the shader is compiled.
  112921. */
  112922. onCompiled: Nullable<(effect: Effect) => void>;
  112923. /**
  112924. * Callback that will be called if an error occurs during shader compilation.
  112925. */
  112926. onError: Nullable<(effect: Effect, errors: string) => void>;
  112927. /**
  112928. * Callback that will be called when effect is bound.
  112929. */
  112930. onBind: Nullable<(effect: Effect) => void>;
  112931. /**
  112932. * Unique ID of the effect.
  112933. */
  112934. uniqueId: number;
  112935. /**
  112936. * Observable that will be called when the shader is compiled.
  112937. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  112938. */
  112939. onCompileObservable: Observable<Effect>;
  112940. /**
  112941. * Observable that will be called if an error occurs during shader compilation.
  112942. */
  112943. onErrorObservable: Observable<Effect>;
  112944. /** @hidden */
  112945. _onBindObservable: Nullable<Observable<Effect>>;
  112946. /**
  112947. * @hidden
  112948. * Specifies if the effect was previously ready
  112949. */
  112950. _wasPreviouslyReady: boolean;
  112951. /**
  112952. * Observable that will be called when effect is bound.
  112953. */
  112954. get onBindObservable(): Observable<Effect>;
  112955. /** @hidden */
  112956. _bonesComputationForcedToCPU: boolean;
  112957. /** @hidden */
  112958. _multiTarget: boolean;
  112959. private static _uniqueIdSeed;
  112960. private _engine;
  112961. private _uniformBuffersNames;
  112962. private _uniformBuffersNamesList;
  112963. private _uniformsNames;
  112964. private _samplerList;
  112965. private _samplers;
  112966. private _isReady;
  112967. private _compilationError;
  112968. private _allFallbacksProcessed;
  112969. private _attributesNames;
  112970. private _attributes;
  112971. private _attributeLocationByName;
  112972. private _uniforms;
  112973. /**
  112974. * Key for the effect.
  112975. * @hidden
  112976. */
  112977. _key: string;
  112978. private _indexParameters;
  112979. private _fallbacks;
  112980. private _vertexSourceCode;
  112981. private _fragmentSourceCode;
  112982. private _vertexSourceCodeOverride;
  112983. private _fragmentSourceCodeOverride;
  112984. private _transformFeedbackVaryings;
  112985. /**
  112986. * Compiled shader to webGL program.
  112987. * @hidden
  112988. */
  112989. _pipelineContext: Nullable<IPipelineContext>;
  112990. private _valueCache;
  112991. private static _baseCache;
  112992. /**
  112993. * Instantiates an effect.
  112994. * An effect can be used to create/manage/execute vertex and fragment shaders.
  112995. * @param baseName Name of the effect.
  112996. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  112997. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  112998. * @param samplers List of sampler variables that will be passed to the shader.
  112999. * @param engine Engine to be used to render the effect
  113000. * @param defines Define statements to be added to the shader.
  113001. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113002. * @param onCompiled Callback that will be called when the shader is compiled.
  113003. * @param onError Callback that will be called if an error occurs during shader compilation.
  113004. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113005. */
  113006. 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);
  113007. private _useFinalCode;
  113008. /**
  113009. * Unique key for this effect
  113010. */
  113011. get key(): string;
  113012. /**
  113013. * If the effect has been compiled and prepared.
  113014. * @returns if the effect is compiled and prepared.
  113015. */
  113016. isReady(): boolean;
  113017. private _isReadyInternal;
  113018. /**
  113019. * The engine the effect was initialized with.
  113020. * @returns the engine.
  113021. */
  113022. getEngine(): Engine;
  113023. /**
  113024. * The pipeline context for this effect
  113025. * @returns the associated pipeline context
  113026. */
  113027. getPipelineContext(): Nullable<IPipelineContext>;
  113028. /**
  113029. * The set of names of attribute variables for the shader.
  113030. * @returns An array of attribute names.
  113031. */
  113032. getAttributesNames(): string[];
  113033. /**
  113034. * Returns the attribute at the given index.
  113035. * @param index The index of the attribute.
  113036. * @returns The location of the attribute.
  113037. */
  113038. getAttributeLocation(index: number): number;
  113039. /**
  113040. * Returns the attribute based on the name of the variable.
  113041. * @param name of the attribute to look up.
  113042. * @returns the attribute location.
  113043. */
  113044. getAttributeLocationByName(name: string): number;
  113045. /**
  113046. * The number of attributes.
  113047. * @returns the numnber of attributes.
  113048. */
  113049. getAttributesCount(): number;
  113050. /**
  113051. * Gets the index of a uniform variable.
  113052. * @param uniformName of the uniform to look up.
  113053. * @returns the index.
  113054. */
  113055. getUniformIndex(uniformName: string): number;
  113056. /**
  113057. * Returns the attribute based on the name of the variable.
  113058. * @param uniformName of the uniform to look up.
  113059. * @returns the location of the uniform.
  113060. */
  113061. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  113062. /**
  113063. * Returns an array of sampler variable names
  113064. * @returns The array of sampler variable names.
  113065. */
  113066. getSamplers(): string[];
  113067. /**
  113068. * Returns an array of uniform variable names
  113069. * @returns The array of uniform variable names.
  113070. */
  113071. getUniformNames(): string[];
  113072. /**
  113073. * Returns an array of uniform buffer variable names
  113074. * @returns The array of uniform buffer variable names.
  113075. */
  113076. getUniformBuffersNames(): string[];
  113077. /**
  113078. * Returns the index parameters used to create the effect
  113079. * @returns The index parameters object
  113080. */
  113081. getIndexParameters(): any;
  113082. /**
  113083. * The error from the last compilation.
  113084. * @returns the error string.
  113085. */
  113086. getCompilationError(): string;
  113087. /**
  113088. * Gets a boolean indicating that all fallbacks were used during compilation
  113089. * @returns true if all fallbacks were used
  113090. */
  113091. allFallbacksProcessed(): boolean;
  113092. /**
  113093. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  113094. * @param func The callback to be used.
  113095. */
  113096. executeWhenCompiled(func: (effect: Effect) => void): void;
  113097. private _checkIsReady;
  113098. private _loadShader;
  113099. /**
  113100. * Gets the vertex shader source code of this effect
  113101. */
  113102. get vertexSourceCode(): string;
  113103. /**
  113104. * Gets the fragment shader source code of this effect
  113105. */
  113106. get fragmentSourceCode(): string;
  113107. /**
  113108. * Recompiles the webGL program
  113109. * @param vertexSourceCode The source code for the vertex shader.
  113110. * @param fragmentSourceCode The source code for the fragment shader.
  113111. * @param onCompiled Callback called when completed.
  113112. * @param onError Callback called on error.
  113113. * @hidden
  113114. */
  113115. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  113116. /**
  113117. * Prepares the effect
  113118. * @hidden
  113119. */
  113120. _prepareEffect(): void;
  113121. private _getShaderCodeAndErrorLine;
  113122. private _processCompilationErrors;
  113123. /**
  113124. * Checks if the effect is supported. (Must be called after compilation)
  113125. */
  113126. get isSupported(): boolean;
  113127. /**
  113128. * Binds a texture to the engine to be used as output of the shader.
  113129. * @param channel Name of the output variable.
  113130. * @param texture Texture to bind.
  113131. * @hidden
  113132. */
  113133. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  113134. /**
  113135. * Sets a texture on the engine to be used in the shader.
  113136. * @param channel Name of the sampler variable.
  113137. * @param texture Texture to set.
  113138. */
  113139. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  113140. /**
  113141. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  113142. * @param channel Name of the sampler variable.
  113143. * @param texture Texture to set.
  113144. */
  113145. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  113146. /**
  113147. * Sets an array of textures on the engine to be used in the shader.
  113148. * @param channel Name of the variable.
  113149. * @param textures Textures to set.
  113150. */
  113151. setTextureArray(channel: string, textures: BaseTexture[]): void;
  113152. /**
  113153. * 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)
  113154. * @param channel Name of the sampler variable.
  113155. * @param postProcess Post process to get the input texture from.
  113156. */
  113157. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  113158. /**
  113159. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  113160. * 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)
  113161. * @param channel Name of the sampler variable.
  113162. * @param postProcess Post process to get the output texture from.
  113163. */
  113164. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  113165. /** @hidden */
  113166. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  113167. /** @hidden */
  113168. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  113169. /** @hidden */
  113170. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  113171. /** @hidden */
  113172. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  113173. /**
  113174. * Binds a buffer to a uniform.
  113175. * @param buffer Buffer to bind.
  113176. * @param name Name of the uniform variable to bind to.
  113177. */
  113178. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113179. /**
  113180. * Binds block to a uniform.
  113181. * @param blockName Name of the block to bind.
  113182. * @param index Index to bind.
  113183. */
  113184. bindUniformBlock(blockName: string, index: number): void;
  113185. /**
  113186. * Sets an interger value on a uniform variable.
  113187. * @param uniformName Name of the variable.
  113188. * @param value Value to be set.
  113189. * @returns this effect.
  113190. */
  113191. setInt(uniformName: string, value: number): Effect;
  113192. /**
  113193. * Sets an int array on a uniform variable.
  113194. * @param uniformName Name of the variable.
  113195. * @param array array to be set.
  113196. * @returns this effect.
  113197. */
  113198. setIntArray(uniformName: string, array: Int32Array): Effect;
  113199. /**
  113200. * 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)
  113201. * @param uniformName Name of the variable.
  113202. * @param array array to be set.
  113203. * @returns this effect.
  113204. */
  113205. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113206. /**
  113207. * 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)
  113208. * @param uniformName Name of the variable.
  113209. * @param array array to be set.
  113210. * @returns this effect.
  113211. */
  113212. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113213. /**
  113214. * 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)
  113215. * @param uniformName Name of the variable.
  113216. * @param array array to be set.
  113217. * @returns this effect.
  113218. */
  113219. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113220. /**
  113221. * Sets an float array on a uniform variable.
  113222. * @param uniformName Name of the variable.
  113223. * @param array array to be set.
  113224. * @returns this effect.
  113225. */
  113226. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113227. /**
  113228. * 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)
  113229. * @param uniformName Name of the variable.
  113230. * @param array array to be set.
  113231. * @returns this effect.
  113232. */
  113233. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113234. /**
  113235. * 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)
  113236. * @param uniformName Name of the variable.
  113237. * @param array array to be set.
  113238. * @returns this effect.
  113239. */
  113240. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113241. /**
  113242. * 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)
  113243. * @param uniformName Name of the variable.
  113244. * @param array array to be set.
  113245. * @returns this effect.
  113246. */
  113247. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113248. /**
  113249. * Sets an array on a uniform variable.
  113250. * @param uniformName Name of the variable.
  113251. * @param array array to be set.
  113252. * @returns this effect.
  113253. */
  113254. setArray(uniformName: string, array: number[]): Effect;
  113255. /**
  113256. * 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)
  113257. * @param uniformName Name of the variable.
  113258. * @param array array to be set.
  113259. * @returns this effect.
  113260. */
  113261. setArray2(uniformName: string, array: number[]): Effect;
  113262. /**
  113263. * 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)
  113264. * @param uniformName Name of the variable.
  113265. * @param array array to be set.
  113266. * @returns this effect.
  113267. */
  113268. setArray3(uniformName: string, array: number[]): Effect;
  113269. /**
  113270. * 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)
  113271. * @param uniformName Name of the variable.
  113272. * @param array array to be set.
  113273. * @returns this effect.
  113274. */
  113275. setArray4(uniformName: string, array: number[]): Effect;
  113276. /**
  113277. * Sets matrices on a uniform variable.
  113278. * @param uniformName Name of the variable.
  113279. * @param matrices matrices to be set.
  113280. * @returns this effect.
  113281. */
  113282. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113283. /**
  113284. * Sets matrix on a uniform variable.
  113285. * @param uniformName Name of the variable.
  113286. * @param matrix matrix to be set.
  113287. * @returns this effect.
  113288. */
  113289. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113290. /**
  113291. * 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)
  113292. * @param uniformName Name of the variable.
  113293. * @param matrix matrix to be set.
  113294. * @returns this effect.
  113295. */
  113296. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113297. /**
  113298. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113299. * @param uniformName Name of the variable.
  113300. * @param matrix matrix to be set.
  113301. * @returns this effect.
  113302. */
  113303. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113304. /**
  113305. * Sets a float on a uniform variable.
  113306. * @param uniformName Name of the variable.
  113307. * @param value value to be set.
  113308. * @returns this effect.
  113309. */
  113310. setFloat(uniformName: string, value: number): Effect;
  113311. /**
  113312. * Sets a boolean on a uniform variable.
  113313. * @param uniformName Name of the variable.
  113314. * @param bool value to be set.
  113315. * @returns this effect.
  113316. */
  113317. setBool(uniformName: string, bool: boolean): Effect;
  113318. /**
  113319. * Sets a Vector2 on a uniform variable.
  113320. * @param uniformName Name of the variable.
  113321. * @param vector2 vector2 to be set.
  113322. * @returns this effect.
  113323. */
  113324. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113325. /**
  113326. * Sets a float2 on a uniform variable.
  113327. * @param uniformName Name of the variable.
  113328. * @param x First float in float2.
  113329. * @param y Second float in float2.
  113330. * @returns this effect.
  113331. */
  113332. setFloat2(uniformName: string, x: number, y: number): Effect;
  113333. /**
  113334. * Sets a Vector3 on a uniform variable.
  113335. * @param uniformName Name of the variable.
  113336. * @param vector3 Value to be set.
  113337. * @returns this effect.
  113338. */
  113339. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113340. /**
  113341. * Sets a float3 on a uniform variable.
  113342. * @param uniformName Name of the variable.
  113343. * @param x First float in float3.
  113344. * @param y Second float in float3.
  113345. * @param z Third float in float3.
  113346. * @returns this effect.
  113347. */
  113348. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113349. /**
  113350. * Sets a Vector4 on a uniform variable.
  113351. * @param uniformName Name of the variable.
  113352. * @param vector4 Value to be set.
  113353. * @returns this effect.
  113354. */
  113355. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113356. /**
  113357. * Sets a float4 on a uniform variable.
  113358. * @param uniformName Name of the variable.
  113359. * @param x First float in float4.
  113360. * @param y Second float in float4.
  113361. * @param z Third float in float4.
  113362. * @param w Fourth float in float4.
  113363. * @returns this effect.
  113364. */
  113365. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113366. /**
  113367. * Sets a Color3 on a uniform variable.
  113368. * @param uniformName Name of the variable.
  113369. * @param color3 Value to be set.
  113370. * @returns this effect.
  113371. */
  113372. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113373. /**
  113374. * Sets a Color4 on a uniform variable.
  113375. * @param uniformName Name of the variable.
  113376. * @param color3 Value to be set.
  113377. * @param alpha Alpha value to be set.
  113378. * @returns this effect.
  113379. */
  113380. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113381. /**
  113382. * Sets a Color4 on a uniform variable
  113383. * @param uniformName defines the name of the variable
  113384. * @param color4 defines the value to be set
  113385. * @returns this effect.
  113386. */
  113387. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113388. /** Release all associated resources */
  113389. dispose(): void;
  113390. /**
  113391. * This function will add a new shader to the shader store
  113392. * @param name the name of the shader
  113393. * @param pixelShader optional pixel shader content
  113394. * @param vertexShader optional vertex shader content
  113395. */
  113396. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113397. /**
  113398. * Store of each shader (The can be looked up using effect.key)
  113399. */
  113400. static ShadersStore: {
  113401. [key: string]: string;
  113402. };
  113403. /**
  113404. * Store of each included file for a shader (The can be looked up using effect.key)
  113405. */
  113406. static IncludesShadersStore: {
  113407. [key: string]: string;
  113408. };
  113409. /**
  113410. * Resets the cache of effects.
  113411. */
  113412. static ResetCache(): void;
  113413. }
  113414. }
  113415. declare module BABYLON {
  113416. /**
  113417. * Interface used to describe the capabilities of the engine relatively to the current browser
  113418. */
  113419. export interface EngineCapabilities {
  113420. /** Maximum textures units per fragment shader */
  113421. maxTexturesImageUnits: number;
  113422. /** Maximum texture units per vertex shader */
  113423. maxVertexTextureImageUnits: number;
  113424. /** Maximum textures units in the entire pipeline */
  113425. maxCombinedTexturesImageUnits: number;
  113426. /** Maximum texture size */
  113427. maxTextureSize: number;
  113428. /** Maximum texture samples */
  113429. maxSamples?: number;
  113430. /** Maximum cube texture size */
  113431. maxCubemapTextureSize: number;
  113432. /** Maximum render texture size */
  113433. maxRenderTextureSize: number;
  113434. /** Maximum number of vertex attributes */
  113435. maxVertexAttribs: number;
  113436. /** Maximum number of varyings */
  113437. maxVaryingVectors: number;
  113438. /** Maximum number of uniforms per vertex shader */
  113439. maxVertexUniformVectors: number;
  113440. /** Maximum number of uniforms per fragment shader */
  113441. maxFragmentUniformVectors: number;
  113442. /** Defines if standard derivates (dx/dy) are supported */
  113443. standardDerivatives: boolean;
  113444. /** Defines if s3tc texture compression is supported */
  113445. s3tc?: WEBGL_compressed_texture_s3tc;
  113446. /** Defines if pvrtc texture compression is supported */
  113447. pvrtc: any;
  113448. /** Defines if etc1 texture compression is supported */
  113449. etc1: any;
  113450. /** Defines if etc2 texture compression is supported */
  113451. etc2: any;
  113452. /** Defines if astc texture compression is supported */
  113453. astc: any;
  113454. /** Defines if float textures are supported */
  113455. textureFloat: boolean;
  113456. /** Defines if vertex array objects are supported */
  113457. vertexArrayObject: boolean;
  113458. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  113459. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  113460. /** Gets the maximum level of anisotropy supported */
  113461. maxAnisotropy: number;
  113462. /** Defines if instancing is supported */
  113463. instancedArrays: boolean;
  113464. /** Defines if 32 bits indices are supported */
  113465. uintIndices: boolean;
  113466. /** Defines if high precision shaders are supported */
  113467. highPrecisionShaderSupported: boolean;
  113468. /** Defines if depth reading in the fragment shader is supported */
  113469. fragmentDepthSupported: boolean;
  113470. /** Defines if float texture linear filtering is supported*/
  113471. textureFloatLinearFiltering: boolean;
  113472. /** Defines if rendering to float textures is supported */
  113473. textureFloatRender: boolean;
  113474. /** Defines if half float textures are supported*/
  113475. textureHalfFloat: boolean;
  113476. /** Defines if half float texture linear filtering is supported*/
  113477. textureHalfFloatLinearFiltering: boolean;
  113478. /** Defines if rendering to half float textures is supported */
  113479. textureHalfFloatRender: boolean;
  113480. /** Defines if textureLOD shader command is supported */
  113481. textureLOD: boolean;
  113482. /** Defines if draw buffers extension is supported */
  113483. drawBuffersExtension: boolean;
  113484. /** Defines if depth textures are supported */
  113485. depthTextureExtension: boolean;
  113486. /** Defines if float color buffer are supported */
  113487. colorBufferFloat: boolean;
  113488. /** Gets disjoint timer query extension (null if not supported) */
  113489. timerQuery?: EXT_disjoint_timer_query;
  113490. /** Defines if timestamp can be used with timer query */
  113491. canUseTimestampForTimerQuery: boolean;
  113492. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  113493. multiview?: any;
  113494. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  113495. oculusMultiview?: any;
  113496. /** Function used to let the system compiles shaders in background */
  113497. parallelShaderCompile?: {
  113498. COMPLETION_STATUS_KHR: number;
  113499. };
  113500. /** Max number of texture samples for MSAA */
  113501. maxMSAASamples: number;
  113502. /** Defines if the blend min max extension is supported */
  113503. blendMinMax: boolean;
  113504. }
  113505. }
  113506. declare module BABYLON {
  113507. /**
  113508. * @hidden
  113509. **/
  113510. export class DepthCullingState {
  113511. private _isDepthTestDirty;
  113512. private _isDepthMaskDirty;
  113513. private _isDepthFuncDirty;
  113514. private _isCullFaceDirty;
  113515. private _isCullDirty;
  113516. private _isZOffsetDirty;
  113517. private _isFrontFaceDirty;
  113518. private _depthTest;
  113519. private _depthMask;
  113520. private _depthFunc;
  113521. private _cull;
  113522. private _cullFace;
  113523. private _zOffset;
  113524. private _frontFace;
  113525. /**
  113526. * Initializes the state.
  113527. */
  113528. constructor();
  113529. get isDirty(): boolean;
  113530. get zOffset(): number;
  113531. set zOffset(value: number);
  113532. get cullFace(): Nullable<number>;
  113533. set cullFace(value: Nullable<number>);
  113534. get cull(): Nullable<boolean>;
  113535. set cull(value: Nullable<boolean>);
  113536. get depthFunc(): Nullable<number>;
  113537. set depthFunc(value: Nullable<number>);
  113538. get depthMask(): boolean;
  113539. set depthMask(value: boolean);
  113540. get depthTest(): boolean;
  113541. set depthTest(value: boolean);
  113542. get frontFace(): Nullable<number>;
  113543. set frontFace(value: Nullable<number>);
  113544. reset(): void;
  113545. apply(gl: WebGLRenderingContext): void;
  113546. }
  113547. }
  113548. declare module BABYLON {
  113549. /**
  113550. * @hidden
  113551. **/
  113552. export class StencilState {
  113553. /** 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 */
  113554. static readonly ALWAYS: number;
  113555. /** Passed to stencilOperation to specify that stencil value must be kept */
  113556. static readonly KEEP: number;
  113557. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113558. static readonly REPLACE: number;
  113559. private _isStencilTestDirty;
  113560. private _isStencilMaskDirty;
  113561. private _isStencilFuncDirty;
  113562. private _isStencilOpDirty;
  113563. private _stencilTest;
  113564. private _stencilMask;
  113565. private _stencilFunc;
  113566. private _stencilFuncRef;
  113567. private _stencilFuncMask;
  113568. private _stencilOpStencilFail;
  113569. private _stencilOpDepthFail;
  113570. private _stencilOpStencilDepthPass;
  113571. get isDirty(): boolean;
  113572. get stencilFunc(): number;
  113573. set stencilFunc(value: number);
  113574. get stencilFuncRef(): number;
  113575. set stencilFuncRef(value: number);
  113576. get stencilFuncMask(): number;
  113577. set stencilFuncMask(value: number);
  113578. get stencilOpStencilFail(): number;
  113579. set stencilOpStencilFail(value: number);
  113580. get stencilOpDepthFail(): number;
  113581. set stencilOpDepthFail(value: number);
  113582. get stencilOpStencilDepthPass(): number;
  113583. set stencilOpStencilDepthPass(value: number);
  113584. get stencilMask(): number;
  113585. set stencilMask(value: number);
  113586. get stencilTest(): boolean;
  113587. set stencilTest(value: boolean);
  113588. constructor();
  113589. reset(): void;
  113590. apply(gl: WebGLRenderingContext): void;
  113591. }
  113592. }
  113593. declare module BABYLON {
  113594. /**
  113595. * @hidden
  113596. **/
  113597. export class AlphaState {
  113598. private _isAlphaBlendDirty;
  113599. private _isBlendFunctionParametersDirty;
  113600. private _isBlendEquationParametersDirty;
  113601. private _isBlendConstantsDirty;
  113602. private _alphaBlend;
  113603. private _blendFunctionParameters;
  113604. private _blendEquationParameters;
  113605. private _blendConstants;
  113606. /**
  113607. * Initializes the state.
  113608. */
  113609. constructor();
  113610. get isDirty(): boolean;
  113611. get alphaBlend(): boolean;
  113612. set alphaBlend(value: boolean);
  113613. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  113614. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  113615. setAlphaEquationParameters(rgb: number, alpha: number): void;
  113616. reset(): void;
  113617. apply(gl: WebGLRenderingContext): void;
  113618. }
  113619. }
  113620. declare module BABYLON {
  113621. /** @hidden */
  113622. export class WebGL2ShaderProcessor implements IShaderProcessor {
  113623. attributeProcessor(attribute: string): string;
  113624. varyingProcessor(varying: string, isFragment: boolean): string;
  113625. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113626. }
  113627. }
  113628. declare module BABYLON {
  113629. /**
  113630. * Interface for attribute information associated with buffer instanciation
  113631. */
  113632. export interface InstancingAttributeInfo {
  113633. /**
  113634. * Name of the GLSL attribute
  113635. * if attribute index is not specified, this is used to retrieve the index from the effect
  113636. */
  113637. attributeName: string;
  113638. /**
  113639. * Index/offset of the attribute in the vertex shader
  113640. * if not specified, this will be computes from the name.
  113641. */
  113642. index?: number;
  113643. /**
  113644. * size of the attribute, 1, 2, 3 or 4
  113645. */
  113646. attributeSize: number;
  113647. /**
  113648. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  113649. */
  113650. offset: number;
  113651. /**
  113652. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  113653. * default to 1
  113654. */
  113655. divisor?: number;
  113656. /**
  113657. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  113658. * default is FLOAT
  113659. */
  113660. attributeType?: number;
  113661. /**
  113662. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  113663. */
  113664. normalized?: boolean;
  113665. }
  113666. }
  113667. declare module BABYLON {
  113668. interface ThinEngine {
  113669. /**
  113670. * Update a video texture
  113671. * @param texture defines the texture to update
  113672. * @param video defines the video element to use
  113673. * @param invertY defines if data must be stored with Y axis inverted
  113674. */
  113675. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  113676. }
  113677. }
  113678. declare module BABYLON {
  113679. interface ThinEngine {
  113680. /**
  113681. * Creates a dynamic texture
  113682. * @param width defines the width of the texture
  113683. * @param height defines the height of the texture
  113684. * @param generateMipMaps defines if the engine should generate the mip levels
  113685. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  113686. * @returns the dynamic texture inside an InternalTexture
  113687. */
  113688. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  113689. /**
  113690. * Update the content of a dynamic texture
  113691. * @param texture defines the texture to update
  113692. * @param canvas defines the canvas containing the source
  113693. * @param invertY defines if data must be stored with Y axis inverted
  113694. * @param premulAlpha defines if alpha is stored as premultiplied
  113695. * @param format defines the format of the data
  113696. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113697. */
  113698. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  113699. }
  113700. }
  113701. declare module BABYLON {
  113702. /**
  113703. * Settings for finer control over video usage
  113704. */
  113705. export interface VideoTextureSettings {
  113706. /**
  113707. * Applies `autoplay` to video, if specified
  113708. */
  113709. autoPlay?: boolean;
  113710. /**
  113711. * Applies `loop` to video, if specified
  113712. */
  113713. loop?: boolean;
  113714. /**
  113715. * Automatically updates internal texture from video at every frame in the render loop
  113716. */
  113717. autoUpdateTexture: boolean;
  113718. /**
  113719. * Image src displayed during the video loading or until the user interacts with the video.
  113720. */
  113721. poster?: string;
  113722. }
  113723. /**
  113724. * If you want to display a video in your scene, this is the special texture for that.
  113725. * This special texture works similar to other textures, with the exception of a few parameters.
  113726. * @see https://doc.babylonjs.com/how_to/video_texture
  113727. */
  113728. export class VideoTexture extends Texture {
  113729. /**
  113730. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  113731. */
  113732. readonly autoUpdateTexture: boolean;
  113733. /**
  113734. * The video instance used by the texture internally
  113735. */
  113736. readonly video: HTMLVideoElement;
  113737. private _onUserActionRequestedObservable;
  113738. /**
  113739. * Event triggerd when a dom action is required by the user to play the video.
  113740. * This happens due to recent changes in browser policies preventing video to auto start.
  113741. */
  113742. get onUserActionRequestedObservable(): Observable<Texture>;
  113743. private _generateMipMaps;
  113744. private _stillImageCaptured;
  113745. private _displayingPosterTexture;
  113746. private _settings;
  113747. private _createInternalTextureOnEvent;
  113748. private _frameId;
  113749. private _currentSrc;
  113750. /**
  113751. * Creates a video texture.
  113752. * If you want to display a video in your scene, this is the special texture for that.
  113753. * This special texture works similar to other textures, with the exception of a few parameters.
  113754. * @see https://doc.babylonjs.com/how_to/video_texture
  113755. * @param name optional name, will detect from video source, if not defined
  113756. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  113757. * @param scene is obviously the current scene.
  113758. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  113759. * @param invertY is false by default but can be used to invert video on Y axis
  113760. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  113761. * @param settings allows finer control over video usage
  113762. */
  113763. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  113764. private _getName;
  113765. private _getVideo;
  113766. private _createInternalTexture;
  113767. private reset;
  113768. /**
  113769. * @hidden Internal method to initiate `update`.
  113770. */
  113771. _rebuild(): void;
  113772. /**
  113773. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  113774. */
  113775. update(): void;
  113776. /**
  113777. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  113778. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  113779. */
  113780. updateTexture(isVisible: boolean): void;
  113781. protected _updateInternalTexture: () => void;
  113782. /**
  113783. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  113784. * @param url New url.
  113785. */
  113786. updateURL(url: string): void;
  113787. /**
  113788. * Clones the texture.
  113789. * @returns the cloned texture
  113790. */
  113791. clone(): VideoTexture;
  113792. /**
  113793. * Dispose the texture and release its associated resources.
  113794. */
  113795. dispose(): void;
  113796. /**
  113797. * Creates a video texture straight from a stream.
  113798. * @param scene Define the scene the texture should be created in
  113799. * @param stream Define the stream the texture should be created from
  113800. * @returns The created video texture as a promise
  113801. */
  113802. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  113803. /**
  113804. * Creates a video texture straight from your WebCam video feed.
  113805. * @param scene Define the scene the texture should be created in
  113806. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113807. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113808. * @returns The created video texture as a promise
  113809. */
  113810. static CreateFromWebCamAsync(scene: Scene, constraints: {
  113811. minWidth: number;
  113812. maxWidth: number;
  113813. minHeight: number;
  113814. maxHeight: number;
  113815. deviceId: string;
  113816. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  113817. /**
  113818. * Creates a video texture straight from your WebCam video feed.
  113819. * @param scene Define the scene the texture should be created in
  113820. * @param onReady Define a callback to triggered once the texture will be ready
  113821. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113822. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113823. */
  113824. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  113825. minWidth: number;
  113826. maxWidth: number;
  113827. minHeight: number;
  113828. maxHeight: number;
  113829. deviceId: string;
  113830. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  113831. }
  113832. }
  113833. declare module BABYLON {
  113834. /**
  113835. * Defines the interface used by objects working like Scene
  113836. * @hidden
  113837. */
  113838. export interface ISceneLike {
  113839. _addPendingData(data: any): void;
  113840. _removePendingData(data: any): void;
  113841. offlineProvider: IOfflineProvider;
  113842. }
  113843. /** Interface defining initialization parameters for Engine class */
  113844. export interface EngineOptions extends WebGLContextAttributes {
  113845. /**
  113846. * Defines if the engine should no exceed a specified device ratio
  113847. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  113848. */
  113849. limitDeviceRatio?: number;
  113850. /**
  113851. * Defines if webvr should be enabled automatically
  113852. * @see https://doc.babylonjs.com/how_to/webvr_camera
  113853. */
  113854. autoEnableWebVR?: boolean;
  113855. /**
  113856. * Defines if webgl2 should be turned off even if supported
  113857. * @see https://doc.babylonjs.com/features/webgl2
  113858. */
  113859. disableWebGL2Support?: boolean;
  113860. /**
  113861. * Defines if webaudio should be initialized as well
  113862. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113863. */
  113864. audioEngine?: boolean;
  113865. /**
  113866. * Defines if animations should run using a deterministic lock step
  113867. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113868. */
  113869. deterministicLockstep?: boolean;
  113870. /** Defines the maximum steps to use with deterministic lock step mode */
  113871. lockstepMaxSteps?: number;
  113872. /** Defines the seconds between each deterministic lock step */
  113873. timeStep?: number;
  113874. /**
  113875. * Defines that engine should ignore context lost events
  113876. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  113877. */
  113878. doNotHandleContextLost?: boolean;
  113879. /**
  113880. * Defines that engine should ignore modifying touch action attribute and style
  113881. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  113882. */
  113883. doNotHandleTouchAction?: boolean;
  113884. /**
  113885. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  113886. */
  113887. useHighPrecisionFloats?: boolean;
  113888. /**
  113889. * Make the canvas XR Compatible for XR sessions
  113890. */
  113891. xrCompatible?: boolean;
  113892. /**
  113893. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  113894. */
  113895. useHighPrecisionMatrix?: boolean;
  113896. }
  113897. /**
  113898. * The base engine class (root of all engines)
  113899. */
  113900. export class ThinEngine {
  113901. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  113902. static ExceptionList: ({
  113903. key: string;
  113904. capture: string;
  113905. captureConstraint: number;
  113906. targets: string[];
  113907. } | {
  113908. key: string;
  113909. capture: null;
  113910. captureConstraint: null;
  113911. targets: string[];
  113912. })[];
  113913. /** @hidden */
  113914. static _TextureLoaders: IInternalTextureLoader[];
  113915. /**
  113916. * Returns the current npm package of the sdk
  113917. */
  113918. static get NpmPackage(): string;
  113919. /**
  113920. * Returns the current version of the framework
  113921. */
  113922. static get Version(): string;
  113923. /**
  113924. * Returns a string describing the current engine
  113925. */
  113926. get description(): string;
  113927. /**
  113928. * Gets or sets the epsilon value used by collision engine
  113929. */
  113930. static CollisionsEpsilon: number;
  113931. /**
  113932. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113933. */
  113934. static get ShadersRepository(): string;
  113935. static set ShadersRepository(value: string);
  113936. /** @hidden */
  113937. _shaderProcessor: IShaderProcessor;
  113938. /**
  113939. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  113940. */
  113941. forcePOTTextures: boolean;
  113942. /**
  113943. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  113944. */
  113945. isFullscreen: boolean;
  113946. /**
  113947. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  113948. */
  113949. cullBackFaces: boolean;
  113950. /**
  113951. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  113952. */
  113953. renderEvenInBackground: boolean;
  113954. /**
  113955. * Gets or sets a boolean indicating that cache can be kept between frames
  113956. */
  113957. preventCacheWipeBetweenFrames: boolean;
  113958. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  113959. validateShaderPrograms: boolean;
  113960. /**
  113961. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  113962. * This can provide greater z depth for distant objects.
  113963. */
  113964. useReverseDepthBuffer: boolean;
  113965. /**
  113966. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  113967. */
  113968. disableUniformBuffers: boolean;
  113969. /** @hidden */
  113970. _uniformBuffers: UniformBuffer[];
  113971. /**
  113972. * Gets a boolean indicating that the engine supports uniform buffers
  113973. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  113974. */
  113975. get supportsUniformBuffers(): boolean;
  113976. /** @hidden */
  113977. _gl: WebGLRenderingContext;
  113978. /** @hidden */
  113979. _webGLVersion: number;
  113980. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  113981. protected _windowIsBackground: boolean;
  113982. protected _creationOptions: EngineOptions;
  113983. protected _highPrecisionShadersAllowed: boolean;
  113984. /** @hidden */
  113985. get _shouldUseHighPrecisionShader(): boolean;
  113986. /**
  113987. * Gets a boolean indicating that only power of 2 textures are supported
  113988. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  113989. */
  113990. get needPOTTextures(): boolean;
  113991. /** @hidden */
  113992. _badOS: boolean;
  113993. /** @hidden */
  113994. _badDesktopOS: boolean;
  113995. private _hardwareScalingLevel;
  113996. /** @hidden */
  113997. _caps: EngineCapabilities;
  113998. private _isStencilEnable;
  113999. private _glVersion;
  114000. private _glRenderer;
  114001. private _glVendor;
  114002. /** @hidden */
  114003. _videoTextureSupported: boolean;
  114004. protected _renderingQueueLaunched: boolean;
  114005. protected _activeRenderLoops: (() => void)[];
  114006. /**
  114007. * Observable signaled when a context lost event is raised
  114008. */
  114009. onContextLostObservable: Observable<ThinEngine>;
  114010. /**
  114011. * Observable signaled when a context restored event is raised
  114012. */
  114013. onContextRestoredObservable: Observable<ThinEngine>;
  114014. private _onContextLost;
  114015. private _onContextRestored;
  114016. protected _contextWasLost: boolean;
  114017. /** @hidden */
  114018. _doNotHandleContextLost: boolean;
  114019. /**
  114020. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114021. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114022. */
  114023. get doNotHandleContextLost(): boolean;
  114024. set doNotHandleContextLost(value: boolean);
  114025. /**
  114026. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114027. */
  114028. disableVertexArrayObjects: boolean;
  114029. /** @hidden */
  114030. protected _colorWrite: boolean;
  114031. /** @hidden */
  114032. protected _colorWriteChanged: boolean;
  114033. /** @hidden */
  114034. protected _depthCullingState: DepthCullingState;
  114035. /** @hidden */
  114036. protected _stencilState: StencilState;
  114037. /** @hidden */
  114038. _alphaState: AlphaState;
  114039. /** @hidden */
  114040. _alphaMode: number;
  114041. /** @hidden */
  114042. _alphaEquation: number;
  114043. /** @hidden */
  114044. _internalTexturesCache: InternalTexture[];
  114045. /** @hidden */
  114046. protected _activeChannel: number;
  114047. private _currentTextureChannel;
  114048. /** @hidden */
  114049. protected _boundTexturesCache: {
  114050. [key: string]: Nullable<InternalTexture>;
  114051. };
  114052. /** @hidden */
  114053. protected _currentEffect: Nullable<Effect>;
  114054. /** @hidden */
  114055. protected _currentProgram: Nullable<WebGLProgram>;
  114056. private _compiledEffects;
  114057. private _vertexAttribArraysEnabled;
  114058. /** @hidden */
  114059. protected _cachedViewport: Nullable<IViewportLike>;
  114060. private _cachedVertexArrayObject;
  114061. /** @hidden */
  114062. protected _cachedVertexBuffers: any;
  114063. /** @hidden */
  114064. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  114065. /** @hidden */
  114066. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  114067. /** @hidden */
  114068. _currentRenderTarget: Nullable<InternalTexture>;
  114069. private _uintIndicesCurrentlySet;
  114070. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  114071. /** @hidden */
  114072. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  114073. /** @hidden */
  114074. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  114075. private _currentBufferPointers;
  114076. private _currentInstanceLocations;
  114077. private _currentInstanceBuffers;
  114078. private _textureUnits;
  114079. /** @hidden */
  114080. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114081. /** @hidden */
  114082. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114083. /** @hidden */
  114084. _boundRenderFunction: any;
  114085. private _vaoRecordInProgress;
  114086. private _mustWipeVertexAttributes;
  114087. private _emptyTexture;
  114088. private _emptyCubeTexture;
  114089. private _emptyTexture3D;
  114090. private _emptyTexture2DArray;
  114091. /** @hidden */
  114092. _frameHandler: number;
  114093. private _nextFreeTextureSlots;
  114094. private _maxSimultaneousTextures;
  114095. private _activeRequests;
  114096. /** @hidden */
  114097. _transformTextureUrl: Nullable<(url: string) => string>;
  114098. protected get _supportsHardwareTextureRescaling(): boolean;
  114099. private _framebufferDimensionsObject;
  114100. /**
  114101. * sets the object from which width and height will be taken from when getting render width and height
  114102. * Will fallback to the gl object
  114103. * @param dimensions the framebuffer width and height that will be used.
  114104. */
  114105. set framebufferDimensionsObject(dimensions: Nullable<{
  114106. framebufferWidth: number;
  114107. framebufferHeight: number;
  114108. }>);
  114109. /**
  114110. * Gets the current viewport
  114111. */
  114112. get currentViewport(): Nullable<IViewportLike>;
  114113. /**
  114114. * Gets the default empty texture
  114115. */
  114116. get emptyTexture(): InternalTexture;
  114117. /**
  114118. * Gets the default empty 3D texture
  114119. */
  114120. get emptyTexture3D(): InternalTexture;
  114121. /**
  114122. * Gets the default empty 2D array texture
  114123. */
  114124. get emptyTexture2DArray(): InternalTexture;
  114125. /**
  114126. * Gets the default empty cube texture
  114127. */
  114128. get emptyCubeTexture(): InternalTexture;
  114129. /**
  114130. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  114131. */
  114132. readonly premultipliedAlpha: boolean;
  114133. /**
  114134. * Observable event triggered before each texture is initialized
  114135. */
  114136. onBeforeTextureInitObservable: Observable<Texture>;
  114137. /**
  114138. * Creates a new engine
  114139. * @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
  114140. * @param antialias defines enable antialiasing (default: false)
  114141. * @param options defines further options to be sent to the getContext() function
  114142. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114143. */
  114144. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114145. private _rebuildInternalTextures;
  114146. private _rebuildEffects;
  114147. /**
  114148. * Gets a boolean indicating if all created effects are ready
  114149. * @returns true if all effects are ready
  114150. */
  114151. areAllEffectsReady(): boolean;
  114152. protected _rebuildBuffers(): void;
  114153. protected _initGLContext(): void;
  114154. /**
  114155. * Gets version of the current webGL context
  114156. */
  114157. get webGLVersion(): number;
  114158. /**
  114159. * Gets a string idenfifying the name of the class
  114160. * @returns "Engine" string
  114161. */
  114162. getClassName(): string;
  114163. /**
  114164. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  114165. */
  114166. get isStencilEnable(): boolean;
  114167. /** @hidden */
  114168. _prepareWorkingCanvas(): void;
  114169. /**
  114170. * Reset the texture cache to empty state
  114171. */
  114172. resetTextureCache(): void;
  114173. /**
  114174. * Gets an object containing information about the current webGL context
  114175. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114176. */
  114177. getGlInfo(): {
  114178. vendor: string;
  114179. renderer: string;
  114180. version: string;
  114181. };
  114182. /**
  114183. * Defines the hardware scaling level.
  114184. * By default the hardware scaling level is computed from the window device ratio.
  114185. * 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.
  114186. * @param level defines the level to use
  114187. */
  114188. setHardwareScalingLevel(level: number): void;
  114189. /**
  114190. * Gets the current hardware scaling level.
  114191. * By default the hardware scaling level is computed from the window device ratio.
  114192. * 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.
  114193. * @returns a number indicating the current hardware scaling level
  114194. */
  114195. getHardwareScalingLevel(): number;
  114196. /**
  114197. * Gets the list of loaded textures
  114198. * @returns an array containing all loaded textures
  114199. */
  114200. getLoadedTexturesCache(): InternalTexture[];
  114201. /**
  114202. * Gets the object containing all engine capabilities
  114203. * @returns the EngineCapabilities object
  114204. */
  114205. getCaps(): EngineCapabilities;
  114206. /**
  114207. * stop executing a render loop function and remove it from the execution array
  114208. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114209. */
  114210. stopRenderLoop(renderFunction?: () => void): void;
  114211. /** @hidden */
  114212. _renderLoop(): void;
  114213. /**
  114214. * Gets the HTML canvas attached with the current webGL context
  114215. * @returns a HTML canvas
  114216. */
  114217. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114218. /**
  114219. * Gets host window
  114220. * @returns the host window object
  114221. */
  114222. getHostWindow(): Nullable<Window>;
  114223. /**
  114224. * Gets the current render width
  114225. * @param useScreen defines if screen size must be used (or the current render target if any)
  114226. * @returns a number defining the current render width
  114227. */
  114228. getRenderWidth(useScreen?: boolean): number;
  114229. /**
  114230. * Gets the current render height
  114231. * @param useScreen defines if screen size must be used (or the current render target if any)
  114232. * @returns a number defining the current render height
  114233. */
  114234. getRenderHeight(useScreen?: boolean): number;
  114235. /**
  114236. * Can be used to override the current requestAnimationFrame requester.
  114237. * @hidden
  114238. */
  114239. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114240. /**
  114241. * Register and execute a render loop. The engine can have more than one render function
  114242. * @param renderFunction defines the function to continuously execute
  114243. */
  114244. runRenderLoop(renderFunction: () => void): void;
  114245. /**
  114246. * Clear the current render buffer or the current render target (if any is set up)
  114247. * @param color defines the color to use
  114248. * @param backBuffer defines if the back buffer must be cleared
  114249. * @param depth defines if the depth buffer must be cleared
  114250. * @param stencil defines if the stencil buffer must be cleared
  114251. */
  114252. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114253. private _viewportCached;
  114254. /** @hidden */
  114255. _viewport(x: number, y: number, width: number, height: number): void;
  114256. /**
  114257. * Set the WebGL's viewport
  114258. * @param viewport defines the viewport element to be used
  114259. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114260. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114261. */
  114262. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114263. /**
  114264. * Begin a new frame
  114265. */
  114266. beginFrame(): void;
  114267. /**
  114268. * Enf the current frame
  114269. */
  114270. endFrame(): void;
  114271. /**
  114272. * Resize the view according to the canvas' size
  114273. */
  114274. resize(): void;
  114275. /**
  114276. * Force a specific size of the canvas
  114277. * @param width defines the new canvas' width
  114278. * @param height defines the new canvas' height
  114279. * @returns true if the size was changed
  114280. */
  114281. setSize(width: number, height: number): boolean;
  114282. /**
  114283. * Binds the frame buffer to the specified texture.
  114284. * @param texture The texture to render to or null for the default canvas
  114285. * @param faceIndex The face of the texture to render to in case of cube texture
  114286. * @param requiredWidth The width of the target to render to
  114287. * @param requiredHeight The height of the target to render to
  114288. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114289. * @param lodLevel defines the lod level to bind to the frame buffer
  114290. * @param layer defines the 2d array index to bind to frame buffer to
  114291. */
  114292. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114293. /** @hidden */
  114294. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114295. /**
  114296. * Unbind the current render target texture from the webGL context
  114297. * @param texture defines the render target texture to unbind
  114298. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114299. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114300. */
  114301. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114302. /**
  114303. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114304. */
  114305. flushFramebuffer(): void;
  114306. /**
  114307. * Unbind the current render target and bind the default framebuffer
  114308. */
  114309. restoreDefaultFramebuffer(): void;
  114310. /** @hidden */
  114311. protected _resetVertexBufferBinding(): void;
  114312. /**
  114313. * Creates a vertex buffer
  114314. * @param data the data for the vertex buffer
  114315. * @returns the new WebGL static buffer
  114316. */
  114317. createVertexBuffer(data: DataArray): DataBuffer;
  114318. private _createVertexBuffer;
  114319. /**
  114320. * Creates a dynamic vertex buffer
  114321. * @param data the data for the dynamic vertex buffer
  114322. * @returns the new WebGL dynamic buffer
  114323. */
  114324. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114325. protected _resetIndexBufferBinding(): void;
  114326. /**
  114327. * Creates a new index buffer
  114328. * @param indices defines the content of the index buffer
  114329. * @param updatable defines if the index buffer must be updatable
  114330. * @returns a new webGL buffer
  114331. */
  114332. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114333. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114334. /**
  114335. * Bind a webGL buffer to the webGL context
  114336. * @param buffer defines the buffer to bind
  114337. */
  114338. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114339. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114340. private bindBuffer;
  114341. /**
  114342. * update the bound buffer with the given data
  114343. * @param data defines the data to update
  114344. */
  114345. updateArrayBuffer(data: Float32Array): void;
  114346. private _vertexAttribPointer;
  114347. /** @hidden */
  114348. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114349. private _bindVertexBuffersAttributes;
  114350. /**
  114351. * Records a vertex array object
  114352. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114353. * @param vertexBuffers defines the list of vertex buffers to store
  114354. * @param indexBuffer defines the index buffer to store
  114355. * @param effect defines the effect to store
  114356. * @returns the new vertex array object
  114357. */
  114358. recordVertexArrayObject(vertexBuffers: {
  114359. [key: string]: VertexBuffer;
  114360. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114361. /**
  114362. * Bind a specific vertex array object
  114363. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114364. * @param vertexArrayObject defines the vertex array object to bind
  114365. * @param indexBuffer defines the index buffer to bind
  114366. */
  114367. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114368. /**
  114369. * Bind webGl buffers directly to the webGL context
  114370. * @param vertexBuffer defines the vertex buffer to bind
  114371. * @param indexBuffer defines the index buffer to bind
  114372. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114373. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114374. * @param effect defines the effect associated with the vertex buffer
  114375. */
  114376. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114377. private _unbindVertexArrayObject;
  114378. /**
  114379. * Bind a list of vertex buffers to the webGL context
  114380. * @param vertexBuffers defines the list of vertex buffers to bind
  114381. * @param indexBuffer defines the index buffer to bind
  114382. * @param effect defines the effect associated with the vertex buffers
  114383. */
  114384. bindBuffers(vertexBuffers: {
  114385. [key: string]: Nullable<VertexBuffer>;
  114386. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114387. /**
  114388. * Unbind all instance attributes
  114389. */
  114390. unbindInstanceAttributes(): void;
  114391. /**
  114392. * Release and free the memory of a vertex array object
  114393. * @param vao defines the vertex array object to delete
  114394. */
  114395. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114396. /** @hidden */
  114397. _releaseBuffer(buffer: DataBuffer): boolean;
  114398. protected _deleteBuffer(buffer: DataBuffer): void;
  114399. /**
  114400. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114401. * @param instancesBuffer defines the webGL buffer to update and bind
  114402. * @param data defines the data to store in the buffer
  114403. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114404. */
  114405. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114406. /**
  114407. * Bind the content of a webGL buffer used with instantiation
  114408. * @param instancesBuffer defines the webGL buffer to bind
  114409. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114410. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114411. */
  114412. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114413. /**
  114414. * Disable the instance attribute corresponding to the name in parameter
  114415. * @param name defines the name of the attribute to disable
  114416. */
  114417. disableInstanceAttributeByName(name: string): void;
  114418. /**
  114419. * Disable the instance attribute corresponding to the location in parameter
  114420. * @param attributeLocation defines the attribute location of the attribute to disable
  114421. */
  114422. disableInstanceAttribute(attributeLocation: number): void;
  114423. /**
  114424. * Disable the attribute corresponding to the location in parameter
  114425. * @param attributeLocation defines the attribute location of the attribute to disable
  114426. */
  114427. disableAttributeByIndex(attributeLocation: number): void;
  114428. /**
  114429. * Send a draw order
  114430. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114431. * @param indexStart defines the starting index
  114432. * @param indexCount defines the number of index to draw
  114433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114434. */
  114435. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114436. /**
  114437. * Draw a list of points
  114438. * @param verticesStart defines the index of first vertex to draw
  114439. * @param verticesCount defines the count of vertices to draw
  114440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114441. */
  114442. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114443. /**
  114444. * Draw a list of unindexed primitives
  114445. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114446. * @param verticesStart defines the index of first vertex to draw
  114447. * @param verticesCount defines the count of vertices to draw
  114448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114449. */
  114450. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114451. /**
  114452. * Draw a list of indexed primitives
  114453. * @param fillMode defines the primitive to use
  114454. * @param indexStart defines the starting index
  114455. * @param indexCount defines the number of index to draw
  114456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114457. */
  114458. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114459. /**
  114460. * Draw a list of unindexed primitives
  114461. * @param fillMode defines the primitive to use
  114462. * @param verticesStart defines the index of first vertex to draw
  114463. * @param verticesCount defines the count of vertices to draw
  114464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114465. */
  114466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114467. private _drawMode;
  114468. /** @hidden */
  114469. protected _reportDrawCall(): void;
  114470. /** @hidden */
  114471. _releaseEffect(effect: Effect): void;
  114472. /** @hidden */
  114473. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114474. /**
  114475. * Create a new effect (used to store vertex/fragment shaders)
  114476. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  114477. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  114478. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  114479. * @param samplers defines an array of string used to represent textures
  114480. * @param defines defines the string containing the defines to use to compile the shaders
  114481. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  114482. * @param onCompiled defines a function to call when the effect creation is successful
  114483. * @param onError defines a function to call when the effect creation has failed
  114484. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  114485. * @returns the new Effect
  114486. */
  114487. 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;
  114488. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  114489. private _compileShader;
  114490. private _compileRawShader;
  114491. /** @hidden */
  114492. _getShaderSource(shader: WebGLShader): Nullable<string>;
  114493. /**
  114494. * Directly creates a webGL program
  114495. * @param pipelineContext defines the pipeline context to attach to
  114496. * @param vertexCode defines the vertex shader code to use
  114497. * @param fragmentCode defines the fragment shader code to use
  114498. * @param context defines the webGL context to use (if not set, the current one will be used)
  114499. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114500. * @returns the new webGL program
  114501. */
  114502. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114503. /**
  114504. * Creates a webGL program
  114505. * @param pipelineContext defines the pipeline context to attach to
  114506. * @param vertexCode defines the vertex shader code to use
  114507. * @param fragmentCode defines the fragment shader code to use
  114508. * @param defines defines the string containing the defines to use to compile the shaders
  114509. * @param context defines the webGL context to use (if not set, the current one will be used)
  114510. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114511. * @returns the new webGL program
  114512. */
  114513. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114514. /**
  114515. * Creates a new pipeline context
  114516. * @returns the new pipeline
  114517. */
  114518. createPipelineContext(): IPipelineContext;
  114519. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114520. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  114521. /** @hidden */
  114522. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114523. /** @hidden */
  114524. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114525. /** @hidden */
  114526. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114527. /**
  114528. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114529. * @param pipelineContext defines the pipeline context to use
  114530. * @param uniformsNames defines the list of uniform names
  114531. * @returns an array of webGL uniform locations
  114532. */
  114533. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114534. /**
  114535. * Gets the lsit of active attributes for a given webGL program
  114536. * @param pipelineContext defines the pipeline context to use
  114537. * @param attributesNames defines the list of attribute names to get
  114538. * @returns an array of indices indicating the offset of each attribute
  114539. */
  114540. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114541. /**
  114542. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114543. * @param effect defines the effect to activate
  114544. */
  114545. enableEffect(effect: Nullable<Effect>): void;
  114546. /**
  114547. * Set the value of an uniform to a number (int)
  114548. * @param uniform defines the webGL uniform location where to store the value
  114549. * @param value defines the int number to store
  114550. */
  114551. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114552. /**
  114553. * Set the value of an uniform to an array of int32
  114554. * @param uniform defines the webGL uniform location where to store the value
  114555. * @param array defines the array of int32 to store
  114556. */
  114557. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114558. /**
  114559. * Set the value of an uniform to an array of int32 (stored as vec2)
  114560. * @param uniform defines the webGL uniform location where to store the value
  114561. * @param array defines the array of int32 to store
  114562. */
  114563. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114564. /**
  114565. * Set the value of an uniform to an array of int32 (stored as vec3)
  114566. * @param uniform defines the webGL uniform location where to store the value
  114567. * @param array defines the array of int32 to store
  114568. */
  114569. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114570. /**
  114571. * Set the value of an uniform to an array of int32 (stored as vec4)
  114572. * @param uniform defines the webGL uniform location where to store the value
  114573. * @param array defines the array of int32 to store
  114574. */
  114575. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114576. /**
  114577. * Set the value of an uniform to an array of number
  114578. * @param uniform defines the webGL uniform location where to store the value
  114579. * @param array defines the array of number to store
  114580. */
  114581. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114582. /**
  114583. * Set the value of an uniform to an array of number (stored as vec2)
  114584. * @param uniform defines the webGL uniform location where to store the value
  114585. * @param array defines the array of number to store
  114586. */
  114587. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114588. /**
  114589. * Set the value of an uniform to an array of number (stored as vec3)
  114590. * @param uniform defines the webGL uniform location where to store the value
  114591. * @param array defines the array of number to store
  114592. */
  114593. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114594. /**
  114595. * Set the value of an uniform to an array of number (stored as vec4)
  114596. * @param uniform defines the webGL uniform location where to store the value
  114597. * @param array defines the array of number to store
  114598. */
  114599. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114600. /**
  114601. * Set the value of an uniform to an array of float32 (stored as matrices)
  114602. * @param uniform defines the webGL uniform location where to store the value
  114603. * @param matrices defines the array of float32 to store
  114604. */
  114605. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  114606. /**
  114607. * Set the value of an uniform to a matrix (3x3)
  114608. * @param uniform defines the webGL uniform location where to store the value
  114609. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114610. */
  114611. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114612. /**
  114613. * Set the value of an uniform to a matrix (2x2)
  114614. * @param uniform defines the webGL uniform location where to store the value
  114615. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114616. */
  114617. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114618. /**
  114619. * Set the value of an uniform to a number (float)
  114620. * @param uniform defines the webGL uniform location where to store the value
  114621. * @param value defines the float number to store
  114622. */
  114623. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114624. /**
  114625. * Set the value of an uniform to a vec2
  114626. * @param uniform defines the webGL uniform location where to store the value
  114627. * @param x defines the 1st component of the value
  114628. * @param y defines the 2nd component of the value
  114629. */
  114630. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  114631. /**
  114632. * Set the value of an uniform to a vec3
  114633. * @param uniform defines the webGL uniform location where to store the value
  114634. * @param x defines the 1st component of the value
  114635. * @param y defines the 2nd component of the value
  114636. * @param z defines the 3rd component of the value
  114637. */
  114638. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  114639. /**
  114640. * Set the value of an uniform to a vec4
  114641. * @param uniform defines the webGL uniform location where to store the value
  114642. * @param x defines the 1st component of the value
  114643. * @param y defines the 2nd component of the value
  114644. * @param z defines the 3rd component of the value
  114645. * @param w defines the 4th component of the value
  114646. */
  114647. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  114648. /**
  114649. * Apply all cached states (depth, culling, stencil and alpha)
  114650. */
  114651. applyStates(): void;
  114652. /**
  114653. * Enable or disable color writing
  114654. * @param enable defines the state to set
  114655. */
  114656. setColorWrite(enable: boolean): void;
  114657. /**
  114658. * Gets a boolean indicating if color writing is enabled
  114659. * @returns the current color writing state
  114660. */
  114661. getColorWrite(): boolean;
  114662. /**
  114663. * Gets the depth culling state manager
  114664. */
  114665. get depthCullingState(): DepthCullingState;
  114666. /**
  114667. * Gets the alpha state manager
  114668. */
  114669. get alphaState(): AlphaState;
  114670. /**
  114671. * Gets the stencil state manager
  114672. */
  114673. get stencilState(): StencilState;
  114674. /**
  114675. * Clears the list of texture accessible through engine.
  114676. * This can help preventing texture load conflict due to name collision.
  114677. */
  114678. clearInternalTexturesCache(): void;
  114679. /**
  114680. * Force the entire cache to be cleared
  114681. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114682. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114683. */
  114684. wipeCaches(bruteForce?: boolean): void;
  114685. /** @hidden */
  114686. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  114687. min: number;
  114688. mag: number;
  114689. };
  114690. /** @hidden */
  114691. _createTexture(): WebGLTexture;
  114692. /**
  114693. * Usually called from Texture.ts.
  114694. * Passed information to create a WebGLTexture
  114695. * @param url defines a value which contains one of the following:
  114696. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114697. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114698. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114700. * @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)
  114701. * @param scene needed for loading to the correct scene
  114702. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114703. * @param onLoad optional callback to be called upon successful completion
  114704. * @param onError optional callback to be called upon failure
  114705. * @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
  114706. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114707. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114708. * @param forcedExtension defines the extension to use to pick the right loader
  114709. * @param mimeType defines an optional mime type
  114710. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114711. */
  114712. 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;
  114713. /**
  114714. * Loads an image as an HTMLImageElement.
  114715. * @param input url string, ArrayBuffer, or Blob to load
  114716. * @param onLoad callback called when the image successfully loads
  114717. * @param onError callback called when the image fails to load
  114718. * @param offlineProvider offline provider for caching
  114719. * @param mimeType optional mime type
  114720. * @returns the HTMLImageElement of the loaded image
  114721. * @hidden
  114722. */
  114723. 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>;
  114724. /**
  114725. * @hidden
  114726. */
  114727. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114728. private _unpackFlipYCached;
  114729. /**
  114730. * In case you are sharing the context with other applications, it might
  114731. * be interested to not cache the unpack flip y state to ensure a consistent
  114732. * value would be set.
  114733. */
  114734. enableUnpackFlipYCached: boolean;
  114735. /** @hidden */
  114736. _unpackFlipY(value: boolean): void;
  114737. /** @hidden */
  114738. _getUnpackAlignement(): number;
  114739. private _getTextureTarget;
  114740. /**
  114741. * Update the sampling mode of a given texture
  114742. * @param samplingMode defines the required sampling mode
  114743. * @param texture defines the texture to update
  114744. * @param generateMipMaps defines whether to generate mipmaps for the texture
  114745. */
  114746. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  114747. /**
  114748. * Update the sampling mode of a given texture
  114749. * @param texture defines the texture to update
  114750. * @param wrapU defines the texture wrap mode of the u coordinates
  114751. * @param wrapV defines the texture wrap mode of the v coordinates
  114752. * @param wrapR defines the texture wrap mode of the r coordinates
  114753. */
  114754. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  114755. /** @hidden */
  114756. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  114757. width: number;
  114758. height: number;
  114759. layers?: number;
  114760. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  114761. /** @hidden */
  114762. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114763. /** @hidden */
  114764. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  114765. /**
  114766. * Update a portion of an internal texture
  114767. * @param texture defines the texture to update
  114768. * @param imageData defines the data to store into the texture
  114769. * @param xOffset defines the x coordinates of the update rectangle
  114770. * @param yOffset defines the y coordinates of the update rectangle
  114771. * @param width defines the width of the update rectangle
  114772. * @param height defines the height of the update rectangle
  114773. * @param faceIndex defines the face index if texture is a cube (0 by default)
  114774. * @param lod defines the lod level to update (0 by default)
  114775. */
  114776. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  114777. /** @hidden */
  114778. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114779. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  114780. private _prepareWebGLTexture;
  114781. /** @hidden */
  114782. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  114783. private _getDepthStencilBuffer;
  114784. /** @hidden */
  114785. _releaseFramebufferObjects(texture: InternalTexture): void;
  114786. /** @hidden */
  114787. _releaseTexture(texture: InternalTexture): void;
  114788. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114789. protected _setProgram(program: WebGLProgram): void;
  114790. protected _boundUniforms: {
  114791. [key: number]: WebGLUniformLocation;
  114792. };
  114793. /**
  114794. * Binds an effect to the webGL context
  114795. * @param effect defines the effect to bind
  114796. */
  114797. bindSamplers(effect: Effect): void;
  114798. private _activateCurrentTexture;
  114799. /** @hidden */
  114800. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  114801. /** @hidden */
  114802. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  114803. /**
  114804. * Unbind all textures from the webGL context
  114805. */
  114806. unbindAllTextures(): void;
  114807. /**
  114808. * Sets a texture to the according uniform.
  114809. * @param channel The texture channel
  114810. * @param uniform The uniform to set
  114811. * @param texture The texture to apply
  114812. */
  114813. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  114814. private _bindSamplerUniformToChannel;
  114815. private _getTextureWrapMode;
  114816. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114817. /**
  114818. * Sets an array of texture to the webGL context
  114819. * @param channel defines the channel where the texture array must be set
  114820. * @param uniform defines the associated uniform location
  114821. * @param textures defines the array of textures to bind
  114822. */
  114823. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  114824. /** @hidden */
  114825. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  114826. private _setTextureParameterFloat;
  114827. private _setTextureParameterInteger;
  114828. /**
  114829. * Unbind all vertex attributes from the webGL context
  114830. */
  114831. unbindAllAttributes(): void;
  114832. /**
  114833. * 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
  114834. */
  114835. releaseEffects(): void;
  114836. /**
  114837. * Dispose and release all associated resources
  114838. */
  114839. dispose(): void;
  114840. /**
  114841. * Attach a new callback raised when context lost event is fired
  114842. * @param callback defines the callback to call
  114843. */
  114844. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114845. /**
  114846. * Attach a new callback raised when context restored event is fired
  114847. * @param callback defines the callback to call
  114848. */
  114849. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114850. /**
  114851. * Get the current error code of the webGL context
  114852. * @returns the error code
  114853. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114854. */
  114855. getError(): number;
  114856. private _canRenderToFloatFramebuffer;
  114857. private _canRenderToHalfFloatFramebuffer;
  114858. private _canRenderToFramebuffer;
  114859. /** @hidden */
  114860. _getWebGLTextureType(type: number): number;
  114861. /** @hidden */
  114862. _getInternalFormat(format: number): number;
  114863. /** @hidden */
  114864. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  114865. /** @hidden */
  114866. _getRGBAMultiSampleBufferFormat(type: number): number;
  114867. /** @hidden */
  114868. _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;
  114869. /**
  114870. * Loads a file from a url
  114871. * @param url url to load
  114872. * @param onSuccess callback called when the file successfully loads
  114873. * @param onProgress callback called while file is loading (if the server supports this mode)
  114874. * @param offlineProvider defines the offline provider for caching
  114875. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114876. * @param onError callback called when the file fails to load
  114877. * @returns a file request object
  114878. * @hidden
  114879. */
  114880. 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;
  114881. /**
  114882. * Reads pixels from the current frame buffer. Please note that this function can be slow
  114883. * @param x defines the x coordinate of the rectangle where pixels must be read
  114884. * @param y defines the y coordinate of the rectangle where pixels must be read
  114885. * @param width defines the width of the rectangle where pixels must be read
  114886. * @param height defines the height of the rectangle where pixels must be read
  114887. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  114888. * @returns a Uint8Array containing RGBA colors
  114889. */
  114890. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  114891. private static _isSupported;
  114892. /**
  114893. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  114894. * @returns true if the engine can be created
  114895. * @ignorenaming
  114896. */
  114897. static isSupported(): boolean;
  114898. /**
  114899. * Find the next highest power of two.
  114900. * @param x Number to start search from.
  114901. * @return Next highest power of two.
  114902. */
  114903. static CeilingPOT(x: number): number;
  114904. /**
  114905. * Find the next lowest power of two.
  114906. * @param x Number to start search from.
  114907. * @return Next lowest power of two.
  114908. */
  114909. static FloorPOT(x: number): number;
  114910. /**
  114911. * Find the nearest power of two.
  114912. * @param x Number to start search from.
  114913. * @return Next nearest power of two.
  114914. */
  114915. static NearestPOT(x: number): number;
  114916. /**
  114917. * Get the closest exponent of two
  114918. * @param value defines the value to approximate
  114919. * @param max defines the maximum value to return
  114920. * @param mode defines how to define the closest value
  114921. * @returns closest exponent of two of the given value
  114922. */
  114923. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  114924. /**
  114925. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  114926. * @param func - the function to be called
  114927. * @param requester - the object that will request the next frame. Falls back to window.
  114928. * @returns frame number
  114929. */
  114930. static QueueNewFrame(func: () => void, requester?: any): number;
  114931. /**
  114932. * Gets host document
  114933. * @returns the host document object
  114934. */
  114935. getHostDocument(): Nullable<Document>;
  114936. }
  114937. }
  114938. declare module BABYLON {
  114939. /**
  114940. * Class representing spherical harmonics coefficients to the 3rd degree
  114941. */
  114942. export class SphericalHarmonics {
  114943. /**
  114944. * Defines whether or not the harmonics have been prescaled for rendering.
  114945. */
  114946. preScaled: boolean;
  114947. /**
  114948. * The l0,0 coefficients of the spherical harmonics
  114949. */
  114950. l00: Vector3;
  114951. /**
  114952. * The l1,-1 coefficients of the spherical harmonics
  114953. */
  114954. l1_1: Vector3;
  114955. /**
  114956. * The l1,0 coefficients of the spherical harmonics
  114957. */
  114958. l10: Vector3;
  114959. /**
  114960. * The l1,1 coefficients of the spherical harmonics
  114961. */
  114962. l11: Vector3;
  114963. /**
  114964. * The l2,-2 coefficients of the spherical harmonics
  114965. */
  114966. l2_2: Vector3;
  114967. /**
  114968. * The l2,-1 coefficients of the spherical harmonics
  114969. */
  114970. l2_1: Vector3;
  114971. /**
  114972. * The l2,0 coefficients of the spherical harmonics
  114973. */
  114974. l20: Vector3;
  114975. /**
  114976. * The l2,1 coefficients of the spherical harmonics
  114977. */
  114978. l21: Vector3;
  114979. /**
  114980. * The l2,2 coefficients of the spherical harmonics
  114981. */
  114982. l22: Vector3;
  114983. /**
  114984. * Adds a light to the spherical harmonics
  114985. * @param direction the direction of the light
  114986. * @param color the color of the light
  114987. * @param deltaSolidAngle the delta solid angle of the light
  114988. */
  114989. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  114990. /**
  114991. * Scales the spherical harmonics by the given amount
  114992. * @param scale the amount to scale
  114993. */
  114994. scaleInPlace(scale: number): void;
  114995. /**
  114996. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  114997. *
  114998. * ```
  114999. * E_lm = A_l * L_lm
  115000. * ```
  115001. *
  115002. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115003. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115004. * the scaling factors are given in equation 9.
  115005. */
  115006. convertIncidentRadianceToIrradiance(): void;
  115007. /**
  115008. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115009. *
  115010. * ```
  115011. * L = (1/pi) * E * rho
  115012. * ```
  115013. *
  115014. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115015. */
  115016. convertIrradianceToLambertianRadiance(): void;
  115017. /**
  115018. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115019. * required operations at run time.
  115020. *
  115021. * This is simply done by scaling back the SH with Ylm constants parameter.
  115022. * The trigonometric part being applied by the shader at run time.
  115023. */
  115024. preScaleForRendering(): void;
  115025. /**
  115026. * Constructs a spherical harmonics from an array.
  115027. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115028. * @returns the spherical harmonics
  115029. */
  115030. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115031. /**
  115032. * Gets the spherical harmonics from polynomial
  115033. * @param polynomial the spherical polynomial
  115034. * @returns the spherical harmonics
  115035. */
  115036. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115037. }
  115038. /**
  115039. * Class representing spherical polynomial coefficients to the 3rd degree
  115040. */
  115041. export class SphericalPolynomial {
  115042. private _harmonics;
  115043. /**
  115044. * The spherical harmonics used to create the polynomials.
  115045. */
  115046. get preScaledHarmonics(): SphericalHarmonics;
  115047. /**
  115048. * The x coefficients of the spherical polynomial
  115049. */
  115050. x: Vector3;
  115051. /**
  115052. * The y coefficients of the spherical polynomial
  115053. */
  115054. y: Vector3;
  115055. /**
  115056. * The z coefficients of the spherical polynomial
  115057. */
  115058. z: Vector3;
  115059. /**
  115060. * The xx coefficients of the spherical polynomial
  115061. */
  115062. xx: Vector3;
  115063. /**
  115064. * The yy coefficients of the spherical polynomial
  115065. */
  115066. yy: Vector3;
  115067. /**
  115068. * The zz coefficients of the spherical polynomial
  115069. */
  115070. zz: Vector3;
  115071. /**
  115072. * The xy coefficients of the spherical polynomial
  115073. */
  115074. xy: Vector3;
  115075. /**
  115076. * The yz coefficients of the spherical polynomial
  115077. */
  115078. yz: Vector3;
  115079. /**
  115080. * The zx coefficients of the spherical polynomial
  115081. */
  115082. zx: Vector3;
  115083. /**
  115084. * Adds an ambient color to the spherical polynomial
  115085. * @param color the color to add
  115086. */
  115087. addAmbient(color: Color3): void;
  115088. /**
  115089. * Scales the spherical polynomial by the given amount
  115090. * @param scale the amount to scale
  115091. */
  115092. scaleInPlace(scale: number): void;
  115093. /**
  115094. * Gets the spherical polynomial from harmonics
  115095. * @param harmonics the spherical harmonics
  115096. * @returns the spherical polynomial
  115097. */
  115098. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  115099. /**
  115100. * Constructs a spherical polynomial from an array.
  115101. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  115102. * @returns the spherical polynomial
  115103. */
  115104. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  115105. }
  115106. }
  115107. declare module BABYLON {
  115108. /**
  115109. * Defines the source of the internal texture
  115110. */
  115111. export enum InternalTextureSource {
  115112. /**
  115113. * The source of the texture data is unknown
  115114. */
  115115. Unknown = 0,
  115116. /**
  115117. * Texture data comes from an URL
  115118. */
  115119. Url = 1,
  115120. /**
  115121. * Texture data is only used for temporary storage
  115122. */
  115123. Temp = 2,
  115124. /**
  115125. * Texture data comes from raw data (ArrayBuffer)
  115126. */
  115127. Raw = 3,
  115128. /**
  115129. * Texture content is dynamic (video or dynamic texture)
  115130. */
  115131. Dynamic = 4,
  115132. /**
  115133. * Texture content is generated by rendering to it
  115134. */
  115135. RenderTarget = 5,
  115136. /**
  115137. * Texture content is part of a multi render target process
  115138. */
  115139. MultiRenderTarget = 6,
  115140. /**
  115141. * Texture data comes from a cube data file
  115142. */
  115143. Cube = 7,
  115144. /**
  115145. * Texture data comes from a raw cube data
  115146. */
  115147. CubeRaw = 8,
  115148. /**
  115149. * Texture data come from a prefiltered cube data file
  115150. */
  115151. CubePrefiltered = 9,
  115152. /**
  115153. * Texture content is raw 3D data
  115154. */
  115155. Raw3D = 10,
  115156. /**
  115157. * Texture content is raw 2D array data
  115158. */
  115159. Raw2DArray = 11,
  115160. /**
  115161. * Texture content is a depth texture
  115162. */
  115163. Depth = 12,
  115164. /**
  115165. * Texture data comes from a raw cube data encoded with RGBD
  115166. */
  115167. CubeRawRGBD = 13
  115168. }
  115169. /**
  115170. * Class used to store data associated with WebGL texture data for the engine
  115171. * This class should not be used directly
  115172. */
  115173. export class InternalTexture {
  115174. /** @hidden */
  115175. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115176. /**
  115177. * Defines if the texture is ready
  115178. */
  115179. isReady: boolean;
  115180. /**
  115181. * Defines if the texture is a cube texture
  115182. */
  115183. isCube: boolean;
  115184. /**
  115185. * Defines if the texture contains 3D data
  115186. */
  115187. is3D: boolean;
  115188. /**
  115189. * Defines if the texture contains 2D array data
  115190. */
  115191. is2DArray: boolean;
  115192. /**
  115193. * Defines if the texture contains multiview data
  115194. */
  115195. isMultiview: boolean;
  115196. /**
  115197. * Gets the URL used to load this texture
  115198. */
  115199. url: string;
  115200. /**
  115201. * Gets the sampling mode of the texture
  115202. */
  115203. samplingMode: number;
  115204. /**
  115205. * Gets a boolean indicating if the texture needs mipmaps generation
  115206. */
  115207. generateMipMaps: boolean;
  115208. /**
  115209. * Gets the number of samples used by the texture (WebGL2+ only)
  115210. */
  115211. samples: number;
  115212. /**
  115213. * Gets the type of the texture (int, float...)
  115214. */
  115215. type: number;
  115216. /**
  115217. * Gets the format of the texture (RGB, RGBA...)
  115218. */
  115219. format: number;
  115220. /**
  115221. * Observable called when the texture is loaded
  115222. */
  115223. onLoadedObservable: Observable<InternalTexture>;
  115224. /**
  115225. * Gets the width of the texture
  115226. */
  115227. width: number;
  115228. /**
  115229. * Gets the height of the texture
  115230. */
  115231. height: number;
  115232. /**
  115233. * Gets the depth of the texture
  115234. */
  115235. depth: number;
  115236. /**
  115237. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115238. */
  115239. baseWidth: number;
  115240. /**
  115241. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115242. */
  115243. baseHeight: number;
  115244. /**
  115245. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115246. */
  115247. baseDepth: number;
  115248. /**
  115249. * Gets a boolean indicating if the texture is inverted on Y axis
  115250. */
  115251. invertY: boolean;
  115252. /** @hidden */
  115253. _invertVScale: boolean;
  115254. /** @hidden */
  115255. _associatedChannel: number;
  115256. /** @hidden */
  115257. _source: InternalTextureSource;
  115258. /** @hidden */
  115259. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115260. /** @hidden */
  115261. _bufferView: Nullable<ArrayBufferView>;
  115262. /** @hidden */
  115263. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115264. /** @hidden */
  115265. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115266. /** @hidden */
  115267. _size: number;
  115268. /** @hidden */
  115269. _extension: string;
  115270. /** @hidden */
  115271. _files: Nullable<string[]>;
  115272. /** @hidden */
  115273. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115274. /** @hidden */
  115275. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115276. /** @hidden */
  115277. _framebuffer: Nullable<WebGLFramebuffer>;
  115278. /** @hidden */
  115279. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115280. /** @hidden */
  115281. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115282. /** @hidden */
  115283. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115284. /** @hidden */
  115285. _attachments: Nullable<number[]>;
  115286. /** @hidden */
  115287. _textureArray: Nullable<InternalTexture[]>;
  115288. /** @hidden */
  115289. _cachedCoordinatesMode: Nullable<number>;
  115290. /** @hidden */
  115291. _cachedWrapU: Nullable<number>;
  115292. /** @hidden */
  115293. _cachedWrapV: Nullable<number>;
  115294. /** @hidden */
  115295. _cachedWrapR: Nullable<number>;
  115296. /** @hidden */
  115297. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115298. /** @hidden */
  115299. _isDisabled: boolean;
  115300. /** @hidden */
  115301. _compression: Nullable<string>;
  115302. /** @hidden */
  115303. _generateStencilBuffer: boolean;
  115304. /** @hidden */
  115305. _generateDepthBuffer: boolean;
  115306. /** @hidden */
  115307. _comparisonFunction: number;
  115308. /** @hidden */
  115309. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115310. /** @hidden */
  115311. _lodGenerationScale: number;
  115312. /** @hidden */
  115313. _lodGenerationOffset: number;
  115314. /** @hidden */
  115315. _depthStencilTexture: Nullable<InternalTexture>;
  115316. /** @hidden */
  115317. _colorTextureArray: Nullable<WebGLTexture>;
  115318. /** @hidden */
  115319. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115320. /** @hidden */
  115321. _lodTextureHigh: Nullable<BaseTexture>;
  115322. /** @hidden */
  115323. _lodTextureMid: Nullable<BaseTexture>;
  115324. /** @hidden */
  115325. _lodTextureLow: Nullable<BaseTexture>;
  115326. /** @hidden */
  115327. _isRGBD: boolean;
  115328. /** @hidden */
  115329. _linearSpecularLOD: boolean;
  115330. /** @hidden */
  115331. _irradianceTexture: Nullable<BaseTexture>;
  115332. /** @hidden */
  115333. _webGLTexture: Nullable<WebGLTexture>;
  115334. /** @hidden */
  115335. _references: number;
  115336. private _engine;
  115337. /**
  115338. * Gets the Engine the texture belongs to.
  115339. * @returns The babylon engine
  115340. */
  115341. getEngine(): ThinEngine;
  115342. /**
  115343. * Gets the data source type of the texture
  115344. */
  115345. get source(): InternalTextureSource;
  115346. /**
  115347. * Creates a new InternalTexture
  115348. * @param engine defines the engine to use
  115349. * @param source defines the type of data that will be used
  115350. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115351. */
  115352. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115353. /**
  115354. * Increments the number of references (ie. the number of Texture that point to it)
  115355. */
  115356. incrementReferences(): void;
  115357. /**
  115358. * Change the size of the texture (not the size of the content)
  115359. * @param width defines the new width
  115360. * @param height defines the new height
  115361. * @param depth defines the new depth (1 by default)
  115362. */
  115363. updateSize(width: int, height: int, depth?: int): void;
  115364. /** @hidden */
  115365. _rebuild(): void;
  115366. /** @hidden */
  115367. _swapAndDie(target: InternalTexture): void;
  115368. /**
  115369. * Dispose the current allocated resources
  115370. */
  115371. dispose(): void;
  115372. }
  115373. }
  115374. declare module BABYLON {
  115375. /**
  115376. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115378. */
  115379. export class Analyser {
  115380. /**
  115381. * Gets or sets the smoothing
  115382. * @ignorenaming
  115383. */
  115384. SMOOTHING: number;
  115385. /**
  115386. * Gets or sets the FFT table size
  115387. * @ignorenaming
  115388. */
  115389. FFT_SIZE: number;
  115390. /**
  115391. * Gets or sets the bar graph amplitude
  115392. * @ignorenaming
  115393. */
  115394. BARGRAPHAMPLITUDE: number;
  115395. /**
  115396. * Gets or sets the position of the debug canvas
  115397. * @ignorenaming
  115398. */
  115399. DEBUGCANVASPOS: {
  115400. x: number;
  115401. y: number;
  115402. };
  115403. /**
  115404. * Gets or sets the debug canvas size
  115405. * @ignorenaming
  115406. */
  115407. DEBUGCANVASSIZE: {
  115408. width: number;
  115409. height: number;
  115410. };
  115411. private _byteFreqs;
  115412. private _byteTime;
  115413. private _floatFreqs;
  115414. private _webAudioAnalyser;
  115415. private _debugCanvas;
  115416. private _debugCanvasContext;
  115417. private _scene;
  115418. private _registerFunc;
  115419. private _audioEngine;
  115420. /**
  115421. * Creates a new analyser
  115422. * @param scene defines hosting scene
  115423. */
  115424. constructor(scene: Scene);
  115425. /**
  115426. * Get the number of data values you will have to play with for the visualization
  115427. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  115428. * @returns a number
  115429. */
  115430. getFrequencyBinCount(): number;
  115431. /**
  115432. * Gets the current frequency data as a byte array
  115433. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115434. * @returns a Uint8Array
  115435. */
  115436. getByteFrequencyData(): Uint8Array;
  115437. /**
  115438. * Gets the current waveform as a byte array
  115439. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  115440. * @returns a Uint8Array
  115441. */
  115442. getByteTimeDomainData(): Uint8Array;
  115443. /**
  115444. * Gets the current frequency data as a float array
  115445. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115446. * @returns a Float32Array
  115447. */
  115448. getFloatFrequencyData(): Float32Array;
  115449. /**
  115450. * Renders the debug canvas
  115451. */
  115452. drawDebugCanvas(): void;
  115453. /**
  115454. * Stops rendering the debug canvas and removes it
  115455. */
  115456. stopDebugCanvas(): void;
  115457. /**
  115458. * Connects two audio nodes
  115459. * @param inputAudioNode defines first node to connect
  115460. * @param outputAudioNode defines second node to connect
  115461. */
  115462. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  115463. /**
  115464. * Releases all associated resources
  115465. */
  115466. dispose(): void;
  115467. }
  115468. }
  115469. declare module BABYLON {
  115470. /**
  115471. * This represents an audio engine and it is responsible
  115472. * to play, synchronize and analyse sounds throughout the application.
  115473. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115474. */
  115475. export interface IAudioEngine extends IDisposable {
  115476. /**
  115477. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115478. */
  115479. readonly canUseWebAudio: boolean;
  115480. /**
  115481. * Gets the current AudioContext if available.
  115482. */
  115483. readonly audioContext: Nullable<AudioContext>;
  115484. /**
  115485. * The master gain node defines the global audio volume of your audio engine.
  115486. */
  115487. readonly masterGain: GainNode;
  115488. /**
  115489. * Gets whether or not mp3 are supported by your browser.
  115490. */
  115491. readonly isMP3supported: boolean;
  115492. /**
  115493. * Gets whether or not ogg are supported by your browser.
  115494. */
  115495. readonly isOGGsupported: boolean;
  115496. /**
  115497. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115498. * @ignoreNaming
  115499. */
  115500. WarnedWebAudioUnsupported: boolean;
  115501. /**
  115502. * Defines if the audio engine relies on a custom unlocked button.
  115503. * In this case, the embedded button will not be displayed.
  115504. */
  115505. useCustomUnlockedButton: boolean;
  115506. /**
  115507. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  115508. */
  115509. readonly unlocked: boolean;
  115510. /**
  115511. * Event raised when audio has been unlocked on the browser.
  115512. */
  115513. onAudioUnlockedObservable: Observable<AudioEngine>;
  115514. /**
  115515. * Event raised when audio has been locked on the browser.
  115516. */
  115517. onAudioLockedObservable: Observable<AudioEngine>;
  115518. /**
  115519. * Flags the audio engine in Locked state.
  115520. * This happens due to new browser policies preventing audio to autoplay.
  115521. */
  115522. lock(): void;
  115523. /**
  115524. * Unlocks the audio engine once a user action has been done on the dom.
  115525. * This is helpful to resume play once browser policies have been satisfied.
  115526. */
  115527. unlock(): void;
  115528. /**
  115529. * Gets the global volume sets on the master gain.
  115530. * @returns the global volume if set or -1 otherwise
  115531. */
  115532. getGlobalVolume(): number;
  115533. /**
  115534. * Sets the global volume of your experience (sets on the master gain).
  115535. * @param newVolume Defines the new global volume of the application
  115536. */
  115537. setGlobalVolume(newVolume: number): void;
  115538. /**
  115539. * Connect the audio engine to an audio analyser allowing some amazing
  115540. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115542. * @param analyser The analyser to connect to the engine
  115543. */
  115544. connectToAnalyser(analyser: Analyser): void;
  115545. }
  115546. /**
  115547. * This represents the default audio engine used in babylon.
  115548. * It is responsible to play, synchronize and analyse sounds throughout the application.
  115549. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115550. */
  115551. export class AudioEngine implements IAudioEngine {
  115552. private _audioContext;
  115553. private _audioContextInitialized;
  115554. private _muteButton;
  115555. private _hostElement;
  115556. /**
  115557. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115558. */
  115559. canUseWebAudio: boolean;
  115560. /**
  115561. * The master gain node defines the global audio volume of your audio engine.
  115562. */
  115563. masterGain: GainNode;
  115564. /**
  115565. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115566. * @ignoreNaming
  115567. */
  115568. WarnedWebAudioUnsupported: boolean;
  115569. /**
  115570. * Gets whether or not mp3 are supported by your browser.
  115571. */
  115572. isMP3supported: boolean;
  115573. /**
  115574. * Gets whether or not ogg are supported by your browser.
  115575. */
  115576. isOGGsupported: boolean;
  115577. /**
  115578. * Gets whether audio has been unlocked on the device.
  115579. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  115580. * a user interaction has happened.
  115581. */
  115582. unlocked: boolean;
  115583. /**
  115584. * Defines if the audio engine relies on a custom unlocked button.
  115585. * In this case, the embedded button will not be displayed.
  115586. */
  115587. useCustomUnlockedButton: boolean;
  115588. /**
  115589. * Event raised when audio has been unlocked on the browser.
  115590. */
  115591. onAudioUnlockedObservable: Observable<AudioEngine>;
  115592. /**
  115593. * Event raised when audio has been locked on the browser.
  115594. */
  115595. onAudioLockedObservable: Observable<AudioEngine>;
  115596. /**
  115597. * Gets the current AudioContext if available.
  115598. */
  115599. get audioContext(): Nullable<AudioContext>;
  115600. private _connectedAnalyser;
  115601. /**
  115602. * Instantiates a new audio engine.
  115603. *
  115604. * There should be only one per page as some browsers restrict the number
  115605. * of audio contexts you can create.
  115606. * @param hostElement defines the host element where to display the mute icon if necessary
  115607. */
  115608. constructor(hostElement?: Nullable<HTMLElement>);
  115609. /**
  115610. * Flags the audio engine in Locked state.
  115611. * This happens due to new browser policies preventing audio to autoplay.
  115612. */
  115613. lock(): void;
  115614. /**
  115615. * Unlocks the audio engine once a user action has been done on the dom.
  115616. * This is helpful to resume play once browser policies have been satisfied.
  115617. */
  115618. unlock(): void;
  115619. private _resumeAudioContext;
  115620. private _initializeAudioContext;
  115621. private _tryToRun;
  115622. private _triggerRunningState;
  115623. private _triggerSuspendedState;
  115624. private _displayMuteButton;
  115625. private _moveButtonToTopLeft;
  115626. private _onResize;
  115627. private _hideMuteButton;
  115628. /**
  115629. * Destroy and release the resources associated with the audio ccontext.
  115630. */
  115631. dispose(): void;
  115632. /**
  115633. * Gets the global volume sets on the master gain.
  115634. * @returns the global volume if set or -1 otherwise
  115635. */
  115636. getGlobalVolume(): number;
  115637. /**
  115638. * Sets the global volume of your experience (sets on the master gain).
  115639. * @param newVolume Defines the new global volume of the application
  115640. */
  115641. setGlobalVolume(newVolume: number): void;
  115642. /**
  115643. * Connect the audio engine to an audio analyser allowing some amazing
  115644. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115645. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115646. * @param analyser The analyser to connect to the engine
  115647. */
  115648. connectToAnalyser(analyser: Analyser): void;
  115649. }
  115650. }
  115651. declare module BABYLON {
  115652. /**
  115653. * Interface used to present a loading screen while loading a scene
  115654. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115655. */
  115656. export interface ILoadingScreen {
  115657. /**
  115658. * Function called to display the loading screen
  115659. */
  115660. displayLoadingUI: () => void;
  115661. /**
  115662. * Function called to hide the loading screen
  115663. */
  115664. hideLoadingUI: () => void;
  115665. /**
  115666. * Gets or sets the color to use for the background
  115667. */
  115668. loadingUIBackgroundColor: string;
  115669. /**
  115670. * Gets or sets the text to display while loading
  115671. */
  115672. loadingUIText: string;
  115673. }
  115674. /**
  115675. * Class used for the default loading screen
  115676. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115677. */
  115678. export class DefaultLoadingScreen implements ILoadingScreen {
  115679. private _renderingCanvas;
  115680. private _loadingText;
  115681. private _loadingDivBackgroundColor;
  115682. private _loadingDiv;
  115683. private _loadingTextDiv;
  115684. /** Gets or sets the logo url to use for the default loading screen */
  115685. static DefaultLogoUrl: string;
  115686. /** Gets or sets the spinner url to use for the default loading screen */
  115687. static DefaultSpinnerUrl: string;
  115688. /**
  115689. * Creates a new default loading screen
  115690. * @param _renderingCanvas defines the canvas used to render the scene
  115691. * @param _loadingText defines the default text to display
  115692. * @param _loadingDivBackgroundColor defines the default background color
  115693. */
  115694. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  115695. /**
  115696. * Function called to display the loading screen
  115697. */
  115698. displayLoadingUI(): void;
  115699. /**
  115700. * Function called to hide the loading screen
  115701. */
  115702. hideLoadingUI(): void;
  115703. /**
  115704. * Gets or sets the text to display while loading
  115705. */
  115706. set loadingUIText(text: string);
  115707. get loadingUIText(): string;
  115708. /**
  115709. * Gets or sets the color to use for the background
  115710. */
  115711. get loadingUIBackgroundColor(): string;
  115712. set loadingUIBackgroundColor(color: string);
  115713. private _resizeLoadingUI;
  115714. }
  115715. }
  115716. declare module BABYLON {
  115717. /**
  115718. * Interface for any object that can request an animation frame
  115719. */
  115720. export interface ICustomAnimationFrameRequester {
  115721. /**
  115722. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  115723. */
  115724. renderFunction?: Function;
  115725. /**
  115726. * Called to request the next frame to render to
  115727. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  115728. */
  115729. requestAnimationFrame: Function;
  115730. /**
  115731. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  115732. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  115733. */
  115734. requestID?: number;
  115735. }
  115736. }
  115737. declare module BABYLON {
  115738. /**
  115739. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  115740. */
  115741. export class PerformanceMonitor {
  115742. private _enabled;
  115743. private _rollingFrameTime;
  115744. private _lastFrameTimeMs;
  115745. /**
  115746. * constructor
  115747. * @param frameSampleSize The number of samples required to saturate the sliding window
  115748. */
  115749. constructor(frameSampleSize?: number);
  115750. /**
  115751. * Samples current frame
  115752. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  115753. */
  115754. sampleFrame(timeMs?: number): void;
  115755. /**
  115756. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115757. */
  115758. get averageFrameTime(): number;
  115759. /**
  115760. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115761. */
  115762. get averageFrameTimeVariance(): number;
  115763. /**
  115764. * Returns the frame time of the most recent frame
  115765. */
  115766. get instantaneousFrameTime(): number;
  115767. /**
  115768. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  115769. */
  115770. get averageFPS(): number;
  115771. /**
  115772. * Returns the average framerate in frames per second using the most recent frame time
  115773. */
  115774. get instantaneousFPS(): number;
  115775. /**
  115776. * Returns true if enough samples have been taken to completely fill the sliding window
  115777. */
  115778. get isSaturated(): boolean;
  115779. /**
  115780. * Enables contributions to the sliding window sample set
  115781. */
  115782. enable(): void;
  115783. /**
  115784. * Disables contributions to the sliding window sample set
  115785. * Samples will not be interpolated over the disabled period
  115786. */
  115787. disable(): void;
  115788. /**
  115789. * Returns true if sampling is enabled
  115790. */
  115791. get isEnabled(): boolean;
  115792. /**
  115793. * Resets performance monitor
  115794. */
  115795. reset(): void;
  115796. }
  115797. /**
  115798. * RollingAverage
  115799. *
  115800. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  115801. */
  115802. export class RollingAverage {
  115803. /**
  115804. * Current average
  115805. */
  115806. average: number;
  115807. /**
  115808. * Current variance
  115809. */
  115810. variance: number;
  115811. protected _samples: Array<number>;
  115812. protected _sampleCount: number;
  115813. protected _pos: number;
  115814. protected _m2: number;
  115815. /**
  115816. * constructor
  115817. * @param length The number of samples required to saturate the sliding window
  115818. */
  115819. constructor(length: number);
  115820. /**
  115821. * Adds a sample to the sample set
  115822. * @param v The sample value
  115823. */
  115824. add(v: number): void;
  115825. /**
  115826. * Returns previously added values or null if outside of history or outside the sliding window domain
  115827. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  115828. * @return Value previously recorded with add() or null if outside of range
  115829. */
  115830. history(i: number): number;
  115831. /**
  115832. * Returns true if enough samples have been taken to completely fill the sliding window
  115833. * @return true if sample-set saturated
  115834. */
  115835. isSaturated(): boolean;
  115836. /**
  115837. * Resets the rolling average (equivalent to 0 samples taken so far)
  115838. */
  115839. reset(): void;
  115840. /**
  115841. * Wraps a value around the sample range boundaries
  115842. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  115843. * @return Wrapped position in sample range
  115844. */
  115845. protected _wrapPosition(i: number): number;
  115846. }
  115847. }
  115848. declare module BABYLON {
  115849. /**
  115850. * This class is used to track a performance counter which is number based.
  115851. * The user has access to many properties which give statistics of different nature.
  115852. *
  115853. * The implementer can track two kinds of Performance Counter: time and count.
  115854. * 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.
  115855. * 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.
  115856. */
  115857. export class PerfCounter {
  115858. /**
  115859. * Gets or sets a global boolean to turn on and off all the counters
  115860. */
  115861. static Enabled: boolean;
  115862. /**
  115863. * Returns the smallest value ever
  115864. */
  115865. get min(): number;
  115866. /**
  115867. * Returns the biggest value ever
  115868. */
  115869. get max(): number;
  115870. /**
  115871. * Returns the average value since the performance counter is running
  115872. */
  115873. get average(): number;
  115874. /**
  115875. * Returns the average value of the last second the counter was monitored
  115876. */
  115877. get lastSecAverage(): number;
  115878. /**
  115879. * Returns the current value
  115880. */
  115881. get current(): number;
  115882. /**
  115883. * Gets the accumulated total
  115884. */
  115885. get total(): number;
  115886. /**
  115887. * Gets the total value count
  115888. */
  115889. get count(): number;
  115890. /**
  115891. * Creates a new counter
  115892. */
  115893. constructor();
  115894. /**
  115895. * Call this method to start monitoring a new frame.
  115896. * 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.
  115897. */
  115898. fetchNewFrame(): void;
  115899. /**
  115900. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  115901. * @param newCount the count value to add to the monitored count
  115902. * @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.
  115903. */
  115904. addCount(newCount: number, fetchResult: boolean): void;
  115905. /**
  115906. * Start monitoring this performance counter
  115907. */
  115908. beginMonitoring(): void;
  115909. /**
  115910. * Compute the time lapsed since the previous beginMonitoring() call.
  115911. * @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
  115912. */
  115913. endMonitoring(newFrame?: boolean): void;
  115914. private _fetchResult;
  115915. private _startMonitoringTime;
  115916. private _min;
  115917. private _max;
  115918. private _average;
  115919. private _current;
  115920. private _totalValueCount;
  115921. private _totalAccumulated;
  115922. private _lastSecAverage;
  115923. private _lastSecAccumulated;
  115924. private _lastSecTime;
  115925. private _lastSecValueCount;
  115926. }
  115927. }
  115928. declare module BABYLON {
  115929. interface ThinEngine {
  115930. /**
  115931. * Sets alpha constants used by some alpha blending modes
  115932. * @param r defines the red component
  115933. * @param g defines the green component
  115934. * @param b defines the blue component
  115935. * @param a defines the alpha component
  115936. */
  115937. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  115938. /**
  115939. * Sets the current alpha mode
  115940. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  115941. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115942. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115943. */
  115944. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115945. /**
  115946. * Gets the current alpha mode
  115947. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115948. * @returns the current alpha mode
  115949. */
  115950. getAlphaMode(): number;
  115951. /**
  115952. * Sets the current alpha equation
  115953. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  115954. */
  115955. setAlphaEquation(equation: number): void;
  115956. /**
  115957. * Gets the current alpha equation.
  115958. * @returns the current alpha equation
  115959. */
  115960. getAlphaEquation(): number;
  115961. }
  115962. }
  115963. declare module BABYLON {
  115964. interface ThinEngine {
  115965. /** @hidden */
  115966. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  115967. }
  115968. }
  115969. declare module BABYLON {
  115970. /**
  115971. * Defines the interface used by display changed events
  115972. */
  115973. export interface IDisplayChangedEventArgs {
  115974. /** Gets the vrDisplay object (if any) */
  115975. vrDisplay: Nullable<any>;
  115976. /** Gets a boolean indicating if webVR is supported */
  115977. vrSupported: boolean;
  115978. }
  115979. /**
  115980. * Defines the interface used by objects containing a viewport (like a camera)
  115981. */
  115982. interface IViewportOwnerLike {
  115983. /**
  115984. * Gets or sets the viewport
  115985. */
  115986. viewport: IViewportLike;
  115987. }
  115988. /**
  115989. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  115990. */
  115991. export class Engine extends ThinEngine {
  115992. /** Defines that alpha blending is disabled */
  115993. static readonly ALPHA_DISABLE: number;
  115994. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  115995. static readonly ALPHA_ADD: number;
  115996. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  115997. static readonly ALPHA_COMBINE: number;
  115998. /** Defines that alpha blending to DEST - SRC * DEST */
  115999. static readonly ALPHA_SUBTRACT: number;
  116000. /** Defines that alpha blending to SRC * DEST */
  116001. static readonly ALPHA_MULTIPLY: number;
  116002. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116003. static readonly ALPHA_MAXIMIZED: number;
  116004. /** Defines that alpha blending to SRC + DEST */
  116005. static readonly ALPHA_ONEONE: number;
  116006. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116007. static readonly ALPHA_PREMULTIPLIED: number;
  116008. /**
  116009. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116010. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116011. */
  116012. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116013. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116014. static readonly ALPHA_INTERPOLATE: number;
  116015. /**
  116016. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116017. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116018. */
  116019. static readonly ALPHA_SCREENMODE: number;
  116020. /** Defines that the ressource is not delayed*/
  116021. static readonly DELAYLOADSTATE_NONE: number;
  116022. /** Defines that the ressource was successfully delay loaded */
  116023. static readonly DELAYLOADSTATE_LOADED: number;
  116024. /** Defines that the ressource is currently delay loading */
  116025. static readonly DELAYLOADSTATE_LOADING: number;
  116026. /** Defines that the ressource is delayed and has not started loading */
  116027. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116028. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116029. static readonly NEVER: number;
  116030. /** 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 */
  116031. static readonly ALWAYS: number;
  116032. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116033. static readonly LESS: number;
  116034. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116035. static readonly EQUAL: number;
  116036. /** 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 */
  116037. static readonly LEQUAL: number;
  116038. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116039. static readonly GREATER: number;
  116040. /** 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 */
  116041. static readonly GEQUAL: number;
  116042. /** 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 */
  116043. static readonly NOTEQUAL: number;
  116044. /** Passed to stencilOperation to specify that stencil value must be kept */
  116045. static readonly KEEP: number;
  116046. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116047. static readonly REPLACE: number;
  116048. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116049. static readonly INCR: number;
  116050. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116051. static readonly DECR: number;
  116052. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116053. static readonly INVERT: number;
  116054. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116055. static readonly INCR_WRAP: number;
  116056. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116057. static readonly DECR_WRAP: number;
  116058. /** Texture is not repeating outside of 0..1 UVs */
  116059. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116060. /** Texture is repeating outside of 0..1 UVs */
  116061. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116062. /** Texture is repeating and mirrored */
  116063. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116064. /** ALPHA */
  116065. static readonly TEXTUREFORMAT_ALPHA: number;
  116066. /** LUMINANCE */
  116067. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116068. /** LUMINANCE_ALPHA */
  116069. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116070. /** RGB */
  116071. static readonly TEXTUREFORMAT_RGB: number;
  116072. /** RGBA */
  116073. static readonly TEXTUREFORMAT_RGBA: number;
  116074. /** RED */
  116075. static readonly TEXTUREFORMAT_RED: number;
  116076. /** RED (2nd reference) */
  116077. static readonly TEXTUREFORMAT_R: number;
  116078. /** RG */
  116079. static readonly TEXTUREFORMAT_RG: number;
  116080. /** RED_INTEGER */
  116081. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  116082. /** RED_INTEGER (2nd reference) */
  116083. static readonly TEXTUREFORMAT_R_INTEGER: number;
  116084. /** RG_INTEGER */
  116085. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  116086. /** RGB_INTEGER */
  116087. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  116088. /** RGBA_INTEGER */
  116089. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  116090. /** UNSIGNED_BYTE */
  116091. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  116092. /** UNSIGNED_BYTE (2nd reference) */
  116093. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  116094. /** FLOAT */
  116095. static readonly TEXTURETYPE_FLOAT: number;
  116096. /** HALF_FLOAT */
  116097. static readonly TEXTURETYPE_HALF_FLOAT: number;
  116098. /** BYTE */
  116099. static readonly TEXTURETYPE_BYTE: number;
  116100. /** SHORT */
  116101. static readonly TEXTURETYPE_SHORT: number;
  116102. /** UNSIGNED_SHORT */
  116103. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  116104. /** INT */
  116105. static readonly TEXTURETYPE_INT: number;
  116106. /** UNSIGNED_INT */
  116107. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  116108. /** UNSIGNED_SHORT_4_4_4_4 */
  116109. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  116110. /** UNSIGNED_SHORT_5_5_5_1 */
  116111. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  116112. /** UNSIGNED_SHORT_5_6_5 */
  116113. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  116114. /** UNSIGNED_INT_2_10_10_10_REV */
  116115. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  116116. /** UNSIGNED_INT_24_8 */
  116117. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  116118. /** UNSIGNED_INT_10F_11F_11F_REV */
  116119. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  116120. /** UNSIGNED_INT_5_9_9_9_REV */
  116121. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  116122. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  116123. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116124. /** nearest is mag = nearest and min = nearest and mip = linear */
  116125. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  116126. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116127. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  116128. /** Trilinear is mag = linear and min = linear and mip = linear */
  116129. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  116130. /** nearest is mag = nearest and min = nearest and mip = linear */
  116131. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  116132. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116133. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  116134. /** Trilinear is mag = linear and min = linear and mip = linear */
  116135. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  116136. /** mag = nearest and min = nearest and mip = nearest */
  116137. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  116138. /** mag = nearest and min = linear and mip = nearest */
  116139. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  116140. /** mag = nearest and min = linear and mip = linear */
  116141. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  116142. /** mag = nearest and min = linear and mip = none */
  116143. static readonly TEXTURE_NEAREST_LINEAR: number;
  116144. /** mag = nearest and min = nearest and mip = none */
  116145. static readonly TEXTURE_NEAREST_NEAREST: number;
  116146. /** mag = linear and min = nearest and mip = nearest */
  116147. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  116148. /** mag = linear and min = nearest and mip = linear */
  116149. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  116150. /** mag = linear and min = linear and mip = none */
  116151. static readonly TEXTURE_LINEAR_LINEAR: number;
  116152. /** mag = linear and min = nearest and mip = none */
  116153. static readonly TEXTURE_LINEAR_NEAREST: number;
  116154. /** Explicit coordinates mode */
  116155. static readonly TEXTURE_EXPLICIT_MODE: number;
  116156. /** Spherical coordinates mode */
  116157. static readonly TEXTURE_SPHERICAL_MODE: number;
  116158. /** Planar coordinates mode */
  116159. static readonly TEXTURE_PLANAR_MODE: number;
  116160. /** Cubic coordinates mode */
  116161. static readonly TEXTURE_CUBIC_MODE: number;
  116162. /** Projection coordinates mode */
  116163. static readonly TEXTURE_PROJECTION_MODE: number;
  116164. /** Skybox coordinates mode */
  116165. static readonly TEXTURE_SKYBOX_MODE: number;
  116166. /** Inverse Cubic coordinates mode */
  116167. static readonly TEXTURE_INVCUBIC_MODE: number;
  116168. /** Equirectangular coordinates mode */
  116169. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  116170. /** Equirectangular Fixed coordinates mode */
  116171. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  116172. /** Equirectangular Fixed Mirrored coordinates mode */
  116173. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  116174. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  116175. static readonly SCALEMODE_FLOOR: number;
  116176. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116177. static readonly SCALEMODE_NEAREST: number;
  116178. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116179. static readonly SCALEMODE_CEILING: number;
  116180. /**
  116181. * Returns the current npm package of the sdk
  116182. */
  116183. static get NpmPackage(): string;
  116184. /**
  116185. * Returns the current version of the framework
  116186. */
  116187. static get Version(): string;
  116188. /** Gets the list of created engines */
  116189. static get Instances(): Engine[];
  116190. /**
  116191. * Gets the latest created engine
  116192. */
  116193. static get LastCreatedEngine(): Nullable<Engine>;
  116194. /**
  116195. * Gets the latest created scene
  116196. */
  116197. static get LastCreatedScene(): Nullable<Scene>;
  116198. /**
  116199. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116200. * @param flag defines which part of the materials must be marked as dirty
  116201. * @param predicate defines a predicate used to filter which materials should be affected
  116202. */
  116203. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116204. /**
  116205. * Method called to create the default loading screen.
  116206. * This can be overriden in your own app.
  116207. * @param canvas The rendering canvas element
  116208. * @returns The loading screen
  116209. */
  116210. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116211. /**
  116212. * Method called to create the default rescale post process on each engine.
  116213. */
  116214. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116215. /**
  116216. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116217. **/
  116218. enableOfflineSupport: boolean;
  116219. /**
  116220. * 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)
  116221. **/
  116222. disableManifestCheck: boolean;
  116223. /**
  116224. * Gets the list of created scenes
  116225. */
  116226. scenes: Scene[];
  116227. /**
  116228. * Event raised when a new scene is created
  116229. */
  116230. onNewSceneAddedObservable: Observable<Scene>;
  116231. /**
  116232. * Gets the list of created postprocesses
  116233. */
  116234. postProcesses: PostProcess[];
  116235. /**
  116236. * Gets a boolean indicating if the pointer is currently locked
  116237. */
  116238. isPointerLock: boolean;
  116239. /**
  116240. * Observable event triggered each time the rendering canvas is resized
  116241. */
  116242. onResizeObservable: Observable<Engine>;
  116243. /**
  116244. * Observable event triggered each time the canvas loses focus
  116245. */
  116246. onCanvasBlurObservable: Observable<Engine>;
  116247. /**
  116248. * Observable event triggered each time the canvas gains focus
  116249. */
  116250. onCanvasFocusObservable: Observable<Engine>;
  116251. /**
  116252. * Observable event triggered each time the canvas receives pointerout event
  116253. */
  116254. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116255. /**
  116256. * Observable raised when the engine begins a new frame
  116257. */
  116258. onBeginFrameObservable: Observable<Engine>;
  116259. /**
  116260. * If set, will be used to request the next animation frame for the render loop
  116261. */
  116262. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116263. /**
  116264. * Observable raised when the engine ends the current frame
  116265. */
  116266. onEndFrameObservable: Observable<Engine>;
  116267. /**
  116268. * Observable raised when the engine is about to compile a shader
  116269. */
  116270. onBeforeShaderCompilationObservable: Observable<Engine>;
  116271. /**
  116272. * Observable raised when the engine has jsut compiled a shader
  116273. */
  116274. onAfterShaderCompilationObservable: Observable<Engine>;
  116275. /**
  116276. * Gets the audio engine
  116277. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116278. * @ignorenaming
  116279. */
  116280. static audioEngine: IAudioEngine;
  116281. /**
  116282. * Default AudioEngine factory responsible of creating the Audio Engine.
  116283. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116284. */
  116285. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116286. /**
  116287. * Default offline support factory responsible of creating a tool used to store data locally.
  116288. * By default, this will create a Database object if the workload has been embedded.
  116289. */
  116290. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116291. private _loadingScreen;
  116292. private _pointerLockRequested;
  116293. private _rescalePostProcess;
  116294. private _deterministicLockstep;
  116295. private _lockstepMaxSteps;
  116296. private _timeStep;
  116297. protected get _supportsHardwareTextureRescaling(): boolean;
  116298. private _fps;
  116299. private _deltaTime;
  116300. /** @hidden */
  116301. _drawCalls: PerfCounter;
  116302. /** 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 */
  116303. canvasTabIndex: number;
  116304. /**
  116305. * Turn this value on if you want to pause FPS computation when in background
  116306. */
  116307. disablePerformanceMonitorInBackground: boolean;
  116308. private _performanceMonitor;
  116309. /**
  116310. * Gets the performance monitor attached to this engine
  116311. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116312. */
  116313. get performanceMonitor(): PerformanceMonitor;
  116314. private _onFocus;
  116315. private _onBlur;
  116316. private _onCanvasPointerOut;
  116317. private _onCanvasBlur;
  116318. private _onCanvasFocus;
  116319. private _onFullscreenChange;
  116320. private _onPointerLockChange;
  116321. /**
  116322. * Gets the HTML element used to attach event listeners
  116323. * @returns a HTML element
  116324. */
  116325. getInputElement(): Nullable<HTMLElement>;
  116326. /**
  116327. * Creates a new engine
  116328. * @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
  116329. * @param antialias defines enable antialiasing (default: false)
  116330. * @param options defines further options to be sent to the getContext() function
  116331. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116332. */
  116333. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116334. /**
  116335. * Gets current aspect ratio
  116336. * @param viewportOwner defines the camera to use to get the aspect ratio
  116337. * @param useScreen defines if screen size must be used (or the current render target if any)
  116338. * @returns a number defining the aspect ratio
  116339. */
  116340. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116341. /**
  116342. * Gets current screen aspect ratio
  116343. * @returns a number defining the aspect ratio
  116344. */
  116345. getScreenAspectRatio(): number;
  116346. /**
  116347. * Gets the client rect of the HTML canvas attached with the current webGL context
  116348. * @returns a client rectanglee
  116349. */
  116350. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116351. /**
  116352. * Gets the client rect of the HTML element used for events
  116353. * @returns a client rectanglee
  116354. */
  116355. getInputElementClientRect(): Nullable<ClientRect>;
  116356. /**
  116357. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116358. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116359. * @returns true if engine is in deterministic lock step mode
  116360. */
  116361. isDeterministicLockStep(): boolean;
  116362. /**
  116363. * Gets the max steps when engine is running in deterministic lock step
  116364. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116365. * @returns the max steps
  116366. */
  116367. getLockstepMaxSteps(): number;
  116368. /**
  116369. * Returns the time in ms between steps when using deterministic lock step.
  116370. * @returns time step in (ms)
  116371. */
  116372. getTimeStep(): number;
  116373. /**
  116374. * Force the mipmap generation for the given render target texture
  116375. * @param texture defines the render target texture to use
  116376. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116377. */
  116378. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116379. /** States */
  116380. /**
  116381. * Set various states to the webGL context
  116382. * @param culling defines backface culling state
  116383. * @param zOffset defines the value to apply to zOffset (0 by default)
  116384. * @param force defines if states must be applied even if cache is up to date
  116385. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116386. */
  116387. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116388. /**
  116389. * Set the z offset to apply to current rendering
  116390. * @param value defines the offset to apply
  116391. */
  116392. setZOffset(value: number): void;
  116393. /**
  116394. * Gets the current value of the zOffset
  116395. * @returns the current zOffset state
  116396. */
  116397. getZOffset(): number;
  116398. /**
  116399. * Enable or disable depth buffering
  116400. * @param enable defines the state to set
  116401. */
  116402. setDepthBuffer(enable: boolean): void;
  116403. /**
  116404. * Gets a boolean indicating if depth writing is enabled
  116405. * @returns the current depth writing state
  116406. */
  116407. getDepthWrite(): boolean;
  116408. /**
  116409. * Enable or disable depth writing
  116410. * @param enable defines the state to set
  116411. */
  116412. setDepthWrite(enable: boolean): void;
  116413. /**
  116414. * Gets a boolean indicating if stencil buffer is enabled
  116415. * @returns the current stencil buffer state
  116416. */
  116417. getStencilBuffer(): boolean;
  116418. /**
  116419. * Enable or disable the stencil buffer
  116420. * @param enable defines if the stencil buffer must be enabled or disabled
  116421. */
  116422. setStencilBuffer(enable: boolean): void;
  116423. /**
  116424. * Gets the current stencil mask
  116425. * @returns a number defining the new stencil mask to use
  116426. */
  116427. getStencilMask(): number;
  116428. /**
  116429. * Sets the current stencil mask
  116430. * @param mask defines the new stencil mask to use
  116431. */
  116432. setStencilMask(mask: number): void;
  116433. /**
  116434. * Gets the current stencil function
  116435. * @returns a number defining the stencil function to use
  116436. */
  116437. getStencilFunction(): number;
  116438. /**
  116439. * Gets the current stencil reference value
  116440. * @returns a number defining the stencil reference value to use
  116441. */
  116442. getStencilFunctionReference(): number;
  116443. /**
  116444. * Gets the current stencil mask
  116445. * @returns a number defining the stencil mask to use
  116446. */
  116447. getStencilFunctionMask(): number;
  116448. /**
  116449. * Sets the current stencil function
  116450. * @param stencilFunc defines the new stencil function to use
  116451. */
  116452. setStencilFunction(stencilFunc: number): void;
  116453. /**
  116454. * Sets the current stencil reference
  116455. * @param reference defines the new stencil reference to use
  116456. */
  116457. setStencilFunctionReference(reference: number): void;
  116458. /**
  116459. * Sets the current stencil mask
  116460. * @param mask defines the new stencil mask to use
  116461. */
  116462. setStencilFunctionMask(mask: number): void;
  116463. /**
  116464. * Gets the current stencil operation when stencil fails
  116465. * @returns a number defining stencil operation to use when stencil fails
  116466. */
  116467. getStencilOperationFail(): number;
  116468. /**
  116469. * Gets the current stencil operation when depth fails
  116470. * @returns a number defining stencil operation to use when depth fails
  116471. */
  116472. getStencilOperationDepthFail(): number;
  116473. /**
  116474. * Gets the current stencil operation when stencil passes
  116475. * @returns a number defining stencil operation to use when stencil passes
  116476. */
  116477. getStencilOperationPass(): number;
  116478. /**
  116479. * Sets the stencil operation to use when stencil fails
  116480. * @param operation defines the stencil operation to use when stencil fails
  116481. */
  116482. setStencilOperationFail(operation: number): void;
  116483. /**
  116484. * Sets the stencil operation to use when depth fails
  116485. * @param operation defines the stencil operation to use when depth fails
  116486. */
  116487. setStencilOperationDepthFail(operation: number): void;
  116488. /**
  116489. * Sets the stencil operation to use when stencil passes
  116490. * @param operation defines the stencil operation to use when stencil passes
  116491. */
  116492. setStencilOperationPass(operation: number): void;
  116493. /**
  116494. * Sets a boolean indicating if the dithering state is enabled or disabled
  116495. * @param value defines the dithering state
  116496. */
  116497. setDitheringState(value: boolean): void;
  116498. /**
  116499. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  116500. * @param value defines the rasterizer state
  116501. */
  116502. setRasterizerState(value: boolean): void;
  116503. /**
  116504. * Gets the current depth function
  116505. * @returns a number defining the depth function
  116506. */
  116507. getDepthFunction(): Nullable<number>;
  116508. /**
  116509. * Sets the current depth function
  116510. * @param depthFunc defines the function to use
  116511. */
  116512. setDepthFunction(depthFunc: number): void;
  116513. /**
  116514. * Sets the current depth function to GREATER
  116515. */
  116516. setDepthFunctionToGreater(): void;
  116517. /**
  116518. * Sets the current depth function to GEQUAL
  116519. */
  116520. setDepthFunctionToGreaterOrEqual(): void;
  116521. /**
  116522. * Sets the current depth function to LESS
  116523. */
  116524. setDepthFunctionToLess(): void;
  116525. /**
  116526. * Sets the current depth function to LEQUAL
  116527. */
  116528. setDepthFunctionToLessOrEqual(): void;
  116529. private _cachedStencilBuffer;
  116530. private _cachedStencilFunction;
  116531. private _cachedStencilMask;
  116532. private _cachedStencilOperationPass;
  116533. private _cachedStencilOperationFail;
  116534. private _cachedStencilOperationDepthFail;
  116535. private _cachedStencilReference;
  116536. /**
  116537. * Caches the the state of the stencil buffer
  116538. */
  116539. cacheStencilState(): void;
  116540. /**
  116541. * Restores the state of the stencil buffer
  116542. */
  116543. restoreStencilState(): void;
  116544. /**
  116545. * Directly set the WebGL Viewport
  116546. * @param x defines the x coordinate of the viewport (in screen space)
  116547. * @param y defines the y coordinate of the viewport (in screen space)
  116548. * @param width defines the width of the viewport (in screen space)
  116549. * @param height defines the height of the viewport (in screen space)
  116550. * @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
  116551. */
  116552. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  116553. /**
  116554. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  116555. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116556. * @param y defines the y-coordinate of the corner of the clear rectangle
  116557. * @param width defines the width of the clear rectangle
  116558. * @param height defines the height of the clear rectangle
  116559. * @param clearColor defines the clear color
  116560. */
  116561. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  116562. /**
  116563. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  116564. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116565. * @param y defines the y-coordinate of the corner of the clear rectangle
  116566. * @param width defines the width of the clear rectangle
  116567. * @param height defines the height of the clear rectangle
  116568. */
  116569. enableScissor(x: number, y: number, width: number, height: number): void;
  116570. /**
  116571. * Disable previously set scissor test rectangle
  116572. */
  116573. disableScissor(): void;
  116574. protected _reportDrawCall(): void;
  116575. /**
  116576. * Initializes a webVR display and starts listening to display change events
  116577. * The onVRDisplayChangedObservable will be notified upon these changes
  116578. * @returns The onVRDisplayChangedObservable
  116579. */
  116580. initWebVR(): Observable<IDisplayChangedEventArgs>;
  116581. /** @hidden */
  116582. _prepareVRComponent(): void;
  116583. /** @hidden */
  116584. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  116585. /** @hidden */
  116586. _submitVRFrame(): void;
  116587. /**
  116588. * Call this function to leave webVR mode
  116589. * Will do nothing if webVR is not supported or if there is no webVR device
  116590. * @see https://doc.babylonjs.com/how_to/webvr_camera
  116591. */
  116592. disableVR(): void;
  116593. /**
  116594. * Gets a boolean indicating that the system is in VR mode and is presenting
  116595. * @returns true if VR mode is engaged
  116596. */
  116597. isVRPresenting(): boolean;
  116598. /** @hidden */
  116599. _requestVRFrame(): void;
  116600. /** @hidden */
  116601. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116602. /**
  116603. * Gets the source code of the vertex shader associated with a specific webGL program
  116604. * @param program defines the program to use
  116605. * @returns a string containing the source code of the vertex shader associated with the program
  116606. */
  116607. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  116608. /**
  116609. * Gets the source code of the fragment shader associated with a specific webGL program
  116610. * @param program defines the program to use
  116611. * @returns a string containing the source code of the fragment shader associated with the program
  116612. */
  116613. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  116614. /**
  116615. * Sets a depth stencil texture from a render target to the according uniform.
  116616. * @param channel The texture channel
  116617. * @param uniform The uniform to set
  116618. * @param texture The render target texture containing the depth stencil texture to apply
  116619. */
  116620. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  116621. /**
  116622. * Sets a texture to the webGL context from a postprocess
  116623. * @param channel defines the channel to use
  116624. * @param postProcess defines the source postprocess
  116625. */
  116626. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  116627. /**
  116628. * Binds the output of the passed in post process to the texture channel specified
  116629. * @param channel The channel the texture should be bound to
  116630. * @param postProcess The post process which's output should be bound
  116631. */
  116632. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  116633. protected _rebuildBuffers(): void;
  116634. /** @hidden */
  116635. _renderFrame(): void;
  116636. _renderLoop(): void;
  116637. /** @hidden */
  116638. _renderViews(): boolean;
  116639. /**
  116640. * Toggle full screen mode
  116641. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116642. */
  116643. switchFullscreen(requestPointerLock: boolean): void;
  116644. /**
  116645. * Enters full screen mode
  116646. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116647. */
  116648. enterFullscreen(requestPointerLock: boolean): void;
  116649. /**
  116650. * Exits full screen mode
  116651. */
  116652. exitFullscreen(): void;
  116653. /**
  116654. * Enters Pointerlock mode
  116655. */
  116656. enterPointerlock(): void;
  116657. /**
  116658. * Exits Pointerlock mode
  116659. */
  116660. exitPointerlock(): void;
  116661. /**
  116662. * Begin a new frame
  116663. */
  116664. beginFrame(): void;
  116665. /**
  116666. * Enf the current frame
  116667. */
  116668. endFrame(): void;
  116669. resize(): void;
  116670. /**
  116671. * Force a specific size of the canvas
  116672. * @param width defines the new canvas' width
  116673. * @param height defines the new canvas' height
  116674. * @returns true if the size was changed
  116675. */
  116676. setSize(width: number, height: number): boolean;
  116677. /**
  116678. * Updates a dynamic vertex buffer.
  116679. * @param vertexBuffer the vertex buffer to update
  116680. * @param data the data used to update the vertex buffer
  116681. * @param byteOffset the byte offset of the data
  116682. * @param byteLength the byte length of the data
  116683. */
  116684. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116685. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116686. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116687. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116688. _releaseTexture(texture: InternalTexture): void;
  116689. /**
  116690. * @hidden
  116691. * Rescales a texture
  116692. * @param source input texutre
  116693. * @param destination destination texture
  116694. * @param scene scene to use to render the resize
  116695. * @param internalFormat format to use when resizing
  116696. * @param onComplete callback to be called when resize has completed
  116697. */
  116698. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116699. /**
  116700. * Gets the current framerate
  116701. * @returns a number representing the framerate
  116702. */
  116703. getFps(): number;
  116704. /**
  116705. * Gets the time spent between current and previous frame
  116706. * @returns a number representing the delta time in ms
  116707. */
  116708. getDeltaTime(): number;
  116709. private _measureFps;
  116710. /** @hidden */
  116711. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  116712. /**
  116713. * Update a dynamic index buffer
  116714. * @param indexBuffer defines the target index buffer
  116715. * @param indices defines the data to update
  116716. * @param offset defines the offset in the target index buffer where update should start
  116717. */
  116718. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  116719. /**
  116720. * Updates the sample count of a render target texture
  116721. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  116722. * @param texture defines the texture to update
  116723. * @param samples defines the sample count to set
  116724. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  116725. */
  116726. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  116727. /**
  116728. * Updates a depth texture Comparison Mode and Function.
  116729. * If the comparison Function is equal to 0, the mode will be set to none.
  116730. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  116731. * @param texture The texture to set the comparison function for
  116732. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  116733. */
  116734. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  116735. /**
  116736. * Creates a webGL buffer to use with instanciation
  116737. * @param capacity defines the size of the buffer
  116738. * @returns the webGL buffer
  116739. */
  116740. createInstancesBuffer(capacity: number): DataBuffer;
  116741. /**
  116742. * Delete a webGL buffer used with instanciation
  116743. * @param buffer defines the webGL buffer to delete
  116744. */
  116745. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  116746. private _clientWaitAsync;
  116747. /** @hidden */
  116748. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  116749. dispose(): void;
  116750. private _disableTouchAction;
  116751. /**
  116752. * Display the loading screen
  116753. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116754. */
  116755. displayLoadingUI(): void;
  116756. /**
  116757. * Hide the loading screen
  116758. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116759. */
  116760. hideLoadingUI(): void;
  116761. /**
  116762. * Gets the current loading screen object
  116763. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116764. */
  116765. get loadingScreen(): ILoadingScreen;
  116766. /**
  116767. * Sets the current loading screen object
  116768. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116769. */
  116770. set loadingScreen(loadingScreen: ILoadingScreen);
  116771. /**
  116772. * Sets the current loading screen text
  116773. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116774. */
  116775. set loadingUIText(text: string);
  116776. /**
  116777. * Sets the current loading screen background color
  116778. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116779. */
  116780. set loadingUIBackgroundColor(color: string);
  116781. /** Pointerlock and fullscreen */
  116782. /**
  116783. * Ask the browser to promote the current element to pointerlock mode
  116784. * @param element defines the DOM element to promote
  116785. */
  116786. static _RequestPointerlock(element: HTMLElement): void;
  116787. /**
  116788. * Asks the browser to exit pointerlock mode
  116789. */
  116790. static _ExitPointerlock(): void;
  116791. /**
  116792. * Ask the browser to promote the current element to fullscreen rendering mode
  116793. * @param element defines the DOM element to promote
  116794. */
  116795. static _RequestFullscreen(element: HTMLElement): void;
  116796. /**
  116797. * Asks the browser to exit fullscreen mode
  116798. */
  116799. static _ExitFullscreen(): void;
  116800. }
  116801. }
  116802. declare module BABYLON {
  116803. /**
  116804. * The engine store class is responsible to hold all the instances of Engine and Scene created
  116805. * during the life time of the application.
  116806. */
  116807. export class EngineStore {
  116808. /** Gets the list of created engines */
  116809. static Instances: Engine[];
  116810. /** @hidden */
  116811. static _LastCreatedScene: Nullable<Scene>;
  116812. /**
  116813. * Gets the latest created engine
  116814. */
  116815. static get LastCreatedEngine(): Nullable<Engine>;
  116816. /**
  116817. * Gets the latest created scene
  116818. */
  116819. static get LastCreatedScene(): Nullable<Scene>;
  116820. /**
  116821. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116822. * @ignorenaming
  116823. */
  116824. static UseFallbackTexture: boolean;
  116825. /**
  116826. * Texture content used if a texture cannot loaded
  116827. * @ignorenaming
  116828. */
  116829. static FallbackTexture: string;
  116830. }
  116831. }
  116832. declare module BABYLON {
  116833. /**
  116834. * Helper class that provides a small promise polyfill
  116835. */
  116836. export class PromisePolyfill {
  116837. /**
  116838. * Static function used to check if the polyfill is required
  116839. * If this is the case then the function will inject the polyfill to window.Promise
  116840. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  116841. */
  116842. static Apply(force?: boolean): void;
  116843. }
  116844. }
  116845. declare module BABYLON {
  116846. /**
  116847. * Interface for screenshot methods with describe argument called `size` as object with options
  116848. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  116849. */
  116850. export interface IScreenshotSize {
  116851. /**
  116852. * number in pixels for canvas height
  116853. */
  116854. height?: number;
  116855. /**
  116856. * multiplier allowing render at a higher or lower resolution
  116857. * If value is defined then height and width will be ignored and taken from camera
  116858. */
  116859. precision?: number;
  116860. /**
  116861. * number in pixels for canvas width
  116862. */
  116863. width?: number;
  116864. }
  116865. }
  116866. declare module BABYLON {
  116867. interface IColor4Like {
  116868. r: float;
  116869. g: float;
  116870. b: float;
  116871. a: float;
  116872. }
  116873. /**
  116874. * Class containing a set of static utilities functions
  116875. */
  116876. export class Tools {
  116877. /**
  116878. * Gets or sets the base URL to use to load assets
  116879. */
  116880. static get BaseUrl(): string;
  116881. static set BaseUrl(value: string);
  116882. /**
  116883. * Enable/Disable Custom HTTP Request Headers globally.
  116884. * default = false
  116885. * @see CustomRequestHeaders
  116886. */
  116887. static UseCustomRequestHeaders: boolean;
  116888. /**
  116889. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  116890. * i.e. when loading files, where the server/service expects an Authorization header
  116891. */
  116892. static CustomRequestHeaders: {
  116893. [key: string]: string;
  116894. };
  116895. /**
  116896. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  116897. */
  116898. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  116899. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  116900. /**
  116901. * Default behaviour for cors in the application.
  116902. * It can be a string if the expected behavior is identical in the entire app.
  116903. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  116904. */
  116905. static get CorsBehavior(): string | ((url: string | string[]) => string);
  116906. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  116907. /**
  116908. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116909. * @ignorenaming
  116910. */
  116911. static get UseFallbackTexture(): boolean;
  116912. static set UseFallbackTexture(value: boolean);
  116913. /**
  116914. * Use this object to register external classes like custom textures or material
  116915. * to allow the laoders to instantiate them
  116916. */
  116917. static get RegisteredExternalClasses(): {
  116918. [key: string]: Object;
  116919. };
  116920. static set RegisteredExternalClasses(classes: {
  116921. [key: string]: Object;
  116922. });
  116923. /**
  116924. * Texture content used if a texture cannot loaded
  116925. * @ignorenaming
  116926. */
  116927. static get fallbackTexture(): string;
  116928. static set fallbackTexture(value: string);
  116929. /**
  116930. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  116931. * @param u defines the coordinate on X axis
  116932. * @param v defines the coordinate on Y axis
  116933. * @param width defines the width of the source data
  116934. * @param height defines the height of the source data
  116935. * @param pixels defines the source byte array
  116936. * @param color defines the output color
  116937. */
  116938. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  116939. /**
  116940. * Interpolates between a and b via alpha
  116941. * @param a The lower value (returned when alpha = 0)
  116942. * @param b The upper value (returned when alpha = 1)
  116943. * @param alpha The interpolation-factor
  116944. * @return The mixed value
  116945. */
  116946. static Mix(a: number, b: number, alpha: number): number;
  116947. /**
  116948. * Tries to instantiate a new object from a given class name
  116949. * @param className defines the class name to instantiate
  116950. * @returns the new object or null if the system was not able to do the instantiation
  116951. */
  116952. static Instantiate(className: string): any;
  116953. /**
  116954. * Provides a slice function that will work even on IE
  116955. * @param data defines the array to slice
  116956. * @param start defines the start of the data (optional)
  116957. * @param end defines the end of the data (optional)
  116958. * @returns the new sliced array
  116959. */
  116960. static Slice<T>(data: T, start?: number, end?: number): T;
  116961. /**
  116962. * Polyfill for setImmediate
  116963. * @param action defines the action to execute after the current execution block
  116964. */
  116965. static SetImmediate(action: () => void): void;
  116966. /**
  116967. * Function indicating if a number is an exponent of 2
  116968. * @param value defines the value to test
  116969. * @returns true if the value is an exponent of 2
  116970. */
  116971. static IsExponentOfTwo(value: number): boolean;
  116972. private static _tmpFloatArray;
  116973. /**
  116974. * Returns the nearest 32-bit single precision float representation of a Number
  116975. * @param value A Number. If the parameter is of a different type, it will get converted
  116976. * to a number or to NaN if it cannot be converted
  116977. * @returns number
  116978. */
  116979. static FloatRound(value: number): number;
  116980. /**
  116981. * Extracts the filename from a path
  116982. * @param path defines the path to use
  116983. * @returns the filename
  116984. */
  116985. static GetFilename(path: string): string;
  116986. /**
  116987. * Extracts the "folder" part of a path (everything before the filename).
  116988. * @param uri The URI to extract the info from
  116989. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  116990. * @returns The "folder" part of the path
  116991. */
  116992. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  116993. /**
  116994. * Extracts text content from a DOM element hierarchy
  116995. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  116996. */
  116997. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  116998. /**
  116999. * Convert an angle in radians to degrees
  117000. * @param angle defines the angle to convert
  117001. * @returns the angle in degrees
  117002. */
  117003. static ToDegrees(angle: number): number;
  117004. /**
  117005. * Convert an angle in degrees to radians
  117006. * @param angle defines the angle to convert
  117007. * @returns the angle in radians
  117008. */
  117009. static ToRadians(angle: number): number;
  117010. /**
  117011. * Returns an array if obj is not an array
  117012. * @param obj defines the object to evaluate as an array
  117013. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117014. * @returns either obj directly if obj is an array or a new array containing obj
  117015. */
  117016. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117017. /**
  117018. * Gets the pointer prefix to use
  117019. * @param engine defines the engine we are finding the prefix for
  117020. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117021. */
  117022. static GetPointerPrefix(engine: Engine): string;
  117023. /**
  117024. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117025. * @param url define the url we are trying
  117026. * @param element define the dom element where to configure the cors policy
  117027. */
  117028. static SetCorsBehavior(url: string | string[], element: {
  117029. crossOrigin: string | null;
  117030. }): void;
  117031. /**
  117032. * Removes unwanted characters from an url
  117033. * @param url defines the url to clean
  117034. * @returns the cleaned url
  117035. */
  117036. static CleanUrl(url: string): string;
  117037. /**
  117038. * Gets or sets a function used to pre-process url before using them to load assets
  117039. */
  117040. static get PreprocessUrl(): (url: string) => string;
  117041. static set PreprocessUrl(processor: (url: string) => string);
  117042. /**
  117043. * Loads an image as an HTMLImageElement.
  117044. * @param input url string, ArrayBuffer, or Blob to load
  117045. * @param onLoad callback called when the image successfully loads
  117046. * @param onError callback called when the image fails to load
  117047. * @param offlineProvider offline provider for caching
  117048. * @param mimeType optional mime type
  117049. * @returns the HTMLImageElement of the loaded image
  117050. */
  117051. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117052. /**
  117053. * Loads a file from a url
  117054. * @param url url string, ArrayBuffer, or Blob to load
  117055. * @param onSuccess callback called when the file successfully loads
  117056. * @param onProgress callback called while file is loading (if the server supports this mode)
  117057. * @param offlineProvider defines the offline provider for caching
  117058. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117059. * @param onError callback called when the file fails to load
  117060. * @returns a file request object
  117061. */
  117062. 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;
  117063. /**
  117064. * Loads a file from a url
  117065. * @param url the file url to load
  117066. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117067. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117068. */
  117069. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117070. /**
  117071. * Load a script (identified by an url). When the url returns, the
  117072. * content of this file is added into a new script element, attached to the DOM (body element)
  117073. * @param scriptUrl defines the url of the script to laod
  117074. * @param onSuccess defines the callback called when the script is loaded
  117075. * @param onError defines the callback to call if an error occurs
  117076. * @param scriptId defines the id of the script element
  117077. */
  117078. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117079. /**
  117080. * Load an asynchronous script (identified by an url). When the url returns, the
  117081. * content of this file is added into a new script element, attached to the DOM (body element)
  117082. * @param scriptUrl defines the url of the script to laod
  117083. * @param scriptId defines the id of the script element
  117084. * @returns a promise request object
  117085. */
  117086. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117087. /**
  117088. * Loads a file from a blob
  117089. * @param fileToLoad defines the blob to use
  117090. * @param callback defines the callback to call when data is loaded
  117091. * @param progressCallback defines the callback to call during loading process
  117092. * @returns a file request object
  117093. */
  117094. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  117095. /**
  117096. * Reads a file from a File object
  117097. * @param file defines the file to load
  117098. * @param onSuccess defines the callback to call when data is loaded
  117099. * @param onProgress defines the callback to call during loading process
  117100. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117101. * @param onError defines the callback to call when an error occurs
  117102. * @returns a file request object
  117103. */
  117104. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117105. /**
  117106. * Creates a data url from a given string content
  117107. * @param content defines the content to convert
  117108. * @returns the new data url link
  117109. */
  117110. static FileAsURL(content: string): string;
  117111. /**
  117112. * Format the given number to a specific decimal format
  117113. * @param value defines the number to format
  117114. * @param decimals defines the number of decimals to use
  117115. * @returns the formatted string
  117116. */
  117117. static Format(value: number, decimals?: number): string;
  117118. /**
  117119. * Tries to copy an object by duplicating every property
  117120. * @param source defines the source object
  117121. * @param destination defines the target object
  117122. * @param doNotCopyList defines a list of properties to avoid
  117123. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  117124. */
  117125. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  117126. /**
  117127. * Gets a boolean indicating if the given object has no own property
  117128. * @param obj defines the object to test
  117129. * @returns true if object has no own property
  117130. */
  117131. static IsEmpty(obj: any): boolean;
  117132. /**
  117133. * Function used to register events at window level
  117134. * @param windowElement defines the Window object to use
  117135. * @param events defines the events to register
  117136. */
  117137. static RegisterTopRootEvents(windowElement: Window, events: {
  117138. name: string;
  117139. handler: Nullable<(e: FocusEvent) => any>;
  117140. }[]): void;
  117141. /**
  117142. * Function used to unregister events from window level
  117143. * @param windowElement defines the Window object to use
  117144. * @param events defines the events to unregister
  117145. */
  117146. static UnregisterTopRootEvents(windowElement: Window, events: {
  117147. name: string;
  117148. handler: Nullable<(e: FocusEvent) => any>;
  117149. }[]): void;
  117150. /**
  117151. * @ignore
  117152. */
  117153. static _ScreenshotCanvas: HTMLCanvasElement;
  117154. /**
  117155. * Dumps the current bound framebuffer
  117156. * @param width defines the rendering width
  117157. * @param height defines the rendering height
  117158. * @param engine defines the hosting engine
  117159. * @param successCallback defines the callback triggered once the data are available
  117160. * @param mimeType defines the mime type of the result
  117161. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  117162. */
  117163. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117164. /**
  117165. * Converts the canvas data to blob.
  117166. * This acts as a polyfill for browsers not supporting the to blob function.
  117167. * @param canvas Defines the canvas to extract the data from
  117168. * @param successCallback Defines the callback triggered once the data are available
  117169. * @param mimeType Defines the mime type of the result
  117170. */
  117171. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  117172. /**
  117173. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  117174. * @param successCallback defines the callback triggered once the data are available
  117175. * @param mimeType defines the mime type of the result
  117176. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117177. */
  117178. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117179. /**
  117180. * Downloads a blob in the browser
  117181. * @param blob defines the blob to download
  117182. * @param fileName defines the name of the downloaded file
  117183. */
  117184. static Download(blob: Blob, fileName: string): void;
  117185. /**
  117186. * Captures a screenshot of the current rendering
  117187. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117188. * @param engine defines the rendering engine
  117189. * @param camera defines the source camera
  117190. * @param size This parameter can be set to a single number or to an object with the
  117191. * following (optional) properties: precision, width, height. If a single number is passed,
  117192. * it will be used for both width and height. If an object is passed, the screenshot size
  117193. * will be derived from the parameters. The precision property is a multiplier allowing
  117194. * rendering at a higher or lower resolution
  117195. * @param successCallback defines the callback receives a single parameter which contains the
  117196. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117197. * src parameter of an <img> to display it
  117198. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117199. * Check your browser for supported MIME types
  117200. */
  117201. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117202. /**
  117203. * Captures a screenshot of the current rendering
  117204. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117205. * @param engine defines the rendering engine
  117206. * @param camera defines the source camera
  117207. * @param size This parameter can be set to a single number or to an object with the
  117208. * following (optional) properties: precision, width, height. If a single number is passed,
  117209. * it will be used for both width and height. If an object is passed, the screenshot size
  117210. * will be derived from the parameters. The precision property is a multiplier allowing
  117211. * rendering at a higher or lower resolution
  117212. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117213. * Check your browser for supported MIME types
  117214. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117215. * to the src parameter of an <img> to display it
  117216. */
  117217. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117218. /**
  117219. * Generates an image screenshot from the specified camera.
  117220. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117221. * @param engine The engine to use for rendering
  117222. * @param camera The camera to use for rendering
  117223. * @param size This parameter can be set to a single number or to an object with the
  117224. * following (optional) properties: precision, width, height. If a single number is passed,
  117225. * it will be used for both width and height. If an object is passed, the screenshot size
  117226. * will be derived from the parameters. The precision property is a multiplier allowing
  117227. * rendering at a higher or lower resolution
  117228. * @param successCallback The callback receives a single parameter which contains the
  117229. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117230. * src parameter of an <img> to display it
  117231. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117232. * Check your browser for supported MIME types
  117233. * @param samples Texture samples (default: 1)
  117234. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117235. * @param fileName A name for for the downloaded file.
  117236. */
  117237. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117238. /**
  117239. * Generates an image screenshot from the specified camera.
  117240. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117241. * @param engine The engine to use for rendering
  117242. * @param camera The camera to use for rendering
  117243. * @param size This parameter can be set to a single number or to an object with the
  117244. * following (optional) properties: precision, width, height. If a single number is passed,
  117245. * it will be used for both width and height. If an object is passed, the screenshot size
  117246. * will be derived from the parameters. The precision property is a multiplier allowing
  117247. * rendering at a higher or lower resolution
  117248. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117249. * Check your browser for supported MIME types
  117250. * @param samples Texture samples (default: 1)
  117251. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117252. * @param fileName A name for for the downloaded file.
  117253. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117254. * to the src parameter of an <img> to display it
  117255. */
  117256. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117257. /**
  117258. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117259. * Be aware Math.random() could cause collisions, but:
  117260. * "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"
  117261. * @returns a pseudo random id
  117262. */
  117263. static RandomId(): string;
  117264. /**
  117265. * Test if the given uri is a base64 string
  117266. * @param uri The uri to test
  117267. * @return True if the uri is a base64 string or false otherwise
  117268. */
  117269. static IsBase64(uri: string): boolean;
  117270. /**
  117271. * Decode the given base64 uri.
  117272. * @param uri The uri to decode
  117273. * @return The decoded base64 data.
  117274. */
  117275. static DecodeBase64(uri: string): ArrayBuffer;
  117276. /**
  117277. * Gets the absolute url.
  117278. * @param url the input url
  117279. * @return the absolute url
  117280. */
  117281. static GetAbsoluteUrl(url: string): string;
  117282. /**
  117283. * No log
  117284. */
  117285. static readonly NoneLogLevel: number;
  117286. /**
  117287. * Only message logs
  117288. */
  117289. static readonly MessageLogLevel: number;
  117290. /**
  117291. * Only warning logs
  117292. */
  117293. static readonly WarningLogLevel: number;
  117294. /**
  117295. * Only error logs
  117296. */
  117297. static readonly ErrorLogLevel: number;
  117298. /**
  117299. * All logs
  117300. */
  117301. static readonly AllLogLevel: number;
  117302. /**
  117303. * Gets a value indicating the number of loading errors
  117304. * @ignorenaming
  117305. */
  117306. static get errorsCount(): number;
  117307. /**
  117308. * Callback called when a new log is added
  117309. */
  117310. static OnNewCacheEntry: (entry: string) => void;
  117311. /**
  117312. * Log a message to the console
  117313. * @param message defines the message to log
  117314. */
  117315. static Log(message: string): void;
  117316. /**
  117317. * Write a warning message to the console
  117318. * @param message defines the message to log
  117319. */
  117320. static Warn(message: string): void;
  117321. /**
  117322. * Write an error message to the console
  117323. * @param message defines the message to log
  117324. */
  117325. static Error(message: string): void;
  117326. /**
  117327. * Gets current log cache (list of logs)
  117328. */
  117329. static get LogCache(): string;
  117330. /**
  117331. * Clears the log cache
  117332. */
  117333. static ClearLogCache(): void;
  117334. /**
  117335. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117336. */
  117337. static set LogLevels(level: number);
  117338. /**
  117339. * Checks if the window object exists
  117340. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117341. */
  117342. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117343. /**
  117344. * No performance log
  117345. */
  117346. static readonly PerformanceNoneLogLevel: number;
  117347. /**
  117348. * Use user marks to log performance
  117349. */
  117350. static readonly PerformanceUserMarkLogLevel: number;
  117351. /**
  117352. * Log performance to the console
  117353. */
  117354. static readonly PerformanceConsoleLogLevel: number;
  117355. private static _performance;
  117356. /**
  117357. * Sets the current performance log level
  117358. */
  117359. static set PerformanceLogLevel(level: number);
  117360. private static _StartPerformanceCounterDisabled;
  117361. private static _EndPerformanceCounterDisabled;
  117362. private static _StartUserMark;
  117363. private static _EndUserMark;
  117364. private static _StartPerformanceConsole;
  117365. private static _EndPerformanceConsole;
  117366. /**
  117367. * Starts a performance counter
  117368. */
  117369. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117370. /**
  117371. * Ends a specific performance coutner
  117372. */
  117373. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117374. /**
  117375. * Gets either window.performance.now() if supported or Date.now() else
  117376. */
  117377. static get Now(): number;
  117378. /**
  117379. * This method will return the name of the class used to create the instance of the given object.
  117380. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117381. * @param object the object to get the class name from
  117382. * @param isType defines if the object is actually a type
  117383. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117384. */
  117385. static GetClassName(object: any, isType?: boolean): string;
  117386. /**
  117387. * Gets the first element of an array satisfying a given predicate
  117388. * @param array defines the array to browse
  117389. * @param predicate defines the predicate to use
  117390. * @returns null if not found or the element
  117391. */
  117392. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117393. /**
  117394. * This method will return the name of the full name of the class, including its owning module (if any).
  117395. * 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).
  117396. * @param object the object to get the class name from
  117397. * @param isType defines if the object is actually a type
  117398. * @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.
  117399. * @ignorenaming
  117400. */
  117401. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117402. /**
  117403. * Returns a promise that resolves after the given amount of time.
  117404. * @param delay Number of milliseconds to delay
  117405. * @returns Promise that resolves after the given amount of time
  117406. */
  117407. static DelayAsync(delay: number): Promise<void>;
  117408. /**
  117409. * Utility function to detect if the current user agent is Safari
  117410. * @returns whether or not the current user agent is safari
  117411. */
  117412. static IsSafari(): boolean;
  117413. }
  117414. /**
  117415. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117416. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117417. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117418. * @param name The name of the class, case should be preserved
  117419. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117420. */
  117421. export function className(name: string, module?: string): (target: Object) => void;
  117422. /**
  117423. * An implementation of a loop for asynchronous functions.
  117424. */
  117425. export class AsyncLoop {
  117426. /**
  117427. * Defines the number of iterations for the loop
  117428. */
  117429. iterations: number;
  117430. /**
  117431. * Defines the current index of the loop.
  117432. */
  117433. index: number;
  117434. private _done;
  117435. private _fn;
  117436. private _successCallback;
  117437. /**
  117438. * Constructor.
  117439. * @param iterations the number of iterations.
  117440. * @param func the function to run each iteration
  117441. * @param successCallback the callback that will be called upon succesful execution
  117442. * @param offset starting offset.
  117443. */
  117444. constructor(
  117445. /**
  117446. * Defines the number of iterations for the loop
  117447. */
  117448. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117449. /**
  117450. * Execute the next iteration. Must be called after the last iteration was finished.
  117451. */
  117452. executeNext(): void;
  117453. /**
  117454. * Break the loop and run the success callback.
  117455. */
  117456. breakLoop(): void;
  117457. /**
  117458. * Create and run an async loop.
  117459. * @param iterations the number of iterations.
  117460. * @param fn the function to run each iteration
  117461. * @param successCallback the callback that will be called upon succesful execution
  117462. * @param offset starting offset.
  117463. * @returns the created async loop object
  117464. */
  117465. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117466. /**
  117467. * A for-loop that will run a given number of iterations synchronous and the rest async.
  117468. * @param iterations total number of iterations
  117469. * @param syncedIterations number of synchronous iterations in each async iteration.
  117470. * @param fn the function to call each iteration.
  117471. * @param callback a success call back that will be called when iterating stops.
  117472. * @param breakFunction a break condition (optional)
  117473. * @param timeout timeout settings for the setTimeout function. default - 0.
  117474. * @returns the created async loop object
  117475. */
  117476. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  117477. }
  117478. }
  117479. declare module BABYLON {
  117480. /**
  117481. * This class implement a typical dictionary using a string as key and the generic type T as value.
  117482. * The underlying implementation relies on an associative array to ensure the best performances.
  117483. * The value can be anything including 'null' but except 'undefined'
  117484. */
  117485. export class StringDictionary<T> {
  117486. /**
  117487. * This will clear this dictionary and copy the content from the 'source' one.
  117488. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  117489. * @param source the dictionary to take the content from and copy to this dictionary
  117490. */
  117491. copyFrom(source: StringDictionary<T>): void;
  117492. /**
  117493. * Get a value based from its key
  117494. * @param key the given key to get the matching value from
  117495. * @return the value if found, otherwise undefined is returned
  117496. */
  117497. get(key: string): T | undefined;
  117498. /**
  117499. * Get a value from its key or add it if it doesn't exist.
  117500. * This method will ensure you that a given key/data will be present in the dictionary.
  117501. * @param key the given key to get the matching value from
  117502. * @param factory the factory that will create the value if the key is not present in the dictionary.
  117503. * The factory will only be invoked if there's no data for the given key.
  117504. * @return the value corresponding to the key.
  117505. */
  117506. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  117507. /**
  117508. * Get a value from its key if present in the dictionary otherwise add it
  117509. * @param key the key to get the value from
  117510. * @param val if there's no such key/value pair in the dictionary add it with this value
  117511. * @return the value corresponding to the key
  117512. */
  117513. getOrAdd(key: string, val: T): T;
  117514. /**
  117515. * Check if there's a given key in the dictionary
  117516. * @param key the key to check for
  117517. * @return true if the key is present, false otherwise
  117518. */
  117519. contains(key: string): boolean;
  117520. /**
  117521. * Add a new key and its corresponding value
  117522. * @param key the key to add
  117523. * @param value the value corresponding to the key
  117524. * @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
  117525. */
  117526. add(key: string, value: T): boolean;
  117527. /**
  117528. * Update a specific value associated to a key
  117529. * @param key defines the key to use
  117530. * @param value defines the value to store
  117531. * @returns true if the value was updated (or false if the key was not found)
  117532. */
  117533. set(key: string, value: T): boolean;
  117534. /**
  117535. * Get the element of the given key and remove it from the dictionary
  117536. * @param key defines the key to search
  117537. * @returns the value associated with the key or null if not found
  117538. */
  117539. getAndRemove(key: string): Nullable<T>;
  117540. /**
  117541. * Remove a key/value from the dictionary.
  117542. * @param key the key to remove
  117543. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  117544. */
  117545. remove(key: string): boolean;
  117546. /**
  117547. * Clear the whole content of the dictionary
  117548. */
  117549. clear(): void;
  117550. /**
  117551. * Gets the current count
  117552. */
  117553. get count(): number;
  117554. /**
  117555. * Execute a callback on each key/val of the dictionary.
  117556. * Note that you can remove any element in this dictionary in the callback implementation
  117557. * @param callback the callback to execute on a given key/value pair
  117558. */
  117559. forEach(callback: (key: string, val: T) => void): void;
  117560. /**
  117561. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  117562. * If the callback returns null or undefined the method will iterate to the next key/value pair
  117563. * Note that you can remove any element in this dictionary in the callback implementation
  117564. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  117565. * @returns the first item
  117566. */
  117567. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  117568. private _count;
  117569. private _data;
  117570. }
  117571. }
  117572. declare module BABYLON {
  117573. /** @hidden */
  117574. export interface ICollisionCoordinator {
  117575. createCollider(): Collider;
  117576. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117577. init(scene: Scene): void;
  117578. }
  117579. /** @hidden */
  117580. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  117581. private _scene;
  117582. private _scaledPosition;
  117583. private _scaledVelocity;
  117584. private _finalPosition;
  117585. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117586. createCollider(): Collider;
  117587. init(scene: Scene): void;
  117588. private _collideWithWorld;
  117589. }
  117590. }
  117591. declare module BABYLON {
  117592. /**
  117593. * Class used to manage all inputs for the scene.
  117594. */
  117595. export class InputManager {
  117596. /** The distance in pixel that you have to move to prevent some events */
  117597. static DragMovementThreshold: number;
  117598. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  117599. static LongPressDelay: number;
  117600. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  117601. static DoubleClickDelay: number;
  117602. /** If you need to check double click without raising a single click at first click, enable this flag */
  117603. static ExclusiveDoubleClickMode: boolean;
  117604. /** 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. */
  117605. private _alreadyAttached;
  117606. private _wheelEventName;
  117607. private _onPointerMove;
  117608. private _onPointerDown;
  117609. private _onPointerUp;
  117610. private _initClickEvent;
  117611. private _initActionManager;
  117612. private _delayedSimpleClick;
  117613. private _delayedSimpleClickTimeout;
  117614. private _previousDelayedSimpleClickTimeout;
  117615. private _meshPickProceed;
  117616. private _previousButtonPressed;
  117617. private _currentPickResult;
  117618. private _previousPickResult;
  117619. private _totalPointersPressed;
  117620. private _doubleClickOccured;
  117621. private _pointerOverMesh;
  117622. private _pickedDownMesh;
  117623. private _pickedUpMesh;
  117624. private _pointerX;
  117625. private _pointerY;
  117626. private _unTranslatedPointerX;
  117627. private _unTranslatedPointerY;
  117628. private _startingPointerPosition;
  117629. private _previousStartingPointerPosition;
  117630. private _startingPointerTime;
  117631. private _previousStartingPointerTime;
  117632. private _pointerCaptures;
  117633. private _onKeyDown;
  117634. private _onKeyUp;
  117635. private _onCanvasFocusObserver;
  117636. private _onCanvasBlurObserver;
  117637. private _scene;
  117638. /**
  117639. * Creates a new InputManager
  117640. * @param scene defines the hosting scene
  117641. */
  117642. constructor(scene: Scene);
  117643. /**
  117644. * Gets the mesh that is currently under the pointer
  117645. */
  117646. get meshUnderPointer(): Nullable<AbstractMesh>;
  117647. /**
  117648. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  117649. */
  117650. get unTranslatedPointer(): Vector2;
  117651. /**
  117652. * Gets or sets the current on-screen X position of the pointer
  117653. */
  117654. get pointerX(): number;
  117655. set pointerX(value: number);
  117656. /**
  117657. * Gets or sets the current on-screen Y position of the pointer
  117658. */
  117659. get pointerY(): number;
  117660. set pointerY(value: number);
  117661. private _updatePointerPosition;
  117662. private _processPointerMove;
  117663. private _setRayOnPointerInfo;
  117664. private _checkPrePointerObservable;
  117665. /**
  117666. * Use this method to simulate a pointer move on a mesh
  117667. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117668. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117669. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117670. */
  117671. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117672. /**
  117673. * Use this method to simulate a pointer down on a mesh
  117674. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117675. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117676. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117677. */
  117678. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117679. private _processPointerDown;
  117680. /** @hidden */
  117681. _isPointerSwiping(): boolean;
  117682. /**
  117683. * Use this method to simulate a pointer up on a mesh
  117684. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117685. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117686. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117687. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117688. */
  117689. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  117690. private _processPointerUp;
  117691. /**
  117692. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117693. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117694. * @returns true if the pointer was captured
  117695. */
  117696. isPointerCaptured(pointerId?: number): boolean;
  117697. /**
  117698. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117699. * @param attachUp defines if you want to attach events to pointerup
  117700. * @param attachDown defines if you want to attach events to pointerdown
  117701. * @param attachMove defines if you want to attach events to pointermove
  117702. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  117703. */
  117704. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  117705. /**
  117706. * Detaches all event handlers
  117707. */
  117708. detachControl(): void;
  117709. /**
  117710. * Force the value of meshUnderPointer
  117711. * @param mesh defines the mesh to use
  117712. */
  117713. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117714. /**
  117715. * Gets the mesh under the pointer
  117716. * @returns a Mesh or null if no mesh is under the pointer
  117717. */
  117718. getPointerOverMesh(): Nullable<AbstractMesh>;
  117719. }
  117720. }
  117721. declare module BABYLON {
  117722. /**
  117723. * This class defines the direct association between an animation and a target
  117724. */
  117725. export class TargetedAnimation {
  117726. /**
  117727. * Animation to perform
  117728. */
  117729. animation: Animation;
  117730. /**
  117731. * Target to animate
  117732. */
  117733. target: any;
  117734. /**
  117735. * Returns the string "TargetedAnimation"
  117736. * @returns "TargetedAnimation"
  117737. */
  117738. getClassName(): string;
  117739. /**
  117740. * Serialize the object
  117741. * @returns the JSON object representing the current entity
  117742. */
  117743. serialize(): any;
  117744. }
  117745. /**
  117746. * Use this class to create coordinated animations on multiple targets
  117747. */
  117748. export class AnimationGroup implements IDisposable {
  117749. /** The name of the animation group */
  117750. name: string;
  117751. private _scene;
  117752. private _targetedAnimations;
  117753. private _animatables;
  117754. private _from;
  117755. private _to;
  117756. private _isStarted;
  117757. private _isPaused;
  117758. private _speedRatio;
  117759. private _loopAnimation;
  117760. private _isAdditive;
  117761. /**
  117762. * Gets or sets the unique id of the node
  117763. */
  117764. uniqueId: number;
  117765. /**
  117766. * This observable will notify when one animation have ended
  117767. */
  117768. onAnimationEndObservable: Observable<TargetedAnimation>;
  117769. /**
  117770. * Observer raised when one animation loops
  117771. */
  117772. onAnimationLoopObservable: Observable<TargetedAnimation>;
  117773. /**
  117774. * Observer raised when all animations have looped
  117775. */
  117776. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  117777. /**
  117778. * This observable will notify when all animations have ended.
  117779. */
  117780. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  117781. /**
  117782. * This observable will notify when all animations have paused.
  117783. */
  117784. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  117785. /**
  117786. * This observable will notify when all animations are playing.
  117787. */
  117788. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  117789. /**
  117790. * Gets the first frame
  117791. */
  117792. get from(): number;
  117793. /**
  117794. * Gets the last frame
  117795. */
  117796. get to(): number;
  117797. /**
  117798. * Define if the animations are started
  117799. */
  117800. get isStarted(): boolean;
  117801. /**
  117802. * Gets a value indicating that the current group is playing
  117803. */
  117804. get isPlaying(): boolean;
  117805. /**
  117806. * Gets or sets the speed ratio to use for all animations
  117807. */
  117808. get speedRatio(): number;
  117809. /**
  117810. * Gets or sets the speed ratio to use for all animations
  117811. */
  117812. set speedRatio(value: number);
  117813. /**
  117814. * Gets or sets if all animations should loop or not
  117815. */
  117816. get loopAnimation(): boolean;
  117817. set loopAnimation(value: boolean);
  117818. /**
  117819. * Gets or sets if all animations should be evaluated additively
  117820. */
  117821. get isAdditive(): boolean;
  117822. set isAdditive(value: boolean);
  117823. /**
  117824. * Gets the targeted animations for this animation group
  117825. */
  117826. get targetedAnimations(): Array<TargetedAnimation>;
  117827. /**
  117828. * returning the list of animatables controlled by this animation group.
  117829. */
  117830. get animatables(): Array<Animatable>;
  117831. /**
  117832. * Gets the list of target animations
  117833. */
  117834. get children(): TargetedAnimation[];
  117835. /**
  117836. * Instantiates a new Animation Group.
  117837. * This helps managing several animations at once.
  117838. * @see https://doc.babylonjs.com/how_to/group
  117839. * @param name Defines the name of the group
  117840. * @param scene Defines the scene the group belongs to
  117841. */
  117842. constructor(
  117843. /** The name of the animation group */
  117844. name: string, scene?: Nullable<Scene>);
  117845. /**
  117846. * Add an animation (with its target) in the group
  117847. * @param animation defines the animation we want to add
  117848. * @param target defines the target of the animation
  117849. * @returns the TargetedAnimation object
  117850. */
  117851. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  117852. /**
  117853. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  117854. * It can add constant keys at begin or end
  117855. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  117856. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  117857. * @returns the animation group
  117858. */
  117859. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  117860. private _animationLoopCount;
  117861. private _animationLoopFlags;
  117862. private _processLoop;
  117863. /**
  117864. * Start all animations on given targets
  117865. * @param loop defines if animations must loop
  117866. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  117867. * @param from defines the from key (optional)
  117868. * @param to defines the to key (optional)
  117869. * @param isAdditive defines the additive state for the resulting animatables (optional)
  117870. * @returns the current animation group
  117871. */
  117872. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  117873. /**
  117874. * Pause all animations
  117875. * @returns the animation group
  117876. */
  117877. pause(): AnimationGroup;
  117878. /**
  117879. * Play all animations to initial state
  117880. * This function will start() the animations if they were not started or will restart() them if they were paused
  117881. * @param loop defines if animations must loop
  117882. * @returns the animation group
  117883. */
  117884. play(loop?: boolean): AnimationGroup;
  117885. /**
  117886. * Reset all animations to initial state
  117887. * @returns the animation group
  117888. */
  117889. reset(): AnimationGroup;
  117890. /**
  117891. * Restart animations from key 0
  117892. * @returns the animation group
  117893. */
  117894. restart(): AnimationGroup;
  117895. /**
  117896. * Stop all animations
  117897. * @returns the animation group
  117898. */
  117899. stop(): AnimationGroup;
  117900. /**
  117901. * Set animation weight for all animatables
  117902. * @param weight defines the weight to use
  117903. * @return the animationGroup
  117904. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117905. */
  117906. setWeightForAllAnimatables(weight: number): AnimationGroup;
  117907. /**
  117908. * Synchronize and normalize all animatables with a source animatable
  117909. * @param root defines the root animatable to synchronize with
  117910. * @return the animationGroup
  117911. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117912. */
  117913. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  117914. /**
  117915. * Goes to a specific frame in this animation group
  117916. * @param frame the frame number to go to
  117917. * @return the animationGroup
  117918. */
  117919. goToFrame(frame: number): AnimationGroup;
  117920. /**
  117921. * Dispose all associated resources
  117922. */
  117923. dispose(): void;
  117924. private _checkAnimationGroupEnded;
  117925. /**
  117926. * Clone the current animation group and returns a copy
  117927. * @param newName defines the name of the new group
  117928. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  117929. * @returns the new aniamtion group
  117930. */
  117931. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  117932. /**
  117933. * Serializes the animationGroup to an object
  117934. * @returns Serialized object
  117935. */
  117936. serialize(): any;
  117937. /**
  117938. * Returns a new AnimationGroup object parsed from the source provided.
  117939. * @param parsedAnimationGroup defines the source
  117940. * @param scene defines the scene that will receive the animationGroup
  117941. * @returns a new AnimationGroup
  117942. */
  117943. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  117944. /**
  117945. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117946. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  117947. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117948. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  117949. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  117950. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  117951. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  117952. */
  117953. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  117954. /**
  117955. * Returns the string "AnimationGroup"
  117956. * @returns "AnimationGroup"
  117957. */
  117958. getClassName(): string;
  117959. /**
  117960. * Creates a detailled string about the object
  117961. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  117962. * @returns a string representing the object
  117963. */
  117964. toString(fullDetails?: boolean): string;
  117965. }
  117966. }
  117967. declare module BABYLON {
  117968. /**
  117969. * Define an interface for all classes that will hold resources
  117970. */
  117971. export interface IDisposable {
  117972. /**
  117973. * Releases all held resources
  117974. */
  117975. dispose(): void;
  117976. }
  117977. /** Interface defining initialization parameters for Scene class */
  117978. export interface SceneOptions {
  117979. /**
  117980. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  117981. * It will improve performance when the number of geometries becomes important.
  117982. */
  117983. useGeometryUniqueIdsMap?: boolean;
  117984. /**
  117985. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  117986. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  117987. */
  117988. useMaterialMeshMap?: boolean;
  117989. /**
  117990. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  117991. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  117992. */
  117993. useClonedMeshMap?: boolean;
  117994. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  117995. virtual?: boolean;
  117996. }
  117997. /**
  117998. * Represents a scene to be rendered by the engine.
  117999. * @see https://doc.babylonjs.com/features/scene
  118000. */
  118001. export class Scene extends AbstractScene implements IAnimatable {
  118002. /** The fog is deactivated */
  118003. static readonly FOGMODE_NONE: number;
  118004. /** The fog density is following an exponential function */
  118005. static readonly FOGMODE_EXP: number;
  118006. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118007. static readonly FOGMODE_EXP2: number;
  118008. /** The fog density is following a linear function. */
  118009. static readonly FOGMODE_LINEAR: number;
  118010. /**
  118011. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118012. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118013. */
  118014. static MinDeltaTime: number;
  118015. /**
  118016. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118017. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118018. */
  118019. static MaxDeltaTime: number;
  118020. /**
  118021. * Factory used to create the default material.
  118022. * @param name The name of the material to create
  118023. * @param scene The scene to create the material for
  118024. * @returns The default material
  118025. */
  118026. static DefaultMaterialFactory(scene: Scene): Material;
  118027. /**
  118028. * Factory used to create the a collision coordinator.
  118029. * @returns The collision coordinator
  118030. */
  118031. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118032. /** @hidden */
  118033. _inputManager: InputManager;
  118034. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118035. cameraToUseForPointers: Nullable<Camera>;
  118036. /** @hidden */
  118037. readonly _isScene: boolean;
  118038. /** @hidden */
  118039. _blockEntityCollection: boolean;
  118040. /**
  118041. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118042. */
  118043. autoClear: boolean;
  118044. /**
  118045. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118046. */
  118047. autoClearDepthAndStencil: boolean;
  118048. /**
  118049. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118050. */
  118051. clearColor: Color4;
  118052. /**
  118053. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118054. */
  118055. ambientColor: Color3;
  118056. /**
  118057. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118058. * It should only be one of the following (if not the default embedded one):
  118059. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118060. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118061. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118062. * The material properties need to be setup according to the type of texture in use.
  118063. */
  118064. environmentBRDFTexture: BaseTexture;
  118065. /** @hidden */
  118066. protected _environmentTexture: Nullable<BaseTexture>;
  118067. /**
  118068. * Texture used in all pbr material as the reflection texture.
  118069. * As in the majority of the scene they are the same (exception for multi room and so on),
  118070. * this is easier to reference from here than from all the materials.
  118071. */
  118072. get environmentTexture(): Nullable<BaseTexture>;
  118073. /**
  118074. * Texture used in all pbr material as the reflection texture.
  118075. * As in the majority of the scene they are the same (exception for multi room and so on),
  118076. * this is easier to set here than in all the materials.
  118077. */
  118078. set environmentTexture(value: Nullable<BaseTexture>);
  118079. /** @hidden */
  118080. protected _environmentIntensity: number;
  118081. /**
  118082. * Intensity of the environment in all pbr material.
  118083. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118084. * As in the majority of the scene they are the same (exception for multi room and so on),
  118085. * this is easier to reference from here than from all the materials.
  118086. */
  118087. get environmentIntensity(): number;
  118088. /**
  118089. * Intensity of the environment in all pbr material.
  118090. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118091. * As in the majority of the scene they are the same (exception for multi room and so on),
  118092. * this is easier to set here than in all the materials.
  118093. */
  118094. set environmentIntensity(value: number);
  118095. /** @hidden */
  118096. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118097. /**
  118098. * Default image processing configuration used either in the rendering
  118099. * Forward main pass or through the imageProcessingPostProcess if present.
  118100. * As in the majority of the scene they are the same (exception for multi camera),
  118101. * this is easier to reference from here than from all the materials and post process.
  118102. *
  118103. * No setter as we it is a shared configuration, you can set the values instead.
  118104. */
  118105. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118106. private _forceWireframe;
  118107. /**
  118108. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  118109. */
  118110. set forceWireframe(value: boolean);
  118111. get forceWireframe(): boolean;
  118112. private _skipFrustumClipping;
  118113. /**
  118114. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  118115. */
  118116. set skipFrustumClipping(value: boolean);
  118117. get skipFrustumClipping(): boolean;
  118118. private _forcePointsCloud;
  118119. /**
  118120. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  118121. */
  118122. set forcePointsCloud(value: boolean);
  118123. get forcePointsCloud(): boolean;
  118124. /**
  118125. * Gets or sets the active clipplane 1
  118126. */
  118127. clipPlane: Nullable<Plane>;
  118128. /**
  118129. * Gets or sets the active clipplane 2
  118130. */
  118131. clipPlane2: Nullable<Plane>;
  118132. /**
  118133. * Gets or sets the active clipplane 3
  118134. */
  118135. clipPlane3: Nullable<Plane>;
  118136. /**
  118137. * Gets or sets the active clipplane 4
  118138. */
  118139. clipPlane4: Nullable<Plane>;
  118140. /**
  118141. * Gets or sets the active clipplane 5
  118142. */
  118143. clipPlane5: Nullable<Plane>;
  118144. /**
  118145. * Gets or sets the active clipplane 6
  118146. */
  118147. clipPlane6: Nullable<Plane>;
  118148. /**
  118149. * Gets or sets a boolean indicating if animations are enabled
  118150. */
  118151. animationsEnabled: boolean;
  118152. private _animationPropertiesOverride;
  118153. /**
  118154. * Gets or sets the animation properties override
  118155. */
  118156. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  118157. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  118158. /**
  118159. * Gets or sets a boolean indicating if a constant deltatime has to be used
  118160. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  118161. */
  118162. useConstantAnimationDeltaTime: boolean;
  118163. /**
  118164. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  118165. * Please note that it requires to run a ray cast through the scene on every frame
  118166. */
  118167. constantlyUpdateMeshUnderPointer: boolean;
  118168. /**
  118169. * Defines the HTML cursor to use when hovering over interactive elements
  118170. */
  118171. hoverCursor: string;
  118172. /**
  118173. * Defines the HTML default cursor to use (empty by default)
  118174. */
  118175. defaultCursor: string;
  118176. /**
  118177. * Defines whether cursors are handled by the scene.
  118178. */
  118179. doNotHandleCursors: boolean;
  118180. /**
  118181. * This is used to call preventDefault() on pointer down
  118182. * in order to block unwanted artifacts like system double clicks
  118183. */
  118184. preventDefaultOnPointerDown: boolean;
  118185. /**
  118186. * This is used to call preventDefault() on pointer up
  118187. * in order to block unwanted artifacts like system double clicks
  118188. */
  118189. preventDefaultOnPointerUp: boolean;
  118190. /**
  118191. * Gets or sets user defined metadata
  118192. */
  118193. metadata: any;
  118194. /**
  118195. * For internal use only. Please do not use.
  118196. */
  118197. reservedDataStore: any;
  118198. /**
  118199. * Gets the name of the plugin used to load this scene (null by default)
  118200. */
  118201. loadingPluginName: string;
  118202. /**
  118203. * Use this array to add regular expressions used to disable offline support for specific urls
  118204. */
  118205. disableOfflineSupportExceptionRules: RegExp[];
  118206. /**
  118207. * An event triggered when the scene is disposed.
  118208. */
  118209. onDisposeObservable: Observable<Scene>;
  118210. private _onDisposeObserver;
  118211. /** Sets a function to be executed when this scene is disposed. */
  118212. set onDispose(callback: () => void);
  118213. /**
  118214. * An event triggered before rendering the scene (right after animations and physics)
  118215. */
  118216. onBeforeRenderObservable: Observable<Scene>;
  118217. private _onBeforeRenderObserver;
  118218. /** Sets a function to be executed before rendering this scene */
  118219. set beforeRender(callback: Nullable<() => void>);
  118220. /**
  118221. * An event triggered after rendering the scene
  118222. */
  118223. onAfterRenderObservable: Observable<Scene>;
  118224. /**
  118225. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118226. */
  118227. onAfterRenderCameraObservable: Observable<Camera>;
  118228. private _onAfterRenderObserver;
  118229. /** Sets a function to be executed after rendering this scene */
  118230. set afterRender(callback: Nullable<() => void>);
  118231. /**
  118232. * An event triggered before animating the scene
  118233. */
  118234. onBeforeAnimationsObservable: Observable<Scene>;
  118235. /**
  118236. * An event triggered after animations processing
  118237. */
  118238. onAfterAnimationsObservable: Observable<Scene>;
  118239. /**
  118240. * An event triggered before draw calls are ready to be sent
  118241. */
  118242. onBeforeDrawPhaseObservable: Observable<Scene>;
  118243. /**
  118244. * An event triggered after draw calls have been sent
  118245. */
  118246. onAfterDrawPhaseObservable: Observable<Scene>;
  118247. /**
  118248. * An event triggered when the scene is ready
  118249. */
  118250. onReadyObservable: Observable<Scene>;
  118251. /**
  118252. * An event triggered before rendering a camera
  118253. */
  118254. onBeforeCameraRenderObservable: Observable<Camera>;
  118255. private _onBeforeCameraRenderObserver;
  118256. /** Sets a function to be executed before rendering a camera*/
  118257. set beforeCameraRender(callback: () => void);
  118258. /**
  118259. * An event triggered after rendering a camera
  118260. */
  118261. onAfterCameraRenderObservable: Observable<Camera>;
  118262. private _onAfterCameraRenderObserver;
  118263. /** Sets a function to be executed after rendering a camera*/
  118264. set afterCameraRender(callback: () => void);
  118265. /**
  118266. * An event triggered when active meshes evaluation is about to start
  118267. */
  118268. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118269. /**
  118270. * An event triggered when active meshes evaluation is done
  118271. */
  118272. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118273. /**
  118274. * An event triggered when particles rendering is about to start
  118275. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118276. */
  118277. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118278. /**
  118279. * An event triggered when particles rendering is done
  118280. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118281. */
  118282. onAfterParticlesRenderingObservable: Observable<Scene>;
  118283. /**
  118284. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118285. */
  118286. onDataLoadedObservable: Observable<Scene>;
  118287. /**
  118288. * An event triggered when a camera is created
  118289. */
  118290. onNewCameraAddedObservable: Observable<Camera>;
  118291. /**
  118292. * An event triggered when a camera is removed
  118293. */
  118294. onCameraRemovedObservable: Observable<Camera>;
  118295. /**
  118296. * An event triggered when a light is created
  118297. */
  118298. onNewLightAddedObservable: Observable<Light>;
  118299. /**
  118300. * An event triggered when a light is removed
  118301. */
  118302. onLightRemovedObservable: Observable<Light>;
  118303. /**
  118304. * An event triggered when a geometry is created
  118305. */
  118306. onNewGeometryAddedObservable: Observable<Geometry>;
  118307. /**
  118308. * An event triggered when a geometry is removed
  118309. */
  118310. onGeometryRemovedObservable: Observable<Geometry>;
  118311. /**
  118312. * An event triggered when a transform node is created
  118313. */
  118314. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118315. /**
  118316. * An event triggered when a transform node is removed
  118317. */
  118318. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118319. /**
  118320. * An event triggered when a mesh is created
  118321. */
  118322. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118323. /**
  118324. * An event triggered when a mesh is removed
  118325. */
  118326. onMeshRemovedObservable: Observable<AbstractMesh>;
  118327. /**
  118328. * An event triggered when a skeleton is created
  118329. */
  118330. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118331. /**
  118332. * An event triggered when a skeleton is removed
  118333. */
  118334. onSkeletonRemovedObservable: Observable<Skeleton>;
  118335. /**
  118336. * An event triggered when a material is created
  118337. */
  118338. onNewMaterialAddedObservable: Observable<Material>;
  118339. /**
  118340. * An event triggered when a material is removed
  118341. */
  118342. onMaterialRemovedObservable: Observable<Material>;
  118343. /**
  118344. * An event triggered when a texture is created
  118345. */
  118346. onNewTextureAddedObservable: Observable<BaseTexture>;
  118347. /**
  118348. * An event triggered when a texture is removed
  118349. */
  118350. onTextureRemovedObservable: Observable<BaseTexture>;
  118351. /**
  118352. * An event triggered when render targets are about to be rendered
  118353. * Can happen multiple times per frame.
  118354. */
  118355. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118356. /**
  118357. * An event triggered when render targets were rendered.
  118358. * Can happen multiple times per frame.
  118359. */
  118360. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118361. /**
  118362. * An event triggered before calculating deterministic simulation step
  118363. */
  118364. onBeforeStepObservable: Observable<Scene>;
  118365. /**
  118366. * An event triggered after calculating deterministic simulation step
  118367. */
  118368. onAfterStepObservable: Observable<Scene>;
  118369. /**
  118370. * An event triggered when the activeCamera property is updated
  118371. */
  118372. onActiveCameraChanged: Observable<Scene>;
  118373. /**
  118374. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118375. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118376. * 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)
  118377. */
  118378. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118379. /**
  118380. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118381. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118382. * 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)
  118383. */
  118384. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118385. /**
  118386. * This Observable will when a mesh has been imported into the scene.
  118387. */
  118388. onMeshImportedObservable: Observable<AbstractMesh>;
  118389. /**
  118390. * This Observable will when an animation file has been imported into the scene.
  118391. */
  118392. onAnimationFileImportedObservable: Observable<Scene>;
  118393. /**
  118394. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118395. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118396. */
  118397. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118398. /** @hidden */
  118399. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118400. /**
  118401. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118402. */
  118403. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118404. /**
  118405. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118406. */
  118407. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118408. /**
  118409. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118410. */
  118411. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118412. /** Callback called when a pointer move is detected */
  118413. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118414. /** Callback called when a pointer down is detected */
  118415. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118416. /** Callback called when a pointer up is detected */
  118417. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118418. /** Callback called when a pointer pick is detected */
  118419. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118420. /**
  118421. * 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).
  118422. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118423. */
  118424. onPrePointerObservable: Observable<PointerInfoPre>;
  118425. /**
  118426. * Observable event triggered each time an input event is received from the rendering canvas
  118427. */
  118428. onPointerObservable: Observable<PointerInfo>;
  118429. /**
  118430. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118431. */
  118432. get unTranslatedPointer(): Vector2;
  118433. /**
  118434. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118435. */
  118436. static get DragMovementThreshold(): number;
  118437. static set DragMovementThreshold(value: number);
  118438. /**
  118439. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118440. */
  118441. static get LongPressDelay(): number;
  118442. static set LongPressDelay(value: number);
  118443. /**
  118444. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118445. */
  118446. static get DoubleClickDelay(): number;
  118447. static set DoubleClickDelay(value: number);
  118448. /** If you need to check double click without raising a single click at first click, enable this flag */
  118449. static get ExclusiveDoubleClickMode(): boolean;
  118450. static set ExclusiveDoubleClickMode(value: boolean);
  118451. /** @hidden */
  118452. _mirroredCameraPosition: Nullable<Vector3>;
  118453. /**
  118454. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118455. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118456. */
  118457. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118458. /**
  118459. * Observable event triggered each time an keyboard event is received from the hosting window
  118460. */
  118461. onKeyboardObservable: Observable<KeyboardInfo>;
  118462. private _useRightHandedSystem;
  118463. /**
  118464. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118465. */
  118466. set useRightHandedSystem(value: boolean);
  118467. get useRightHandedSystem(): boolean;
  118468. private _timeAccumulator;
  118469. private _currentStepId;
  118470. private _currentInternalStep;
  118471. /**
  118472. * Sets the step Id used by deterministic lock step
  118473. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118474. * @param newStepId defines the step Id
  118475. */
  118476. setStepId(newStepId: number): void;
  118477. /**
  118478. * Gets the step Id used by deterministic lock step
  118479. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118480. * @returns the step Id
  118481. */
  118482. getStepId(): number;
  118483. /**
  118484. * Gets the internal step used by deterministic lock step
  118485. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118486. * @returns the internal step
  118487. */
  118488. getInternalStep(): number;
  118489. private _fogEnabled;
  118490. /**
  118491. * Gets or sets a boolean indicating if fog is enabled on this scene
  118492. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118493. * (Default is true)
  118494. */
  118495. set fogEnabled(value: boolean);
  118496. get fogEnabled(): boolean;
  118497. private _fogMode;
  118498. /**
  118499. * Gets or sets the fog mode to use
  118500. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118501. * | mode | value |
  118502. * | --- | --- |
  118503. * | FOGMODE_NONE | 0 |
  118504. * | FOGMODE_EXP | 1 |
  118505. * | FOGMODE_EXP2 | 2 |
  118506. * | FOGMODE_LINEAR | 3 |
  118507. */
  118508. set fogMode(value: number);
  118509. get fogMode(): number;
  118510. /**
  118511. * Gets or sets the fog color to use
  118512. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118513. * (Default is Color3(0.2, 0.2, 0.3))
  118514. */
  118515. fogColor: Color3;
  118516. /**
  118517. * Gets or sets the fog density to use
  118518. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118519. * (Default is 0.1)
  118520. */
  118521. fogDensity: number;
  118522. /**
  118523. * Gets or sets the fog start distance to use
  118524. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118525. * (Default is 0)
  118526. */
  118527. fogStart: number;
  118528. /**
  118529. * Gets or sets the fog end distance to use
  118530. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118531. * (Default is 1000)
  118532. */
  118533. fogEnd: number;
  118534. /**
  118535. * Flag indicating that the frame buffer binding is handled by another component
  118536. */
  118537. prePass: boolean;
  118538. private _shadowsEnabled;
  118539. /**
  118540. * Gets or sets a boolean indicating if shadows are enabled on this scene
  118541. */
  118542. set shadowsEnabled(value: boolean);
  118543. get shadowsEnabled(): boolean;
  118544. private _lightsEnabled;
  118545. /**
  118546. * Gets or sets a boolean indicating if lights are enabled on this scene
  118547. */
  118548. set lightsEnabled(value: boolean);
  118549. get lightsEnabled(): boolean;
  118550. /** All of the active cameras added to this scene. */
  118551. activeCameras: Camera[];
  118552. /** @hidden */
  118553. _activeCamera: Nullable<Camera>;
  118554. /** Gets or sets the current active camera */
  118555. get activeCamera(): Nullable<Camera>;
  118556. set activeCamera(value: Nullable<Camera>);
  118557. private _defaultMaterial;
  118558. /** The default material used on meshes when no material is affected */
  118559. get defaultMaterial(): Material;
  118560. /** The default material used on meshes when no material is affected */
  118561. set defaultMaterial(value: Material);
  118562. private _texturesEnabled;
  118563. /**
  118564. * Gets or sets a boolean indicating if textures are enabled on this scene
  118565. */
  118566. set texturesEnabled(value: boolean);
  118567. get texturesEnabled(): boolean;
  118568. /**
  118569. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  118570. */
  118571. physicsEnabled: boolean;
  118572. /**
  118573. * Gets or sets a boolean indicating if particles are enabled on this scene
  118574. */
  118575. particlesEnabled: boolean;
  118576. /**
  118577. * Gets or sets a boolean indicating if sprites are enabled on this scene
  118578. */
  118579. spritesEnabled: boolean;
  118580. private _skeletonsEnabled;
  118581. /**
  118582. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  118583. */
  118584. set skeletonsEnabled(value: boolean);
  118585. get skeletonsEnabled(): boolean;
  118586. /**
  118587. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  118588. */
  118589. lensFlaresEnabled: boolean;
  118590. /**
  118591. * Gets or sets a boolean indicating if collisions are enabled on this scene
  118592. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118593. */
  118594. collisionsEnabled: boolean;
  118595. private _collisionCoordinator;
  118596. /** @hidden */
  118597. get collisionCoordinator(): ICollisionCoordinator;
  118598. /**
  118599. * Defines the gravity applied to this scene (used only for collisions)
  118600. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118601. */
  118602. gravity: Vector3;
  118603. /**
  118604. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  118605. */
  118606. postProcessesEnabled: boolean;
  118607. /**
  118608. * The list of postprocesses added to the scene
  118609. */
  118610. postProcesses: PostProcess[];
  118611. /**
  118612. * Gets the current postprocess manager
  118613. */
  118614. postProcessManager: PostProcessManager;
  118615. /**
  118616. * Gets or sets a boolean indicating if render targets are enabled on this scene
  118617. */
  118618. renderTargetsEnabled: boolean;
  118619. /**
  118620. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  118621. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  118622. */
  118623. dumpNextRenderTargets: boolean;
  118624. /**
  118625. * The list of user defined render targets added to the scene
  118626. */
  118627. customRenderTargets: RenderTargetTexture[];
  118628. /**
  118629. * Defines if texture loading must be delayed
  118630. * If true, textures will only be loaded when they need to be rendered
  118631. */
  118632. useDelayedTextureLoading: boolean;
  118633. /**
  118634. * Gets the list of meshes imported to the scene through SceneLoader
  118635. */
  118636. importedMeshesFiles: String[];
  118637. /**
  118638. * Gets or sets a boolean indicating if probes are enabled on this scene
  118639. */
  118640. probesEnabled: boolean;
  118641. /**
  118642. * Gets or sets the current offline provider to use to store scene data
  118643. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118644. */
  118645. offlineProvider: IOfflineProvider;
  118646. /**
  118647. * Gets or sets the action manager associated with the scene
  118648. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  118649. */
  118650. actionManager: AbstractActionManager;
  118651. private _meshesForIntersections;
  118652. /**
  118653. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  118654. */
  118655. proceduralTexturesEnabled: boolean;
  118656. private _engine;
  118657. private _totalVertices;
  118658. /** @hidden */
  118659. _activeIndices: PerfCounter;
  118660. /** @hidden */
  118661. _activeParticles: PerfCounter;
  118662. /** @hidden */
  118663. _activeBones: PerfCounter;
  118664. private _animationRatio;
  118665. /** @hidden */
  118666. _animationTimeLast: number;
  118667. /** @hidden */
  118668. _animationTime: number;
  118669. /**
  118670. * Gets or sets a general scale for animation speed
  118671. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  118672. */
  118673. animationTimeScale: number;
  118674. /** @hidden */
  118675. _cachedMaterial: Nullable<Material>;
  118676. /** @hidden */
  118677. _cachedEffect: Nullable<Effect>;
  118678. /** @hidden */
  118679. _cachedVisibility: Nullable<number>;
  118680. private _renderId;
  118681. private _frameId;
  118682. private _executeWhenReadyTimeoutId;
  118683. private _intermediateRendering;
  118684. private _viewUpdateFlag;
  118685. private _projectionUpdateFlag;
  118686. /** @hidden */
  118687. _toBeDisposed: Nullable<IDisposable>[];
  118688. private _activeRequests;
  118689. /** @hidden */
  118690. _pendingData: any[];
  118691. private _isDisposed;
  118692. /**
  118693. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  118694. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  118695. */
  118696. dispatchAllSubMeshesOfActiveMeshes: boolean;
  118697. private _activeMeshes;
  118698. private _processedMaterials;
  118699. private _renderTargets;
  118700. /** @hidden */
  118701. _activeParticleSystems: SmartArray<IParticleSystem>;
  118702. private _activeSkeletons;
  118703. private _softwareSkinnedMeshes;
  118704. private _renderingManager;
  118705. /** @hidden */
  118706. _activeAnimatables: Animatable[];
  118707. private _transformMatrix;
  118708. private _sceneUbo;
  118709. /** @hidden */
  118710. _viewMatrix: Matrix;
  118711. private _projectionMatrix;
  118712. /** @hidden */
  118713. _forcedViewPosition: Nullable<Vector3>;
  118714. /** @hidden */
  118715. _frustumPlanes: Plane[];
  118716. /**
  118717. * Gets the list of frustum planes (built from the active camera)
  118718. */
  118719. get frustumPlanes(): Plane[];
  118720. /**
  118721. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  118722. * This is useful if there are more lights that the maximum simulteanous authorized
  118723. */
  118724. requireLightSorting: boolean;
  118725. /** @hidden */
  118726. readonly useMaterialMeshMap: boolean;
  118727. /** @hidden */
  118728. readonly useClonedMeshMap: boolean;
  118729. private _externalData;
  118730. private _uid;
  118731. /**
  118732. * @hidden
  118733. * Backing store of defined scene components.
  118734. */
  118735. _components: ISceneComponent[];
  118736. /**
  118737. * @hidden
  118738. * Backing store of defined scene components.
  118739. */
  118740. _serializableComponents: ISceneSerializableComponent[];
  118741. /**
  118742. * List of components to register on the next registration step.
  118743. */
  118744. private _transientComponents;
  118745. /**
  118746. * Registers the transient components if needed.
  118747. */
  118748. private _registerTransientComponents;
  118749. /**
  118750. * @hidden
  118751. * Add a component to the scene.
  118752. * Note that the ccomponent could be registered on th next frame if this is called after
  118753. * the register component stage.
  118754. * @param component Defines the component to add to the scene
  118755. */
  118756. _addComponent(component: ISceneComponent): void;
  118757. /**
  118758. * @hidden
  118759. * Gets a component from the scene.
  118760. * @param name defines the name of the component to retrieve
  118761. * @returns the component or null if not present
  118762. */
  118763. _getComponent(name: string): Nullable<ISceneComponent>;
  118764. /**
  118765. * @hidden
  118766. * Defines the actions happening before camera updates.
  118767. */
  118768. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  118769. /**
  118770. * @hidden
  118771. * Defines the actions happening before clear the canvas.
  118772. */
  118773. _beforeClearStage: Stage<SimpleStageAction>;
  118774. /**
  118775. * @hidden
  118776. * Defines the actions when collecting render targets for the frame.
  118777. */
  118778. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118779. /**
  118780. * @hidden
  118781. * Defines the actions happening for one camera in the frame.
  118782. */
  118783. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118784. /**
  118785. * @hidden
  118786. * Defines the actions happening during the per mesh ready checks.
  118787. */
  118788. _isReadyForMeshStage: Stage<MeshStageAction>;
  118789. /**
  118790. * @hidden
  118791. * Defines the actions happening before evaluate active mesh checks.
  118792. */
  118793. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  118794. /**
  118795. * @hidden
  118796. * Defines the actions happening during the evaluate sub mesh checks.
  118797. */
  118798. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  118799. /**
  118800. * @hidden
  118801. * Defines the actions happening during the active mesh stage.
  118802. */
  118803. _activeMeshStage: Stage<ActiveMeshStageAction>;
  118804. /**
  118805. * @hidden
  118806. * Defines the actions happening during the per camera render target step.
  118807. */
  118808. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  118809. /**
  118810. * @hidden
  118811. * Defines the actions happening just before the active camera is drawing.
  118812. */
  118813. _beforeCameraDrawStage: Stage<CameraStageAction>;
  118814. /**
  118815. * @hidden
  118816. * Defines the actions happening just before a render target is drawing.
  118817. */
  118818. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118819. /**
  118820. * @hidden
  118821. * Defines the actions happening just before a rendering group is drawing.
  118822. */
  118823. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118824. /**
  118825. * @hidden
  118826. * Defines the actions happening just before a mesh is drawing.
  118827. */
  118828. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118829. /**
  118830. * @hidden
  118831. * Defines the actions happening just after a mesh has been drawn.
  118832. */
  118833. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118834. /**
  118835. * @hidden
  118836. * Defines the actions happening just after a rendering group has been drawn.
  118837. */
  118838. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118839. /**
  118840. * @hidden
  118841. * Defines the actions happening just after the active camera has been drawn.
  118842. */
  118843. _afterCameraDrawStage: Stage<CameraStageAction>;
  118844. /**
  118845. * @hidden
  118846. * Defines the actions happening just after a render target has been drawn.
  118847. */
  118848. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118849. /**
  118850. * @hidden
  118851. * Defines the actions happening just after rendering all cameras and computing intersections.
  118852. */
  118853. _afterRenderStage: Stage<SimpleStageAction>;
  118854. /**
  118855. * @hidden
  118856. * Defines the actions happening when a pointer move event happens.
  118857. */
  118858. _pointerMoveStage: Stage<PointerMoveStageAction>;
  118859. /**
  118860. * @hidden
  118861. * Defines the actions happening when a pointer down event happens.
  118862. */
  118863. _pointerDownStage: Stage<PointerUpDownStageAction>;
  118864. /**
  118865. * @hidden
  118866. * Defines the actions happening when a pointer up event happens.
  118867. */
  118868. _pointerUpStage: Stage<PointerUpDownStageAction>;
  118869. /**
  118870. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  118871. */
  118872. private geometriesByUniqueId;
  118873. /**
  118874. * Creates a new Scene
  118875. * @param engine defines the engine to use to render this scene
  118876. * @param options defines the scene options
  118877. */
  118878. constructor(engine: Engine, options?: SceneOptions);
  118879. /**
  118880. * Gets a string idenfifying the name of the class
  118881. * @returns "Scene" string
  118882. */
  118883. getClassName(): string;
  118884. private _defaultMeshCandidates;
  118885. /**
  118886. * @hidden
  118887. */
  118888. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118889. private _defaultSubMeshCandidates;
  118890. /**
  118891. * @hidden
  118892. */
  118893. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118894. /**
  118895. * Sets the default candidate providers for the scene.
  118896. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  118897. * and getCollidingSubMeshCandidates to their default function
  118898. */
  118899. setDefaultCandidateProviders(): void;
  118900. /**
  118901. * Gets the mesh that is currently under the pointer
  118902. */
  118903. get meshUnderPointer(): Nullable<AbstractMesh>;
  118904. /**
  118905. * Gets or sets the current on-screen X position of the pointer
  118906. */
  118907. get pointerX(): number;
  118908. set pointerX(value: number);
  118909. /**
  118910. * Gets or sets the current on-screen Y position of the pointer
  118911. */
  118912. get pointerY(): number;
  118913. set pointerY(value: number);
  118914. /**
  118915. * Gets the cached material (ie. the latest rendered one)
  118916. * @returns the cached material
  118917. */
  118918. getCachedMaterial(): Nullable<Material>;
  118919. /**
  118920. * Gets the cached effect (ie. the latest rendered one)
  118921. * @returns the cached effect
  118922. */
  118923. getCachedEffect(): Nullable<Effect>;
  118924. /**
  118925. * Gets the cached visibility state (ie. the latest rendered one)
  118926. * @returns the cached visibility state
  118927. */
  118928. getCachedVisibility(): Nullable<number>;
  118929. /**
  118930. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  118931. * @param material defines the current material
  118932. * @param effect defines the current effect
  118933. * @param visibility defines the current visibility state
  118934. * @returns true if one parameter is not cached
  118935. */
  118936. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  118937. /**
  118938. * Gets the engine associated with the scene
  118939. * @returns an Engine
  118940. */
  118941. getEngine(): Engine;
  118942. /**
  118943. * Gets the total number of vertices rendered per frame
  118944. * @returns the total number of vertices rendered per frame
  118945. */
  118946. getTotalVertices(): number;
  118947. /**
  118948. * Gets the performance counter for total vertices
  118949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118950. */
  118951. get totalVerticesPerfCounter(): PerfCounter;
  118952. /**
  118953. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  118954. * @returns the total number of active indices rendered per frame
  118955. */
  118956. getActiveIndices(): number;
  118957. /**
  118958. * Gets the performance counter for active indices
  118959. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118960. */
  118961. get totalActiveIndicesPerfCounter(): PerfCounter;
  118962. /**
  118963. * Gets the total number of active particles rendered per frame
  118964. * @returns the total number of active particles rendered per frame
  118965. */
  118966. getActiveParticles(): number;
  118967. /**
  118968. * Gets the performance counter for active particles
  118969. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118970. */
  118971. get activeParticlesPerfCounter(): PerfCounter;
  118972. /**
  118973. * Gets the total number of active bones rendered per frame
  118974. * @returns the total number of active bones rendered per frame
  118975. */
  118976. getActiveBones(): number;
  118977. /**
  118978. * Gets the performance counter for active bones
  118979. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118980. */
  118981. get activeBonesPerfCounter(): PerfCounter;
  118982. /**
  118983. * Gets the array of active meshes
  118984. * @returns an array of AbstractMesh
  118985. */
  118986. getActiveMeshes(): SmartArray<AbstractMesh>;
  118987. /**
  118988. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  118989. * @returns a number
  118990. */
  118991. getAnimationRatio(): number;
  118992. /**
  118993. * Gets an unique Id for the current render phase
  118994. * @returns a number
  118995. */
  118996. getRenderId(): number;
  118997. /**
  118998. * Gets an unique Id for the current frame
  118999. * @returns a number
  119000. */
  119001. getFrameId(): number;
  119002. /** Call this function if you want to manually increment the render Id*/
  119003. incrementRenderId(): void;
  119004. private _createUbo;
  119005. /**
  119006. * Use this method to simulate a pointer move on a mesh
  119007. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119008. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119009. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119010. * @returns the current scene
  119011. */
  119012. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119013. /**
  119014. * Use this method to simulate a pointer down on a mesh
  119015. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119016. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119017. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119018. * @returns the current scene
  119019. */
  119020. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119021. /**
  119022. * Use this method to simulate a pointer up on a mesh
  119023. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119024. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119025. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119026. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119027. * @returns the current scene
  119028. */
  119029. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119030. /**
  119031. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119032. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119033. * @returns true if the pointer was captured
  119034. */
  119035. isPointerCaptured(pointerId?: number): boolean;
  119036. /**
  119037. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119038. * @param attachUp defines if you want to attach events to pointerup
  119039. * @param attachDown defines if you want to attach events to pointerdown
  119040. * @param attachMove defines if you want to attach events to pointermove
  119041. */
  119042. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119043. /** Detaches all event handlers*/
  119044. detachControl(): void;
  119045. /**
  119046. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119047. * Delay loaded resources are not taking in account
  119048. * @return true if all required resources are ready
  119049. */
  119050. isReady(): boolean;
  119051. /** Resets all cached information relative to material (including effect and visibility) */
  119052. resetCachedMaterial(): void;
  119053. /**
  119054. * Registers a function to be called before every frame render
  119055. * @param func defines the function to register
  119056. */
  119057. registerBeforeRender(func: () => void): void;
  119058. /**
  119059. * Unregisters a function called before every frame render
  119060. * @param func defines the function to unregister
  119061. */
  119062. unregisterBeforeRender(func: () => void): void;
  119063. /**
  119064. * Registers a function to be called after every frame render
  119065. * @param func defines the function to register
  119066. */
  119067. registerAfterRender(func: () => void): void;
  119068. /**
  119069. * Unregisters a function called after every frame render
  119070. * @param func defines the function to unregister
  119071. */
  119072. unregisterAfterRender(func: () => void): void;
  119073. private _executeOnceBeforeRender;
  119074. /**
  119075. * The provided function will run before render once and will be disposed afterwards.
  119076. * A timeout delay can be provided so that the function will be executed in N ms.
  119077. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119078. * @param func The function to be executed.
  119079. * @param timeout optional delay in ms
  119080. */
  119081. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119082. /** @hidden */
  119083. _addPendingData(data: any): void;
  119084. /** @hidden */
  119085. _removePendingData(data: any): void;
  119086. /**
  119087. * Returns the number of items waiting to be loaded
  119088. * @returns the number of items waiting to be loaded
  119089. */
  119090. getWaitingItemsCount(): number;
  119091. /**
  119092. * Returns a boolean indicating if the scene is still loading data
  119093. */
  119094. get isLoading(): boolean;
  119095. /**
  119096. * Registers a function to be executed when the scene is ready
  119097. * @param {Function} func - the function to be executed
  119098. */
  119099. executeWhenReady(func: () => void): void;
  119100. /**
  119101. * Returns a promise that resolves when the scene is ready
  119102. * @returns A promise that resolves when the scene is ready
  119103. */
  119104. whenReadyAsync(): Promise<void>;
  119105. /** @hidden */
  119106. _checkIsReady(): void;
  119107. /**
  119108. * Gets all animatable attached to the scene
  119109. */
  119110. get animatables(): Animatable[];
  119111. /**
  119112. * Resets the last animation time frame.
  119113. * Useful to override when animations start running when loading a scene for the first time.
  119114. */
  119115. resetLastAnimationTimeFrame(): void;
  119116. /**
  119117. * Gets the current view matrix
  119118. * @returns a Matrix
  119119. */
  119120. getViewMatrix(): Matrix;
  119121. /**
  119122. * Gets the current projection matrix
  119123. * @returns a Matrix
  119124. */
  119125. getProjectionMatrix(): Matrix;
  119126. /**
  119127. * Gets the current transform matrix
  119128. * @returns a Matrix made of View * Projection
  119129. */
  119130. getTransformMatrix(): Matrix;
  119131. /**
  119132. * Sets the current transform matrix
  119133. * @param viewL defines the View matrix to use
  119134. * @param projectionL defines the Projection matrix to use
  119135. * @param viewR defines the right View matrix to use (if provided)
  119136. * @param projectionR defines the right Projection matrix to use (if provided)
  119137. */
  119138. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  119139. /**
  119140. * Gets the uniform buffer used to store scene data
  119141. * @returns a UniformBuffer
  119142. */
  119143. getSceneUniformBuffer(): UniformBuffer;
  119144. /**
  119145. * Gets an unique (relatively to the current scene) Id
  119146. * @returns an unique number for the scene
  119147. */
  119148. getUniqueId(): number;
  119149. /**
  119150. * Add a mesh to the list of scene's meshes
  119151. * @param newMesh defines the mesh to add
  119152. * @param recursive if all child meshes should also be added to the scene
  119153. */
  119154. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  119155. /**
  119156. * Remove a mesh for the list of scene's meshes
  119157. * @param toRemove defines the mesh to remove
  119158. * @param recursive if all child meshes should also be removed from the scene
  119159. * @returns the index where the mesh was in the mesh list
  119160. */
  119161. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  119162. /**
  119163. * Add a transform node to the list of scene's transform nodes
  119164. * @param newTransformNode defines the transform node to add
  119165. */
  119166. addTransformNode(newTransformNode: TransformNode): void;
  119167. /**
  119168. * Remove a transform node for the list of scene's transform nodes
  119169. * @param toRemove defines the transform node to remove
  119170. * @returns the index where the transform node was in the transform node list
  119171. */
  119172. removeTransformNode(toRemove: TransformNode): number;
  119173. /**
  119174. * Remove a skeleton for the list of scene's skeletons
  119175. * @param toRemove defines the skeleton to remove
  119176. * @returns the index where the skeleton was in the skeleton list
  119177. */
  119178. removeSkeleton(toRemove: Skeleton): number;
  119179. /**
  119180. * Remove a morph target for the list of scene's morph targets
  119181. * @param toRemove defines the morph target to remove
  119182. * @returns the index where the morph target was in the morph target list
  119183. */
  119184. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119185. /**
  119186. * Remove a light for the list of scene's lights
  119187. * @param toRemove defines the light to remove
  119188. * @returns the index where the light was in the light list
  119189. */
  119190. removeLight(toRemove: Light): number;
  119191. /**
  119192. * Remove a camera for the list of scene's cameras
  119193. * @param toRemove defines the camera to remove
  119194. * @returns the index where the camera was in the camera list
  119195. */
  119196. removeCamera(toRemove: Camera): number;
  119197. /**
  119198. * Remove a particle system for the list of scene's particle systems
  119199. * @param toRemove defines the particle system to remove
  119200. * @returns the index where the particle system was in the particle system list
  119201. */
  119202. removeParticleSystem(toRemove: IParticleSystem): number;
  119203. /**
  119204. * Remove a animation for the list of scene's animations
  119205. * @param toRemove defines the animation to remove
  119206. * @returns the index where the animation was in the animation list
  119207. */
  119208. removeAnimation(toRemove: Animation): number;
  119209. /**
  119210. * Will stop the animation of the given target
  119211. * @param target - the target
  119212. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119213. * @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)
  119214. */
  119215. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119216. /**
  119217. * Removes the given animation group from this scene.
  119218. * @param toRemove The animation group to remove
  119219. * @returns The index of the removed animation group
  119220. */
  119221. removeAnimationGroup(toRemove: AnimationGroup): number;
  119222. /**
  119223. * Removes the given multi-material from this scene.
  119224. * @param toRemove The multi-material to remove
  119225. * @returns The index of the removed multi-material
  119226. */
  119227. removeMultiMaterial(toRemove: MultiMaterial): number;
  119228. /**
  119229. * Removes the given material from this scene.
  119230. * @param toRemove The material to remove
  119231. * @returns The index of the removed material
  119232. */
  119233. removeMaterial(toRemove: Material): number;
  119234. /**
  119235. * Removes the given action manager from this scene.
  119236. * @param toRemove The action manager to remove
  119237. * @returns The index of the removed action manager
  119238. */
  119239. removeActionManager(toRemove: AbstractActionManager): number;
  119240. /**
  119241. * Removes the given texture from this scene.
  119242. * @param toRemove The texture to remove
  119243. * @returns The index of the removed texture
  119244. */
  119245. removeTexture(toRemove: BaseTexture): number;
  119246. /**
  119247. * Adds the given light to this scene
  119248. * @param newLight The light to add
  119249. */
  119250. addLight(newLight: Light): void;
  119251. /**
  119252. * Sorts the list list based on light priorities
  119253. */
  119254. sortLightsByPriority(): void;
  119255. /**
  119256. * Adds the given camera to this scene
  119257. * @param newCamera The camera to add
  119258. */
  119259. addCamera(newCamera: Camera): void;
  119260. /**
  119261. * Adds the given skeleton to this scene
  119262. * @param newSkeleton The skeleton to add
  119263. */
  119264. addSkeleton(newSkeleton: Skeleton): void;
  119265. /**
  119266. * Adds the given particle system to this scene
  119267. * @param newParticleSystem The particle system to add
  119268. */
  119269. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119270. /**
  119271. * Adds the given animation to this scene
  119272. * @param newAnimation The animation to add
  119273. */
  119274. addAnimation(newAnimation: Animation): void;
  119275. /**
  119276. * Adds the given animation group to this scene.
  119277. * @param newAnimationGroup The animation group to add
  119278. */
  119279. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119280. /**
  119281. * Adds the given multi-material to this scene
  119282. * @param newMultiMaterial The multi-material to add
  119283. */
  119284. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119285. /**
  119286. * Adds the given material to this scene
  119287. * @param newMaterial The material to add
  119288. */
  119289. addMaterial(newMaterial: Material): void;
  119290. /**
  119291. * Adds the given morph target to this scene
  119292. * @param newMorphTargetManager The morph target to add
  119293. */
  119294. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119295. /**
  119296. * Adds the given geometry to this scene
  119297. * @param newGeometry The geometry to add
  119298. */
  119299. addGeometry(newGeometry: Geometry): void;
  119300. /**
  119301. * Adds the given action manager to this scene
  119302. * @param newActionManager The action manager to add
  119303. */
  119304. addActionManager(newActionManager: AbstractActionManager): void;
  119305. /**
  119306. * Adds the given texture to this scene.
  119307. * @param newTexture The texture to add
  119308. */
  119309. addTexture(newTexture: BaseTexture): void;
  119310. /**
  119311. * Switch active camera
  119312. * @param newCamera defines the new active camera
  119313. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119314. */
  119315. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119316. /**
  119317. * sets the active camera of the scene using its ID
  119318. * @param id defines the camera's ID
  119319. * @return the new active camera or null if none found.
  119320. */
  119321. setActiveCameraByID(id: string): Nullable<Camera>;
  119322. /**
  119323. * sets the active camera of the scene using its name
  119324. * @param name defines the camera's name
  119325. * @returns the new active camera or null if none found.
  119326. */
  119327. setActiveCameraByName(name: string): Nullable<Camera>;
  119328. /**
  119329. * get an animation group using its name
  119330. * @param name defines the material's name
  119331. * @return the animation group or null if none found.
  119332. */
  119333. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119334. /**
  119335. * Get a material using its unique id
  119336. * @param uniqueId defines the material's unique id
  119337. * @return the material or null if none found.
  119338. */
  119339. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119340. /**
  119341. * get a material using its id
  119342. * @param id defines the material's ID
  119343. * @return the material or null if none found.
  119344. */
  119345. getMaterialByID(id: string): Nullable<Material>;
  119346. /**
  119347. * Gets a the last added material using a given id
  119348. * @param id defines the material's ID
  119349. * @return the last material with the given id or null if none found.
  119350. */
  119351. getLastMaterialByID(id: string): Nullable<Material>;
  119352. /**
  119353. * Gets a material using its name
  119354. * @param name defines the material's name
  119355. * @return the material or null if none found.
  119356. */
  119357. getMaterialByName(name: string): Nullable<Material>;
  119358. /**
  119359. * Get a texture using its unique id
  119360. * @param uniqueId defines the texture's unique id
  119361. * @return the texture or null if none found.
  119362. */
  119363. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119364. /**
  119365. * Gets a camera using its id
  119366. * @param id defines the id to look for
  119367. * @returns the camera or null if not found
  119368. */
  119369. getCameraByID(id: string): Nullable<Camera>;
  119370. /**
  119371. * Gets a camera using its unique id
  119372. * @param uniqueId defines the unique id to look for
  119373. * @returns the camera or null if not found
  119374. */
  119375. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119376. /**
  119377. * Gets a camera using its name
  119378. * @param name defines the camera's name
  119379. * @return the camera or null if none found.
  119380. */
  119381. getCameraByName(name: string): Nullable<Camera>;
  119382. /**
  119383. * Gets a bone using its id
  119384. * @param id defines the bone's id
  119385. * @return the bone or null if not found
  119386. */
  119387. getBoneByID(id: string): Nullable<Bone>;
  119388. /**
  119389. * Gets a bone using its id
  119390. * @param name defines the bone's name
  119391. * @return the bone or null if not found
  119392. */
  119393. getBoneByName(name: string): Nullable<Bone>;
  119394. /**
  119395. * Gets a light node using its name
  119396. * @param name defines the the light's name
  119397. * @return the light or null if none found.
  119398. */
  119399. getLightByName(name: string): Nullable<Light>;
  119400. /**
  119401. * Gets a light node using its id
  119402. * @param id defines the light's id
  119403. * @return the light or null if none found.
  119404. */
  119405. getLightByID(id: string): Nullable<Light>;
  119406. /**
  119407. * Gets a light node using its scene-generated unique ID
  119408. * @param uniqueId defines the light's unique id
  119409. * @return the light or null if none found.
  119410. */
  119411. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119412. /**
  119413. * Gets a particle system by id
  119414. * @param id defines the particle system id
  119415. * @return the corresponding system or null if none found
  119416. */
  119417. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119418. /**
  119419. * Gets a geometry using its ID
  119420. * @param id defines the geometry's id
  119421. * @return the geometry or null if none found.
  119422. */
  119423. getGeometryByID(id: string): Nullable<Geometry>;
  119424. private _getGeometryByUniqueID;
  119425. /**
  119426. * Add a new geometry to this scene
  119427. * @param geometry defines the geometry to be added to the scene.
  119428. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119429. * @return a boolean defining if the geometry was added or not
  119430. */
  119431. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119432. /**
  119433. * Removes an existing geometry
  119434. * @param geometry defines the geometry to be removed from the scene
  119435. * @return a boolean defining if the geometry was removed or not
  119436. */
  119437. removeGeometry(geometry: Geometry): boolean;
  119438. /**
  119439. * Gets the list of geometries attached to the scene
  119440. * @returns an array of Geometry
  119441. */
  119442. getGeometries(): Geometry[];
  119443. /**
  119444. * Gets the first added mesh found of a given ID
  119445. * @param id defines the id to search for
  119446. * @return the mesh found or null if not found at all
  119447. */
  119448. getMeshByID(id: string): Nullable<AbstractMesh>;
  119449. /**
  119450. * Gets a list of meshes using their id
  119451. * @param id defines the id to search for
  119452. * @returns a list of meshes
  119453. */
  119454. getMeshesByID(id: string): Array<AbstractMesh>;
  119455. /**
  119456. * Gets the first added transform node found of a given ID
  119457. * @param id defines the id to search for
  119458. * @return the found transform node or null if not found at all.
  119459. */
  119460. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119461. /**
  119462. * Gets a transform node with its auto-generated unique id
  119463. * @param uniqueId efines the unique id to search for
  119464. * @return the found transform node or null if not found at all.
  119465. */
  119466. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119467. /**
  119468. * Gets a list of transform nodes using their id
  119469. * @param id defines the id to search for
  119470. * @returns a list of transform nodes
  119471. */
  119472. getTransformNodesByID(id: string): Array<TransformNode>;
  119473. /**
  119474. * Gets a mesh with its auto-generated unique id
  119475. * @param uniqueId defines the unique id to search for
  119476. * @return the found mesh or null if not found at all.
  119477. */
  119478. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  119479. /**
  119480. * Gets a the last added mesh using a given id
  119481. * @param id defines the id to search for
  119482. * @return the found mesh or null if not found at all.
  119483. */
  119484. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  119485. /**
  119486. * Gets a the last added node (Mesh, Camera, Light) using a given id
  119487. * @param id defines the id to search for
  119488. * @return the found node or null if not found at all
  119489. */
  119490. getLastEntryByID(id: string): Nullable<Node>;
  119491. /**
  119492. * Gets a node (Mesh, Camera, Light) using a given id
  119493. * @param id defines the id to search for
  119494. * @return the found node or null if not found at all
  119495. */
  119496. getNodeByID(id: string): Nullable<Node>;
  119497. /**
  119498. * Gets a node (Mesh, Camera, Light) using a given name
  119499. * @param name defines the name to search for
  119500. * @return the found node or null if not found at all.
  119501. */
  119502. getNodeByName(name: string): Nullable<Node>;
  119503. /**
  119504. * Gets a mesh using a given name
  119505. * @param name defines the name to search for
  119506. * @return the found mesh or null if not found at all.
  119507. */
  119508. getMeshByName(name: string): Nullable<AbstractMesh>;
  119509. /**
  119510. * Gets a transform node using a given name
  119511. * @param name defines the name to search for
  119512. * @return the found transform node or null if not found at all.
  119513. */
  119514. getTransformNodeByName(name: string): Nullable<TransformNode>;
  119515. /**
  119516. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  119517. * @param id defines the id to search for
  119518. * @return the found skeleton or null if not found at all.
  119519. */
  119520. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  119521. /**
  119522. * Gets a skeleton using a given auto generated unique id
  119523. * @param uniqueId defines the unique id to search for
  119524. * @return the found skeleton or null if not found at all.
  119525. */
  119526. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  119527. /**
  119528. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  119529. * @param id defines the id to search for
  119530. * @return the found skeleton or null if not found at all.
  119531. */
  119532. getSkeletonById(id: string): Nullable<Skeleton>;
  119533. /**
  119534. * Gets a skeleton using a given name
  119535. * @param name defines the name to search for
  119536. * @return the found skeleton or null if not found at all.
  119537. */
  119538. getSkeletonByName(name: string): Nullable<Skeleton>;
  119539. /**
  119540. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  119541. * @param id defines the id to search for
  119542. * @return the found morph target manager or null if not found at all.
  119543. */
  119544. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  119545. /**
  119546. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  119547. * @param id defines the id to search for
  119548. * @return the found morph target or null if not found at all.
  119549. */
  119550. getMorphTargetById(id: string): Nullable<MorphTarget>;
  119551. /**
  119552. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  119553. * @param name defines the name to search for
  119554. * @return the found morph target or null if not found at all.
  119555. */
  119556. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  119557. /**
  119558. * Gets a boolean indicating if the given mesh is active
  119559. * @param mesh defines the mesh to look for
  119560. * @returns true if the mesh is in the active list
  119561. */
  119562. isActiveMesh(mesh: AbstractMesh): boolean;
  119563. /**
  119564. * Return a unique id as a string which can serve as an identifier for the scene
  119565. */
  119566. get uid(): string;
  119567. /**
  119568. * Add an externaly attached data from its key.
  119569. * This method call will fail and return false, if such key already exists.
  119570. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  119571. * @param key the unique key that identifies the data
  119572. * @param data the data object to associate to the key for this Engine instance
  119573. * @return true if no such key were already present and the data was added successfully, false otherwise
  119574. */
  119575. addExternalData<T>(key: string, data: T): boolean;
  119576. /**
  119577. * Get an externaly attached data from its key
  119578. * @param key the unique key that identifies the data
  119579. * @return the associated data, if present (can be null), or undefined if not present
  119580. */
  119581. getExternalData<T>(key: string): Nullable<T>;
  119582. /**
  119583. * Get an externaly attached data from its key, create it using a factory if it's not already present
  119584. * @param key the unique key that identifies the data
  119585. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  119586. * @return the associated data, can be null if the factory returned null.
  119587. */
  119588. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  119589. /**
  119590. * Remove an externaly attached data from the Engine instance
  119591. * @param key the unique key that identifies the data
  119592. * @return true if the data was successfully removed, false if it doesn't exist
  119593. */
  119594. removeExternalData(key: string): boolean;
  119595. private _evaluateSubMesh;
  119596. /**
  119597. * Clear the processed materials smart array preventing retention point in material dispose.
  119598. */
  119599. freeProcessedMaterials(): void;
  119600. private _preventFreeActiveMeshesAndRenderingGroups;
  119601. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  119602. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  119603. * when disposing several meshes in a row or a hierarchy of meshes.
  119604. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  119605. */
  119606. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  119607. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  119608. /**
  119609. * Clear the active meshes smart array preventing retention point in mesh dispose.
  119610. */
  119611. freeActiveMeshes(): void;
  119612. /**
  119613. * Clear the info related to rendering groups preventing retention points during dispose.
  119614. */
  119615. freeRenderingGroups(): void;
  119616. /** @hidden */
  119617. _isInIntermediateRendering(): boolean;
  119618. /**
  119619. * Lambda returning the list of potentially active meshes.
  119620. */
  119621. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  119622. /**
  119623. * Lambda returning the list of potentially active sub meshes.
  119624. */
  119625. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  119626. /**
  119627. * Lambda returning the list of potentially intersecting sub meshes.
  119628. */
  119629. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  119630. /**
  119631. * Lambda returning the list of potentially colliding sub meshes.
  119632. */
  119633. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  119634. private _activeMeshesFrozen;
  119635. private _skipEvaluateActiveMeshesCompletely;
  119636. /**
  119637. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  119638. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  119639. * @returns the current scene
  119640. */
  119641. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  119642. /**
  119643. * Use this function to restart evaluating active meshes on every frame
  119644. * @returns the current scene
  119645. */
  119646. unfreezeActiveMeshes(): Scene;
  119647. private _evaluateActiveMeshes;
  119648. private _activeMesh;
  119649. /**
  119650. * Update the transform matrix to update from the current active camera
  119651. * @param force defines a boolean used to force the update even if cache is up to date
  119652. */
  119653. updateTransformMatrix(force?: boolean): void;
  119654. private _bindFrameBuffer;
  119655. /** @hidden */
  119656. _allowPostProcessClearColor: boolean;
  119657. /** @hidden */
  119658. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  119659. private _processSubCameras;
  119660. private _checkIntersections;
  119661. /** @hidden */
  119662. _advancePhysicsEngineStep(step: number): void;
  119663. /**
  119664. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  119665. */
  119666. getDeterministicFrameTime: () => number;
  119667. /** @hidden */
  119668. _animate(): void;
  119669. /** Execute all animations (for a frame) */
  119670. animate(): void;
  119671. /**
  119672. * Render the scene
  119673. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  119674. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  119675. */
  119676. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  119677. /**
  119678. * Freeze all materials
  119679. * A frozen material will not be updatable but should be faster to render
  119680. */
  119681. freezeMaterials(): void;
  119682. /**
  119683. * Unfreeze all materials
  119684. * A frozen material will not be updatable but should be faster to render
  119685. */
  119686. unfreezeMaterials(): void;
  119687. /**
  119688. * Releases all held ressources
  119689. */
  119690. dispose(): void;
  119691. /**
  119692. * Gets if the scene is already disposed
  119693. */
  119694. get isDisposed(): boolean;
  119695. /**
  119696. * Call this function to reduce memory footprint of the scene.
  119697. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  119698. */
  119699. clearCachedVertexData(): void;
  119700. /**
  119701. * This function will remove the local cached buffer data from texture.
  119702. * It will save memory but will prevent the texture from being rebuilt
  119703. */
  119704. cleanCachedTextureBuffer(): void;
  119705. /**
  119706. * Get the world extend vectors with an optional filter
  119707. *
  119708. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  119709. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  119710. */
  119711. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  119712. min: Vector3;
  119713. max: Vector3;
  119714. };
  119715. /**
  119716. * Creates a ray that can be used to pick in the scene
  119717. * @param x defines the x coordinate of the origin (on-screen)
  119718. * @param y defines the y coordinate of the origin (on-screen)
  119719. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119720. * @param camera defines the camera to use for the picking
  119721. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119722. * @returns a Ray
  119723. */
  119724. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  119725. /**
  119726. * Creates a ray that can be used to pick in the scene
  119727. * @param x defines the x coordinate of the origin (on-screen)
  119728. * @param y defines the y coordinate of the origin (on-screen)
  119729. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119730. * @param result defines the ray where to store the picking ray
  119731. * @param camera defines the camera to use for the picking
  119732. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119733. * @returns the current scene
  119734. */
  119735. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  119736. /**
  119737. * Creates a ray that can be used to pick in the scene
  119738. * @param x defines the x coordinate of the origin (on-screen)
  119739. * @param y defines the y coordinate of the origin (on-screen)
  119740. * @param camera defines the camera to use for the picking
  119741. * @returns a Ray
  119742. */
  119743. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  119744. /**
  119745. * Creates a ray that can be used to pick in the scene
  119746. * @param x defines the x coordinate of the origin (on-screen)
  119747. * @param y defines the y coordinate of the origin (on-screen)
  119748. * @param result defines the ray where to store the picking ray
  119749. * @param camera defines the camera to use for the picking
  119750. * @returns the current scene
  119751. */
  119752. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  119753. /** Launch a ray to try to pick a mesh in the scene
  119754. * @param x position on screen
  119755. * @param y position on screen
  119756. * @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
  119757. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119758. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119760. * @returns a PickingInfo
  119761. */
  119762. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119763. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  119764. * @param x position on screen
  119765. * @param y position on screen
  119766. * @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
  119767. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119768. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119769. * @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)
  119770. */
  119771. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  119772. /** Use the given ray to pick a mesh in the scene
  119773. * @param ray The ray to use to pick meshes
  119774. * @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
  119775. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119776. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119777. * @returns a PickingInfo
  119778. */
  119779. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119780. /**
  119781. * Launch a ray to try to pick a mesh in the scene
  119782. * @param x X position on screen
  119783. * @param y Y position on screen
  119784. * @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
  119785. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119786. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119787. * @returns an array of PickingInfo
  119788. */
  119789. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119790. /**
  119791. * Launch a ray to try to pick a mesh in the scene
  119792. * @param ray Ray to use
  119793. * @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
  119794. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119795. * @returns an array of PickingInfo
  119796. */
  119797. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119798. /**
  119799. * Force the value of meshUnderPointer
  119800. * @param mesh defines the mesh to use
  119801. */
  119802. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  119803. /**
  119804. * Gets the mesh under the pointer
  119805. * @returns a Mesh or null if no mesh is under the pointer
  119806. */
  119807. getPointerOverMesh(): Nullable<AbstractMesh>;
  119808. /** @hidden */
  119809. _rebuildGeometries(): void;
  119810. /** @hidden */
  119811. _rebuildTextures(): void;
  119812. private _getByTags;
  119813. /**
  119814. * Get a list of meshes by tags
  119815. * @param tagsQuery defines the tags query to use
  119816. * @param forEach defines a predicate used to filter results
  119817. * @returns an array of Mesh
  119818. */
  119819. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  119820. /**
  119821. * Get a list of cameras by tags
  119822. * @param tagsQuery defines the tags query to use
  119823. * @param forEach defines a predicate used to filter results
  119824. * @returns an array of Camera
  119825. */
  119826. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  119827. /**
  119828. * Get a list of lights by tags
  119829. * @param tagsQuery defines the tags query to use
  119830. * @param forEach defines a predicate used to filter results
  119831. * @returns an array of Light
  119832. */
  119833. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  119834. /**
  119835. * Get a list of materials by tags
  119836. * @param tagsQuery defines the tags query to use
  119837. * @param forEach defines a predicate used to filter results
  119838. * @returns an array of Material
  119839. */
  119840. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  119841. /**
  119842. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119843. * This allowed control for front to back rendering or reversly depending of the special needs.
  119844. *
  119845. * @param renderingGroupId The rendering group id corresponding to its index
  119846. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119847. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119848. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119849. */
  119850. 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;
  119851. /**
  119852. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119853. *
  119854. * @param renderingGroupId The rendering group id corresponding to its index
  119855. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119856. * @param depth Automatically clears depth between groups if true and autoClear is true.
  119857. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  119858. */
  119859. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  119860. /**
  119861. * Gets the current auto clear configuration for one rendering group of the rendering
  119862. * manager.
  119863. * @param index the rendering group index to get the information for
  119864. * @returns The auto clear setup for the requested rendering group
  119865. */
  119866. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  119867. private _blockMaterialDirtyMechanism;
  119868. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  119869. get blockMaterialDirtyMechanism(): boolean;
  119870. set blockMaterialDirtyMechanism(value: boolean);
  119871. /**
  119872. * Will flag all materials as dirty to trigger new shader compilation
  119873. * @param flag defines the flag used to specify which material part must be marked as dirty
  119874. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  119875. */
  119876. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  119877. /** @hidden */
  119878. _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;
  119879. /** @hidden */
  119880. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119881. /** @hidden */
  119882. _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;
  119883. /** @hidden */
  119884. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  119885. /** @hidden */
  119886. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119887. /** @hidden */
  119888. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119889. }
  119890. }
  119891. declare module BABYLON {
  119892. /**
  119893. * Set of assets to keep when moving a scene into an asset container.
  119894. */
  119895. export class KeepAssets extends AbstractScene {
  119896. }
  119897. /**
  119898. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  119899. */
  119900. export class InstantiatedEntries {
  119901. /**
  119902. * List of new root nodes (eg. nodes with no parent)
  119903. */
  119904. rootNodes: TransformNode[];
  119905. /**
  119906. * List of new skeletons
  119907. */
  119908. skeletons: Skeleton[];
  119909. /**
  119910. * List of new animation groups
  119911. */
  119912. animationGroups: AnimationGroup[];
  119913. }
  119914. /**
  119915. * Container with a set of assets that can be added or removed from a scene.
  119916. */
  119917. export class AssetContainer extends AbstractScene {
  119918. private _wasAddedToScene;
  119919. /**
  119920. * The scene the AssetContainer belongs to.
  119921. */
  119922. scene: Scene;
  119923. /**
  119924. * Instantiates an AssetContainer.
  119925. * @param scene The scene the AssetContainer belongs to.
  119926. */
  119927. constructor(scene: Scene);
  119928. /**
  119929. * Instantiate or clone all meshes and add the new ones to the scene.
  119930. * Skeletons and animation groups will all be cloned
  119931. * @param nameFunction defines an optional function used to get new names for clones
  119932. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  119933. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  119934. */
  119935. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  119936. /**
  119937. * Adds all the assets from the container to the scene.
  119938. */
  119939. addAllToScene(): void;
  119940. /**
  119941. * Removes all the assets in the container from the scene
  119942. */
  119943. removeAllFromScene(): void;
  119944. /**
  119945. * Disposes all the assets in the container
  119946. */
  119947. dispose(): void;
  119948. private _moveAssets;
  119949. /**
  119950. * Removes all the assets contained in the scene and adds them to the container.
  119951. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  119952. */
  119953. moveAllFromScene(keepAssets?: KeepAssets): void;
  119954. /**
  119955. * 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.
  119956. * @returns the root mesh
  119957. */
  119958. createRootMesh(): Mesh;
  119959. /**
  119960. * Merge animations (direct and animation groups) from this asset container into a scene
  119961. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119962. * @param animatables set of animatables to retarget to a node from the scene
  119963. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  119964. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  119965. */
  119966. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  119967. }
  119968. }
  119969. declare module BABYLON {
  119970. /**
  119971. * Defines how the parser contract is defined.
  119972. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  119973. */
  119974. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  119975. /**
  119976. * Defines how the individual parser contract is defined.
  119977. * These parser can parse an individual asset
  119978. */
  119979. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  119980. /**
  119981. * Base class of the scene acting as a container for the different elements composing a scene.
  119982. * This class is dynamically extended by the different components of the scene increasing
  119983. * flexibility and reducing coupling
  119984. */
  119985. export abstract class AbstractScene {
  119986. /**
  119987. * Stores the list of available parsers in the application.
  119988. */
  119989. private static _BabylonFileParsers;
  119990. /**
  119991. * Stores the list of available individual parsers in the application.
  119992. */
  119993. private static _IndividualBabylonFileParsers;
  119994. /**
  119995. * Adds a parser in the list of available ones
  119996. * @param name Defines the name of the parser
  119997. * @param parser Defines the parser to add
  119998. */
  119999. static AddParser(name: string, parser: BabylonFileParser): void;
  120000. /**
  120001. * Gets a general parser from the list of avaialble ones
  120002. * @param name Defines the name of the parser
  120003. * @returns the requested parser or null
  120004. */
  120005. static GetParser(name: string): Nullable<BabylonFileParser>;
  120006. /**
  120007. * Adds n individual parser in the list of available ones
  120008. * @param name Defines the name of the parser
  120009. * @param parser Defines the parser to add
  120010. */
  120011. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120012. /**
  120013. * Gets an individual parser from the list of avaialble ones
  120014. * @param name Defines the name of the parser
  120015. * @returns the requested parser or null
  120016. */
  120017. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120018. /**
  120019. * Parser json data and populate both a scene and its associated container object
  120020. * @param jsonData Defines the data to parse
  120021. * @param scene Defines the scene to parse the data for
  120022. * @param container Defines the container attached to the parsing sequence
  120023. * @param rootUrl Defines the root url of the data
  120024. */
  120025. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120026. /**
  120027. * Gets the list of root nodes (ie. nodes with no parent)
  120028. */
  120029. rootNodes: Node[];
  120030. /** All of the cameras added to this scene
  120031. * @see https://doc.babylonjs.com/babylon101/cameras
  120032. */
  120033. cameras: Camera[];
  120034. /**
  120035. * All of the lights added to this scene
  120036. * @see https://doc.babylonjs.com/babylon101/lights
  120037. */
  120038. lights: Light[];
  120039. /**
  120040. * All of the (abstract) meshes added to this scene
  120041. */
  120042. meshes: AbstractMesh[];
  120043. /**
  120044. * The list of skeletons added to the scene
  120045. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120046. */
  120047. skeletons: Skeleton[];
  120048. /**
  120049. * All of the particle systems added to this scene
  120050. * @see https://doc.babylonjs.com/babylon101/particles
  120051. */
  120052. particleSystems: IParticleSystem[];
  120053. /**
  120054. * Gets a list of Animations associated with the scene
  120055. */
  120056. animations: Animation[];
  120057. /**
  120058. * All of the animation groups added to this scene
  120059. * @see https://doc.babylonjs.com/how_to/group
  120060. */
  120061. animationGroups: AnimationGroup[];
  120062. /**
  120063. * All of the multi-materials added to this scene
  120064. * @see https://doc.babylonjs.com/how_to/multi_materials
  120065. */
  120066. multiMaterials: MultiMaterial[];
  120067. /**
  120068. * All of the materials added to this scene
  120069. * In the context of a Scene, it is not supposed to be modified manually.
  120070. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120071. * Note also that the order of the Material within the array is not significant and might change.
  120072. * @see https://doc.babylonjs.com/babylon101/materials
  120073. */
  120074. materials: Material[];
  120075. /**
  120076. * The list of morph target managers added to the scene
  120077. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120078. */
  120079. morphTargetManagers: MorphTargetManager[];
  120080. /**
  120081. * The list of geometries used in the scene.
  120082. */
  120083. geometries: Geometry[];
  120084. /**
  120085. * All of the tranform nodes added to this scene
  120086. * In the context of a Scene, it is not supposed to be modified manually.
  120087. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120088. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  120089. * @see https://doc.babylonjs.com/how_to/transformnode
  120090. */
  120091. transformNodes: TransformNode[];
  120092. /**
  120093. * ActionManagers available on the scene.
  120094. */
  120095. actionManagers: AbstractActionManager[];
  120096. /**
  120097. * Textures to keep.
  120098. */
  120099. textures: BaseTexture[];
  120100. /**
  120101. * Environment texture for the scene
  120102. */
  120103. environmentTexture: Nullable<BaseTexture>;
  120104. /**
  120105. * @returns all meshes, lights, cameras, transformNodes and bones
  120106. */
  120107. getNodes(): Array<Node>;
  120108. }
  120109. }
  120110. declare module BABYLON {
  120111. /**
  120112. * Interface used to define options for Sound class
  120113. */
  120114. export interface ISoundOptions {
  120115. /**
  120116. * Does the sound autoplay once loaded.
  120117. */
  120118. autoplay?: boolean;
  120119. /**
  120120. * Does the sound loop after it finishes playing once.
  120121. */
  120122. loop?: boolean;
  120123. /**
  120124. * Sound's volume
  120125. */
  120126. volume?: number;
  120127. /**
  120128. * Is it a spatial sound?
  120129. */
  120130. spatialSound?: boolean;
  120131. /**
  120132. * Maximum distance to hear that sound
  120133. */
  120134. maxDistance?: number;
  120135. /**
  120136. * Uses user defined attenuation function
  120137. */
  120138. useCustomAttenuation?: boolean;
  120139. /**
  120140. * Define the roll off factor of spatial sounds.
  120141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120142. */
  120143. rolloffFactor?: number;
  120144. /**
  120145. * Define the reference distance the sound should be heard perfectly.
  120146. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120147. */
  120148. refDistance?: number;
  120149. /**
  120150. * Define the distance attenuation model the sound will follow.
  120151. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120152. */
  120153. distanceModel?: string;
  120154. /**
  120155. * Defines the playback speed (1 by default)
  120156. */
  120157. playbackRate?: number;
  120158. /**
  120159. * Defines if the sound is from a streaming source
  120160. */
  120161. streaming?: boolean;
  120162. /**
  120163. * Defines an optional length (in seconds) inside the sound file
  120164. */
  120165. length?: number;
  120166. /**
  120167. * Defines an optional offset (in seconds) inside the sound file
  120168. */
  120169. offset?: number;
  120170. /**
  120171. * If true, URLs will not be required to state the audio file codec to use.
  120172. */
  120173. skipCodecCheck?: boolean;
  120174. }
  120175. /**
  120176. * Defines a sound that can be played in the application.
  120177. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120179. */
  120180. export class Sound {
  120181. /**
  120182. * The name of the sound in the scene.
  120183. */
  120184. name: string;
  120185. /**
  120186. * Does the sound autoplay once loaded.
  120187. */
  120188. autoplay: boolean;
  120189. /**
  120190. * Does the sound loop after it finishes playing once.
  120191. */
  120192. loop: boolean;
  120193. /**
  120194. * Does the sound use a custom attenuation curve to simulate the falloff
  120195. * happening when the source gets further away from the camera.
  120196. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120197. */
  120198. useCustomAttenuation: boolean;
  120199. /**
  120200. * The sound track id this sound belongs to.
  120201. */
  120202. soundTrackId: number;
  120203. /**
  120204. * Is this sound currently played.
  120205. */
  120206. isPlaying: boolean;
  120207. /**
  120208. * Is this sound currently paused.
  120209. */
  120210. isPaused: boolean;
  120211. /**
  120212. * Does this sound enables spatial sound.
  120213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120214. */
  120215. spatialSound: boolean;
  120216. /**
  120217. * Define the reference distance the sound should be heard perfectly.
  120218. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120219. */
  120220. refDistance: number;
  120221. /**
  120222. * Define the roll off factor of spatial sounds.
  120223. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120224. */
  120225. rolloffFactor: number;
  120226. /**
  120227. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120228. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120229. */
  120230. maxDistance: number;
  120231. /**
  120232. * Define the distance attenuation model the sound will follow.
  120233. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120234. */
  120235. distanceModel: string;
  120236. /**
  120237. * @hidden
  120238. * Back Compat
  120239. **/
  120240. onended: () => any;
  120241. /**
  120242. * Gets or sets an object used to store user defined information for the sound.
  120243. */
  120244. metadata: any;
  120245. /**
  120246. * Observable event when the current playing sound finishes.
  120247. */
  120248. onEndedObservable: Observable<Sound>;
  120249. private _panningModel;
  120250. private _playbackRate;
  120251. private _streaming;
  120252. private _startTime;
  120253. private _startOffset;
  120254. private _position;
  120255. /** @hidden */
  120256. _positionInEmitterSpace: boolean;
  120257. private _localDirection;
  120258. private _volume;
  120259. private _isReadyToPlay;
  120260. private _isDirectional;
  120261. private _readyToPlayCallback;
  120262. private _audioBuffer;
  120263. private _soundSource;
  120264. private _streamingSource;
  120265. private _soundPanner;
  120266. private _soundGain;
  120267. private _inputAudioNode;
  120268. private _outputAudioNode;
  120269. private _coneInnerAngle;
  120270. private _coneOuterAngle;
  120271. private _coneOuterGain;
  120272. private _scene;
  120273. private _connectedTransformNode;
  120274. private _customAttenuationFunction;
  120275. private _registerFunc;
  120276. private _isOutputConnected;
  120277. private _htmlAudioElement;
  120278. private _urlType;
  120279. private _length?;
  120280. private _offset?;
  120281. /** @hidden */
  120282. static _SceneComponentInitialization: (scene: Scene) => void;
  120283. /**
  120284. * Create a sound and attach it to a scene
  120285. * @param name Name of your sound
  120286. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120287. * @param scene defines the scene the sound belongs to
  120288. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120289. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120290. */
  120291. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120292. /**
  120293. * Release the sound and its associated resources
  120294. */
  120295. dispose(): void;
  120296. /**
  120297. * Gets if the sounds is ready to be played or not.
  120298. * @returns true if ready, otherwise false
  120299. */
  120300. isReady(): boolean;
  120301. private _soundLoaded;
  120302. /**
  120303. * Sets the data of the sound from an audiobuffer
  120304. * @param audioBuffer The audioBuffer containing the data
  120305. */
  120306. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120307. /**
  120308. * Updates the current sounds options such as maxdistance, loop...
  120309. * @param options A JSON object containing values named as the object properties
  120310. */
  120311. updateOptions(options: ISoundOptions): void;
  120312. private _createSpatialParameters;
  120313. private _updateSpatialParameters;
  120314. /**
  120315. * Switch the panning model to HRTF:
  120316. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120317. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120318. */
  120319. switchPanningModelToHRTF(): void;
  120320. /**
  120321. * Switch the panning model to Equal Power:
  120322. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120323. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120324. */
  120325. switchPanningModelToEqualPower(): void;
  120326. private _switchPanningModel;
  120327. /**
  120328. * Connect this sound to a sound track audio node like gain...
  120329. * @param soundTrackAudioNode the sound track audio node to connect to
  120330. */
  120331. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120332. /**
  120333. * Transform this sound into a directional source
  120334. * @param coneInnerAngle Size of the inner cone in degree
  120335. * @param coneOuterAngle Size of the outer cone in degree
  120336. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120337. */
  120338. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120339. /**
  120340. * Gets or sets the inner angle for the directional cone.
  120341. */
  120342. get directionalConeInnerAngle(): number;
  120343. /**
  120344. * Gets or sets the inner angle for the directional cone.
  120345. */
  120346. set directionalConeInnerAngle(value: number);
  120347. /**
  120348. * Gets or sets the outer angle for the directional cone.
  120349. */
  120350. get directionalConeOuterAngle(): number;
  120351. /**
  120352. * Gets or sets the outer angle for the directional cone.
  120353. */
  120354. set directionalConeOuterAngle(value: number);
  120355. /**
  120356. * Sets the position of the emitter if spatial sound is enabled
  120357. * @param newPosition Defines the new posisiton
  120358. */
  120359. setPosition(newPosition: Vector3): void;
  120360. /**
  120361. * Sets the local direction of the emitter if spatial sound is enabled
  120362. * @param newLocalDirection Defines the new local direction
  120363. */
  120364. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120365. private _updateDirection;
  120366. /** @hidden */
  120367. updateDistanceFromListener(): void;
  120368. /**
  120369. * Sets a new custom attenuation function for the sound.
  120370. * @param callback Defines the function used for the attenuation
  120371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120372. */
  120373. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120374. /**
  120375. * Play the sound
  120376. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120377. * @param offset (optional) Start the sound at a specific time in seconds
  120378. * @param length (optional) Sound duration (in seconds)
  120379. */
  120380. play(time?: number, offset?: number, length?: number): void;
  120381. private _onended;
  120382. /**
  120383. * Stop the sound
  120384. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120385. */
  120386. stop(time?: number): void;
  120387. /**
  120388. * Put the sound in pause
  120389. */
  120390. pause(): void;
  120391. /**
  120392. * Sets a dedicated volume for this sounds
  120393. * @param newVolume Define the new volume of the sound
  120394. * @param time Define time for gradual change to new volume
  120395. */
  120396. setVolume(newVolume: number, time?: number): void;
  120397. /**
  120398. * Set the sound play back rate
  120399. * @param newPlaybackRate Define the playback rate the sound should be played at
  120400. */
  120401. setPlaybackRate(newPlaybackRate: number): void;
  120402. /**
  120403. * Gets the volume of the sound.
  120404. * @returns the volume of the sound
  120405. */
  120406. getVolume(): number;
  120407. /**
  120408. * Attach the sound to a dedicated mesh
  120409. * @param transformNode The transform node to connect the sound with
  120410. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120411. */
  120412. attachToMesh(transformNode: TransformNode): void;
  120413. /**
  120414. * Detach the sound from the previously attached mesh
  120415. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120416. */
  120417. detachFromMesh(): void;
  120418. private _onRegisterAfterWorldMatrixUpdate;
  120419. /**
  120420. * Clone the current sound in the scene.
  120421. * @returns the new sound clone
  120422. */
  120423. clone(): Nullable<Sound>;
  120424. /**
  120425. * Gets the current underlying audio buffer containing the data
  120426. * @returns the audio buffer
  120427. */
  120428. getAudioBuffer(): Nullable<AudioBuffer>;
  120429. /**
  120430. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120431. * @returns the source node
  120432. */
  120433. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120434. /**
  120435. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120436. * @returns the gain node
  120437. */
  120438. getSoundGain(): Nullable<GainNode>;
  120439. /**
  120440. * Serializes the Sound in a JSON representation
  120441. * @returns the JSON representation of the sound
  120442. */
  120443. serialize(): any;
  120444. /**
  120445. * Parse a JSON representation of a sound to innstantiate in a given scene
  120446. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120447. * @param scene Define the scene the new parsed sound should be created in
  120448. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120449. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120450. * @returns the newly parsed sound
  120451. */
  120452. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120453. }
  120454. }
  120455. declare module BABYLON {
  120456. /**
  120457. * This defines an action helpful to play a defined sound on a triggered action.
  120458. */
  120459. export class PlaySoundAction extends Action {
  120460. private _sound;
  120461. /**
  120462. * Instantiate the action
  120463. * @param triggerOptions defines the trigger options
  120464. * @param sound defines the sound to play
  120465. * @param condition defines the trigger related conditions
  120466. */
  120467. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120468. /** @hidden */
  120469. _prepare(): void;
  120470. /**
  120471. * Execute the action and play the sound.
  120472. */
  120473. execute(): void;
  120474. /**
  120475. * Serializes the actions and its related information.
  120476. * @param parent defines the object to serialize in
  120477. * @returns the serialized object
  120478. */
  120479. serialize(parent: any): any;
  120480. }
  120481. /**
  120482. * This defines an action helpful to stop a defined sound on a triggered action.
  120483. */
  120484. export class StopSoundAction extends Action {
  120485. private _sound;
  120486. /**
  120487. * Instantiate the action
  120488. * @param triggerOptions defines the trigger options
  120489. * @param sound defines the sound to stop
  120490. * @param condition defines the trigger related conditions
  120491. */
  120492. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120493. /** @hidden */
  120494. _prepare(): void;
  120495. /**
  120496. * Execute the action and stop the sound.
  120497. */
  120498. execute(): void;
  120499. /**
  120500. * Serializes the actions and its related information.
  120501. * @param parent defines the object to serialize in
  120502. * @returns the serialized object
  120503. */
  120504. serialize(parent: any): any;
  120505. }
  120506. }
  120507. declare module BABYLON {
  120508. /**
  120509. * This defines an action responsible to change the value of a property
  120510. * by interpolating between its current value and the newly set one once triggered.
  120511. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120512. */
  120513. export class InterpolateValueAction extends Action {
  120514. /**
  120515. * Defines the path of the property where the value should be interpolated
  120516. */
  120517. propertyPath: string;
  120518. /**
  120519. * Defines the target value at the end of the interpolation.
  120520. */
  120521. value: any;
  120522. /**
  120523. * Defines the time it will take for the property to interpolate to the value.
  120524. */
  120525. duration: number;
  120526. /**
  120527. * Defines if the other scene animations should be stopped when the action has been triggered
  120528. */
  120529. stopOtherAnimations?: boolean;
  120530. /**
  120531. * Defines a callback raised once the interpolation animation has been done.
  120532. */
  120533. onInterpolationDone?: () => void;
  120534. /**
  120535. * Observable triggered once the interpolation animation has been done.
  120536. */
  120537. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  120538. private _target;
  120539. private _effectiveTarget;
  120540. private _property;
  120541. /**
  120542. * Instantiate the action
  120543. * @param triggerOptions defines the trigger options
  120544. * @param target defines the object containing the value to interpolate
  120545. * @param propertyPath defines the path to the property in the target object
  120546. * @param value defines the target value at the end of the interpolation
  120547. * @param duration deines the time it will take for the property to interpolate to the value.
  120548. * @param condition defines the trigger related conditions
  120549. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  120550. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  120551. */
  120552. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  120553. /** @hidden */
  120554. _prepare(): void;
  120555. /**
  120556. * Execute the action starts the value interpolation.
  120557. */
  120558. execute(): void;
  120559. /**
  120560. * Serializes the actions and its related information.
  120561. * @param parent defines the object to serialize in
  120562. * @returns the serialized object
  120563. */
  120564. serialize(parent: any): any;
  120565. }
  120566. }
  120567. declare module BABYLON {
  120568. /**
  120569. * Options allowed during the creation of a sound track.
  120570. */
  120571. export interface ISoundTrackOptions {
  120572. /**
  120573. * The volume the sound track should take during creation
  120574. */
  120575. volume?: number;
  120576. /**
  120577. * Define if the sound track is the main sound track of the scene
  120578. */
  120579. mainTrack?: boolean;
  120580. }
  120581. /**
  120582. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  120583. * It will be also used in a future release to apply effects on a specific track.
  120584. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120585. */
  120586. export class SoundTrack {
  120587. /**
  120588. * The unique identifier of the sound track in the scene.
  120589. */
  120590. id: number;
  120591. /**
  120592. * The list of sounds included in the sound track.
  120593. */
  120594. soundCollection: Array<Sound>;
  120595. private _outputAudioNode;
  120596. private _scene;
  120597. private _connectedAnalyser;
  120598. private _options;
  120599. private _isInitialized;
  120600. /**
  120601. * Creates a new sound track.
  120602. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120603. * @param scene Define the scene the sound track belongs to
  120604. * @param options
  120605. */
  120606. constructor(scene: Scene, options?: ISoundTrackOptions);
  120607. private _initializeSoundTrackAudioGraph;
  120608. /**
  120609. * Release the sound track and its associated resources
  120610. */
  120611. dispose(): void;
  120612. /**
  120613. * Adds a sound to this sound track
  120614. * @param sound define the cound to add
  120615. * @ignoreNaming
  120616. */
  120617. AddSound(sound: Sound): void;
  120618. /**
  120619. * Removes a sound to this sound track
  120620. * @param sound define the cound to remove
  120621. * @ignoreNaming
  120622. */
  120623. RemoveSound(sound: Sound): void;
  120624. /**
  120625. * Set a global volume for the full sound track.
  120626. * @param newVolume Define the new volume of the sound track
  120627. */
  120628. setVolume(newVolume: number): void;
  120629. /**
  120630. * Switch the panning model to HRTF:
  120631. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120633. */
  120634. switchPanningModelToHRTF(): void;
  120635. /**
  120636. * Switch the panning model to Equal Power:
  120637. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120638. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120639. */
  120640. switchPanningModelToEqualPower(): void;
  120641. /**
  120642. * Connect the sound track to an audio analyser allowing some amazing
  120643. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120644. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120645. * @param analyser The analyser to connect to the engine
  120646. */
  120647. connectToAnalyser(analyser: Analyser): void;
  120648. }
  120649. }
  120650. declare module BABYLON {
  120651. interface AbstractScene {
  120652. /**
  120653. * The list of sounds used in the scene.
  120654. */
  120655. sounds: Nullable<Array<Sound>>;
  120656. }
  120657. interface Scene {
  120658. /**
  120659. * @hidden
  120660. * Backing field
  120661. */
  120662. _mainSoundTrack: SoundTrack;
  120663. /**
  120664. * The main sound track played by the scene.
  120665. * It cotains your primary collection of sounds.
  120666. */
  120667. mainSoundTrack: SoundTrack;
  120668. /**
  120669. * The list of sound tracks added to the scene
  120670. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120671. */
  120672. soundTracks: Nullable<Array<SoundTrack>>;
  120673. /**
  120674. * Gets a sound using a given name
  120675. * @param name defines the name to search for
  120676. * @return the found sound or null if not found at all.
  120677. */
  120678. getSoundByName(name: string): Nullable<Sound>;
  120679. /**
  120680. * Gets or sets if audio support is enabled
  120681. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120682. */
  120683. audioEnabled: boolean;
  120684. /**
  120685. * Gets or sets if audio will be output to headphones
  120686. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120687. */
  120688. headphone: boolean;
  120689. /**
  120690. * Gets or sets custom audio listener position provider
  120691. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120692. */
  120693. audioListenerPositionProvider: Nullable<() => Vector3>;
  120694. /**
  120695. * Gets or sets a refresh rate when using 3D audio positioning
  120696. */
  120697. audioPositioningRefreshRate: number;
  120698. }
  120699. /**
  120700. * Defines the sound scene component responsible to manage any sounds
  120701. * in a given scene.
  120702. */
  120703. export class AudioSceneComponent implements ISceneSerializableComponent {
  120704. /**
  120705. * The component name helpfull to identify the component in the list of scene components.
  120706. */
  120707. readonly name: string;
  120708. /**
  120709. * The scene the component belongs to.
  120710. */
  120711. scene: Scene;
  120712. private _audioEnabled;
  120713. /**
  120714. * Gets whether audio is enabled or not.
  120715. * Please use related enable/disable method to switch state.
  120716. */
  120717. get audioEnabled(): boolean;
  120718. private _headphone;
  120719. /**
  120720. * Gets whether audio is outputing to headphone or not.
  120721. * Please use the according Switch methods to change output.
  120722. */
  120723. get headphone(): boolean;
  120724. /**
  120725. * Gets or sets a refresh rate when using 3D audio positioning
  120726. */
  120727. audioPositioningRefreshRate: number;
  120728. private _audioListenerPositionProvider;
  120729. /**
  120730. * Gets the current audio listener position provider
  120731. */
  120732. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  120733. /**
  120734. * Sets a custom listener position for all sounds in the scene
  120735. * By default, this is the position of the first active camera
  120736. */
  120737. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  120738. /**
  120739. * Creates a new instance of the component for the given scene
  120740. * @param scene Defines the scene to register the component in
  120741. */
  120742. constructor(scene: Scene);
  120743. /**
  120744. * Registers the component in a given scene
  120745. */
  120746. register(): void;
  120747. /**
  120748. * Rebuilds the elements related to this component in case of
  120749. * context lost for instance.
  120750. */
  120751. rebuild(): void;
  120752. /**
  120753. * Serializes the component data to the specified json object
  120754. * @param serializationObject The object to serialize to
  120755. */
  120756. serialize(serializationObject: any): void;
  120757. /**
  120758. * Adds all the elements from the container to the scene
  120759. * @param container the container holding the elements
  120760. */
  120761. addFromContainer(container: AbstractScene): void;
  120762. /**
  120763. * Removes all the elements in the container from the scene
  120764. * @param container contains the elements to remove
  120765. * @param dispose if the removed element should be disposed (default: false)
  120766. */
  120767. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120768. /**
  120769. * Disposes the component and the associated ressources.
  120770. */
  120771. dispose(): void;
  120772. /**
  120773. * Disables audio in the associated scene.
  120774. */
  120775. disableAudio(): void;
  120776. /**
  120777. * Enables audio in the associated scene.
  120778. */
  120779. enableAudio(): void;
  120780. /**
  120781. * Switch audio to headphone output.
  120782. */
  120783. switchAudioModeForHeadphones(): void;
  120784. /**
  120785. * Switch audio to normal speakers.
  120786. */
  120787. switchAudioModeForNormalSpeakers(): void;
  120788. private _cachedCameraDirection;
  120789. private _cachedCameraPosition;
  120790. private _lastCheck;
  120791. private _afterRender;
  120792. }
  120793. }
  120794. declare module BABYLON {
  120795. /**
  120796. * Wraps one or more Sound objects and selects one with random weight for playback.
  120797. */
  120798. export class WeightedSound {
  120799. /** When true a Sound will be selected and played when the current playing Sound completes. */
  120800. loop: boolean;
  120801. private _coneInnerAngle;
  120802. private _coneOuterAngle;
  120803. private _volume;
  120804. /** A Sound is currently playing. */
  120805. isPlaying: boolean;
  120806. /** A Sound is currently paused. */
  120807. isPaused: boolean;
  120808. private _sounds;
  120809. private _weights;
  120810. private _currentIndex?;
  120811. /**
  120812. * Creates a new WeightedSound from the list of sounds given.
  120813. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  120814. * @param sounds Array of Sounds that will be selected from.
  120815. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  120816. */
  120817. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  120818. /**
  120819. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  120820. */
  120821. get directionalConeInnerAngle(): number;
  120822. /**
  120823. * The size of cone in degress for a directional sound in which there will be no attenuation.
  120824. */
  120825. set directionalConeInnerAngle(value: number);
  120826. /**
  120827. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120828. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120829. */
  120830. get directionalConeOuterAngle(): number;
  120831. /**
  120832. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120833. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120834. */
  120835. set directionalConeOuterAngle(value: number);
  120836. /**
  120837. * Playback volume.
  120838. */
  120839. get volume(): number;
  120840. /**
  120841. * Playback volume.
  120842. */
  120843. set volume(value: number);
  120844. private _onended;
  120845. /**
  120846. * Suspend playback
  120847. */
  120848. pause(): void;
  120849. /**
  120850. * Stop playback
  120851. */
  120852. stop(): void;
  120853. /**
  120854. * Start playback.
  120855. * @param startOffset Position the clip head at a specific time in seconds.
  120856. */
  120857. play(startOffset?: number): void;
  120858. }
  120859. }
  120860. declare module BABYLON {
  120861. /**
  120862. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  120863. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120864. */
  120865. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  120866. /**
  120867. * Gets the name of the behavior.
  120868. */
  120869. get name(): string;
  120870. /**
  120871. * The easing function used by animations
  120872. */
  120873. static EasingFunction: BackEase;
  120874. /**
  120875. * The easing mode used by animations
  120876. */
  120877. static EasingMode: number;
  120878. /**
  120879. * The duration of the animation, in milliseconds
  120880. */
  120881. transitionDuration: number;
  120882. /**
  120883. * Length of the distance animated by the transition when lower radius is reached
  120884. */
  120885. lowerRadiusTransitionRange: number;
  120886. /**
  120887. * Length of the distance animated by the transition when upper radius is reached
  120888. */
  120889. upperRadiusTransitionRange: number;
  120890. private _autoTransitionRange;
  120891. /**
  120892. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120893. */
  120894. get autoTransitionRange(): boolean;
  120895. /**
  120896. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120897. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  120898. */
  120899. set autoTransitionRange(value: boolean);
  120900. private _attachedCamera;
  120901. private _onAfterCheckInputsObserver;
  120902. private _onMeshTargetChangedObserver;
  120903. /**
  120904. * Initializes the behavior.
  120905. */
  120906. init(): void;
  120907. /**
  120908. * Attaches the behavior to its arc rotate camera.
  120909. * @param camera Defines the camera to attach the behavior to
  120910. */
  120911. attach(camera: ArcRotateCamera): void;
  120912. /**
  120913. * Detaches the behavior from its current arc rotate camera.
  120914. */
  120915. detach(): void;
  120916. private _radiusIsAnimating;
  120917. private _radiusBounceTransition;
  120918. private _animatables;
  120919. private _cachedWheelPrecision;
  120920. /**
  120921. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  120922. * @param radiusLimit The limit to check against.
  120923. * @return Bool to indicate if at limit.
  120924. */
  120925. private _isRadiusAtLimit;
  120926. /**
  120927. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  120928. * @param radiusDelta The delta by which to animate to. Can be negative.
  120929. */
  120930. private _applyBoundRadiusAnimation;
  120931. /**
  120932. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  120933. */
  120934. protected _clearAnimationLocks(): void;
  120935. /**
  120936. * Stops and removes all animations that have been applied to the camera
  120937. */
  120938. stopAllAnimations(): void;
  120939. }
  120940. }
  120941. declare module BABYLON {
  120942. /**
  120943. * 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.
  120944. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120945. */
  120946. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  120947. /**
  120948. * Gets the name of the behavior.
  120949. */
  120950. get name(): string;
  120951. private _mode;
  120952. private _radiusScale;
  120953. private _positionScale;
  120954. private _defaultElevation;
  120955. private _elevationReturnTime;
  120956. private _elevationReturnWaitTime;
  120957. private _zoomStopsAnimation;
  120958. private _framingTime;
  120959. /**
  120960. * The easing function used by animations
  120961. */
  120962. static EasingFunction: ExponentialEase;
  120963. /**
  120964. * The easing mode used by animations
  120965. */
  120966. static EasingMode: number;
  120967. /**
  120968. * Sets the current mode used by the behavior
  120969. */
  120970. set mode(mode: number);
  120971. /**
  120972. * Gets current mode used by the behavior.
  120973. */
  120974. get mode(): number;
  120975. /**
  120976. * Sets the scale applied to the radius (1 by default)
  120977. */
  120978. set radiusScale(radius: number);
  120979. /**
  120980. * Gets the scale applied to the radius
  120981. */
  120982. get radiusScale(): number;
  120983. /**
  120984. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  120985. */
  120986. set positionScale(scale: number);
  120987. /**
  120988. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  120989. */
  120990. get positionScale(): number;
  120991. /**
  120992. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  120993. * behaviour is triggered, in radians.
  120994. */
  120995. set defaultElevation(elevation: number);
  120996. /**
  120997. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  120998. * behaviour is triggered, in radians.
  120999. */
  121000. get defaultElevation(): number;
  121001. /**
  121002. * Sets the time (in milliseconds) taken to return to the default beta position.
  121003. * Negative value indicates camera should not return to default.
  121004. */
  121005. set elevationReturnTime(speed: number);
  121006. /**
  121007. * Gets the time (in milliseconds) taken to return to the default beta position.
  121008. * Negative value indicates camera should not return to default.
  121009. */
  121010. get elevationReturnTime(): number;
  121011. /**
  121012. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121013. */
  121014. set elevationReturnWaitTime(time: number);
  121015. /**
  121016. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121017. */
  121018. get elevationReturnWaitTime(): number;
  121019. /**
  121020. * Sets the flag that indicates if user zooming should stop animation.
  121021. */
  121022. set zoomStopsAnimation(flag: boolean);
  121023. /**
  121024. * Gets the flag that indicates if user zooming should stop animation.
  121025. */
  121026. get zoomStopsAnimation(): boolean;
  121027. /**
  121028. * Sets the transition time when framing the mesh, in milliseconds
  121029. */
  121030. set framingTime(time: number);
  121031. /**
  121032. * Gets the transition time when framing the mesh, in milliseconds
  121033. */
  121034. get framingTime(): number;
  121035. /**
  121036. * Define if the behavior should automatically change the configured
  121037. * camera limits and sensibilities.
  121038. */
  121039. autoCorrectCameraLimitsAndSensibility: boolean;
  121040. private _onPrePointerObservableObserver;
  121041. private _onAfterCheckInputsObserver;
  121042. private _onMeshTargetChangedObserver;
  121043. private _attachedCamera;
  121044. private _isPointerDown;
  121045. private _lastInteractionTime;
  121046. /**
  121047. * Initializes the behavior.
  121048. */
  121049. init(): void;
  121050. /**
  121051. * Attaches the behavior to its arc rotate camera.
  121052. * @param camera Defines the camera to attach the behavior to
  121053. */
  121054. attach(camera: ArcRotateCamera): void;
  121055. /**
  121056. * Detaches the behavior from its current arc rotate camera.
  121057. */
  121058. detach(): void;
  121059. private _animatables;
  121060. private _betaIsAnimating;
  121061. private _betaTransition;
  121062. private _radiusTransition;
  121063. private _vectorTransition;
  121064. /**
  121065. * Targets the given mesh and updates zoom level accordingly.
  121066. * @param mesh The mesh to target.
  121067. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121068. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121069. */
  121070. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121071. /**
  121072. * Targets the given mesh with its children and updates zoom level accordingly.
  121073. * @param mesh The mesh to target.
  121074. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121075. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121076. */
  121077. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121078. /**
  121079. * Targets the given meshes with their children and updates zoom level accordingly.
  121080. * @param meshes The mesh to target.
  121081. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121082. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121083. */
  121084. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121085. /**
  121086. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  121087. * @param minimumWorld Determines the smaller position of the bounding box extend
  121088. * @param maximumWorld Determines the bigger position of the bounding box extend
  121089. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121090. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121091. */
  121092. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121093. /**
  121094. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  121095. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  121096. * frustum width.
  121097. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  121098. * to fully enclose the mesh in the viewing frustum.
  121099. */
  121100. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  121101. /**
  121102. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  121103. * is automatically returned to its default position (expected to be above ground plane).
  121104. */
  121105. private _maintainCameraAboveGround;
  121106. /**
  121107. * Returns the frustum slope based on the canvas ratio and camera FOV
  121108. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  121109. */
  121110. private _getFrustumSlope;
  121111. /**
  121112. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  121113. */
  121114. private _clearAnimationLocks;
  121115. /**
  121116. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121117. */
  121118. private _applyUserInteraction;
  121119. /**
  121120. * Stops and removes all animations that have been applied to the camera
  121121. */
  121122. stopAllAnimations(): void;
  121123. /**
  121124. * Gets a value indicating if the user is moving the camera
  121125. */
  121126. get isUserIsMoving(): boolean;
  121127. /**
  121128. * The camera can move all the way towards the mesh.
  121129. */
  121130. static IgnoreBoundsSizeMode: number;
  121131. /**
  121132. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  121133. */
  121134. static FitFrustumSidesMode: number;
  121135. }
  121136. }
  121137. declare module BABYLON {
  121138. /**
  121139. * Base class for Camera Pointer Inputs.
  121140. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  121141. * for example usage.
  121142. */
  121143. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  121144. /**
  121145. * Defines the camera the input is attached to.
  121146. */
  121147. abstract camera: Camera;
  121148. /**
  121149. * Whether keyboard modifier keys are pressed at time of last mouse event.
  121150. */
  121151. protected _altKey: boolean;
  121152. protected _ctrlKey: boolean;
  121153. protected _metaKey: boolean;
  121154. protected _shiftKey: boolean;
  121155. /**
  121156. * Which mouse buttons were pressed at time of last mouse event.
  121157. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  121158. */
  121159. protected _buttonsPressed: number;
  121160. /**
  121161. * Defines the buttons associated with the input to handle camera move.
  121162. */
  121163. buttons: number[];
  121164. /**
  121165. * Attach the input controls to a specific dom element to get the input from.
  121166. * @param element Defines the element the controls should be listened from
  121167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121168. */
  121169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121170. /**
  121171. * Detach the current controls from the specified dom element.
  121172. * @param element Defines the element to stop listening the inputs from
  121173. */
  121174. detachControl(element: Nullable<HTMLElement>): void;
  121175. /**
  121176. * Gets the class name of the current input.
  121177. * @returns the class name
  121178. */
  121179. getClassName(): string;
  121180. /**
  121181. * Get the friendly name associated with the input class.
  121182. * @returns the input friendly name
  121183. */
  121184. getSimpleName(): string;
  121185. /**
  121186. * Called on pointer POINTERDOUBLETAP event.
  121187. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121188. */
  121189. protected onDoubleTap(type: string): void;
  121190. /**
  121191. * Called on pointer POINTERMOVE event if only a single touch is active.
  121192. * Override this method to provide functionality.
  121193. */
  121194. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121195. /**
  121196. * Called on pointer POINTERMOVE event if multiple touches are active.
  121197. * Override this method to provide functionality.
  121198. */
  121199. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121200. /**
  121201. * Called on JS contextmenu event.
  121202. * Override this method to provide functionality.
  121203. */
  121204. protected onContextMenu(evt: PointerEvent): void;
  121205. /**
  121206. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121207. * press.
  121208. * Override this method to provide functionality.
  121209. */
  121210. protected onButtonDown(evt: PointerEvent): void;
  121211. /**
  121212. * Called each time a new POINTERUP event occurs. Ie, for each button
  121213. * release.
  121214. * Override this method to provide functionality.
  121215. */
  121216. protected onButtonUp(evt: PointerEvent): void;
  121217. /**
  121218. * Called when window becomes inactive.
  121219. * Override this method to provide functionality.
  121220. */
  121221. protected onLostFocus(): void;
  121222. private _pointerInput;
  121223. private _observer;
  121224. private _onLostFocus;
  121225. private pointA;
  121226. private pointB;
  121227. }
  121228. }
  121229. declare module BABYLON {
  121230. /**
  121231. * Manage the pointers inputs to control an arc rotate camera.
  121232. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121233. */
  121234. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121235. /**
  121236. * Defines the camera the input is attached to.
  121237. */
  121238. camera: ArcRotateCamera;
  121239. /**
  121240. * Gets the class name of the current input.
  121241. * @returns the class name
  121242. */
  121243. getClassName(): string;
  121244. /**
  121245. * Defines the buttons associated with the input to handle camera move.
  121246. */
  121247. buttons: number[];
  121248. /**
  121249. * Defines the pointer angular sensibility along the X axis or how fast is
  121250. * the camera rotating.
  121251. */
  121252. angularSensibilityX: number;
  121253. /**
  121254. * Defines the pointer angular sensibility along the Y axis or how fast is
  121255. * the camera rotating.
  121256. */
  121257. angularSensibilityY: number;
  121258. /**
  121259. * Defines the pointer pinch precision or how fast is the camera zooming.
  121260. */
  121261. pinchPrecision: number;
  121262. /**
  121263. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121264. * from 0.
  121265. * It defines the percentage of current camera.radius to use as delta when
  121266. * pinch zoom is used.
  121267. */
  121268. pinchDeltaPercentage: number;
  121269. /**
  121270. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121271. * that any object in the plane at the camera's target point will scale
  121272. * perfectly with finger motion.
  121273. * Overrides pinchDeltaPercentage and pinchPrecision.
  121274. */
  121275. useNaturalPinchZoom: boolean;
  121276. /**
  121277. * Defines the pointer panning sensibility or how fast is the camera moving.
  121278. */
  121279. panningSensibility: number;
  121280. /**
  121281. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121282. */
  121283. multiTouchPanning: boolean;
  121284. /**
  121285. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121286. * zoom (pinch) through multitouch.
  121287. */
  121288. multiTouchPanAndZoom: boolean;
  121289. /**
  121290. * Revers pinch action direction.
  121291. */
  121292. pinchInwards: boolean;
  121293. private _isPanClick;
  121294. private _twoFingerActivityCount;
  121295. private _isPinching;
  121296. /**
  121297. * Called on pointer POINTERMOVE event if only a single touch is active.
  121298. */
  121299. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121300. /**
  121301. * Called on pointer POINTERDOUBLETAP event.
  121302. */
  121303. protected onDoubleTap(type: string): void;
  121304. /**
  121305. * Called on pointer POINTERMOVE event if multiple touches are active.
  121306. */
  121307. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121308. /**
  121309. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121310. * press.
  121311. */
  121312. protected onButtonDown(evt: PointerEvent): void;
  121313. /**
  121314. * Called each time a new POINTERUP event occurs. Ie, for each button
  121315. * release.
  121316. */
  121317. protected onButtonUp(evt: PointerEvent): void;
  121318. /**
  121319. * Called when window becomes inactive.
  121320. */
  121321. protected onLostFocus(): void;
  121322. }
  121323. }
  121324. declare module BABYLON {
  121325. /**
  121326. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121327. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121328. */
  121329. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121330. /**
  121331. * Defines the camera the input is attached to.
  121332. */
  121333. camera: ArcRotateCamera;
  121334. /**
  121335. * Defines the list of key codes associated with the up action (increase alpha)
  121336. */
  121337. keysUp: number[];
  121338. /**
  121339. * Defines the list of key codes associated with the down action (decrease alpha)
  121340. */
  121341. keysDown: number[];
  121342. /**
  121343. * Defines the list of key codes associated with the left action (increase beta)
  121344. */
  121345. keysLeft: number[];
  121346. /**
  121347. * Defines the list of key codes associated with the right action (decrease beta)
  121348. */
  121349. keysRight: number[];
  121350. /**
  121351. * Defines the list of key codes associated with the reset action.
  121352. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121353. */
  121354. keysReset: number[];
  121355. /**
  121356. * Defines the panning sensibility of the inputs.
  121357. * (How fast is the camera panning)
  121358. */
  121359. panningSensibility: number;
  121360. /**
  121361. * Defines the zooming sensibility of the inputs.
  121362. * (How fast is the camera zooming)
  121363. */
  121364. zoomingSensibility: number;
  121365. /**
  121366. * Defines whether maintaining the alt key down switch the movement mode from
  121367. * orientation to zoom.
  121368. */
  121369. useAltToZoom: boolean;
  121370. /**
  121371. * Rotation speed of the camera
  121372. */
  121373. angularSpeed: number;
  121374. private _keys;
  121375. private _ctrlPressed;
  121376. private _altPressed;
  121377. private _onCanvasBlurObserver;
  121378. private _onKeyboardObserver;
  121379. private _engine;
  121380. private _scene;
  121381. /**
  121382. * Attach the input controls to a specific dom element to get the input from.
  121383. * @param element Defines the element the controls should be listened from
  121384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121385. */
  121386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121387. /**
  121388. * Detach the current controls from the specified dom element.
  121389. * @param element Defines the element to stop listening the inputs from
  121390. */
  121391. detachControl(element: Nullable<HTMLElement>): void;
  121392. /**
  121393. * Update the current camera state depending on the inputs that have been used this frame.
  121394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121395. */
  121396. checkInputs(): void;
  121397. /**
  121398. * Gets the class name of the current intput.
  121399. * @returns the class name
  121400. */
  121401. getClassName(): string;
  121402. /**
  121403. * Get the friendly name associated with the input class.
  121404. * @returns the input friendly name
  121405. */
  121406. getSimpleName(): string;
  121407. }
  121408. }
  121409. declare module BABYLON {
  121410. /**
  121411. * Manage the mouse wheel inputs to control an arc rotate camera.
  121412. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121413. */
  121414. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121415. /**
  121416. * Defines the camera the input is attached to.
  121417. */
  121418. camera: ArcRotateCamera;
  121419. /**
  121420. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121421. */
  121422. wheelPrecision: number;
  121423. /**
  121424. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121425. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121426. */
  121427. wheelDeltaPercentage: number;
  121428. private _wheel;
  121429. private _observer;
  121430. private computeDeltaFromMouseWheelLegacyEvent;
  121431. /**
  121432. * Attach the input controls to a specific dom element to get the input from.
  121433. * @param element Defines the element the controls should be listened from
  121434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121435. */
  121436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121437. /**
  121438. * Detach the current controls from the specified dom element.
  121439. * @param element Defines the element to stop listening the inputs from
  121440. */
  121441. detachControl(element: Nullable<HTMLElement>): void;
  121442. /**
  121443. * Gets the class name of the current intput.
  121444. * @returns the class name
  121445. */
  121446. getClassName(): string;
  121447. /**
  121448. * Get the friendly name associated with the input class.
  121449. * @returns the input friendly name
  121450. */
  121451. getSimpleName(): string;
  121452. }
  121453. }
  121454. declare module BABYLON {
  121455. /**
  121456. * Default Inputs manager for the ArcRotateCamera.
  121457. * It groups all the default supported inputs for ease of use.
  121458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121459. */
  121460. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  121461. /**
  121462. * Instantiates a new ArcRotateCameraInputsManager.
  121463. * @param camera Defines the camera the inputs belong to
  121464. */
  121465. constructor(camera: ArcRotateCamera);
  121466. /**
  121467. * Add mouse wheel input support to the input manager.
  121468. * @returns the current input manager
  121469. */
  121470. addMouseWheel(): ArcRotateCameraInputsManager;
  121471. /**
  121472. * Add pointers input support to the input manager.
  121473. * @returns the current input manager
  121474. */
  121475. addPointers(): ArcRotateCameraInputsManager;
  121476. /**
  121477. * Add keyboard input support to the input manager.
  121478. * @returns the current input manager
  121479. */
  121480. addKeyboard(): ArcRotateCameraInputsManager;
  121481. }
  121482. }
  121483. declare module BABYLON {
  121484. /**
  121485. * This represents an orbital type of camera.
  121486. *
  121487. * 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.
  121488. * 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.
  121489. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  121490. */
  121491. export class ArcRotateCamera extends TargetCamera {
  121492. /**
  121493. * Defines the rotation angle of the camera along the longitudinal axis.
  121494. */
  121495. alpha: number;
  121496. /**
  121497. * Defines the rotation angle of the camera along the latitudinal axis.
  121498. */
  121499. beta: number;
  121500. /**
  121501. * Defines the radius of the camera from it s target point.
  121502. */
  121503. radius: number;
  121504. protected _target: Vector3;
  121505. protected _targetHost: Nullable<AbstractMesh>;
  121506. /**
  121507. * Defines the target point of the camera.
  121508. * The camera looks towards it form the radius distance.
  121509. */
  121510. get target(): Vector3;
  121511. set target(value: Vector3);
  121512. /**
  121513. * Define the current local position of the camera in the scene
  121514. */
  121515. get position(): Vector3;
  121516. set position(newPosition: Vector3);
  121517. protected _upVector: Vector3;
  121518. protected _upToYMatrix: Matrix;
  121519. protected _YToUpMatrix: Matrix;
  121520. /**
  121521. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  121522. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  121523. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  121524. */
  121525. set upVector(vec: Vector3);
  121526. get upVector(): Vector3;
  121527. /**
  121528. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  121529. */
  121530. setMatUp(): void;
  121531. /**
  121532. * Current inertia value on the longitudinal axis.
  121533. * The bigger this number the longer it will take for the camera to stop.
  121534. */
  121535. inertialAlphaOffset: number;
  121536. /**
  121537. * Current inertia value on the latitudinal axis.
  121538. * The bigger this number the longer it will take for the camera to stop.
  121539. */
  121540. inertialBetaOffset: number;
  121541. /**
  121542. * Current inertia value on the radius axis.
  121543. * The bigger this number the longer it will take for the camera to stop.
  121544. */
  121545. inertialRadiusOffset: number;
  121546. /**
  121547. * Minimum allowed angle on the longitudinal axis.
  121548. * This can help limiting how the Camera is able to move in the scene.
  121549. */
  121550. lowerAlphaLimit: Nullable<number>;
  121551. /**
  121552. * Maximum allowed angle on the longitudinal axis.
  121553. * This can help limiting how the Camera is able to move in the scene.
  121554. */
  121555. upperAlphaLimit: Nullable<number>;
  121556. /**
  121557. * Minimum allowed angle on the latitudinal axis.
  121558. * This can help limiting how the Camera is able to move in the scene.
  121559. */
  121560. lowerBetaLimit: number;
  121561. /**
  121562. * Maximum allowed angle on the latitudinal axis.
  121563. * This can help limiting how the Camera is able to move in the scene.
  121564. */
  121565. upperBetaLimit: number;
  121566. /**
  121567. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  121568. * This can help limiting how the Camera is able to move in the scene.
  121569. */
  121570. lowerRadiusLimit: Nullable<number>;
  121571. /**
  121572. * Maximum allowed distance of the camera to the target (The camera can not get further).
  121573. * This can help limiting how the Camera is able to move in the scene.
  121574. */
  121575. upperRadiusLimit: Nullable<number>;
  121576. /**
  121577. * Defines the current inertia value used during panning of the camera along the X axis.
  121578. */
  121579. inertialPanningX: number;
  121580. /**
  121581. * Defines the current inertia value used during panning of the camera along the Y axis.
  121582. */
  121583. inertialPanningY: number;
  121584. /**
  121585. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  121586. * Basically if your fingers moves away from more than this distance you will be considered
  121587. * in pinch mode.
  121588. */
  121589. pinchToPanMaxDistance: number;
  121590. /**
  121591. * Defines the maximum distance the camera can pan.
  121592. * This could help keeping the cammera always in your scene.
  121593. */
  121594. panningDistanceLimit: Nullable<number>;
  121595. /**
  121596. * Defines the target of the camera before paning.
  121597. */
  121598. panningOriginTarget: Vector3;
  121599. /**
  121600. * Defines the value of the inertia used during panning.
  121601. * 0 would mean stop inertia and one would mean no decelleration at all.
  121602. */
  121603. panningInertia: number;
  121604. /**
  121605. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  121606. */
  121607. get angularSensibilityX(): number;
  121608. set angularSensibilityX(value: number);
  121609. /**
  121610. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  121611. */
  121612. get angularSensibilityY(): number;
  121613. set angularSensibilityY(value: number);
  121614. /**
  121615. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  121616. */
  121617. get pinchPrecision(): number;
  121618. set pinchPrecision(value: number);
  121619. /**
  121620. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  121621. * It will be used instead of pinchDeltaPrecision if different from 0.
  121622. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121623. */
  121624. get pinchDeltaPercentage(): number;
  121625. set pinchDeltaPercentage(value: number);
  121626. /**
  121627. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  121628. * and pinch delta percentage.
  121629. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121630. * that any object in the plane at the camera's target point will scale
  121631. * perfectly with finger motion.
  121632. */
  121633. get useNaturalPinchZoom(): boolean;
  121634. set useNaturalPinchZoom(value: boolean);
  121635. /**
  121636. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  121637. */
  121638. get panningSensibility(): number;
  121639. set panningSensibility(value: number);
  121640. /**
  121641. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  121642. */
  121643. get keysUp(): number[];
  121644. set keysUp(value: number[]);
  121645. /**
  121646. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  121647. */
  121648. get keysDown(): number[];
  121649. set keysDown(value: number[]);
  121650. /**
  121651. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  121652. */
  121653. get keysLeft(): number[];
  121654. set keysLeft(value: number[]);
  121655. /**
  121656. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  121657. */
  121658. get keysRight(): number[];
  121659. set keysRight(value: number[]);
  121660. /**
  121661. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121662. */
  121663. get wheelPrecision(): number;
  121664. set wheelPrecision(value: number);
  121665. /**
  121666. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  121667. * It will be used instead of pinchDeltaPrecision if different from 0.
  121668. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121669. */
  121670. get wheelDeltaPercentage(): number;
  121671. set wheelDeltaPercentage(value: number);
  121672. /**
  121673. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  121674. */
  121675. zoomOnFactor: number;
  121676. /**
  121677. * Defines a screen offset for the camera position.
  121678. */
  121679. targetScreenOffset: Vector2;
  121680. /**
  121681. * Allows the camera to be completely reversed.
  121682. * If false the camera can not arrive upside down.
  121683. */
  121684. allowUpsideDown: boolean;
  121685. /**
  121686. * Define if double tap/click is used to restore the previously saved state of the camera.
  121687. */
  121688. useInputToRestoreState: boolean;
  121689. /** @hidden */
  121690. _viewMatrix: Matrix;
  121691. /** @hidden */
  121692. _useCtrlForPanning: boolean;
  121693. /** @hidden */
  121694. _panningMouseButton: number;
  121695. /**
  121696. * Defines the input associated to the camera.
  121697. */
  121698. inputs: ArcRotateCameraInputsManager;
  121699. /** @hidden */
  121700. _reset: () => void;
  121701. /**
  121702. * Defines the allowed panning axis.
  121703. */
  121704. panningAxis: Vector3;
  121705. protected _localDirection: Vector3;
  121706. protected _transformedDirection: Vector3;
  121707. private _bouncingBehavior;
  121708. /**
  121709. * Gets the bouncing behavior of the camera if it has been enabled.
  121710. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121711. */
  121712. get bouncingBehavior(): Nullable<BouncingBehavior>;
  121713. /**
  121714. * Defines if the bouncing behavior of the camera is enabled on the camera.
  121715. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121716. */
  121717. get useBouncingBehavior(): boolean;
  121718. set useBouncingBehavior(value: boolean);
  121719. private _framingBehavior;
  121720. /**
  121721. * Gets the framing behavior of the camera if it has been enabled.
  121722. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121723. */
  121724. get framingBehavior(): Nullable<FramingBehavior>;
  121725. /**
  121726. * Defines if the framing behavior of the camera is enabled on the camera.
  121727. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121728. */
  121729. get useFramingBehavior(): boolean;
  121730. set useFramingBehavior(value: boolean);
  121731. private _autoRotationBehavior;
  121732. /**
  121733. * Gets the auto rotation behavior of the camera if it has been enabled.
  121734. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121735. */
  121736. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  121737. /**
  121738. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  121739. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121740. */
  121741. get useAutoRotationBehavior(): boolean;
  121742. set useAutoRotationBehavior(value: boolean);
  121743. /**
  121744. * Observable triggered when the mesh target has been changed on the camera.
  121745. */
  121746. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  121747. /**
  121748. * Event raised when the camera is colliding with a mesh.
  121749. */
  121750. onCollide: (collidedMesh: AbstractMesh) => void;
  121751. /**
  121752. * Defines whether the camera should check collision with the objects oh the scene.
  121753. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  121754. */
  121755. checkCollisions: boolean;
  121756. /**
  121757. * Defines the collision radius of the camera.
  121758. * This simulates a sphere around the camera.
  121759. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121760. */
  121761. collisionRadius: Vector3;
  121762. protected _collider: Collider;
  121763. protected _previousPosition: Vector3;
  121764. protected _collisionVelocity: Vector3;
  121765. protected _newPosition: Vector3;
  121766. protected _previousAlpha: number;
  121767. protected _previousBeta: number;
  121768. protected _previousRadius: number;
  121769. protected _collisionTriggered: boolean;
  121770. protected _targetBoundingCenter: Nullable<Vector3>;
  121771. private _computationVector;
  121772. /**
  121773. * Instantiates a new ArcRotateCamera in a given scene
  121774. * @param name Defines the name of the camera
  121775. * @param alpha Defines the camera rotation along the logitudinal axis
  121776. * @param beta Defines the camera rotation along the latitudinal axis
  121777. * @param radius Defines the camera distance from its target
  121778. * @param target Defines the camera target
  121779. * @param scene Defines the scene the camera belongs to
  121780. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  121781. */
  121782. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121783. /** @hidden */
  121784. _initCache(): void;
  121785. /** @hidden */
  121786. _updateCache(ignoreParentClass?: boolean): void;
  121787. protected _getTargetPosition(): Vector3;
  121788. private _storedAlpha;
  121789. private _storedBeta;
  121790. private _storedRadius;
  121791. private _storedTarget;
  121792. private _storedTargetScreenOffset;
  121793. /**
  121794. * Stores the current state of the camera (alpha, beta, radius and target)
  121795. * @returns the camera itself
  121796. */
  121797. storeState(): Camera;
  121798. /**
  121799. * @hidden
  121800. * Restored camera state. You must call storeState() first
  121801. */
  121802. _restoreStateValues(): boolean;
  121803. /** @hidden */
  121804. _isSynchronizedViewMatrix(): boolean;
  121805. /**
  121806. * Attached controls to the current camera.
  121807. * @param element Defines the element the controls should be listened from
  121808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121809. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  121810. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  121811. */
  121812. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  121813. /**
  121814. * Detach the current controls from the camera.
  121815. * The camera will stop reacting to inputs.
  121816. * @param element Defines the element to stop listening the inputs from
  121817. */
  121818. detachControl(element: HTMLElement): void;
  121819. /** @hidden */
  121820. _checkInputs(): void;
  121821. protected _checkLimits(): void;
  121822. /**
  121823. * Rebuilds angles (alpha, beta) and radius from the give position and target
  121824. */
  121825. rebuildAnglesAndRadius(): void;
  121826. /**
  121827. * Use a position to define the current camera related information like alpha, beta and radius
  121828. * @param position Defines the position to set the camera at
  121829. */
  121830. setPosition(position: Vector3): void;
  121831. /**
  121832. * Defines the target the camera should look at.
  121833. * This will automatically adapt alpha beta and radius to fit within the new target.
  121834. * @param target Defines the new target as a Vector or a mesh
  121835. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  121836. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  121837. */
  121838. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  121839. /** @hidden */
  121840. _getViewMatrix(): Matrix;
  121841. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  121842. /**
  121843. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  121844. * @param meshes Defines the mesh to zoom on
  121845. * @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)
  121846. */
  121847. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  121848. /**
  121849. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  121850. * The target will be changed but the radius
  121851. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  121852. * @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)
  121853. */
  121854. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  121855. min: Vector3;
  121856. max: Vector3;
  121857. distance: number;
  121858. }, doNotUpdateMaxZ?: boolean): void;
  121859. /**
  121860. * @override
  121861. * Override Camera.createRigCamera
  121862. */
  121863. createRigCamera(name: string, cameraIndex: number): Camera;
  121864. /**
  121865. * @hidden
  121866. * @override
  121867. * Override Camera._updateRigCameras
  121868. */
  121869. _updateRigCameras(): void;
  121870. /**
  121871. * Destroy the camera and release the current resources hold by it.
  121872. */
  121873. dispose(): void;
  121874. /**
  121875. * Gets the current object class name.
  121876. * @return the class name
  121877. */
  121878. getClassName(): string;
  121879. }
  121880. }
  121881. declare module BABYLON {
  121882. /**
  121883. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  121884. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121885. */
  121886. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  121887. /**
  121888. * Gets the name of the behavior.
  121889. */
  121890. get name(): string;
  121891. private _zoomStopsAnimation;
  121892. private _idleRotationSpeed;
  121893. private _idleRotationWaitTime;
  121894. private _idleRotationSpinupTime;
  121895. /**
  121896. * Sets the flag that indicates if user zooming should stop animation.
  121897. */
  121898. set zoomStopsAnimation(flag: boolean);
  121899. /**
  121900. * Gets the flag that indicates if user zooming should stop animation.
  121901. */
  121902. get zoomStopsAnimation(): boolean;
  121903. /**
  121904. * Sets the default speed at which the camera rotates around the model.
  121905. */
  121906. set idleRotationSpeed(speed: number);
  121907. /**
  121908. * Gets the default speed at which the camera rotates around the model.
  121909. */
  121910. get idleRotationSpeed(): number;
  121911. /**
  121912. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  121913. */
  121914. set idleRotationWaitTime(time: number);
  121915. /**
  121916. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  121917. */
  121918. get idleRotationWaitTime(): number;
  121919. /**
  121920. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121921. */
  121922. set idleRotationSpinupTime(time: number);
  121923. /**
  121924. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121925. */
  121926. get idleRotationSpinupTime(): number;
  121927. /**
  121928. * Gets a value indicating if the camera is currently rotating because of this behavior
  121929. */
  121930. get rotationInProgress(): boolean;
  121931. private _onPrePointerObservableObserver;
  121932. private _onAfterCheckInputsObserver;
  121933. private _attachedCamera;
  121934. private _isPointerDown;
  121935. private _lastFrameTime;
  121936. private _lastInteractionTime;
  121937. private _cameraRotationSpeed;
  121938. /**
  121939. * Initializes the behavior.
  121940. */
  121941. init(): void;
  121942. /**
  121943. * Attaches the behavior to its arc rotate camera.
  121944. * @param camera Defines the camera to attach the behavior to
  121945. */
  121946. attach(camera: ArcRotateCamera): void;
  121947. /**
  121948. * Detaches the behavior from its current arc rotate camera.
  121949. */
  121950. detach(): void;
  121951. /**
  121952. * Returns true if user is scrolling.
  121953. * @return true if user is scrolling.
  121954. */
  121955. private _userIsZooming;
  121956. private _lastFrameRadius;
  121957. private _shouldAnimationStopForInteraction;
  121958. /**
  121959. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121960. */
  121961. private _applyUserInteraction;
  121962. private _userIsMoving;
  121963. }
  121964. }
  121965. declare module BABYLON {
  121966. /**
  121967. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  121968. */
  121969. export class AttachToBoxBehavior implements Behavior<Mesh> {
  121970. private ui;
  121971. /**
  121972. * The name of the behavior
  121973. */
  121974. name: string;
  121975. /**
  121976. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  121977. */
  121978. distanceAwayFromFace: number;
  121979. /**
  121980. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  121981. */
  121982. distanceAwayFromBottomOfFace: number;
  121983. private _faceVectors;
  121984. private _target;
  121985. private _scene;
  121986. private _onRenderObserver;
  121987. private _tmpMatrix;
  121988. private _tmpVector;
  121989. /**
  121990. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  121991. * @param ui The transform node that should be attched to the mesh
  121992. */
  121993. constructor(ui: TransformNode);
  121994. /**
  121995. * Initializes the behavior
  121996. */
  121997. init(): void;
  121998. private _closestFace;
  121999. private _zeroVector;
  122000. private _lookAtTmpMatrix;
  122001. private _lookAtToRef;
  122002. /**
  122003. * Attaches the AttachToBoxBehavior to the passed in mesh
  122004. * @param target The mesh that the specified node will be attached to
  122005. */
  122006. attach(target: Mesh): void;
  122007. /**
  122008. * Detaches the behavior from the mesh
  122009. */
  122010. detach(): void;
  122011. }
  122012. }
  122013. declare module BABYLON {
  122014. /**
  122015. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122016. */
  122017. export class FadeInOutBehavior implements Behavior<Mesh> {
  122018. /**
  122019. * Time in milliseconds to delay before fading in (Default: 0)
  122020. */
  122021. delay: number;
  122022. /**
  122023. * Time in milliseconds for the mesh to fade in (Default: 300)
  122024. */
  122025. fadeInTime: number;
  122026. private _millisecondsPerFrame;
  122027. private _hovered;
  122028. private _hoverValue;
  122029. private _ownerNode;
  122030. /**
  122031. * Instatiates the FadeInOutBehavior
  122032. */
  122033. constructor();
  122034. /**
  122035. * The name of the behavior
  122036. */
  122037. get name(): string;
  122038. /**
  122039. * Initializes the behavior
  122040. */
  122041. init(): void;
  122042. /**
  122043. * Attaches the fade behavior on the passed in mesh
  122044. * @param ownerNode The mesh that will be faded in/out once attached
  122045. */
  122046. attach(ownerNode: Mesh): void;
  122047. /**
  122048. * Detaches the behavior from the mesh
  122049. */
  122050. detach(): void;
  122051. /**
  122052. * Triggers the mesh to begin fading in or out
  122053. * @param value if the object should fade in or out (true to fade in)
  122054. */
  122055. fadeIn(value: boolean): void;
  122056. private _update;
  122057. private _setAllVisibility;
  122058. }
  122059. }
  122060. declare module BABYLON {
  122061. /**
  122062. * Class containing a set of static utilities functions for managing Pivots
  122063. * @hidden
  122064. */
  122065. export class PivotTools {
  122066. private static _PivotCached;
  122067. private static _OldPivotPoint;
  122068. private static _PivotTranslation;
  122069. private static _PivotTmpVector;
  122070. /** @hidden */
  122071. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122072. /** @hidden */
  122073. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122074. }
  122075. }
  122076. declare module BABYLON {
  122077. /**
  122078. * Class containing static functions to help procedurally build meshes
  122079. */
  122080. export class PlaneBuilder {
  122081. /**
  122082. * Creates a plane mesh
  122083. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122084. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122085. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122089. * @param name defines the name of the mesh
  122090. * @param options defines the options used to create the mesh
  122091. * @param scene defines the hosting scene
  122092. * @returns the plane mesh
  122093. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122094. */
  122095. static CreatePlane(name: string, options: {
  122096. size?: number;
  122097. width?: number;
  122098. height?: number;
  122099. sideOrientation?: number;
  122100. frontUVs?: Vector4;
  122101. backUVs?: Vector4;
  122102. updatable?: boolean;
  122103. sourcePlane?: Plane;
  122104. }, scene?: Nullable<Scene>): Mesh;
  122105. }
  122106. }
  122107. declare module BABYLON {
  122108. /**
  122109. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  122110. */
  122111. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  122112. private static _AnyMouseID;
  122113. /**
  122114. * Abstract mesh the behavior is set on
  122115. */
  122116. attachedNode: AbstractMesh;
  122117. private _dragPlane;
  122118. private _scene;
  122119. private _pointerObserver;
  122120. private _beforeRenderObserver;
  122121. private static _planeScene;
  122122. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  122123. /**
  122124. * 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)
  122125. */
  122126. maxDragAngle: number;
  122127. /**
  122128. * @hidden
  122129. */
  122130. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  122131. /**
  122132. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122133. */
  122134. currentDraggingPointerID: number;
  122135. /**
  122136. * The last position where the pointer hit the drag plane in world space
  122137. */
  122138. lastDragPosition: Vector3;
  122139. /**
  122140. * If the behavior is currently in a dragging state
  122141. */
  122142. dragging: boolean;
  122143. /**
  122144. * 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)
  122145. */
  122146. dragDeltaRatio: number;
  122147. /**
  122148. * If the drag plane orientation should be updated during the dragging (Default: true)
  122149. */
  122150. updateDragPlane: boolean;
  122151. private _debugMode;
  122152. private _moving;
  122153. /**
  122154. * Fires each time the attached mesh is dragged with the pointer
  122155. * * delta between last drag position and current drag position in world space
  122156. * * dragDistance along the drag axis
  122157. * * dragPlaneNormal normal of the current drag plane used during the drag
  122158. * * dragPlanePoint in world space where the drag intersects the drag plane
  122159. */
  122160. onDragObservable: Observable<{
  122161. delta: Vector3;
  122162. dragPlanePoint: Vector3;
  122163. dragPlaneNormal: Vector3;
  122164. dragDistance: number;
  122165. pointerId: number;
  122166. }>;
  122167. /**
  122168. * Fires each time a drag begins (eg. mouse down on mesh)
  122169. */
  122170. onDragStartObservable: Observable<{
  122171. dragPlanePoint: Vector3;
  122172. pointerId: number;
  122173. }>;
  122174. /**
  122175. * Fires each time a drag ends (eg. mouse release after drag)
  122176. */
  122177. onDragEndObservable: Observable<{
  122178. dragPlanePoint: Vector3;
  122179. pointerId: number;
  122180. }>;
  122181. /**
  122182. * If the attached mesh should be moved when dragged
  122183. */
  122184. moveAttached: boolean;
  122185. /**
  122186. * If the drag behavior will react to drag events (Default: true)
  122187. */
  122188. enabled: boolean;
  122189. /**
  122190. * If pointer events should start and release the drag (Default: true)
  122191. */
  122192. startAndReleaseDragOnPointerEvents: boolean;
  122193. /**
  122194. * If camera controls should be detached during the drag
  122195. */
  122196. detachCameraControls: boolean;
  122197. /**
  122198. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122199. */
  122200. useObjectOrientationForDragging: boolean;
  122201. private _options;
  122202. /**
  122203. * Gets the options used by the behavior
  122204. */
  122205. get options(): {
  122206. dragAxis?: Vector3;
  122207. dragPlaneNormal?: Vector3;
  122208. };
  122209. /**
  122210. * Sets the options used by the behavior
  122211. */
  122212. set options(options: {
  122213. dragAxis?: Vector3;
  122214. dragPlaneNormal?: Vector3;
  122215. });
  122216. /**
  122217. * Creates a pointer drag behavior that can be attached to a mesh
  122218. * @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)
  122219. */
  122220. constructor(options?: {
  122221. dragAxis?: Vector3;
  122222. dragPlaneNormal?: Vector3;
  122223. });
  122224. /**
  122225. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122226. */
  122227. validateDrag: (targetPosition: Vector3) => boolean;
  122228. /**
  122229. * The name of the behavior
  122230. */
  122231. get name(): string;
  122232. /**
  122233. * Initializes the behavior
  122234. */
  122235. init(): void;
  122236. private _tmpVector;
  122237. private _alternatePickedPoint;
  122238. private _worldDragAxis;
  122239. private _targetPosition;
  122240. private _attachedElement;
  122241. /**
  122242. * Attaches the drag behavior the passed in mesh
  122243. * @param ownerNode The mesh that will be dragged around once attached
  122244. * @param predicate Predicate to use for pick filtering
  122245. */
  122246. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122247. /**
  122248. * Force relase the drag action by code.
  122249. */
  122250. releaseDrag(): void;
  122251. private _startDragRay;
  122252. private _lastPointerRay;
  122253. /**
  122254. * Simulates the start of a pointer drag event on the behavior
  122255. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122256. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122257. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122258. */
  122259. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122260. private _startDrag;
  122261. private _dragDelta;
  122262. private _moveDrag;
  122263. private _pickWithRayOnDragPlane;
  122264. private _pointA;
  122265. private _pointC;
  122266. private _localAxis;
  122267. private _lookAt;
  122268. private _updateDragPlanePosition;
  122269. /**
  122270. * Detaches the behavior from the mesh
  122271. */
  122272. detach(): void;
  122273. }
  122274. }
  122275. declare module BABYLON {
  122276. /**
  122277. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122278. */
  122279. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122280. private _dragBehaviorA;
  122281. private _dragBehaviorB;
  122282. private _startDistance;
  122283. private _initialScale;
  122284. private _targetScale;
  122285. private _ownerNode;
  122286. private _sceneRenderObserver;
  122287. /**
  122288. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122289. */
  122290. constructor();
  122291. /**
  122292. * The name of the behavior
  122293. */
  122294. get name(): string;
  122295. /**
  122296. * Initializes the behavior
  122297. */
  122298. init(): void;
  122299. private _getCurrentDistance;
  122300. /**
  122301. * Attaches the scale behavior the passed in mesh
  122302. * @param ownerNode The mesh that will be scaled around once attached
  122303. */
  122304. attach(ownerNode: Mesh): void;
  122305. /**
  122306. * Detaches the behavior from the mesh
  122307. */
  122308. detach(): void;
  122309. }
  122310. }
  122311. declare module BABYLON {
  122312. /**
  122313. * 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
  122314. */
  122315. export class SixDofDragBehavior implements Behavior<Mesh> {
  122316. private static _virtualScene;
  122317. private _ownerNode;
  122318. private _sceneRenderObserver;
  122319. private _scene;
  122320. private _targetPosition;
  122321. private _virtualOriginMesh;
  122322. private _virtualDragMesh;
  122323. private _pointerObserver;
  122324. private _moving;
  122325. private _startingOrientation;
  122326. private _attachedElement;
  122327. /**
  122328. * 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)
  122329. */
  122330. private zDragFactor;
  122331. /**
  122332. * If the object should rotate to face the drag origin
  122333. */
  122334. rotateDraggedObject: boolean;
  122335. /**
  122336. * If the behavior is currently in a dragging state
  122337. */
  122338. dragging: boolean;
  122339. /**
  122340. * 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)
  122341. */
  122342. dragDeltaRatio: number;
  122343. /**
  122344. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122345. */
  122346. currentDraggingPointerID: number;
  122347. /**
  122348. * If camera controls should be detached during the drag
  122349. */
  122350. detachCameraControls: boolean;
  122351. /**
  122352. * Fires each time a drag starts
  122353. */
  122354. onDragStartObservable: Observable<{}>;
  122355. /**
  122356. * Fires each time a drag ends (eg. mouse release after drag)
  122357. */
  122358. onDragEndObservable: Observable<{}>;
  122359. /**
  122360. * 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
  122361. */
  122362. constructor();
  122363. /**
  122364. * The name of the behavior
  122365. */
  122366. get name(): string;
  122367. /**
  122368. * Initializes the behavior
  122369. */
  122370. init(): void;
  122371. /**
  122372. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122373. */
  122374. private get _pointerCamera();
  122375. /**
  122376. * Attaches the scale behavior the passed in mesh
  122377. * @param ownerNode The mesh that will be scaled around once attached
  122378. */
  122379. attach(ownerNode: Mesh): void;
  122380. /**
  122381. * Detaches the behavior from the mesh
  122382. */
  122383. detach(): void;
  122384. }
  122385. }
  122386. declare module BABYLON {
  122387. /**
  122388. * Class used to apply inverse kinematics to bones
  122389. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122390. */
  122391. export class BoneIKController {
  122392. private static _tmpVecs;
  122393. private static _tmpQuat;
  122394. private static _tmpMats;
  122395. /**
  122396. * Gets or sets the target mesh
  122397. */
  122398. targetMesh: AbstractMesh;
  122399. /** Gets or sets the mesh used as pole */
  122400. poleTargetMesh: AbstractMesh;
  122401. /**
  122402. * Gets or sets the bone used as pole
  122403. */
  122404. poleTargetBone: Nullable<Bone>;
  122405. /**
  122406. * Gets or sets the target position
  122407. */
  122408. targetPosition: Vector3;
  122409. /**
  122410. * Gets or sets the pole target position
  122411. */
  122412. poleTargetPosition: Vector3;
  122413. /**
  122414. * Gets or sets the pole target local offset
  122415. */
  122416. poleTargetLocalOffset: Vector3;
  122417. /**
  122418. * Gets or sets the pole angle
  122419. */
  122420. poleAngle: number;
  122421. /**
  122422. * Gets or sets the mesh associated with the controller
  122423. */
  122424. mesh: AbstractMesh;
  122425. /**
  122426. * 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)
  122427. */
  122428. slerpAmount: number;
  122429. private _bone1Quat;
  122430. private _bone1Mat;
  122431. private _bone2Ang;
  122432. private _bone1;
  122433. private _bone2;
  122434. private _bone1Length;
  122435. private _bone2Length;
  122436. private _maxAngle;
  122437. private _maxReach;
  122438. private _rightHandedSystem;
  122439. private _bendAxis;
  122440. private _slerping;
  122441. private _adjustRoll;
  122442. /**
  122443. * Gets or sets maximum allowed angle
  122444. */
  122445. get maxAngle(): number;
  122446. set maxAngle(value: number);
  122447. /**
  122448. * Creates a new BoneIKController
  122449. * @param mesh defines the mesh to control
  122450. * @param bone defines the bone to control
  122451. * @param options defines options to set up the controller
  122452. */
  122453. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122454. targetMesh?: AbstractMesh;
  122455. poleTargetMesh?: AbstractMesh;
  122456. poleTargetBone?: Bone;
  122457. poleTargetLocalOffset?: Vector3;
  122458. poleAngle?: number;
  122459. bendAxis?: Vector3;
  122460. maxAngle?: number;
  122461. slerpAmount?: number;
  122462. });
  122463. private _setMaxAngle;
  122464. /**
  122465. * Force the controller to update the bones
  122466. */
  122467. update(): void;
  122468. }
  122469. }
  122470. declare module BABYLON {
  122471. /**
  122472. * Class used to make a bone look toward a point in space
  122473. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  122474. */
  122475. export class BoneLookController {
  122476. private static _tmpVecs;
  122477. private static _tmpQuat;
  122478. private static _tmpMats;
  122479. /**
  122480. * The target Vector3 that the bone will look at
  122481. */
  122482. target: Vector3;
  122483. /**
  122484. * The mesh that the bone is attached to
  122485. */
  122486. mesh: AbstractMesh;
  122487. /**
  122488. * The bone that will be looking to the target
  122489. */
  122490. bone: Bone;
  122491. /**
  122492. * The up axis of the coordinate system that is used when the bone is rotated
  122493. */
  122494. upAxis: Vector3;
  122495. /**
  122496. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  122497. */
  122498. upAxisSpace: Space;
  122499. /**
  122500. * Used to make an adjustment to the yaw of the bone
  122501. */
  122502. adjustYaw: number;
  122503. /**
  122504. * Used to make an adjustment to the pitch of the bone
  122505. */
  122506. adjustPitch: number;
  122507. /**
  122508. * Used to make an adjustment to the roll of the bone
  122509. */
  122510. adjustRoll: number;
  122511. /**
  122512. * 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)
  122513. */
  122514. slerpAmount: number;
  122515. private _minYaw;
  122516. private _maxYaw;
  122517. private _minPitch;
  122518. private _maxPitch;
  122519. private _minYawSin;
  122520. private _minYawCos;
  122521. private _maxYawSin;
  122522. private _maxYawCos;
  122523. private _midYawConstraint;
  122524. private _minPitchTan;
  122525. private _maxPitchTan;
  122526. private _boneQuat;
  122527. private _slerping;
  122528. private _transformYawPitch;
  122529. private _transformYawPitchInv;
  122530. private _firstFrameSkipped;
  122531. private _yawRange;
  122532. private _fowardAxis;
  122533. /**
  122534. * Gets or sets the minimum yaw angle that the bone can look to
  122535. */
  122536. get minYaw(): number;
  122537. set minYaw(value: number);
  122538. /**
  122539. * Gets or sets the maximum yaw angle that the bone can look to
  122540. */
  122541. get maxYaw(): number;
  122542. set maxYaw(value: number);
  122543. /**
  122544. * Gets or sets the minimum pitch angle that the bone can look to
  122545. */
  122546. get minPitch(): number;
  122547. set minPitch(value: number);
  122548. /**
  122549. * Gets or sets the maximum pitch angle that the bone can look to
  122550. */
  122551. get maxPitch(): number;
  122552. set maxPitch(value: number);
  122553. /**
  122554. * Create a BoneLookController
  122555. * @param mesh the mesh that the bone belongs to
  122556. * @param bone the bone that will be looking to the target
  122557. * @param target the target Vector3 to look at
  122558. * @param options optional settings:
  122559. * * maxYaw: the maximum angle the bone will yaw to
  122560. * * minYaw: the minimum angle the bone will yaw to
  122561. * * maxPitch: the maximum angle the bone will pitch to
  122562. * * minPitch: the minimum angle the bone will yaw to
  122563. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  122564. * * upAxis: the up axis of the coordinate system
  122565. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  122566. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  122567. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  122568. * * adjustYaw: used to make an adjustment to the yaw of the bone
  122569. * * adjustPitch: used to make an adjustment to the pitch of the bone
  122570. * * adjustRoll: used to make an adjustment to the roll of the bone
  122571. **/
  122572. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  122573. maxYaw?: number;
  122574. minYaw?: number;
  122575. maxPitch?: number;
  122576. minPitch?: number;
  122577. slerpAmount?: number;
  122578. upAxis?: Vector3;
  122579. upAxisSpace?: Space;
  122580. yawAxis?: Vector3;
  122581. pitchAxis?: Vector3;
  122582. adjustYaw?: number;
  122583. adjustPitch?: number;
  122584. adjustRoll?: number;
  122585. });
  122586. /**
  122587. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  122588. */
  122589. update(): void;
  122590. private _getAngleDiff;
  122591. private _getAngleBetween;
  122592. private _isAngleBetween;
  122593. }
  122594. }
  122595. declare module BABYLON {
  122596. /**
  122597. * Manage the gamepad inputs to control an arc rotate camera.
  122598. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122599. */
  122600. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  122601. /**
  122602. * Defines the camera the input is attached to.
  122603. */
  122604. camera: ArcRotateCamera;
  122605. /**
  122606. * Defines the gamepad the input is gathering event from.
  122607. */
  122608. gamepad: Nullable<Gamepad>;
  122609. /**
  122610. * Defines the gamepad rotation sensiblity.
  122611. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122612. */
  122613. gamepadRotationSensibility: number;
  122614. /**
  122615. * Defines the gamepad move sensiblity.
  122616. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122617. */
  122618. gamepadMoveSensibility: number;
  122619. private _yAxisScale;
  122620. /**
  122621. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122622. */
  122623. get invertYAxis(): boolean;
  122624. set invertYAxis(value: boolean);
  122625. private _onGamepadConnectedObserver;
  122626. private _onGamepadDisconnectedObserver;
  122627. /**
  122628. * Attach the input controls to a specific dom element to get the input from.
  122629. * @param element Defines the element the controls should be listened from
  122630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122631. */
  122632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122633. /**
  122634. * Detach the current controls from the specified dom element.
  122635. * @param element Defines the element to stop listening the inputs from
  122636. */
  122637. detachControl(element: Nullable<HTMLElement>): void;
  122638. /**
  122639. * Update the current camera state depending on the inputs that have been used this frame.
  122640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122641. */
  122642. checkInputs(): void;
  122643. /**
  122644. * Gets the class name of the current intput.
  122645. * @returns the class name
  122646. */
  122647. getClassName(): string;
  122648. /**
  122649. * Get the friendly name associated with the input class.
  122650. * @returns the input friendly name
  122651. */
  122652. getSimpleName(): string;
  122653. }
  122654. }
  122655. declare module BABYLON {
  122656. interface ArcRotateCameraInputsManager {
  122657. /**
  122658. * Add orientation input support to the input manager.
  122659. * @returns the current input manager
  122660. */
  122661. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  122662. }
  122663. /**
  122664. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  122665. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122666. */
  122667. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  122668. /**
  122669. * Defines the camera the input is attached to.
  122670. */
  122671. camera: ArcRotateCamera;
  122672. /**
  122673. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  122674. */
  122675. alphaCorrection: number;
  122676. /**
  122677. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  122678. */
  122679. gammaCorrection: number;
  122680. private _alpha;
  122681. private _gamma;
  122682. private _dirty;
  122683. private _deviceOrientationHandler;
  122684. /**
  122685. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  122686. */
  122687. constructor();
  122688. /**
  122689. * Attach the input controls to a specific dom element to get the input from.
  122690. * @param element Defines the element the controls should be listened from
  122691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122692. */
  122693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122694. /** @hidden */
  122695. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  122696. /**
  122697. * Update the current camera state depending on the inputs that have been used this frame.
  122698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122699. */
  122700. checkInputs(): void;
  122701. /**
  122702. * Detach the current controls from the specified dom element.
  122703. * @param element Defines the element to stop listening the inputs from
  122704. */
  122705. detachControl(element: Nullable<HTMLElement>): void;
  122706. /**
  122707. * Gets the class name of the current intput.
  122708. * @returns the class name
  122709. */
  122710. getClassName(): string;
  122711. /**
  122712. * Get the friendly name associated with the input class.
  122713. * @returns the input friendly name
  122714. */
  122715. getSimpleName(): string;
  122716. }
  122717. }
  122718. declare module BABYLON {
  122719. /**
  122720. * Listen to mouse events to control the camera.
  122721. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122722. */
  122723. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  122724. /**
  122725. * Defines the camera the input is attached to.
  122726. */
  122727. camera: FlyCamera;
  122728. /**
  122729. * Defines if touch is enabled. (Default is true.)
  122730. */
  122731. touchEnabled: boolean;
  122732. /**
  122733. * Defines the buttons associated with the input to handle camera rotation.
  122734. */
  122735. buttons: number[];
  122736. /**
  122737. * Assign buttons for Yaw control.
  122738. */
  122739. buttonsYaw: number[];
  122740. /**
  122741. * Assign buttons for Pitch control.
  122742. */
  122743. buttonsPitch: number[];
  122744. /**
  122745. * Assign buttons for Roll control.
  122746. */
  122747. buttonsRoll: number[];
  122748. /**
  122749. * Detect if any button is being pressed while mouse is moved.
  122750. * -1 = Mouse locked.
  122751. * 0 = Left button.
  122752. * 1 = Middle Button.
  122753. * 2 = Right Button.
  122754. */
  122755. activeButton: number;
  122756. /**
  122757. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  122758. * Higher values reduce its sensitivity.
  122759. */
  122760. angularSensibility: number;
  122761. private _mousemoveCallback;
  122762. private _observer;
  122763. private _rollObserver;
  122764. private previousPosition;
  122765. private noPreventDefault;
  122766. private element;
  122767. /**
  122768. * Listen to mouse events to control the camera.
  122769. * @param touchEnabled Define if touch is enabled. (Default is true.)
  122770. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122771. */
  122772. constructor(touchEnabled?: boolean);
  122773. /**
  122774. * Attach the mouse control to the HTML DOM element.
  122775. * @param element Defines the element that listens to the input events.
  122776. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  122777. */
  122778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122779. /**
  122780. * Detach the current controls from the specified dom element.
  122781. * @param element Defines the element to stop listening the inputs from
  122782. */
  122783. detachControl(element: Nullable<HTMLElement>): void;
  122784. /**
  122785. * Gets the class name of the current input.
  122786. * @returns the class name.
  122787. */
  122788. getClassName(): string;
  122789. /**
  122790. * Get the friendly name associated with the input class.
  122791. * @returns the input's friendly name.
  122792. */
  122793. getSimpleName(): string;
  122794. private _pointerInput;
  122795. private _onMouseMove;
  122796. /**
  122797. * Rotate camera by mouse offset.
  122798. */
  122799. private rotateCamera;
  122800. }
  122801. }
  122802. declare module BABYLON {
  122803. /**
  122804. * Default Inputs manager for the FlyCamera.
  122805. * It groups all the default supported inputs for ease of use.
  122806. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122807. */
  122808. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  122809. /**
  122810. * Instantiates a new FlyCameraInputsManager.
  122811. * @param camera Defines the camera the inputs belong to.
  122812. */
  122813. constructor(camera: FlyCamera);
  122814. /**
  122815. * Add keyboard input support to the input manager.
  122816. * @returns the new FlyCameraKeyboardMoveInput().
  122817. */
  122818. addKeyboard(): FlyCameraInputsManager;
  122819. /**
  122820. * Add mouse input support to the input manager.
  122821. * @param touchEnabled Enable touch screen support.
  122822. * @returns the new FlyCameraMouseInput().
  122823. */
  122824. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  122825. }
  122826. }
  122827. declare module BABYLON {
  122828. /**
  122829. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122830. * such as in a 3D Space Shooter or a Flight Simulator.
  122831. */
  122832. export class FlyCamera extends TargetCamera {
  122833. /**
  122834. * Define the collision ellipsoid of the camera.
  122835. * This is helpful for simulating a camera body, like a player's body.
  122836. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122837. */
  122838. ellipsoid: Vector3;
  122839. /**
  122840. * Define an offset for the position of the ellipsoid around the camera.
  122841. * This can be helpful if the camera is attached away from the player's body center,
  122842. * such as at its head.
  122843. */
  122844. ellipsoidOffset: Vector3;
  122845. /**
  122846. * Enable or disable collisions of the camera with the rest of the scene objects.
  122847. */
  122848. checkCollisions: boolean;
  122849. /**
  122850. * Enable or disable gravity on the camera.
  122851. */
  122852. applyGravity: boolean;
  122853. /**
  122854. * Define the current direction the camera is moving to.
  122855. */
  122856. cameraDirection: Vector3;
  122857. /**
  122858. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  122859. * This overrides and empties cameraRotation.
  122860. */
  122861. rotationQuaternion: Quaternion;
  122862. /**
  122863. * Track Roll to maintain the wanted Rolling when looking around.
  122864. */
  122865. _trackRoll: number;
  122866. /**
  122867. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  122868. */
  122869. rollCorrect: number;
  122870. /**
  122871. * Mimic a banked turn, Rolling the camera when Yawing.
  122872. * It's recommended to use rollCorrect = 10 for faster banking correction.
  122873. */
  122874. bankedTurn: boolean;
  122875. /**
  122876. * Limit in radians for how much Roll banking will add. (Default: 90°)
  122877. */
  122878. bankedTurnLimit: number;
  122879. /**
  122880. * Value of 0 disables the banked Roll.
  122881. * Value of 1 is equal to the Yaw angle in radians.
  122882. */
  122883. bankedTurnMultiplier: number;
  122884. /**
  122885. * The inputs manager loads all the input sources, such as keyboard and mouse.
  122886. */
  122887. inputs: FlyCameraInputsManager;
  122888. /**
  122889. * Gets the input sensibility for mouse input.
  122890. * Higher values reduce sensitivity.
  122891. */
  122892. get angularSensibility(): number;
  122893. /**
  122894. * Sets the input sensibility for a mouse input.
  122895. * Higher values reduce sensitivity.
  122896. */
  122897. set angularSensibility(value: number);
  122898. /**
  122899. * Get the keys for camera movement forward.
  122900. */
  122901. get keysForward(): number[];
  122902. /**
  122903. * Set the keys for camera movement forward.
  122904. */
  122905. set keysForward(value: number[]);
  122906. /**
  122907. * Get the keys for camera movement backward.
  122908. */
  122909. get keysBackward(): number[];
  122910. set keysBackward(value: number[]);
  122911. /**
  122912. * Get the keys for camera movement up.
  122913. */
  122914. get keysUp(): number[];
  122915. /**
  122916. * Set the keys for camera movement up.
  122917. */
  122918. set keysUp(value: number[]);
  122919. /**
  122920. * Get the keys for camera movement down.
  122921. */
  122922. get keysDown(): number[];
  122923. /**
  122924. * Set the keys for camera movement down.
  122925. */
  122926. set keysDown(value: number[]);
  122927. /**
  122928. * Get the keys for camera movement left.
  122929. */
  122930. get keysLeft(): number[];
  122931. /**
  122932. * Set the keys for camera movement left.
  122933. */
  122934. set keysLeft(value: number[]);
  122935. /**
  122936. * Set the keys for camera movement right.
  122937. */
  122938. get keysRight(): number[];
  122939. /**
  122940. * Set the keys for camera movement right.
  122941. */
  122942. set keysRight(value: number[]);
  122943. /**
  122944. * Event raised when the camera collides with a mesh in the scene.
  122945. */
  122946. onCollide: (collidedMesh: AbstractMesh) => void;
  122947. private _collider;
  122948. private _needMoveForGravity;
  122949. private _oldPosition;
  122950. private _diffPosition;
  122951. private _newPosition;
  122952. /** @hidden */
  122953. _localDirection: Vector3;
  122954. /** @hidden */
  122955. _transformedDirection: Vector3;
  122956. /**
  122957. * Instantiates a FlyCamera.
  122958. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122959. * such as in a 3D Space Shooter or a Flight Simulator.
  122960. * @param name Define the name of the camera in the scene.
  122961. * @param position Define the starting position of the camera in the scene.
  122962. * @param scene Define the scene the camera belongs to.
  122963. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  122964. */
  122965. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122966. /**
  122967. * Attach a control to the HTML DOM element.
  122968. * @param element Defines the element that listens to the input events.
  122969. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  122970. */
  122971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122972. /**
  122973. * Detach a control from the HTML DOM element.
  122974. * The camera will stop reacting to that input.
  122975. * @param element Defines the element that listens to the input events.
  122976. */
  122977. detachControl(element: HTMLElement): void;
  122978. private _collisionMask;
  122979. /**
  122980. * Get the mask that the camera ignores in collision events.
  122981. */
  122982. get collisionMask(): number;
  122983. /**
  122984. * Set the mask that the camera ignores in collision events.
  122985. */
  122986. set collisionMask(mask: number);
  122987. /** @hidden */
  122988. _collideWithWorld(displacement: Vector3): void;
  122989. /** @hidden */
  122990. private _onCollisionPositionChange;
  122991. /** @hidden */
  122992. _checkInputs(): void;
  122993. /** @hidden */
  122994. _decideIfNeedsToMove(): boolean;
  122995. /** @hidden */
  122996. _updatePosition(): void;
  122997. /**
  122998. * Restore the Roll to its target value at the rate specified.
  122999. * @param rate - Higher means slower restoring.
  123000. * @hidden
  123001. */
  123002. restoreRoll(rate: number): void;
  123003. /**
  123004. * Destroy the camera and release the current resources held by it.
  123005. */
  123006. dispose(): void;
  123007. /**
  123008. * Get the current object class name.
  123009. * @returns the class name.
  123010. */
  123011. getClassName(): string;
  123012. }
  123013. }
  123014. declare module BABYLON {
  123015. /**
  123016. * Listen to keyboard events to control the camera.
  123017. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123018. */
  123019. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123020. /**
  123021. * Defines the camera the input is attached to.
  123022. */
  123023. camera: FlyCamera;
  123024. /**
  123025. * The list of keyboard keys used to control the forward move of the camera.
  123026. */
  123027. keysForward: number[];
  123028. /**
  123029. * The list of keyboard keys used to control the backward move of the camera.
  123030. */
  123031. keysBackward: number[];
  123032. /**
  123033. * The list of keyboard keys used to control the forward move of the camera.
  123034. */
  123035. keysUp: number[];
  123036. /**
  123037. * The list of keyboard keys used to control the backward move of the camera.
  123038. */
  123039. keysDown: number[];
  123040. /**
  123041. * The list of keyboard keys used to control the right strafe move of the camera.
  123042. */
  123043. keysRight: number[];
  123044. /**
  123045. * The list of keyboard keys used to control the left strafe move of the camera.
  123046. */
  123047. keysLeft: number[];
  123048. private _keys;
  123049. private _onCanvasBlurObserver;
  123050. private _onKeyboardObserver;
  123051. private _engine;
  123052. private _scene;
  123053. /**
  123054. * Attach the input controls to a specific dom element to get the input from.
  123055. * @param element Defines the element the controls should be listened from
  123056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123057. */
  123058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123059. /**
  123060. * Detach the current controls from the specified dom element.
  123061. * @param element Defines the element to stop listening the inputs from
  123062. */
  123063. detachControl(element: Nullable<HTMLElement>): void;
  123064. /**
  123065. * Gets the class name of the current intput.
  123066. * @returns the class name
  123067. */
  123068. getClassName(): string;
  123069. /** @hidden */
  123070. _onLostFocus(e: FocusEvent): void;
  123071. /**
  123072. * Get the friendly name associated with the input class.
  123073. * @returns the input friendly name
  123074. */
  123075. getSimpleName(): string;
  123076. /**
  123077. * Update the current camera state depending on the inputs that have been used this frame.
  123078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123079. */
  123080. checkInputs(): void;
  123081. }
  123082. }
  123083. declare module BABYLON {
  123084. /**
  123085. * Manage the mouse wheel inputs to control a follow camera.
  123086. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123087. */
  123088. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  123089. /**
  123090. * Defines the camera the input is attached to.
  123091. */
  123092. camera: FollowCamera;
  123093. /**
  123094. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  123095. */
  123096. axisControlRadius: boolean;
  123097. /**
  123098. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  123099. */
  123100. axisControlHeight: boolean;
  123101. /**
  123102. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  123103. */
  123104. axisControlRotation: boolean;
  123105. /**
  123106. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  123107. * relation to mouseWheel events.
  123108. */
  123109. wheelPrecision: number;
  123110. /**
  123111. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123112. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123113. */
  123114. wheelDeltaPercentage: number;
  123115. private _wheel;
  123116. private _observer;
  123117. /**
  123118. * Attach the input controls to a specific dom element to get the input from.
  123119. * @param element Defines the element the controls should be listened from
  123120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123121. */
  123122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123123. /**
  123124. * Detach the current controls from the specified dom element.
  123125. * @param element Defines the element to stop listening the inputs from
  123126. */
  123127. detachControl(element: Nullable<HTMLElement>): void;
  123128. /**
  123129. * Gets the class name of the current intput.
  123130. * @returns the class name
  123131. */
  123132. getClassName(): string;
  123133. /**
  123134. * Get the friendly name associated with the input class.
  123135. * @returns the input friendly name
  123136. */
  123137. getSimpleName(): string;
  123138. }
  123139. }
  123140. declare module BABYLON {
  123141. /**
  123142. * Manage the pointers inputs to control an follow camera.
  123143. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123144. */
  123145. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  123146. /**
  123147. * Defines the camera the input is attached to.
  123148. */
  123149. camera: FollowCamera;
  123150. /**
  123151. * Gets the class name of the current input.
  123152. * @returns the class name
  123153. */
  123154. getClassName(): string;
  123155. /**
  123156. * Defines the pointer angular sensibility along the X axis or how fast is
  123157. * the camera rotating.
  123158. * A negative number will reverse the axis direction.
  123159. */
  123160. angularSensibilityX: number;
  123161. /**
  123162. * Defines the pointer angular sensibility along the Y axis or how fast is
  123163. * the camera rotating.
  123164. * A negative number will reverse the axis direction.
  123165. */
  123166. angularSensibilityY: number;
  123167. /**
  123168. * Defines the pointer pinch precision or how fast is the camera zooming.
  123169. * A negative number will reverse the axis direction.
  123170. */
  123171. pinchPrecision: number;
  123172. /**
  123173. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123174. * from 0.
  123175. * It defines the percentage of current camera.radius to use as delta when
  123176. * pinch zoom is used.
  123177. */
  123178. pinchDeltaPercentage: number;
  123179. /**
  123180. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123181. */
  123182. axisXControlRadius: boolean;
  123183. /**
  123184. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123185. */
  123186. axisXControlHeight: boolean;
  123187. /**
  123188. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123189. */
  123190. axisXControlRotation: boolean;
  123191. /**
  123192. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123193. */
  123194. axisYControlRadius: boolean;
  123195. /**
  123196. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123197. */
  123198. axisYControlHeight: boolean;
  123199. /**
  123200. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123201. */
  123202. axisYControlRotation: boolean;
  123203. /**
  123204. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123205. */
  123206. axisPinchControlRadius: boolean;
  123207. /**
  123208. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123209. */
  123210. axisPinchControlHeight: boolean;
  123211. /**
  123212. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123213. */
  123214. axisPinchControlRotation: boolean;
  123215. /**
  123216. * Log error messages if basic misconfiguration has occurred.
  123217. */
  123218. warningEnable: boolean;
  123219. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123220. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123221. private _warningCounter;
  123222. private _warning;
  123223. }
  123224. }
  123225. declare module BABYLON {
  123226. /**
  123227. * Default Inputs manager for the FollowCamera.
  123228. * It groups all the default supported inputs for ease of use.
  123229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123230. */
  123231. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123232. /**
  123233. * Instantiates a new FollowCameraInputsManager.
  123234. * @param camera Defines the camera the inputs belong to
  123235. */
  123236. constructor(camera: FollowCamera);
  123237. /**
  123238. * Add keyboard input support to the input manager.
  123239. * @returns the current input manager
  123240. */
  123241. addKeyboard(): FollowCameraInputsManager;
  123242. /**
  123243. * Add mouse wheel input support to the input manager.
  123244. * @returns the current input manager
  123245. */
  123246. addMouseWheel(): FollowCameraInputsManager;
  123247. /**
  123248. * Add pointers input support to the input manager.
  123249. * @returns the current input manager
  123250. */
  123251. addPointers(): FollowCameraInputsManager;
  123252. /**
  123253. * Add orientation input support to the input manager.
  123254. * @returns the current input manager
  123255. */
  123256. addVRDeviceOrientation(): FollowCameraInputsManager;
  123257. }
  123258. }
  123259. declare module BABYLON {
  123260. /**
  123261. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123262. * an arc rotate version arcFollowCamera are available.
  123263. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123264. */
  123265. export class FollowCamera extends TargetCamera {
  123266. /**
  123267. * Distance the follow camera should follow an object at
  123268. */
  123269. radius: number;
  123270. /**
  123271. * Minimum allowed distance of the camera to the axis of rotation
  123272. * (The camera can not get closer).
  123273. * This can help limiting how the Camera is able to move in the scene.
  123274. */
  123275. lowerRadiusLimit: Nullable<number>;
  123276. /**
  123277. * Maximum allowed distance of the camera to the axis of rotation
  123278. * (The camera can not get further).
  123279. * This can help limiting how the Camera is able to move in the scene.
  123280. */
  123281. upperRadiusLimit: Nullable<number>;
  123282. /**
  123283. * Define a rotation offset between the camera and the object it follows
  123284. */
  123285. rotationOffset: number;
  123286. /**
  123287. * Minimum allowed angle to camera position relative to target object.
  123288. * This can help limiting how the Camera is able to move in the scene.
  123289. */
  123290. lowerRotationOffsetLimit: Nullable<number>;
  123291. /**
  123292. * Maximum allowed angle to camera position relative to target object.
  123293. * This can help limiting how the Camera is able to move in the scene.
  123294. */
  123295. upperRotationOffsetLimit: Nullable<number>;
  123296. /**
  123297. * Define a height offset between the camera and the object it follows.
  123298. * It can help following an object from the top (like a car chaing a plane)
  123299. */
  123300. heightOffset: number;
  123301. /**
  123302. * Minimum allowed height of camera position relative to target object.
  123303. * This can help limiting how the Camera is able to move in the scene.
  123304. */
  123305. lowerHeightOffsetLimit: Nullable<number>;
  123306. /**
  123307. * Maximum allowed height of camera position relative to target object.
  123308. * This can help limiting how the Camera is able to move in the scene.
  123309. */
  123310. upperHeightOffsetLimit: Nullable<number>;
  123311. /**
  123312. * Define how fast the camera can accelerate to follow it s target.
  123313. */
  123314. cameraAcceleration: number;
  123315. /**
  123316. * Define the speed limit of the camera following an object.
  123317. */
  123318. maxCameraSpeed: number;
  123319. /**
  123320. * Define the target of the camera.
  123321. */
  123322. lockedTarget: Nullable<AbstractMesh>;
  123323. /**
  123324. * Defines the input associated with the camera.
  123325. */
  123326. inputs: FollowCameraInputsManager;
  123327. /**
  123328. * Instantiates the follow camera.
  123329. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123330. * @param name Define the name of the camera in the scene
  123331. * @param position Define the position of the camera
  123332. * @param scene Define the scene the camera belong to
  123333. * @param lockedTarget Define the target of the camera
  123334. */
  123335. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123336. private _follow;
  123337. /**
  123338. * Attached controls to the current camera.
  123339. * @param element Defines the element the controls should be listened from
  123340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123341. */
  123342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123343. /**
  123344. * Detach the current controls from the camera.
  123345. * The camera will stop reacting to inputs.
  123346. * @param element Defines the element to stop listening the inputs from
  123347. */
  123348. detachControl(element: HTMLElement): void;
  123349. /** @hidden */
  123350. _checkInputs(): void;
  123351. private _checkLimits;
  123352. /**
  123353. * Gets the camera class name.
  123354. * @returns the class name
  123355. */
  123356. getClassName(): string;
  123357. }
  123358. /**
  123359. * Arc Rotate version of the follow camera.
  123360. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123361. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123362. */
  123363. export class ArcFollowCamera extends TargetCamera {
  123364. /** The longitudinal angle of the camera */
  123365. alpha: number;
  123366. /** The latitudinal angle of the camera */
  123367. beta: number;
  123368. /** The radius of the camera from its target */
  123369. radius: number;
  123370. /** Define the camera target (the mesh it should follow) */
  123371. target: Nullable<AbstractMesh>;
  123372. private _cartesianCoordinates;
  123373. /**
  123374. * Instantiates a new ArcFollowCamera
  123375. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123376. * @param name Define the name of the camera
  123377. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123378. * @param beta Define the rotation angle of the camera around the elevation axis
  123379. * @param radius Define the radius of the camera from its target point
  123380. * @param target Define the target of the camera
  123381. * @param scene Define the scene the camera belongs to
  123382. */
  123383. constructor(name: string,
  123384. /** The longitudinal angle of the camera */
  123385. alpha: number,
  123386. /** The latitudinal angle of the camera */
  123387. beta: number,
  123388. /** The radius of the camera from its target */
  123389. radius: number,
  123390. /** Define the camera target (the mesh it should follow) */
  123391. target: Nullable<AbstractMesh>, scene: Scene);
  123392. private _follow;
  123393. /** @hidden */
  123394. _checkInputs(): void;
  123395. /**
  123396. * Returns the class name of the object.
  123397. * It is mostly used internally for serialization purposes.
  123398. */
  123399. getClassName(): string;
  123400. }
  123401. }
  123402. declare module BABYLON {
  123403. /**
  123404. * Manage the keyboard inputs to control the movement of a follow camera.
  123405. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123406. */
  123407. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123408. /**
  123409. * Defines the camera the input is attached to.
  123410. */
  123411. camera: FollowCamera;
  123412. /**
  123413. * Defines the list of key codes associated with the up action (increase heightOffset)
  123414. */
  123415. keysHeightOffsetIncr: number[];
  123416. /**
  123417. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123418. */
  123419. keysHeightOffsetDecr: number[];
  123420. /**
  123421. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123422. */
  123423. keysHeightOffsetModifierAlt: boolean;
  123424. /**
  123425. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123426. */
  123427. keysHeightOffsetModifierCtrl: boolean;
  123428. /**
  123429. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123430. */
  123431. keysHeightOffsetModifierShift: boolean;
  123432. /**
  123433. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123434. */
  123435. keysRotationOffsetIncr: number[];
  123436. /**
  123437. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123438. */
  123439. keysRotationOffsetDecr: number[];
  123440. /**
  123441. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123442. */
  123443. keysRotationOffsetModifierAlt: boolean;
  123444. /**
  123445. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123446. */
  123447. keysRotationOffsetModifierCtrl: boolean;
  123448. /**
  123449. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123450. */
  123451. keysRotationOffsetModifierShift: boolean;
  123452. /**
  123453. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123454. */
  123455. keysRadiusIncr: number[];
  123456. /**
  123457. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123458. */
  123459. keysRadiusDecr: number[];
  123460. /**
  123461. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  123462. */
  123463. keysRadiusModifierAlt: boolean;
  123464. /**
  123465. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  123466. */
  123467. keysRadiusModifierCtrl: boolean;
  123468. /**
  123469. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  123470. */
  123471. keysRadiusModifierShift: boolean;
  123472. /**
  123473. * Defines the rate of change of heightOffset.
  123474. */
  123475. heightSensibility: number;
  123476. /**
  123477. * Defines the rate of change of rotationOffset.
  123478. */
  123479. rotationSensibility: number;
  123480. /**
  123481. * Defines the rate of change of radius.
  123482. */
  123483. radiusSensibility: number;
  123484. private _keys;
  123485. private _ctrlPressed;
  123486. private _altPressed;
  123487. private _shiftPressed;
  123488. private _onCanvasBlurObserver;
  123489. private _onKeyboardObserver;
  123490. private _engine;
  123491. private _scene;
  123492. /**
  123493. * Attach the input controls to a specific dom element to get the input from.
  123494. * @param element Defines the element the controls should be listened from
  123495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123496. */
  123497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123498. /**
  123499. * Detach the current controls from the specified dom element.
  123500. * @param element Defines the element to stop listening the inputs from
  123501. */
  123502. detachControl(element: Nullable<HTMLElement>): void;
  123503. /**
  123504. * Update the current camera state depending on the inputs that have been used this frame.
  123505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123506. */
  123507. checkInputs(): void;
  123508. /**
  123509. * Gets the class name of the current input.
  123510. * @returns the class name
  123511. */
  123512. getClassName(): string;
  123513. /**
  123514. * Get the friendly name associated with the input class.
  123515. * @returns the input friendly name
  123516. */
  123517. getSimpleName(): string;
  123518. /**
  123519. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123520. * allow modification of the heightOffset value.
  123521. */
  123522. private _modifierHeightOffset;
  123523. /**
  123524. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123525. * allow modification of the rotationOffset value.
  123526. */
  123527. private _modifierRotationOffset;
  123528. /**
  123529. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123530. * allow modification of the radius value.
  123531. */
  123532. private _modifierRadius;
  123533. }
  123534. }
  123535. declare module BABYLON {
  123536. interface FreeCameraInputsManager {
  123537. /**
  123538. * @hidden
  123539. */
  123540. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  123541. /**
  123542. * Add orientation input support to the input manager.
  123543. * @returns the current input manager
  123544. */
  123545. addDeviceOrientation(): FreeCameraInputsManager;
  123546. }
  123547. /**
  123548. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  123549. * Screen rotation is taken into account.
  123550. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123551. */
  123552. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  123553. private _camera;
  123554. private _screenOrientationAngle;
  123555. private _constantTranform;
  123556. private _screenQuaternion;
  123557. private _alpha;
  123558. private _beta;
  123559. private _gamma;
  123560. /**
  123561. * Can be used to detect if a device orientation sensor is available on a device
  123562. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  123563. * @returns a promise that will resolve on orientation change
  123564. */
  123565. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  123566. /**
  123567. * @hidden
  123568. */
  123569. _onDeviceOrientationChangedObservable: Observable<void>;
  123570. /**
  123571. * Instantiates a new input
  123572. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123573. */
  123574. constructor();
  123575. /**
  123576. * Define the camera controlled by the input.
  123577. */
  123578. get camera(): FreeCamera;
  123579. set camera(camera: FreeCamera);
  123580. /**
  123581. * Attach the input controls to a specific dom element to get the input from.
  123582. * @param element Defines the element the controls should be listened from
  123583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123584. */
  123585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123586. private _orientationChanged;
  123587. private _deviceOrientation;
  123588. /**
  123589. * Detach the current controls from the specified dom element.
  123590. * @param element Defines the element to stop listening the inputs from
  123591. */
  123592. detachControl(element: Nullable<HTMLElement>): void;
  123593. /**
  123594. * Update the current camera state depending on the inputs that have been used this frame.
  123595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123596. */
  123597. checkInputs(): void;
  123598. /**
  123599. * Gets the class name of the current intput.
  123600. * @returns the class name
  123601. */
  123602. getClassName(): string;
  123603. /**
  123604. * Get the friendly name associated with the input class.
  123605. * @returns the input friendly name
  123606. */
  123607. getSimpleName(): string;
  123608. }
  123609. }
  123610. declare module BABYLON {
  123611. /**
  123612. * Manage the gamepad inputs to control a free camera.
  123613. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123614. */
  123615. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  123616. /**
  123617. * Define the camera the input is attached to.
  123618. */
  123619. camera: FreeCamera;
  123620. /**
  123621. * Define the Gamepad controlling the input
  123622. */
  123623. gamepad: Nullable<Gamepad>;
  123624. /**
  123625. * Defines the gamepad rotation sensiblity.
  123626. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123627. */
  123628. gamepadAngularSensibility: number;
  123629. /**
  123630. * Defines the gamepad move sensiblity.
  123631. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123632. */
  123633. gamepadMoveSensibility: number;
  123634. private _yAxisScale;
  123635. /**
  123636. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123637. */
  123638. get invertYAxis(): boolean;
  123639. set invertYAxis(value: boolean);
  123640. private _onGamepadConnectedObserver;
  123641. private _onGamepadDisconnectedObserver;
  123642. private _cameraTransform;
  123643. private _deltaTransform;
  123644. private _vector3;
  123645. private _vector2;
  123646. /**
  123647. * Attach the input controls to a specific dom element to get the input from.
  123648. * @param element Defines the element the controls should be listened from
  123649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123650. */
  123651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123652. /**
  123653. * Detach the current controls from the specified dom element.
  123654. * @param element Defines the element to stop listening the inputs from
  123655. */
  123656. detachControl(element: Nullable<HTMLElement>): void;
  123657. /**
  123658. * Update the current camera state depending on the inputs that have been used this frame.
  123659. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123660. */
  123661. checkInputs(): void;
  123662. /**
  123663. * Gets the class name of the current intput.
  123664. * @returns the class name
  123665. */
  123666. getClassName(): string;
  123667. /**
  123668. * Get the friendly name associated with the input class.
  123669. * @returns the input friendly name
  123670. */
  123671. getSimpleName(): string;
  123672. }
  123673. }
  123674. declare module BABYLON {
  123675. /**
  123676. * Defines the potential axis of a Joystick
  123677. */
  123678. export enum JoystickAxis {
  123679. /** X axis */
  123680. X = 0,
  123681. /** Y axis */
  123682. Y = 1,
  123683. /** Z axis */
  123684. Z = 2
  123685. }
  123686. /**
  123687. * Represents the different customization options available
  123688. * for VirtualJoystick
  123689. */
  123690. interface VirtualJoystickCustomizations {
  123691. /**
  123692. * Size of the joystick's puck
  123693. */
  123694. puckSize: number;
  123695. /**
  123696. * Size of the joystick's container
  123697. */
  123698. containerSize: number;
  123699. /**
  123700. * Color of the joystick && puck
  123701. */
  123702. color: string;
  123703. /**
  123704. * Image URL for the joystick's puck
  123705. */
  123706. puckImage?: string;
  123707. /**
  123708. * Image URL for the joystick's container
  123709. */
  123710. containerImage?: string;
  123711. /**
  123712. * Defines the unmoving position of the joystick container
  123713. */
  123714. position?: {
  123715. x: number;
  123716. y: number;
  123717. };
  123718. /**
  123719. * Defines whether or not the joystick container is always visible
  123720. */
  123721. alwaysVisible: boolean;
  123722. /**
  123723. * Defines whether or not to limit the movement of the puck to the joystick's container
  123724. */
  123725. limitToContainer: boolean;
  123726. }
  123727. /**
  123728. * Class used to define virtual joystick (used in touch mode)
  123729. */
  123730. export class VirtualJoystick {
  123731. /**
  123732. * Gets or sets a boolean indicating that left and right values must be inverted
  123733. */
  123734. reverseLeftRight: boolean;
  123735. /**
  123736. * Gets or sets a boolean indicating that up and down values must be inverted
  123737. */
  123738. reverseUpDown: boolean;
  123739. /**
  123740. * Gets the offset value for the position (ie. the change of the position value)
  123741. */
  123742. deltaPosition: Vector3;
  123743. /**
  123744. * Gets a boolean indicating if the virtual joystick was pressed
  123745. */
  123746. pressed: boolean;
  123747. /**
  123748. * Canvas the virtual joystick will render onto, default z-index of this is 5
  123749. */
  123750. static Canvas: Nullable<HTMLCanvasElement>;
  123751. /**
  123752. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  123753. */
  123754. limitToContainer: boolean;
  123755. private static _globalJoystickIndex;
  123756. private static _alwaysVisibleSticks;
  123757. private static vjCanvasContext;
  123758. private static vjCanvasWidth;
  123759. private static vjCanvasHeight;
  123760. private static halfWidth;
  123761. private static _GetDefaultOptions;
  123762. private _action;
  123763. private _axisTargetedByLeftAndRight;
  123764. private _axisTargetedByUpAndDown;
  123765. private _joystickSensibility;
  123766. private _inversedSensibility;
  123767. private _joystickPointerID;
  123768. private _joystickColor;
  123769. private _joystickPointerPos;
  123770. private _joystickPreviousPointerPos;
  123771. private _joystickPointerStartPos;
  123772. private _deltaJoystickVector;
  123773. private _leftJoystick;
  123774. private _touches;
  123775. private _joystickPosition;
  123776. private _alwaysVisible;
  123777. private _puckImage;
  123778. private _containerImage;
  123779. private _joystickPuckSize;
  123780. private _joystickContainerSize;
  123781. private _clearPuckSize;
  123782. private _clearContainerSize;
  123783. private _clearPuckSizeOffset;
  123784. private _clearContainerSizeOffset;
  123785. private _onPointerDownHandlerRef;
  123786. private _onPointerMoveHandlerRef;
  123787. private _onPointerUpHandlerRef;
  123788. private _onResize;
  123789. /**
  123790. * Creates a new virtual joystick
  123791. * @param leftJoystick defines that the joystick is for left hand (false by default)
  123792. * @param customizations Defines the options we want to customize the VirtualJoystick
  123793. */
  123794. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  123795. /**
  123796. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  123797. * @param newJoystickSensibility defines the new sensibility
  123798. */
  123799. setJoystickSensibility(newJoystickSensibility: number): void;
  123800. private _onPointerDown;
  123801. private _onPointerMove;
  123802. private _onPointerUp;
  123803. /**
  123804. * Change the color of the virtual joystick
  123805. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  123806. */
  123807. setJoystickColor(newColor: string): void;
  123808. /**
  123809. * Size of the joystick's container
  123810. */
  123811. set containerSize(newSize: number);
  123812. get containerSize(): number;
  123813. /**
  123814. * Size of the joystick's puck
  123815. */
  123816. set puckSize(newSize: number);
  123817. get puckSize(): number;
  123818. /**
  123819. * Clears the set position of the joystick
  123820. */
  123821. clearPosition(): void;
  123822. /**
  123823. * Defines whether or not the joystick container is always visible
  123824. */
  123825. set alwaysVisible(value: boolean);
  123826. get alwaysVisible(): boolean;
  123827. /**
  123828. * Sets the constant position of the Joystick container
  123829. * @param x X axis coordinate
  123830. * @param y Y axis coordinate
  123831. */
  123832. setPosition(x: number, y: number): void;
  123833. /**
  123834. * Defines a callback to call when the joystick is touched
  123835. * @param action defines the callback
  123836. */
  123837. setActionOnTouch(action: () => any): void;
  123838. /**
  123839. * Defines which axis you'd like to control for left & right
  123840. * @param axis defines the axis to use
  123841. */
  123842. setAxisForLeftRight(axis: JoystickAxis): void;
  123843. /**
  123844. * Defines which axis you'd like to control for up & down
  123845. * @param axis defines the axis to use
  123846. */
  123847. setAxisForUpDown(axis: JoystickAxis): void;
  123848. /**
  123849. * Clears the canvas from the previous puck / container draw
  123850. */
  123851. private _clearPreviousDraw;
  123852. /**
  123853. * Loads `urlPath` to be used for the container's image
  123854. * @param urlPath defines the urlPath of an image to use
  123855. */
  123856. setContainerImage(urlPath: string): void;
  123857. /**
  123858. * Loads `urlPath` to be used for the puck's image
  123859. * @param urlPath defines the urlPath of an image to use
  123860. */
  123861. setPuckImage(urlPath: string): void;
  123862. /**
  123863. * Draws the Virtual Joystick's container
  123864. */
  123865. private _drawContainer;
  123866. /**
  123867. * Draws the Virtual Joystick's puck
  123868. */
  123869. private _drawPuck;
  123870. private _drawVirtualJoystick;
  123871. /**
  123872. * Release internal HTML canvas
  123873. */
  123874. releaseCanvas(): void;
  123875. }
  123876. }
  123877. declare module BABYLON {
  123878. interface FreeCameraInputsManager {
  123879. /**
  123880. * Add virtual joystick input support to the input manager.
  123881. * @returns the current input manager
  123882. */
  123883. addVirtualJoystick(): FreeCameraInputsManager;
  123884. }
  123885. /**
  123886. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  123887. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123888. */
  123889. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  123890. /**
  123891. * Defines the camera the input is attached to.
  123892. */
  123893. camera: FreeCamera;
  123894. private _leftjoystick;
  123895. private _rightjoystick;
  123896. /**
  123897. * Gets the left stick of the virtual joystick.
  123898. * @returns The virtual Joystick
  123899. */
  123900. getLeftJoystick(): VirtualJoystick;
  123901. /**
  123902. * Gets the right stick of the virtual joystick.
  123903. * @returns The virtual Joystick
  123904. */
  123905. getRightJoystick(): VirtualJoystick;
  123906. /**
  123907. * Update the current camera state depending on the inputs that have been used this frame.
  123908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123909. */
  123910. checkInputs(): void;
  123911. /**
  123912. * Attach the input controls to a specific dom element to get the input from.
  123913. * @param element Defines the element the controls should be listened from
  123914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123915. */
  123916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123917. /**
  123918. * Detach the current controls from the specified dom element.
  123919. * @param element Defines the element to stop listening the inputs from
  123920. */
  123921. detachControl(element: Nullable<HTMLElement>): void;
  123922. /**
  123923. * Gets the class name of the current intput.
  123924. * @returns the class name
  123925. */
  123926. getClassName(): string;
  123927. /**
  123928. * Get the friendly name associated with the input class.
  123929. * @returns the input friendly name
  123930. */
  123931. getSimpleName(): string;
  123932. }
  123933. }
  123934. declare module BABYLON {
  123935. /**
  123936. * This represents a FPS type of camera controlled by touch.
  123937. * This is like a universal camera minus the Gamepad controls.
  123938. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123939. */
  123940. export class TouchCamera extends FreeCamera {
  123941. /**
  123942. * Defines the touch sensibility for rotation.
  123943. * The higher the faster.
  123944. */
  123945. get touchAngularSensibility(): number;
  123946. set touchAngularSensibility(value: number);
  123947. /**
  123948. * Defines the touch sensibility for move.
  123949. * The higher the faster.
  123950. */
  123951. get touchMoveSensibility(): number;
  123952. set touchMoveSensibility(value: number);
  123953. /**
  123954. * Instantiates a new touch camera.
  123955. * This represents a FPS type of camera controlled by touch.
  123956. * This is like a universal camera minus the Gamepad controls.
  123957. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123958. * @param name Define the name of the camera in the scene
  123959. * @param position Define the start position of the camera in the scene
  123960. * @param scene Define the scene the camera belongs to
  123961. */
  123962. constructor(name: string, position: Vector3, scene: Scene);
  123963. /**
  123964. * Gets the current object class name.
  123965. * @return the class name
  123966. */
  123967. getClassName(): string;
  123968. /** @hidden */
  123969. _setupInputs(): void;
  123970. }
  123971. }
  123972. declare module BABYLON {
  123973. /**
  123974. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  123975. * being tilted forward or back and left or right.
  123976. */
  123977. export class DeviceOrientationCamera extends FreeCamera {
  123978. private _initialQuaternion;
  123979. private _quaternionCache;
  123980. private _tmpDragQuaternion;
  123981. private _disablePointerInputWhenUsingDeviceOrientation;
  123982. /**
  123983. * Creates a new device orientation camera
  123984. * @param name The name of the camera
  123985. * @param position The start position camera
  123986. * @param scene The scene the camera belongs to
  123987. */
  123988. constructor(name: string, position: Vector3, scene: Scene);
  123989. /**
  123990. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  123991. */
  123992. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  123993. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  123994. private _dragFactor;
  123995. /**
  123996. * Enabled turning on the y axis when the orientation sensor is active
  123997. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  123998. */
  123999. enableHorizontalDragging(dragFactor?: number): void;
  124000. /**
  124001. * Gets the current instance class name ("DeviceOrientationCamera").
  124002. * This helps avoiding instanceof at run time.
  124003. * @returns the class name
  124004. */
  124005. getClassName(): string;
  124006. /**
  124007. * @hidden
  124008. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124009. */
  124010. _checkInputs(): void;
  124011. /**
  124012. * Reset the camera to its default orientation on the specified axis only.
  124013. * @param axis The axis to reset
  124014. */
  124015. resetToCurrentRotation(axis?: Axis): void;
  124016. }
  124017. }
  124018. declare module BABYLON {
  124019. /**
  124020. * Defines supported buttons for XBox360 compatible gamepads
  124021. */
  124022. export enum Xbox360Button {
  124023. /** A */
  124024. A = 0,
  124025. /** B */
  124026. B = 1,
  124027. /** X */
  124028. X = 2,
  124029. /** Y */
  124030. Y = 3,
  124031. /** Left button */
  124032. LB = 4,
  124033. /** Right button */
  124034. RB = 5,
  124035. /** Back */
  124036. Back = 8,
  124037. /** Start */
  124038. Start = 9,
  124039. /** Left stick */
  124040. LeftStick = 10,
  124041. /** Right stick */
  124042. RightStick = 11
  124043. }
  124044. /** Defines values for XBox360 DPad */
  124045. export enum Xbox360Dpad {
  124046. /** Up */
  124047. Up = 12,
  124048. /** Down */
  124049. Down = 13,
  124050. /** Left */
  124051. Left = 14,
  124052. /** Right */
  124053. Right = 15
  124054. }
  124055. /**
  124056. * Defines a XBox360 gamepad
  124057. */
  124058. export class Xbox360Pad extends Gamepad {
  124059. private _leftTrigger;
  124060. private _rightTrigger;
  124061. private _onlefttriggerchanged;
  124062. private _onrighttriggerchanged;
  124063. private _onbuttondown;
  124064. private _onbuttonup;
  124065. private _ondpaddown;
  124066. private _ondpadup;
  124067. /** Observable raised when a button is pressed */
  124068. onButtonDownObservable: Observable<Xbox360Button>;
  124069. /** Observable raised when a button is released */
  124070. onButtonUpObservable: Observable<Xbox360Button>;
  124071. /** Observable raised when a pad is pressed */
  124072. onPadDownObservable: Observable<Xbox360Dpad>;
  124073. /** Observable raised when a pad is released */
  124074. onPadUpObservable: Observable<Xbox360Dpad>;
  124075. private _buttonA;
  124076. private _buttonB;
  124077. private _buttonX;
  124078. private _buttonY;
  124079. private _buttonBack;
  124080. private _buttonStart;
  124081. private _buttonLB;
  124082. private _buttonRB;
  124083. private _buttonLeftStick;
  124084. private _buttonRightStick;
  124085. private _dPadUp;
  124086. private _dPadDown;
  124087. private _dPadLeft;
  124088. private _dPadRight;
  124089. private _isXboxOnePad;
  124090. /**
  124091. * Creates a new XBox360 gamepad object
  124092. * @param id defines the id of this gamepad
  124093. * @param index defines its index
  124094. * @param gamepad defines the internal HTML gamepad object
  124095. * @param xboxOne defines if it is a XBox One gamepad
  124096. */
  124097. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  124098. /**
  124099. * Defines the callback to call when left trigger is pressed
  124100. * @param callback defines the callback to use
  124101. */
  124102. onlefttriggerchanged(callback: (value: number) => void): void;
  124103. /**
  124104. * Defines the callback to call when right trigger is pressed
  124105. * @param callback defines the callback to use
  124106. */
  124107. onrighttriggerchanged(callback: (value: number) => void): void;
  124108. /**
  124109. * Gets the left trigger value
  124110. */
  124111. get leftTrigger(): number;
  124112. /**
  124113. * Sets the left trigger value
  124114. */
  124115. set leftTrigger(newValue: number);
  124116. /**
  124117. * Gets the right trigger value
  124118. */
  124119. get rightTrigger(): number;
  124120. /**
  124121. * Sets the right trigger value
  124122. */
  124123. set rightTrigger(newValue: number);
  124124. /**
  124125. * Defines the callback to call when a button is pressed
  124126. * @param callback defines the callback to use
  124127. */
  124128. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  124129. /**
  124130. * Defines the callback to call when a button is released
  124131. * @param callback defines the callback to use
  124132. */
  124133. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  124134. /**
  124135. * Defines the callback to call when a pad is pressed
  124136. * @param callback defines the callback to use
  124137. */
  124138. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  124139. /**
  124140. * Defines the callback to call when a pad is released
  124141. * @param callback defines the callback to use
  124142. */
  124143. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  124144. private _setButtonValue;
  124145. private _setDPadValue;
  124146. /**
  124147. * Gets the value of the `A` button
  124148. */
  124149. get buttonA(): number;
  124150. /**
  124151. * Sets the value of the `A` button
  124152. */
  124153. set buttonA(value: number);
  124154. /**
  124155. * Gets the value of the `B` button
  124156. */
  124157. get buttonB(): number;
  124158. /**
  124159. * Sets the value of the `B` button
  124160. */
  124161. set buttonB(value: number);
  124162. /**
  124163. * Gets the value of the `X` button
  124164. */
  124165. get buttonX(): number;
  124166. /**
  124167. * Sets the value of the `X` button
  124168. */
  124169. set buttonX(value: number);
  124170. /**
  124171. * Gets the value of the `Y` button
  124172. */
  124173. get buttonY(): number;
  124174. /**
  124175. * Sets the value of the `Y` button
  124176. */
  124177. set buttonY(value: number);
  124178. /**
  124179. * Gets the value of the `Start` button
  124180. */
  124181. get buttonStart(): number;
  124182. /**
  124183. * Sets the value of the `Start` button
  124184. */
  124185. set buttonStart(value: number);
  124186. /**
  124187. * Gets the value of the `Back` button
  124188. */
  124189. get buttonBack(): number;
  124190. /**
  124191. * Sets the value of the `Back` button
  124192. */
  124193. set buttonBack(value: number);
  124194. /**
  124195. * Gets the value of the `Left` button
  124196. */
  124197. get buttonLB(): number;
  124198. /**
  124199. * Sets the value of the `Left` button
  124200. */
  124201. set buttonLB(value: number);
  124202. /**
  124203. * Gets the value of the `Right` button
  124204. */
  124205. get buttonRB(): number;
  124206. /**
  124207. * Sets the value of the `Right` button
  124208. */
  124209. set buttonRB(value: number);
  124210. /**
  124211. * Gets the value of the Left joystick
  124212. */
  124213. get buttonLeftStick(): number;
  124214. /**
  124215. * Sets the value of the Left joystick
  124216. */
  124217. set buttonLeftStick(value: number);
  124218. /**
  124219. * Gets the value of the Right joystick
  124220. */
  124221. get buttonRightStick(): number;
  124222. /**
  124223. * Sets the value of the Right joystick
  124224. */
  124225. set buttonRightStick(value: number);
  124226. /**
  124227. * Gets the value of D-pad up
  124228. */
  124229. get dPadUp(): number;
  124230. /**
  124231. * Sets the value of D-pad up
  124232. */
  124233. set dPadUp(value: number);
  124234. /**
  124235. * Gets the value of D-pad down
  124236. */
  124237. get dPadDown(): number;
  124238. /**
  124239. * Sets the value of D-pad down
  124240. */
  124241. set dPadDown(value: number);
  124242. /**
  124243. * Gets the value of D-pad left
  124244. */
  124245. get dPadLeft(): number;
  124246. /**
  124247. * Sets the value of D-pad left
  124248. */
  124249. set dPadLeft(value: number);
  124250. /**
  124251. * Gets the value of D-pad right
  124252. */
  124253. get dPadRight(): number;
  124254. /**
  124255. * Sets the value of D-pad right
  124256. */
  124257. set dPadRight(value: number);
  124258. /**
  124259. * Force the gamepad to synchronize with device values
  124260. */
  124261. update(): void;
  124262. /**
  124263. * Disposes the gamepad
  124264. */
  124265. dispose(): void;
  124266. }
  124267. }
  124268. declare module BABYLON {
  124269. /**
  124270. * Defines supported buttons for DualShock compatible gamepads
  124271. */
  124272. export enum DualShockButton {
  124273. /** Cross */
  124274. Cross = 0,
  124275. /** Circle */
  124276. Circle = 1,
  124277. /** Square */
  124278. Square = 2,
  124279. /** Triangle */
  124280. Triangle = 3,
  124281. /** L1 */
  124282. L1 = 4,
  124283. /** R1 */
  124284. R1 = 5,
  124285. /** Share */
  124286. Share = 8,
  124287. /** Options */
  124288. Options = 9,
  124289. /** Left stick */
  124290. LeftStick = 10,
  124291. /** Right stick */
  124292. RightStick = 11
  124293. }
  124294. /** Defines values for DualShock DPad */
  124295. export enum DualShockDpad {
  124296. /** Up */
  124297. Up = 12,
  124298. /** Down */
  124299. Down = 13,
  124300. /** Left */
  124301. Left = 14,
  124302. /** Right */
  124303. Right = 15
  124304. }
  124305. /**
  124306. * Defines a DualShock gamepad
  124307. */
  124308. export class DualShockPad extends Gamepad {
  124309. private _leftTrigger;
  124310. private _rightTrigger;
  124311. private _onlefttriggerchanged;
  124312. private _onrighttriggerchanged;
  124313. private _onbuttondown;
  124314. private _onbuttonup;
  124315. private _ondpaddown;
  124316. private _ondpadup;
  124317. /** Observable raised when a button is pressed */
  124318. onButtonDownObservable: Observable<DualShockButton>;
  124319. /** Observable raised when a button is released */
  124320. onButtonUpObservable: Observable<DualShockButton>;
  124321. /** Observable raised when a pad is pressed */
  124322. onPadDownObservable: Observable<DualShockDpad>;
  124323. /** Observable raised when a pad is released */
  124324. onPadUpObservable: Observable<DualShockDpad>;
  124325. private _buttonCross;
  124326. private _buttonCircle;
  124327. private _buttonSquare;
  124328. private _buttonTriangle;
  124329. private _buttonShare;
  124330. private _buttonOptions;
  124331. private _buttonL1;
  124332. private _buttonR1;
  124333. private _buttonLeftStick;
  124334. private _buttonRightStick;
  124335. private _dPadUp;
  124336. private _dPadDown;
  124337. private _dPadLeft;
  124338. private _dPadRight;
  124339. /**
  124340. * Creates a new DualShock gamepad object
  124341. * @param id defines the id of this gamepad
  124342. * @param index defines its index
  124343. * @param gamepad defines the internal HTML gamepad object
  124344. */
  124345. constructor(id: string, index: number, gamepad: any);
  124346. /**
  124347. * Defines the callback to call when left trigger is pressed
  124348. * @param callback defines the callback to use
  124349. */
  124350. onlefttriggerchanged(callback: (value: number) => void): void;
  124351. /**
  124352. * Defines the callback to call when right trigger is pressed
  124353. * @param callback defines the callback to use
  124354. */
  124355. onrighttriggerchanged(callback: (value: number) => void): void;
  124356. /**
  124357. * Gets the left trigger value
  124358. */
  124359. get leftTrigger(): number;
  124360. /**
  124361. * Sets the left trigger value
  124362. */
  124363. set leftTrigger(newValue: number);
  124364. /**
  124365. * Gets the right trigger value
  124366. */
  124367. get rightTrigger(): number;
  124368. /**
  124369. * Sets the right trigger value
  124370. */
  124371. set rightTrigger(newValue: number);
  124372. /**
  124373. * Defines the callback to call when a button is pressed
  124374. * @param callback defines the callback to use
  124375. */
  124376. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124377. /**
  124378. * Defines the callback to call when a button is released
  124379. * @param callback defines the callback to use
  124380. */
  124381. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124382. /**
  124383. * Defines the callback to call when a pad is pressed
  124384. * @param callback defines the callback to use
  124385. */
  124386. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124387. /**
  124388. * Defines the callback to call when a pad is released
  124389. * @param callback defines the callback to use
  124390. */
  124391. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124392. private _setButtonValue;
  124393. private _setDPadValue;
  124394. /**
  124395. * Gets the value of the `Cross` button
  124396. */
  124397. get buttonCross(): number;
  124398. /**
  124399. * Sets the value of the `Cross` button
  124400. */
  124401. set buttonCross(value: number);
  124402. /**
  124403. * Gets the value of the `Circle` button
  124404. */
  124405. get buttonCircle(): number;
  124406. /**
  124407. * Sets the value of the `Circle` button
  124408. */
  124409. set buttonCircle(value: number);
  124410. /**
  124411. * Gets the value of the `Square` button
  124412. */
  124413. get buttonSquare(): number;
  124414. /**
  124415. * Sets the value of the `Square` button
  124416. */
  124417. set buttonSquare(value: number);
  124418. /**
  124419. * Gets the value of the `Triangle` button
  124420. */
  124421. get buttonTriangle(): number;
  124422. /**
  124423. * Sets the value of the `Triangle` button
  124424. */
  124425. set buttonTriangle(value: number);
  124426. /**
  124427. * Gets the value of the `Options` button
  124428. */
  124429. get buttonOptions(): number;
  124430. /**
  124431. * Sets the value of the `Options` button
  124432. */
  124433. set buttonOptions(value: number);
  124434. /**
  124435. * Gets the value of the `Share` button
  124436. */
  124437. get buttonShare(): number;
  124438. /**
  124439. * Sets the value of the `Share` button
  124440. */
  124441. set buttonShare(value: number);
  124442. /**
  124443. * Gets the value of the `L1` button
  124444. */
  124445. get buttonL1(): number;
  124446. /**
  124447. * Sets the value of the `L1` button
  124448. */
  124449. set buttonL1(value: number);
  124450. /**
  124451. * Gets the value of the `R1` button
  124452. */
  124453. get buttonR1(): number;
  124454. /**
  124455. * Sets the value of the `R1` button
  124456. */
  124457. set buttonR1(value: number);
  124458. /**
  124459. * Gets the value of the Left joystick
  124460. */
  124461. get buttonLeftStick(): number;
  124462. /**
  124463. * Sets the value of the Left joystick
  124464. */
  124465. set buttonLeftStick(value: number);
  124466. /**
  124467. * Gets the value of the Right joystick
  124468. */
  124469. get buttonRightStick(): number;
  124470. /**
  124471. * Sets the value of the Right joystick
  124472. */
  124473. set buttonRightStick(value: number);
  124474. /**
  124475. * Gets the value of D-pad up
  124476. */
  124477. get dPadUp(): number;
  124478. /**
  124479. * Sets the value of D-pad up
  124480. */
  124481. set dPadUp(value: number);
  124482. /**
  124483. * Gets the value of D-pad down
  124484. */
  124485. get dPadDown(): number;
  124486. /**
  124487. * Sets the value of D-pad down
  124488. */
  124489. set dPadDown(value: number);
  124490. /**
  124491. * Gets the value of D-pad left
  124492. */
  124493. get dPadLeft(): number;
  124494. /**
  124495. * Sets the value of D-pad left
  124496. */
  124497. set dPadLeft(value: number);
  124498. /**
  124499. * Gets the value of D-pad right
  124500. */
  124501. get dPadRight(): number;
  124502. /**
  124503. * Sets the value of D-pad right
  124504. */
  124505. set dPadRight(value: number);
  124506. /**
  124507. * Force the gamepad to synchronize with device values
  124508. */
  124509. update(): void;
  124510. /**
  124511. * Disposes the gamepad
  124512. */
  124513. dispose(): void;
  124514. }
  124515. }
  124516. declare module BABYLON {
  124517. /**
  124518. * Manager for handling gamepads
  124519. */
  124520. export class GamepadManager {
  124521. private _scene?;
  124522. private _babylonGamepads;
  124523. private _oneGamepadConnected;
  124524. /** @hidden */
  124525. _isMonitoring: boolean;
  124526. private _gamepadEventSupported;
  124527. private _gamepadSupport?;
  124528. /**
  124529. * observable to be triggered when the gamepad controller has been connected
  124530. */
  124531. onGamepadConnectedObservable: Observable<Gamepad>;
  124532. /**
  124533. * observable to be triggered when the gamepad controller has been disconnected
  124534. */
  124535. onGamepadDisconnectedObservable: Observable<Gamepad>;
  124536. private _onGamepadConnectedEvent;
  124537. private _onGamepadDisconnectedEvent;
  124538. /**
  124539. * Initializes the gamepad manager
  124540. * @param _scene BabylonJS scene
  124541. */
  124542. constructor(_scene?: Scene | undefined);
  124543. /**
  124544. * The gamepads in the game pad manager
  124545. */
  124546. get gamepads(): Gamepad[];
  124547. /**
  124548. * Get the gamepad controllers based on type
  124549. * @param type The type of gamepad controller
  124550. * @returns Nullable gamepad
  124551. */
  124552. getGamepadByType(type?: number): Nullable<Gamepad>;
  124553. /**
  124554. * Disposes the gamepad manager
  124555. */
  124556. dispose(): void;
  124557. private _addNewGamepad;
  124558. private _startMonitoringGamepads;
  124559. private _stopMonitoringGamepads;
  124560. /** @hidden */
  124561. _checkGamepadsStatus(): void;
  124562. private _updateGamepadObjects;
  124563. }
  124564. }
  124565. declare module BABYLON {
  124566. interface Scene {
  124567. /** @hidden */
  124568. _gamepadManager: Nullable<GamepadManager>;
  124569. /**
  124570. * Gets the gamepad manager associated with the scene
  124571. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  124572. */
  124573. gamepadManager: GamepadManager;
  124574. }
  124575. /**
  124576. * Interface representing a free camera inputs manager
  124577. */
  124578. interface FreeCameraInputsManager {
  124579. /**
  124580. * Adds gamepad input support to the FreeCameraInputsManager.
  124581. * @returns the FreeCameraInputsManager
  124582. */
  124583. addGamepad(): FreeCameraInputsManager;
  124584. }
  124585. /**
  124586. * Interface representing an arc rotate camera inputs manager
  124587. */
  124588. interface ArcRotateCameraInputsManager {
  124589. /**
  124590. * Adds gamepad input support to the ArcRotateCamera InputManager.
  124591. * @returns the camera inputs manager
  124592. */
  124593. addGamepad(): ArcRotateCameraInputsManager;
  124594. }
  124595. /**
  124596. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  124597. */
  124598. export class GamepadSystemSceneComponent implements ISceneComponent {
  124599. /**
  124600. * The component name helpfull to identify the component in the list of scene components.
  124601. */
  124602. readonly name: string;
  124603. /**
  124604. * The scene the component belongs to.
  124605. */
  124606. scene: Scene;
  124607. /**
  124608. * Creates a new instance of the component for the given scene
  124609. * @param scene Defines the scene to register the component in
  124610. */
  124611. constructor(scene: Scene);
  124612. /**
  124613. * Registers the component in a given scene
  124614. */
  124615. register(): void;
  124616. /**
  124617. * Rebuilds the elements related to this component in case of
  124618. * context lost for instance.
  124619. */
  124620. rebuild(): void;
  124621. /**
  124622. * Disposes the component and the associated ressources
  124623. */
  124624. dispose(): void;
  124625. private _beforeCameraUpdate;
  124626. }
  124627. }
  124628. declare module BABYLON {
  124629. /**
  124630. * 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,
  124631. * which still works and will still be found in many Playgrounds.
  124632. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124633. */
  124634. export class UniversalCamera extends TouchCamera {
  124635. /**
  124636. * Defines the gamepad rotation sensiblity.
  124637. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124638. */
  124639. get gamepadAngularSensibility(): number;
  124640. set gamepadAngularSensibility(value: number);
  124641. /**
  124642. * Defines the gamepad move sensiblity.
  124643. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124644. */
  124645. get gamepadMoveSensibility(): number;
  124646. set gamepadMoveSensibility(value: number);
  124647. /**
  124648. * 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,
  124649. * which still works and will still be found in many Playgrounds.
  124650. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124651. * @param name Define the name of the camera in the scene
  124652. * @param position Define the start position of the camera in the scene
  124653. * @param scene Define the scene the camera belongs to
  124654. */
  124655. constructor(name: string, position: Vector3, scene: Scene);
  124656. /**
  124657. * Gets the current object class name.
  124658. * @return the class name
  124659. */
  124660. getClassName(): string;
  124661. }
  124662. }
  124663. declare module BABYLON {
  124664. /**
  124665. * This represents a FPS type of camera. This is only here for back compat purpose.
  124666. * Please use the UniversalCamera instead as both are identical.
  124667. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124668. */
  124669. export class GamepadCamera extends UniversalCamera {
  124670. /**
  124671. * Instantiates a new Gamepad Camera
  124672. * This represents a FPS type of camera. This is only here for back compat purpose.
  124673. * Please use the UniversalCamera instead as both are identical.
  124674. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124675. * @param name Define the name of the camera in the scene
  124676. * @param position Define the start position of the camera in the scene
  124677. * @param scene Define the scene the camera belongs to
  124678. */
  124679. constructor(name: string, position: Vector3, scene: Scene);
  124680. /**
  124681. * Gets the current object class name.
  124682. * @return the class name
  124683. */
  124684. getClassName(): string;
  124685. }
  124686. }
  124687. declare module BABYLON {
  124688. /** @hidden */
  124689. export var passPixelShader: {
  124690. name: string;
  124691. shader: string;
  124692. };
  124693. }
  124694. declare module BABYLON {
  124695. /** @hidden */
  124696. export var passCubePixelShader: {
  124697. name: string;
  124698. shader: string;
  124699. };
  124700. }
  124701. declare module BABYLON {
  124702. /**
  124703. * PassPostProcess which produces an output the same as it's input
  124704. */
  124705. export class PassPostProcess extends PostProcess {
  124706. /**
  124707. * Creates the PassPostProcess
  124708. * @param name The name of the effect.
  124709. * @param options The required width/height ratio to downsize to before computing the render pass.
  124710. * @param camera The camera to apply the render pass to.
  124711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124712. * @param engine The engine which the post process will be applied. (default: current engine)
  124713. * @param reusable If the post process can be reused on the same frame. (default: false)
  124714. * @param textureType The type of texture to be used when performing the post processing.
  124715. * @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)
  124716. */
  124717. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124718. }
  124719. /**
  124720. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124721. */
  124722. export class PassCubePostProcess extends PostProcess {
  124723. private _face;
  124724. /**
  124725. * Gets or sets the cube face to display.
  124726. * * 0 is +X
  124727. * * 1 is -X
  124728. * * 2 is +Y
  124729. * * 3 is -Y
  124730. * * 4 is +Z
  124731. * * 5 is -Z
  124732. */
  124733. get face(): number;
  124734. set face(value: number);
  124735. /**
  124736. * Creates the PassCubePostProcess
  124737. * @param name The name of the effect.
  124738. * @param options The required width/height ratio to downsize to before computing the render pass.
  124739. * @param camera The camera to apply the render pass to.
  124740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124741. * @param engine The engine which the post process will be applied. (default: current engine)
  124742. * @param reusable If the post process can be reused on the same frame. (default: false)
  124743. * @param textureType The type of texture to be used when performing the post processing.
  124744. * @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)
  124745. */
  124746. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124747. }
  124748. }
  124749. declare module BABYLON {
  124750. /** @hidden */
  124751. export var anaglyphPixelShader: {
  124752. name: string;
  124753. shader: string;
  124754. };
  124755. }
  124756. declare module BABYLON {
  124757. /**
  124758. * Postprocess used to generate anaglyphic rendering
  124759. */
  124760. export class AnaglyphPostProcess extends PostProcess {
  124761. private _passedProcess;
  124762. /**
  124763. * Creates a new AnaglyphPostProcess
  124764. * @param name defines postprocess name
  124765. * @param options defines creation options or target ratio scale
  124766. * @param rigCameras defines cameras using this postprocess
  124767. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  124768. * @param engine defines hosting engine
  124769. * @param reusable defines if the postprocess will be reused multiple times per frame
  124770. */
  124771. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  124772. }
  124773. }
  124774. declare module BABYLON {
  124775. /**
  124776. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  124777. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124778. */
  124779. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  124780. /**
  124781. * Creates a new AnaglyphArcRotateCamera
  124782. * @param name defines camera name
  124783. * @param alpha defines alpha angle (in radians)
  124784. * @param beta defines beta angle (in radians)
  124785. * @param radius defines radius
  124786. * @param target defines camera target
  124787. * @param interaxialDistance defines distance between each color axis
  124788. * @param scene defines the hosting scene
  124789. */
  124790. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  124791. /**
  124792. * Gets camera class name
  124793. * @returns AnaglyphArcRotateCamera
  124794. */
  124795. getClassName(): string;
  124796. }
  124797. }
  124798. declare module BABYLON {
  124799. /**
  124800. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  124801. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124802. */
  124803. export class AnaglyphFreeCamera extends FreeCamera {
  124804. /**
  124805. * Creates a new AnaglyphFreeCamera
  124806. * @param name defines camera name
  124807. * @param position defines initial position
  124808. * @param interaxialDistance defines distance between each color axis
  124809. * @param scene defines the hosting scene
  124810. */
  124811. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124812. /**
  124813. * Gets camera class name
  124814. * @returns AnaglyphFreeCamera
  124815. */
  124816. getClassName(): string;
  124817. }
  124818. }
  124819. declare module BABYLON {
  124820. /**
  124821. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  124822. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124823. */
  124824. export class AnaglyphGamepadCamera extends GamepadCamera {
  124825. /**
  124826. * Creates a new AnaglyphGamepadCamera
  124827. * @param name defines camera name
  124828. * @param position defines initial position
  124829. * @param interaxialDistance defines distance between each color axis
  124830. * @param scene defines the hosting scene
  124831. */
  124832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124833. /**
  124834. * Gets camera class name
  124835. * @returns AnaglyphGamepadCamera
  124836. */
  124837. getClassName(): string;
  124838. }
  124839. }
  124840. declare module BABYLON {
  124841. /**
  124842. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  124843. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124844. */
  124845. export class AnaglyphUniversalCamera extends UniversalCamera {
  124846. /**
  124847. * Creates a new AnaglyphUniversalCamera
  124848. * @param name defines camera name
  124849. * @param position defines initial position
  124850. * @param interaxialDistance defines distance between each color axis
  124851. * @param scene defines the hosting scene
  124852. */
  124853. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124854. /**
  124855. * Gets camera class name
  124856. * @returns AnaglyphUniversalCamera
  124857. */
  124858. getClassName(): string;
  124859. }
  124860. }
  124861. declare module BABYLON {
  124862. /**
  124863. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  124864. * @see https://doc.babylonjs.com/features/cameras
  124865. */
  124866. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  124867. /**
  124868. * Creates a new StereoscopicArcRotateCamera
  124869. * @param name defines camera name
  124870. * @param alpha defines alpha angle (in radians)
  124871. * @param beta defines beta angle (in radians)
  124872. * @param radius defines radius
  124873. * @param target defines camera target
  124874. * @param interaxialDistance defines distance between each color axis
  124875. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124876. * @param scene defines the hosting scene
  124877. */
  124878. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124879. /**
  124880. * Gets camera class name
  124881. * @returns StereoscopicArcRotateCamera
  124882. */
  124883. getClassName(): string;
  124884. }
  124885. }
  124886. declare module BABYLON {
  124887. /**
  124888. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  124889. * @see https://doc.babylonjs.com/features/cameras
  124890. */
  124891. export class StereoscopicFreeCamera extends FreeCamera {
  124892. /**
  124893. * Creates a new StereoscopicFreeCamera
  124894. * @param name defines camera name
  124895. * @param position defines initial position
  124896. * @param interaxialDistance defines distance between each color axis
  124897. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124898. * @param scene defines the hosting scene
  124899. */
  124900. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124901. /**
  124902. * Gets camera class name
  124903. * @returns StereoscopicFreeCamera
  124904. */
  124905. getClassName(): string;
  124906. }
  124907. }
  124908. declare module BABYLON {
  124909. /**
  124910. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  124911. * @see https://doc.babylonjs.com/features/cameras
  124912. */
  124913. export class StereoscopicGamepadCamera extends GamepadCamera {
  124914. /**
  124915. * Creates a new StereoscopicGamepadCamera
  124916. * @param name defines camera name
  124917. * @param position defines initial position
  124918. * @param interaxialDistance defines distance between each color axis
  124919. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124920. * @param scene defines the hosting scene
  124921. */
  124922. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124923. /**
  124924. * Gets camera class name
  124925. * @returns StereoscopicGamepadCamera
  124926. */
  124927. getClassName(): string;
  124928. }
  124929. }
  124930. declare module BABYLON {
  124931. /**
  124932. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  124933. * @see https://doc.babylonjs.com/features/cameras
  124934. */
  124935. export class StereoscopicUniversalCamera extends UniversalCamera {
  124936. /**
  124937. * Creates a new StereoscopicUniversalCamera
  124938. * @param name defines camera name
  124939. * @param position defines initial position
  124940. * @param interaxialDistance defines distance between each color axis
  124941. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124942. * @param scene defines the hosting scene
  124943. */
  124944. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124945. /**
  124946. * Gets camera class name
  124947. * @returns StereoscopicUniversalCamera
  124948. */
  124949. getClassName(): string;
  124950. }
  124951. }
  124952. declare module BABYLON {
  124953. /**
  124954. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  124955. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124956. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124957. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124958. */
  124959. export class VirtualJoysticksCamera extends FreeCamera {
  124960. /**
  124961. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  124962. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124963. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124964. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124965. * @param name Define the name of the camera in the scene
  124966. * @param position Define the start position of the camera in the scene
  124967. * @param scene Define the scene the camera belongs to
  124968. */
  124969. constructor(name: string, position: Vector3, scene: Scene);
  124970. /**
  124971. * Gets the current object class name.
  124972. * @return the class name
  124973. */
  124974. getClassName(): string;
  124975. }
  124976. }
  124977. declare module BABYLON {
  124978. /**
  124979. * This represents all the required metrics to create a VR camera.
  124980. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  124981. */
  124982. export class VRCameraMetrics {
  124983. /**
  124984. * Define the horizontal resolution off the screen.
  124985. */
  124986. hResolution: number;
  124987. /**
  124988. * Define the vertical resolution off the screen.
  124989. */
  124990. vResolution: number;
  124991. /**
  124992. * Define the horizontal screen size.
  124993. */
  124994. hScreenSize: number;
  124995. /**
  124996. * Define the vertical screen size.
  124997. */
  124998. vScreenSize: number;
  124999. /**
  125000. * Define the vertical screen center position.
  125001. */
  125002. vScreenCenter: number;
  125003. /**
  125004. * Define the distance of the eyes to the screen.
  125005. */
  125006. eyeToScreenDistance: number;
  125007. /**
  125008. * Define the distance between both lenses
  125009. */
  125010. lensSeparationDistance: number;
  125011. /**
  125012. * Define the distance between both viewer's eyes.
  125013. */
  125014. interpupillaryDistance: number;
  125015. /**
  125016. * Define the distortion factor of the VR postprocess.
  125017. * Please, touch with care.
  125018. */
  125019. distortionK: number[];
  125020. /**
  125021. * Define the chromatic aberration correction factors for the VR post process.
  125022. */
  125023. chromaAbCorrection: number[];
  125024. /**
  125025. * Define the scale factor of the post process.
  125026. * The smaller the better but the slower.
  125027. */
  125028. postProcessScaleFactor: number;
  125029. /**
  125030. * Define an offset for the lens center.
  125031. */
  125032. lensCenterOffset: number;
  125033. /**
  125034. * Define if the current vr camera should compensate the distortion of the lense or not.
  125035. */
  125036. compensateDistortion: boolean;
  125037. /**
  125038. * Defines if multiview should be enabled when rendering (Default: false)
  125039. */
  125040. multiviewEnabled: boolean;
  125041. /**
  125042. * Gets the rendering aspect ratio based on the provided resolutions.
  125043. */
  125044. get aspectRatio(): number;
  125045. /**
  125046. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125047. */
  125048. get aspectRatioFov(): number;
  125049. /**
  125050. * @hidden
  125051. */
  125052. get leftHMatrix(): Matrix;
  125053. /**
  125054. * @hidden
  125055. */
  125056. get rightHMatrix(): Matrix;
  125057. /**
  125058. * @hidden
  125059. */
  125060. get leftPreViewMatrix(): Matrix;
  125061. /**
  125062. * @hidden
  125063. */
  125064. get rightPreViewMatrix(): Matrix;
  125065. /**
  125066. * Get the default VRMetrics based on the most generic setup.
  125067. * @returns the default vr metrics
  125068. */
  125069. static GetDefault(): VRCameraMetrics;
  125070. }
  125071. }
  125072. declare module BABYLON {
  125073. /** @hidden */
  125074. export var vrDistortionCorrectionPixelShader: {
  125075. name: string;
  125076. shader: string;
  125077. };
  125078. }
  125079. declare module BABYLON {
  125080. /**
  125081. * VRDistortionCorrectionPostProcess used for mobile VR
  125082. */
  125083. export class VRDistortionCorrectionPostProcess extends PostProcess {
  125084. private _isRightEye;
  125085. private _distortionFactors;
  125086. private _postProcessScaleFactor;
  125087. private _lensCenterOffset;
  125088. private _scaleIn;
  125089. private _scaleFactor;
  125090. private _lensCenter;
  125091. /**
  125092. * Initializes the VRDistortionCorrectionPostProcess
  125093. * @param name The name of the effect.
  125094. * @param camera The camera to apply the render pass to.
  125095. * @param isRightEye If this is for the right eye distortion
  125096. * @param vrMetrics All the required metrics for the VR camera
  125097. */
  125098. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  125099. }
  125100. }
  125101. declare module BABYLON {
  125102. /**
  125103. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  125104. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125105. */
  125106. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  125107. /**
  125108. * Creates a new VRDeviceOrientationArcRotateCamera
  125109. * @param name defines camera name
  125110. * @param alpha defines the camera rotation along the logitudinal axis
  125111. * @param beta defines the camera rotation along the latitudinal axis
  125112. * @param radius defines the camera distance from its target
  125113. * @param target defines the camera target
  125114. * @param scene defines the scene the camera belongs to
  125115. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125116. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125117. */
  125118. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125119. /**
  125120. * Gets camera class name
  125121. * @returns VRDeviceOrientationArcRotateCamera
  125122. */
  125123. getClassName(): string;
  125124. }
  125125. }
  125126. declare module BABYLON {
  125127. /**
  125128. * Camera used to simulate VR rendering (based on FreeCamera)
  125129. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125130. */
  125131. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  125132. /**
  125133. * Creates a new VRDeviceOrientationFreeCamera
  125134. * @param name defines camera name
  125135. * @param position defines the start position of the camera
  125136. * @param scene defines the scene the camera belongs to
  125137. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125138. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125139. */
  125140. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125141. /**
  125142. * Gets camera class name
  125143. * @returns VRDeviceOrientationFreeCamera
  125144. */
  125145. getClassName(): string;
  125146. }
  125147. }
  125148. declare module BABYLON {
  125149. /**
  125150. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  125151. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125152. */
  125153. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  125154. /**
  125155. * Creates a new VRDeviceOrientationGamepadCamera
  125156. * @param name defines camera name
  125157. * @param position defines the start position of the camera
  125158. * @param scene defines the scene the camera belongs to
  125159. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125160. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125161. */
  125162. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125163. /**
  125164. * Gets camera class name
  125165. * @returns VRDeviceOrientationGamepadCamera
  125166. */
  125167. getClassName(): string;
  125168. }
  125169. }
  125170. declare module BABYLON {
  125171. /**
  125172. * A class extending Texture allowing drawing on a texture
  125173. * @see https://doc.babylonjs.com/how_to/dynamictexture
  125174. */
  125175. export class DynamicTexture extends Texture {
  125176. private _generateMipMaps;
  125177. private _canvas;
  125178. private _context;
  125179. /**
  125180. * Creates a DynamicTexture
  125181. * @param name defines the name of the texture
  125182. * @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
  125183. * @param scene defines the scene where you want the texture
  125184. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125185. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125186. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125187. */
  125188. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125189. /**
  125190. * Get the current class name of the texture useful for serialization or dynamic coding.
  125191. * @returns "DynamicTexture"
  125192. */
  125193. getClassName(): string;
  125194. /**
  125195. * Gets the current state of canRescale
  125196. */
  125197. get canRescale(): boolean;
  125198. private _recreate;
  125199. /**
  125200. * Scales the texture
  125201. * @param ratio the scale factor to apply to both width and height
  125202. */
  125203. scale(ratio: number): void;
  125204. /**
  125205. * Resizes the texture
  125206. * @param width the new width
  125207. * @param height the new height
  125208. */
  125209. scaleTo(width: number, height: number): void;
  125210. /**
  125211. * Gets the context of the canvas used by the texture
  125212. * @returns the canvas context of the dynamic texture
  125213. */
  125214. getContext(): CanvasRenderingContext2D;
  125215. /**
  125216. * Clears the texture
  125217. */
  125218. clear(): void;
  125219. /**
  125220. * Updates the texture
  125221. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125222. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125223. */
  125224. update(invertY?: boolean, premulAlpha?: boolean): void;
  125225. /**
  125226. * Draws text onto the texture
  125227. * @param text defines the text to be drawn
  125228. * @param x defines the placement of the text from the left
  125229. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125230. * @param font defines the font to be used with font-style, font-size, font-name
  125231. * @param color defines the color used for the text
  125232. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125233. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125234. * @param update defines whether texture is immediately update (default is true)
  125235. */
  125236. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125237. /**
  125238. * Clones the texture
  125239. * @returns the clone of the texture.
  125240. */
  125241. clone(): DynamicTexture;
  125242. /**
  125243. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125244. * @returns a serialized dynamic texture object
  125245. */
  125246. serialize(): any;
  125247. private _IsCanvasElement;
  125248. /** @hidden */
  125249. _rebuild(): void;
  125250. }
  125251. }
  125252. declare module BABYLON {
  125253. /**
  125254. * Class containing static functions to help procedurally build meshes
  125255. */
  125256. export class GroundBuilder {
  125257. /**
  125258. * Creates a ground mesh
  125259. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125260. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125262. * @param name defines the name of the mesh
  125263. * @param options defines the options used to create the mesh
  125264. * @param scene defines the hosting scene
  125265. * @returns the ground mesh
  125266. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125267. */
  125268. static CreateGround(name: string, options: {
  125269. width?: number;
  125270. height?: number;
  125271. subdivisions?: number;
  125272. subdivisionsX?: number;
  125273. subdivisionsY?: number;
  125274. updatable?: boolean;
  125275. }, scene: any): Mesh;
  125276. /**
  125277. * Creates a tiled ground mesh
  125278. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125279. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125280. * * 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
  125281. * * 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
  125282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125283. * @param name defines the name of the mesh
  125284. * @param options defines the options used to create the mesh
  125285. * @param scene defines the hosting scene
  125286. * @returns the tiled ground mesh
  125287. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125288. */
  125289. static CreateTiledGround(name: string, options: {
  125290. xmin: number;
  125291. zmin: number;
  125292. xmax: number;
  125293. zmax: number;
  125294. subdivisions?: {
  125295. w: number;
  125296. h: number;
  125297. };
  125298. precision?: {
  125299. w: number;
  125300. h: number;
  125301. };
  125302. updatable?: boolean;
  125303. }, scene?: Nullable<Scene>): Mesh;
  125304. /**
  125305. * Creates a ground mesh from a height map
  125306. * * The parameter `url` sets the URL of the height map image resource.
  125307. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125308. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125309. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125310. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125311. * * 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.
  125312. * * 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).
  125313. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125315. * @param name defines the name of the mesh
  125316. * @param url defines the url to the height map
  125317. * @param options defines the options used to create the mesh
  125318. * @param scene defines the hosting scene
  125319. * @returns the ground mesh
  125320. * @see https://doc.babylonjs.com/babylon101/height_map
  125321. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125322. */
  125323. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125324. width?: number;
  125325. height?: number;
  125326. subdivisions?: number;
  125327. minHeight?: number;
  125328. maxHeight?: number;
  125329. colorFilter?: Color3;
  125330. alphaFilter?: number;
  125331. updatable?: boolean;
  125332. onReady?: (mesh: GroundMesh) => void;
  125333. }, scene?: Nullable<Scene>): GroundMesh;
  125334. }
  125335. }
  125336. declare module BABYLON {
  125337. /**
  125338. * Class containing static functions to help procedurally build meshes
  125339. */
  125340. export class TorusBuilder {
  125341. /**
  125342. * Creates a torus mesh
  125343. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125344. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125345. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125349. * @param name defines the name of the mesh
  125350. * @param options defines the options used to create the mesh
  125351. * @param scene defines the hosting scene
  125352. * @returns the torus mesh
  125353. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125354. */
  125355. static CreateTorus(name: string, options: {
  125356. diameter?: number;
  125357. thickness?: number;
  125358. tessellation?: number;
  125359. updatable?: boolean;
  125360. sideOrientation?: number;
  125361. frontUVs?: Vector4;
  125362. backUVs?: Vector4;
  125363. }, scene: any): Mesh;
  125364. }
  125365. }
  125366. declare module BABYLON {
  125367. /**
  125368. * Class containing static functions to help procedurally build meshes
  125369. */
  125370. export class CylinderBuilder {
  125371. /**
  125372. * Creates a cylinder or a cone mesh
  125373. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125374. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125375. * * 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.
  125376. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125377. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125378. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125379. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125380. * * 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).
  125381. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125382. * * 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).
  125383. * * 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
  125384. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125385. * * 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
  125386. * * 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.
  125387. * * If `enclose` is false, a ring surface is one element.
  125388. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125389. * * 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
  125390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125393. * @param name defines the name of the mesh
  125394. * @param options defines the options used to create the mesh
  125395. * @param scene defines the hosting scene
  125396. * @returns the cylinder mesh
  125397. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125398. */
  125399. static CreateCylinder(name: string, options: {
  125400. height?: number;
  125401. diameterTop?: number;
  125402. diameterBottom?: number;
  125403. diameter?: number;
  125404. tessellation?: number;
  125405. subdivisions?: number;
  125406. arc?: number;
  125407. faceColors?: Color4[];
  125408. faceUV?: Vector4[];
  125409. updatable?: boolean;
  125410. hasRings?: boolean;
  125411. enclose?: boolean;
  125412. cap?: number;
  125413. sideOrientation?: number;
  125414. frontUVs?: Vector4;
  125415. backUVs?: Vector4;
  125416. }, scene: any): Mesh;
  125417. }
  125418. }
  125419. declare module BABYLON {
  125420. /**
  125421. * States of the webXR experience
  125422. */
  125423. export enum WebXRState {
  125424. /**
  125425. * Transitioning to being in XR mode
  125426. */
  125427. ENTERING_XR = 0,
  125428. /**
  125429. * Transitioning to non XR mode
  125430. */
  125431. EXITING_XR = 1,
  125432. /**
  125433. * In XR mode and presenting
  125434. */
  125435. IN_XR = 2,
  125436. /**
  125437. * Not entered XR mode
  125438. */
  125439. NOT_IN_XR = 3
  125440. }
  125441. /**
  125442. * Abstraction of the XR render target
  125443. */
  125444. export interface WebXRRenderTarget extends IDisposable {
  125445. /**
  125446. * xrpresent context of the canvas which can be used to display/mirror xr content
  125447. */
  125448. canvasContext: WebGLRenderingContext;
  125449. /**
  125450. * xr layer for the canvas
  125451. */
  125452. xrLayer: Nullable<XRWebGLLayer>;
  125453. /**
  125454. * Initializes the xr layer for the session
  125455. * @param xrSession xr session
  125456. * @returns a promise that will resolve once the XR Layer has been created
  125457. */
  125458. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125459. }
  125460. }
  125461. declare module BABYLON {
  125462. /**
  125463. * COnfiguration object for WebXR output canvas
  125464. */
  125465. export class WebXRManagedOutputCanvasOptions {
  125466. /**
  125467. * An optional canvas in case you wish to create it yourself and provide it here.
  125468. * If not provided, a new canvas will be created
  125469. */
  125470. canvasElement?: HTMLCanvasElement;
  125471. /**
  125472. * Options for this XR Layer output
  125473. */
  125474. canvasOptions?: XRWebGLLayerOptions;
  125475. /**
  125476. * CSS styling for a newly created canvas (if not provided)
  125477. */
  125478. newCanvasCssStyle?: string;
  125479. /**
  125480. * Get the default values of the configuration object
  125481. * @returns default values of this configuration object
  125482. */
  125483. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  125484. }
  125485. /**
  125486. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  125487. */
  125488. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  125489. private _options;
  125490. private _canvas;
  125491. private _engine;
  125492. private _originalCanvasSize;
  125493. /**
  125494. * Rendering context of the canvas which can be used to display/mirror xr content
  125495. */
  125496. canvasContext: WebGLRenderingContext;
  125497. /**
  125498. * xr layer for the canvas
  125499. */
  125500. xrLayer: Nullable<XRWebGLLayer>;
  125501. /**
  125502. * Obseervers registered here will be triggered when the xr layer was initialized
  125503. */
  125504. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  125505. /**
  125506. * Initializes the canvas to be added/removed upon entering/exiting xr
  125507. * @param _xrSessionManager The XR Session manager
  125508. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  125509. */
  125510. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  125511. /**
  125512. * Disposes of the object
  125513. */
  125514. dispose(): void;
  125515. /**
  125516. * Initializes the xr layer for the session
  125517. * @param xrSession xr session
  125518. * @returns a promise that will resolve once the XR Layer has been created
  125519. */
  125520. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125521. private _addCanvas;
  125522. private _removeCanvas;
  125523. private _setCanvasSize;
  125524. private _setManagedOutputCanvas;
  125525. }
  125526. }
  125527. declare module BABYLON {
  125528. /**
  125529. * Manages an XRSession to work with Babylon's engine
  125530. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  125531. */
  125532. export class WebXRSessionManager implements IDisposable {
  125533. /** The scene which the session should be created for */
  125534. scene: Scene;
  125535. private _referenceSpace;
  125536. private _rttProvider;
  125537. private _sessionEnded;
  125538. private _xrNavigator;
  125539. private baseLayer;
  125540. /**
  125541. * The base reference space from which the session started. good if you want to reset your
  125542. * reference space
  125543. */
  125544. baseReferenceSpace: XRReferenceSpace;
  125545. /**
  125546. * Current XR frame
  125547. */
  125548. currentFrame: Nullable<XRFrame>;
  125549. /** WebXR timestamp updated every frame */
  125550. currentTimestamp: number;
  125551. /**
  125552. * Used just in case of a failure to initialize an immersive session.
  125553. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  125554. */
  125555. defaultHeightCompensation: number;
  125556. /**
  125557. * Fires every time a new xrFrame arrives which can be used to update the camera
  125558. */
  125559. onXRFrameObservable: Observable<XRFrame>;
  125560. /**
  125561. * Fires when the reference space changed
  125562. */
  125563. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  125564. /**
  125565. * Fires when the xr session is ended either by the device or manually done
  125566. */
  125567. onXRSessionEnded: Observable<any>;
  125568. /**
  125569. * Fires when the xr session is ended either by the device or manually done
  125570. */
  125571. onXRSessionInit: Observable<XRSession>;
  125572. /**
  125573. * Underlying xr session
  125574. */
  125575. session: XRSession;
  125576. /**
  125577. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  125578. * or get the offset the player is currently at.
  125579. */
  125580. viewerReferenceSpace: XRReferenceSpace;
  125581. /**
  125582. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  125583. * @param scene The scene which the session should be created for
  125584. */
  125585. constructor(
  125586. /** The scene which the session should be created for */
  125587. scene: Scene);
  125588. /**
  125589. * The current reference space used in this session. This reference space can constantly change!
  125590. * It is mainly used to offset the camera's position.
  125591. */
  125592. get referenceSpace(): XRReferenceSpace;
  125593. /**
  125594. * Set a new reference space and triggers the observable
  125595. */
  125596. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  125597. /**
  125598. * Disposes of the session manager
  125599. */
  125600. dispose(): void;
  125601. /**
  125602. * Stops the xrSession and restores the render loop
  125603. * @returns Promise which resolves after it exits XR
  125604. */
  125605. exitXRAsync(): Promise<void>;
  125606. /**
  125607. * Gets the correct render target texture to be rendered this frame for this eye
  125608. * @param eye the eye for which to get the render target
  125609. * @returns the render target for the specified eye
  125610. */
  125611. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  125612. /**
  125613. * Creates a WebXRRenderTarget object for the XR session
  125614. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  125615. * @param options optional options to provide when creating a new render target
  125616. * @returns a WebXR render target to which the session can render
  125617. */
  125618. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  125619. /**
  125620. * Initializes the manager
  125621. * After initialization enterXR can be called to start an XR session
  125622. * @returns Promise which resolves after it is initialized
  125623. */
  125624. initializeAsync(): Promise<void>;
  125625. /**
  125626. * Initializes an xr session
  125627. * @param xrSessionMode mode to initialize
  125628. * @param xrSessionInit defines optional and required values to pass to the session builder
  125629. * @returns a promise which will resolve once the session has been initialized
  125630. */
  125631. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  125632. /**
  125633. * Checks if a session would be supported for the creation options specified
  125634. * @param sessionMode session mode to check if supported eg. immersive-vr
  125635. * @returns A Promise that resolves to true if supported and false if not
  125636. */
  125637. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125638. /**
  125639. * Resets the reference space to the one started the session
  125640. */
  125641. resetReferenceSpace(): void;
  125642. /**
  125643. * Starts rendering to the xr layer
  125644. */
  125645. runXRRenderLoop(): void;
  125646. /**
  125647. * Sets the reference space on the xr session
  125648. * @param referenceSpaceType space to set
  125649. * @returns a promise that will resolve once the reference space has been set
  125650. */
  125651. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125652. /**
  125653. * Updates the render state of the session
  125654. * @param state state to set
  125655. * @returns a promise that resolves once the render state has been updated
  125656. */
  125657. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  125658. /**
  125659. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  125660. * @param sessionMode defines the session to test
  125661. * @returns a promise with boolean as final value
  125662. */
  125663. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125664. private _createRenderTargetTexture;
  125665. }
  125666. }
  125667. declare module BABYLON {
  125668. /**
  125669. * WebXR Camera which holds the views for the xrSession
  125670. * @see https://doc.babylonjs.com/how_to/webxr_camera
  125671. */
  125672. export class WebXRCamera extends FreeCamera {
  125673. private _xrSessionManager;
  125674. private _firstFrame;
  125675. private _referenceQuaternion;
  125676. private _referencedPosition;
  125677. private _xrInvPositionCache;
  125678. private _xrInvQuaternionCache;
  125679. /**
  125680. * Should position compensation execute on first frame.
  125681. * This is used when copying the position from a native (non XR) camera
  125682. */
  125683. compensateOnFirstFrame: boolean;
  125684. /**
  125685. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  125686. * @param name the name of the camera
  125687. * @param scene the scene to add the camera to
  125688. * @param _xrSessionManager a constructed xr session manager
  125689. */
  125690. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  125691. /**
  125692. * Return the user's height, unrelated to the current ground.
  125693. * This will be the y position of this camera, when ground level is 0.
  125694. */
  125695. get realWorldHeight(): number;
  125696. /** @hidden */
  125697. _updateForDualEyeDebugging(): void;
  125698. /**
  125699. * Sets this camera's transformation based on a non-vr camera
  125700. * @param otherCamera the non-vr camera to copy the transformation from
  125701. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  125702. */
  125703. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  125704. /**
  125705. * Gets the current instance class name ("WebXRCamera").
  125706. * @returns the class name
  125707. */
  125708. getClassName(): string;
  125709. private _rotate180;
  125710. private _updateFromXRSession;
  125711. private _updateNumberOfRigCameras;
  125712. private _updateReferenceSpace;
  125713. private _updateReferenceSpaceOffset;
  125714. }
  125715. }
  125716. declare module BABYLON {
  125717. /**
  125718. * Defining the interface required for a (webxr) feature
  125719. */
  125720. export interface IWebXRFeature extends IDisposable {
  125721. /**
  125722. * Is this feature attached
  125723. */
  125724. attached: boolean;
  125725. /**
  125726. * Should auto-attach be disabled?
  125727. */
  125728. disableAutoAttach: boolean;
  125729. /**
  125730. * Attach the feature to the session
  125731. * Will usually be called by the features manager
  125732. *
  125733. * @param force should attachment be forced (even when already attached)
  125734. * @returns true if successful.
  125735. */
  125736. attach(force?: boolean): boolean;
  125737. /**
  125738. * Detach the feature from the session
  125739. * Will usually be called by the features manager
  125740. *
  125741. * @returns true if successful.
  125742. */
  125743. detach(): boolean;
  125744. /**
  125745. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  125746. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  125747. *
  125748. * @returns whether or not the feature is compatible in this environment
  125749. */
  125750. isCompatible(): boolean;
  125751. /**
  125752. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  125753. */
  125754. xrNativeFeatureName?: string;
  125755. }
  125756. /**
  125757. * A list of the currently available features without referencing them
  125758. */
  125759. export class WebXRFeatureName {
  125760. /**
  125761. * The name of the anchor system feature
  125762. */
  125763. static ANCHOR_SYSTEM: string;
  125764. /**
  125765. * The name of the background remover feature
  125766. */
  125767. static BACKGROUND_REMOVER: string;
  125768. /**
  125769. * The name of the hit test feature
  125770. */
  125771. static HIT_TEST: string;
  125772. /**
  125773. * physics impostors for xr controllers feature
  125774. */
  125775. static PHYSICS_CONTROLLERS: string;
  125776. /**
  125777. * The name of the plane detection feature
  125778. */
  125779. static PLANE_DETECTION: string;
  125780. /**
  125781. * The name of the pointer selection feature
  125782. */
  125783. static POINTER_SELECTION: string;
  125784. /**
  125785. * The name of the teleportation feature
  125786. */
  125787. static TELEPORTATION: string;
  125788. }
  125789. /**
  125790. * Defining the constructor of a feature. Used to register the modules.
  125791. */
  125792. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  125793. /**
  125794. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  125795. * It is mainly used in AR sessions.
  125796. *
  125797. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  125798. */
  125799. export class WebXRFeaturesManager implements IDisposable {
  125800. private _xrSessionManager;
  125801. private static readonly _AvailableFeatures;
  125802. private _features;
  125803. /**
  125804. * constructs a new features manages.
  125805. *
  125806. * @param _xrSessionManager an instance of WebXRSessionManager
  125807. */
  125808. constructor(_xrSessionManager: WebXRSessionManager);
  125809. /**
  125810. * Used to register a module. After calling this function a developer can use this feature in the scene.
  125811. * Mainly used internally.
  125812. *
  125813. * @param featureName the name of the feature to register
  125814. * @param constructorFunction the function used to construct the module
  125815. * @param version the (babylon) version of the module
  125816. * @param stable is that a stable version of this module
  125817. */
  125818. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  125819. /**
  125820. * Returns a constructor of a specific feature.
  125821. *
  125822. * @param featureName the name of the feature to construct
  125823. * @param version the version of the feature to load
  125824. * @param xrSessionManager the xrSessionManager. Used to construct the module
  125825. * @param options optional options provided to the module.
  125826. * @returns a function that, when called, will return a new instance of this feature
  125827. */
  125828. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  125829. /**
  125830. * Can be used to return the list of features currently registered
  125831. *
  125832. * @returns an Array of available features
  125833. */
  125834. static GetAvailableFeatures(): string[];
  125835. /**
  125836. * Gets the versions available for a specific feature
  125837. * @param featureName the name of the feature
  125838. * @returns an array with the available versions
  125839. */
  125840. static GetAvailableVersions(featureName: string): string[];
  125841. /**
  125842. * Return the latest unstable version of this feature
  125843. * @param featureName the name of the feature to search
  125844. * @returns the version number. if not found will return -1
  125845. */
  125846. static GetLatestVersionOfFeature(featureName: string): number;
  125847. /**
  125848. * Return the latest stable version of this feature
  125849. * @param featureName the name of the feature to search
  125850. * @returns the version number. if not found will return -1
  125851. */
  125852. static GetStableVersionOfFeature(featureName: string): number;
  125853. /**
  125854. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  125855. * Can be used during a session to start a feature
  125856. * @param featureName the name of feature to attach
  125857. */
  125858. attachFeature(featureName: string): void;
  125859. /**
  125860. * Can be used inside a session or when the session ends to detach a specific feature
  125861. * @param featureName the name of the feature to detach
  125862. */
  125863. detachFeature(featureName: string): void;
  125864. /**
  125865. * Used to disable an already-enabled feature
  125866. * The feature will be disposed and will be recreated once enabled.
  125867. * @param featureName the feature to disable
  125868. * @returns true if disable was successful
  125869. */
  125870. disableFeature(featureName: string | {
  125871. Name: string;
  125872. }): boolean;
  125873. /**
  125874. * dispose this features manager
  125875. */
  125876. dispose(): void;
  125877. /**
  125878. * 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.
  125879. * 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.
  125880. *
  125881. * @param featureName the name of the feature to load or the class of the feature
  125882. * @param version optional version to load. if not provided the latest version will be enabled
  125883. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  125884. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  125885. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  125886. * @returns a new constructed feature or throws an error if feature not found.
  125887. */
  125888. enableFeature(featureName: string | {
  125889. Name: string;
  125890. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  125891. /**
  125892. * get the implementation of an enabled feature.
  125893. * @param featureName the name of the feature to load
  125894. * @returns the feature class, if found
  125895. */
  125896. getEnabledFeature(featureName: string): IWebXRFeature;
  125897. /**
  125898. * Get the list of enabled features
  125899. * @returns an array of enabled features
  125900. */
  125901. getEnabledFeatures(): string[];
  125902. /**
  125903. * This function will exten the session creation configuration object with enabled features.
  125904. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  125905. * according to the defined "required" variable, provided during enableFeature call
  125906. * @param xrSessionInit the xr Session init object to extend
  125907. *
  125908. * @returns an extended XRSessionInit object
  125909. */
  125910. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  125911. }
  125912. }
  125913. declare module BABYLON {
  125914. /**
  125915. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  125916. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  125917. */
  125918. export class WebXRExperienceHelper implements IDisposable {
  125919. private scene;
  125920. private _nonVRCamera;
  125921. private _originalSceneAutoClear;
  125922. private _supported;
  125923. /**
  125924. * Camera used to render xr content
  125925. */
  125926. camera: WebXRCamera;
  125927. /** A features manager for this xr session */
  125928. featuresManager: WebXRFeaturesManager;
  125929. /**
  125930. * Observers registered here will be triggered after the camera's initial transformation is set
  125931. * This can be used to set a different ground level or an extra rotation.
  125932. *
  125933. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  125934. * to the position set after this observable is done executing.
  125935. */
  125936. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  125937. /**
  125938. * Fires when the state of the experience helper has changed
  125939. */
  125940. onStateChangedObservable: Observable<WebXRState>;
  125941. /** Session manager used to keep track of xr session */
  125942. sessionManager: WebXRSessionManager;
  125943. /**
  125944. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  125945. */
  125946. state: WebXRState;
  125947. /**
  125948. * Creates a WebXRExperienceHelper
  125949. * @param scene The scene the helper should be created in
  125950. */
  125951. private constructor();
  125952. /**
  125953. * Creates the experience helper
  125954. * @param scene the scene to attach the experience helper to
  125955. * @returns a promise for the experience helper
  125956. */
  125957. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  125958. /**
  125959. * Disposes of the experience helper
  125960. */
  125961. dispose(): void;
  125962. /**
  125963. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  125964. * @param sessionMode options for the XR session
  125965. * @param referenceSpaceType frame of reference of the XR session
  125966. * @param renderTarget the output canvas that will be used to enter XR mode
  125967. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  125968. * @returns promise that resolves after xr mode has entered
  125969. */
  125970. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  125971. /**
  125972. * Exits XR mode and returns the scene to its original state
  125973. * @returns promise that resolves after xr mode has exited
  125974. */
  125975. exitXRAsync(): Promise<void>;
  125976. private _nonXRToXRCamera;
  125977. private _setState;
  125978. }
  125979. }
  125980. declare module BABYLON {
  125981. /**
  125982. * X-Y values for axes in WebXR
  125983. */
  125984. export interface IWebXRMotionControllerAxesValue {
  125985. /**
  125986. * The value of the x axis
  125987. */
  125988. x: number;
  125989. /**
  125990. * The value of the y-axis
  125991. */
  125992. y: number;
  125993. }
  125994. /**
  125995. * changed / previous values for the values of this component
  125996. */
  125997. export interface IWebXRMotionControllerComponentChangesValues<T> {
  125998. /**
  125999. * current (this frame) value
  126000. */
  126001. current: T;
  126002. /**
  126003. * previous (last change) value
  126004. */
  126005. previous: T;
  126006. }
  126007. /**
  126008. * Represents changes in the component between current frame and last values recorded
  126009. */
  126010. export interface IWebXRMotionControllerComponentChanges {
  126011. /**
  126012. * will be populated with previous and current values if axes changed
  126013. */
  126014. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126015. /**
  126016. * will be populated with previous and current values if pressed changed
  126017. */
  126018. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126019. /**
  126020. * will be populated with previous and current values if touched changed
  126021. */
  126022. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126023. /**
  126024. * will be populated with previous and current values if value changed
  126025. */
  126026. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126027. }
  126028. /**
  126029. * This class represents a single component (for example button or thumbstick) of a motion controller
  126030. */
  126031. export class WebXRControllerComponent implements IDisposable {
  126032. /**
  126033. * the id of this component
  126034. */
  126035. id: string;
  126036. /**
  126037. * the type of the component
  126038. */
  126039. type: MotionControllerComponentType;
  126040. private _buttonIndex;
  126041. private _axesIndices;
  126042. private _axes;
  126043. private _changes;
  126044. private _currentValue;
  126045. private _hasChanges;
  126046. private _pressed;
  126047. private _touched;
  126048. /**
  126049. * button component type
  126050. */
  126051. static BUTTON_TYPE: MotionControllerComponentType;
  126052. /**
  126053. * squeeze component type
  126054. */
  126055. static SQUEEZE_TYPE: MotionControllerComponentType;
  126056. /**
  126057. * Thumbstick component type
  126058. */
  126059. static THUMBSTICK_TYPE: MotionControllerComponentType;
  126060. /**
  126061. * Touchpad component type
  126062. */
  126063. static TOUCHPAD_TYPE: MotionControllerComponentType;
  126064. /**
  126065. * trigger component type
  126066. */
  126067. static TRIGGER_TYPE: MotionControllerComponentType;
  126068. /**
  126069. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  126070. * the axes data changes
  126071. */
  126072. onAxisValueChangedObservable: Observable<{
  126073. x: number;
  126074. y: number;
  126075. }>;
  126076. /**
  126077. * Observers registered here will be triggered when the state of a button changes
  126078. * State change is either pressed / touched / value
  126079. */
  126080. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  126081. /**
  126082. * Creates a new component for a motion controller.
  126083. * It is created by the motion controller itself
  126084. *
  126085. * @param id the id of this component
  126086. * @param type the type of the component
  126087. * @param _buttonIndex index in the buttons array of the gamepad
  126088. * @param _axesIndices indices of the values in the axes array of the gamepad
  126089. */
  126090. constructor(
  126091. /**
  126092. * the id of this component
  126093. */
  126094. id: string,
  126095. /**
  126096. * the type of the component
  126097. */
  126098. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  126099. /**
  126100. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  126101. */
  126102. get axes(): IWebXRMotionControllerAxesValue;
  126103. /**
  126104. * Get the changes. Elements will be populated only if they changed with their previous and current value
  126105. */
  126106. get changes(): IWebXRMotionControllerComponentChanges;
  126107. /**
  126108. * Return whether or not the component changed the last frame
  126109. */
  126110. get hasChanges(): boolean;
  126111. /**
  126112. * is the button currently pressed
  126113. */
  126114. get pressed(): boolean;
  126115. /**
  126116. * is the button currently touched
  126117. */
  126118. get touched(): boolean;
  126119. /**
  126120. * Get the current value of this component
  126121. */
  126122. get value(): number;
  126123. /**
  126124. * Dispose this component
  126125. */
  126126. dispose(): void;
  126127. /**
  126128. * Are there axes correlating to this component
  126129. * @return true is axes data is available
  126130. */
  126131. isAxes(): boolean;
  126132. /**
  126133. * Is this component a button (hence - pressable)
  126134. * @returns true if can be pressed
  126135. */
  126136. isButton(): boolean;
  126137. /**
  126138. * update this component using the gamepad object it is in. Called on every frame
  126139. * @param nativeController the native gamepad controller object
  126140. */
  126141. update(nativeController: IMinimalMotionControllerObject): void;
  126142. }
  126143. }
  126144. declare module BABYLON {
  126145. /**
  126146. * Interface used to represent data loading progression
  126147. */
  126148. export interface ISceneLoaderProgressEvent {
  126149. /**
  126150. * Defines if data length to load can be evaluated
  126151. */
  126152. readonly lengthComputable: boolean;
  126153. /**
  126154. * Defines the loaded data length
  126155. */
  126156. readonly loaded: number;
  126157. /**
  126158. * Defines the data length to load
  126159. */
  126160. readonly total: number;
  126161. }
  126162. /**
  126163. * Interface used by SceneLoader plugins to define supported file extensions
  126164. */
  126165. export interface ISceneLoaderPluginExtensions {
  126166. /**
  126167. * Defines the list of supported extensions
  126168. */
  126169. [extension: string]: {
  126170. isBinary: boolean;
  126171. };
  126172. }
  126173. /**
  126174. * Interface used by SceneLoader plugin factory
  126175. */
  126176. export interface ISceneLoaderPluginFactory {
  126177. /**
  126178. * Defines the name of the factory
  126179. */
  126180. name: string;
  126181. /**
  126182. * Function called to create a new plugin
  126183. * @return the new plugin
  126184. */
  126185. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126186. /**
  126187. * The callback that returns true if the data can be directly loaded.
  126188. * @param data string containing the file data
  126189. * @returns if the data can be loaded directly
  126190. */
  126191. canDirectLoad?(data: string): boolean;
  126192. }
  126193. /**
  126194. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126195. */
  126196. export interface ISceneLoaderPluginBase {
  126197. /**
  126198. * The friendly name of this plugin.
  126199. */
  126200. name: string;
  126201. /**
  126202. * The file extensions supported by this plugin.
  126203. */
  126204. extensions: string | ISceneLoaderPluginExtensions;
  126205. /**
  126206. * The callback called when loading from a url.
  126207. * @param scene scene loading this url
  126208. * @param url url to load
  126209. * @param onSuccess callback called when the file successfully loads
  126210. * @param onProgress callback called while file is loading (if the server supports this mode)
  126211. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126212. * @param onError callback called when the file fails to load
  126213. * @returns a file request object
  126214. */
  126215. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126216. /**
  126217. * The callback called when loading from a file object.
  126218. * @param scene scene loading this file
  126219. * @param file defines the file to load
  126220. * @param onSuccess defines the callback to call when data is loaded
  126221. * @param onProgress defines the callback to call during loading process
  126222. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126223. * @param onError defines the callback to call when an error occurs
  126224. * @returns a file request object
  126225. */
  126226. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126227. /**
  126228. * The callback that returns true if the data can be directly loaded.
  126229. * @param data string containing the file data
  126230. * @returns if the data can be loaded directly
  126231. */
  126232. canDirectLoad?(data: string): boolean;
  126233. /**
  126234. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126235. * @param scene scene loading this data
  126236. * @param data string containing the data
  126237. * @returns data to pass to the plugin
  126238. */
  126239. directLoad?(scene: Scene, data: string): any;
  126240. /**
  126241. * The callback that allows custom handling of the root url based on the response url.
  126242. * @param rootUrl the original root url
  126243. * @param responseURL the response url if available
  126244. * @returns the new root url
  126245. */
  126246. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126247. }
  126248. /**
  126249. * Interface used to define a SceneLoader plugin
  126250. */
  126251. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126252. /**
  126253. * Import meshes into a scene.
  126254. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126255. * @param scene The scene to import into
  126256. * @param data The data to import
  126257. * @param rootUrl The root url for scene and resources
  126258. * @param meshes The meshes array to import into
  126259. * @param particleSystems The particle systems array to import into
  126260. * @param skeletons The skeletons array to import into
  126261. * @param onError The callback when import fails
  126262. * @returns True if successful or false otherwise
  126263. */
  126264. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126265. /**
  126266. * Load into a scene.
  126267. * @param scene The scene to load into
  126268. * @param data The data to import
  126269. * @param rootUrl The root url for scene and resources
  126270. * @param onError The callback when import fails
  126271. * @returns True if successful or false otherwise
  126272. */
  126273. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126274. /**
  126275. * Load into an asset container.
  126276. * @param scene The scene to load into
  126277. * @param data The data to import
  126278. * @param rootUrl The root url for scene and resources
  126279. * @param onError The callback when import fails
  126280. * @returns The loaded asset container
  126281. */
  126282. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126283. }
  126284. /**
  126285. * Interface used to define an async SceneLoader plugin
  126286. */
  126287. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126288. /**
  126289. * Import meshes into a scene.
  126290. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126291. * @param scene The scene to import into
  126292. * @param data The data to import
  126293. * @param rootUrl The root url for scene and resources
  126294. * @param onProgress The callback when the load progresses
  126295. * @param fileName Defines the name of the file to load
  126296. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126297. */
  126298. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126299. meshes: AbstractMesh[];
  126300. particleSystems: IParticleSystem[];
  126301. skeletons: Skeleton[];
  126302. animationGroups: AnimationGroup[];
  126303. }>;
  126304. /**
  126305. * Load into a scene.
  126306. * @param scene The scene to load into
  126307. * @param data The data to import
  126308. * @param rootUrl The root url for scene and resources
  126309. * @param onProgress The callback when the load progresses
  126310. * @param fileName Defines the name of the file to load
  126311. * @returns Nothing
  126312. */
  126313. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126314. /**
  126315. * Load into an asset container.
  126316. * @param scene The scene to load into
  126317. * @param data The data to import
  126318. * @param rootUrl The root url for scene and resources
  126319. * @param onProgress The callback when the load progresses
  126320. * @param fileName Defines the name of the file to load
  126321. * @returns The loaded asset container
  126322. */
  126323. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126324. }
  126325. /**
  126326. * Mode that determines how to handle old animation groups before loading new ones.
  126327. */
  126328. export enum SceneLoaderAnimationGroupLoadingMode {
  126329. /**
  126330. * Reset all old animations to initial state then dispose them.
  126331. */
  126332. Clean = 0,
  126333. /**
  126334. * Stop all old animations.
  126335. */
  126336. Stop = 1,
  126337. /**
  126338. * Restart old animations from first frame.
  126339. */
  126340. Sync = 2,
  126341. /**
  126342. * Old animations remains untouched.
  126343. */
  126344. NoSync = 3
  126345. }
  126346. /**
  126347. * Defines a plugin registered by the SceneLoader
  126348. */
  126349. interface IRegisteredPlugin {
  126350. /**
  126351. * Defines the plugin to use
  126352. */
  126353. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126354. /**
  126355. * Defines if the plugin supports binary data
  126356. */
  126357. isBinary: boolean;
  126358. }
  126359. /**
  126360. * Class used to load scene from various file formats using registered plugins
  126361. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126362. */
  126363. export class SceneLoader {
  126364. /**
  126365. * No logging while loading
  126366. */
  126367. static readonly NO_LOGGING: number;
  126368. /**
  126369. * Minimal logging while loading
  126370. */
  126371. static readonly MINIMAL_LOGGING: number;
  126372. /**
  126373. * Summary logging while loading
  126374. */
  126375. static readonly SUMMARY_LOGGING: number;
  126376. /**
  126377. * Detailled logging while loading
  126378. */
  126379. static readonly DETAILED_LOGGING: number;
  126380. /**
  126381. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126382. */
  126383. static get ForceFullSceneLoadingForIncremental(): boolean;
  126384. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126385. /**
  126386. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126387. */
  126388. static get ShowLoadingScreen(): boolean;
  126389. static set ShowLoadingScreen(value: boolean);
  126390. /**
  126391. * Defines the current logging level (while loading the scene)
  126392. * @ignorenaming
  126393. */
  126394. static get loggingLevel(): number;
  126395. static set loggingLevel(value: number);
  126396. /**
  126397. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126398. */
  126399. static get CleanBoneMatrixWeights(): boolean;
  126400. static set CleanBoneMatrixWeights(value: boolean);
  126401. /**
  126402. * Event raised when a plugin is used to load a scene
  126403. */
  126404. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126405. private static _registeredPlugins;
  126406. private static _showingLoadingScreen;
  126407. /**
  126408. * Gets the default plugin (used to load Babylon files)
  126409. * @returns the .babylon plugin
  126410. */
  126411. static GetDefaultPlugin(): IRegisteredPlugin;
  126412. private static _GetPluginForExtension;
  126413. private static _GetPluginForDirectLoad;
  126414. private static _GetPluginForFilename;
  126415. private static _GetDirectLoad;
  126416. private static _LoadData;
  126417. private static _GetFileInfo;
  126418. /**
  126419. * Gets a plugin that can load the given extension
  126420. * @param extension defines the extension to load
  126421. * @returns a plugin or null if none works
  126422. */
  126423. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126424. /**
  126425. * Gets a boolean indicating that the given extension can be loaded
  126426. * @param extension defines the extension to load
  126427. * @returns true if the extension is supported
  126428. */
  126429. static IsPluginForExtensionAvailable(extension: string): boolean;
  126430. /**
  126431. * Adds a new plugin to the list of registered plugins
  126432. * @param plugin defines the plugin to add
  126433. */
  126434. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  126435. /**
  126436. * Import meshes into a scene
  126437. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126438. * @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)
  126439. * @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)
  126440. * @param scene the instance of BABYLON.Scene to append to
  126441. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  126442. * @param onProgress a callback with a progress event for each file being loaded
  126443. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126444. * @param pluginExtension the extension used to determine the plugin
  126445. * @returns The loaded plugin
  126446. */
  126447. 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>;
  126448. /**
  126449. * Import meshes into a scene
  126450. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126451. * @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)
  126452. * @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)
  126453. * @param scene the instance of BABYLON.Scene to append to
  126454. * @param onProgress a callback with a progress event for each file being loaded
  126455. * @param pluginExtension the extension used to determine the plugin
  126456. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  126457. */
  126458. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  126459. meshes: AbstractMesh[];
  126460. particleSystems: IParticleSystem[];
  126461. skeletons: Skeleton[];
  126462. animationGroups: AnimationGroup[];
  126463. }>;
  126464. /**
  126465. * Load a scene
  126466. * @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)
  126467. * @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)
  126468. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126469. * @param onSuccess a callback with the scene when import succeeds
  126470. * @param onProgress a callback with a progress event for each file being loaded
  126471. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126472. * @param pluginExtension the extension used to determine the plugin
  126473. * @returns The loaded plugin
  126474. */
  126475. 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>;
  126476. /**
  126477. * Load a scene
  126478. * @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)
  126479. * @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)
  126480. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126481. * @param onProgress a callback with a progress event for each file being loaded
  126482. * @param pluginExtension the extension used to determine the plugin
  126483. * @returns The loaded scene
  126484. */
  126485. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126486. /**
  126487. * Append a scene
  126488. * @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)
  126489. * @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)
  126490. * @param scene is the instance of BABYLON.Scene to append to
  126491. * @param onSuccess a callback with the scene when import succeeds
  126492. * @param onProgress a callback with a progress event for each file being loaded
  126493. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126494. * @param pluginExtension the extension used to determine the plugin
  126495. * @returns The loaded plugin
  126496. */
  126497. 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>;
  126498. /**
  126499. * Append a scene
  126500. * @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)
  126501. * @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)
  126502. * @param scene is the instance of BABYLON.Scene to append to
  126503. * @param onProgress a callback with a progress event for each file being loaded
  126504. * @param pluginExtension the extension used to determine the plugin
  126505. * @returns The given scene
  126506. */
  126507. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126508. /**
  126509. * Load a scene into an asset container
  126510. * @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)
  126511. * @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)
  126512. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126513. * @param onSuccess a callback with the scene when import succeeds
  126514. * @param onProgress a callback with a progress event for each file being loaded
  126515. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126516. * @param pluginExtension the extension used to determine the plugin
  126517. * @returns The loaded plugin
  126518. */
  126519. 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>;
  126520. /**
  126521. * Load a scene into an asset container
  126522. * @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)
  126523. * @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)
  126524. * @param scene is the instance of Scene to append to
  126525. * @param onProgress a callback with a progress event for each file being loaded
  126526. * @param pluginExtension the extension used to determine the plugin
  126527. * @returns The loaded asset container
  126528. */
  126529. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  126530. /**
  126531. * Import animations from a file into a scene
  126532. * @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)
  126533. * @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)
  126534. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126535. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126536. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126537. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126538. * @param onSuccess a callback with the scene when import succeeds
  126539. * @param onProgress a callback with a progress event for each file being loaded
  126540. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126541. * @param pluginExtension the extension used to determine the plugin
  126542. */
  126543. 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;
  126544. /**
  126545. * Import animations from a file into a scene
  126546. * @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)
  126547. * @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)
  126548. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126549. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126550. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126551. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126552. * @param onSuccess a callback with the scene when import succeeds
  126553. * @param onProgress a callback with a progress event for each file being loaded
  126554. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126555. * @param pluginExtension the extension used to determine the plugin
  126556. * @returns the updated scene with imported animations
  126557. */
  126558. 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>;
  126559. }
  126560. }
  126561. declare module BABYLON {
  126562. /**
  126563. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  126564. */
  126565. export type MotionControllerHandedness = "none" | "left" | "right";
  126566. /**
  126567. * The type of components available in motion controllers.
  126568. * This is not the name of the component.
  126569. */
  126570. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  126571. /**
  126572. * The state of a controller component
  126573. */
  126574. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  126575. /**
  126576. * The schema of motion controller layout.
  126577. * No object will be initialized using this interface
  126578. * This is used just to define the profile.
  126579. */
  126580. export interface IMotionControllerLayout {
  126581. /**
  126582. * Path to load the assets. Usually relative to the base path
  126583. */
  126584. assetPath: string;
  126585. /**
  126586. * Available components (unsorted)
  126587. */
  126588. components: {
  126589. /**
  126590. * A map of component Ids
  126591. */
  126592. [componentId: string]: {
  126593. /**
  126594. * The type of input the component outputs
  126595. */
  126596. type: MotionControllerComponentType;
  126597. /**
  126598. * The indices of this component in the gamepad object
  126599. */
  126600. gamepadIndices: {
  126601. /**
  126602. * Index of button
  126603. */
  126604. button?: number;
  126605. /**
  126606. * If available, index of x-axis
  126607. */
  126608. xAxis?: number;
  126609. /**
  126610. * If available, index of y-axis
  126611. */
  126612. yAxis?: number;
  126613. };
  126614. /**
  126615. * The mesh's root node name
  126616. */
  126617. rootNodeName: string;
  126618. /**
  126619. * Animation definitions for this model
  126620. */
  126621. visualResponses: {
  126622. [stateKey: string]: {
  126623. /**
  126624. * What property will be animated
  126625. */
  126626. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  126627. /**
  126628. * What states influence this visual response
  126629. */
  126630. states: MotionControllerComponentStateType[];
  126631. /**
  126632. * Type of animation - movement or visibility
  126633. */
  126634. valueNodeProperty: "transform" | "visibility";
  126635. /**
  126636. * Base node name to move. Its position will be calculated according to the min and max nodes
  126637. */
  126638. valueNodeName?: string;
  126639. /**
  126640. * Minimum movement node
  126641. */
  126642. minNodeName?: string;
  126643. /**
  126644. * Max movement node
  126645. */
  126646. maxNodeName?: string;
  126647. };
  126648. };
  126649. /**
  126650. * If touch enabled, what is the name of node to display user feedback
  126651. */
  126652. touchPointNodeName?: string;
  126653. };
  126654. };
  126655. /**
  126656. * Is it xr standard mapping or not
  126657. */
  126658. gamepadMapping: "" | "xr-standard";
  126659. /**
  126660. * Base root node of this entire model
  126661. */
  126662. rootNodeName: string;
  126663. /**
  126664. * Defines the main button component id
  126665. */
  126666. selectComponentId: string;
  126667. }
  126668. /**
  126669. * A definition for the layout map in the input profile
  126670. */
  126671. export interface IMotionControllerLayoutMap {
  126672. /**
  126673. * Layouts with handedness type as a key
  126674. */
  126675. [handedness: string]: IMotionControllerLayout;
  126676. }
  126677. /**
  126678. * The XR Input profile schema
  126679. * Profiles can be found here:
  126680. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  126681. */
  126682. export interface IMotionControllerProfile {
  126683. /**
  126684. * fallback profiles for this profileId
  126685. */
  126686. fallbackProfileIds: string[];
  126687. /**
  126688. * The layout map, with handedness as key
  126689. */
  126690. layouts: IMotionControllerLayoutMap;
  126691. /**
  126692. * The id of this profile
  126693. * correlates to the profile(s) in the xrInput.profiles array
  126694. */
  126695. profileId: string;
  126696. }
  126697. /**
  126698. * A helper-interface for the 3 meshes needed for controller button animation
  126699. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  126700. */
  126701. export interface IMotionControllerButtonMeshMap {
  126702. /**
  126703. * the mesh that defines the pressed value mesh position.
  126704. * This is used to find the max-position of this button
  126705. */
  126706. pressedMesh: AbstractMesh;
  126707. /**
  126708. * the mesh that defines the unpressed value mesh position.
  126709. * This is used to find the min (or initial) position of this button
  126710. */
  126711. unpressedMesh: AbstractMesh;
  126712. /**
  126713. * The mesh that will be changed when value changes
  126714. */
  126715. valueMesh: AbstractMesh;
  126716. }
  126717. /**
  126718. * A helper-interface for the 3 meshes needed for controller axis animation.
  126719. * This will be expanded when touchpad animations are fully supported
  126720. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  126721. */
  126722. export interface IMotionControllerMeshMap {
  126723. /**
  126724. * the mesh that defines the maximum value mesh position.
  126725. */
  126726. maxMesh?: AbstractMesh;
  126727. /**
  126728. * the mesh that defines the minimum value mesh position.
  126729. */
  126730. minMesh?: AbstractMesh;
  126731. /**
  126732. * The mesh that will be changed when axis value changes
  126733. */
  126734. valueMesh: AbstractMesh;
  126735. }
  126736. /**
  126737. * The elements needed for change-detection of the gamepad objects in motion controllers
  126738. */
  126739. export interface IMinimalMotionControllerObject {
  126740. /**
  126741. * Available axes of this controller
  126742. */
  126743. axes: number[];
  126744. /**
  126745. * An array of available buttons
  126746. */
  126747. buttons: Array<{
  126748. /**
  126749. * Value of the button/trigger
  126750. */
  126751. value: number;
  126752. /**
  126753. * If the button/trigger is currently touched
  126754. */
  126755. touched: boolean;
  126756. /**
  126757. * If the button/trigger is currently pressed
  126758. */
  126759. pressed: boolean;
  126760. }>;
  126761. /**
  126762. * EXPERIMENTAL haptic support.
  126763. */
  126764. hapticActuators?: Array<{
  126765. pulse: (value: number, duration: number) => Promise<boolean>;
  126766. }>;
  126767. }
  126768. /**
  126769. * An Abstract Motion controller
  126770. * This class receives an xrInput and a profile layout and uses those to initialize the components
  126771. * Each component has an observable to check for changes in value and state
  126772. */
  126773. export abstract class WebXRAbstractMotionController implements IDisposable {
  126774. protected scene: Scene;
  126775. protected layout: IMotionControllerLayout;
  126776. /**
  126777. * The gamepad object correlating to this controller
  126778. */
  126779. gamepadObject: IMinimalMotionControllerObject;
  126780. /**
  126781. * handedness (left/right/none) of this controller
  126782. */
  126783. handedness: MotionControllerHandedness;
  126784. private _initComponent;
  126785. private _modelReady;
  126786. /**
  126787. * A map of components (WebXRControllerComponent) in this motion controller
  126788. * Components have a ComponentType and can also have both button and axis definitions
  126789. */
  126790. readonly components: {
  126791. [id: string]: WebXRControllerComponent;
  126792. };
  126793. /**
  126794. * Disable the model's animation. Can be set at any time.
  126795. */
  126796. disableAnimation: boolean;
  126797. /**
  126798. * Observers registered here will be triggered when the model of this controller is done loading
  126799. */
  126800. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  126801. /**
  126802. * The profile id of this motion controller
  126803. */
  126804. abstract profileId: string;
  126805. /**
  126806. * The root mesh of the model. It is null if the model was not yet initialized
  126807. */
  126808. rootMesh: Nullable<AbstractMesh>;
  126809. /**
  126810. * constructs a new abstract motion controller
  126811. * @param scene the scene to which the model of the controller will be added
  126812. * @param layout The profile layout to load
  126813. * @param gamepadObject The gamepad object correlating to this controller
  126814. * @param handedness handedness (left/right/none) of this controller
  126815. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  126816. */
  126817. constructor(scene: Scene, layout: IMotionControllerLayout,
  126818. /**
  126819. * The gamepad object correlating to this controller
  126820. */
  126821. gamepadObject: IMinimalMotionControllerObject,
  126822. /**
  126823. * handedness (left/right/none) of this controller
  126824. */
  126825. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  126826. /**
  126827. * Dispose this controller, the model mesh and all its components
  126828. */
  126829. dispose(): void;
  126830. /**
  126831. * Returns all components of specific type
  126832. * @param type the type to search for
  126833. * @return an array of components with this type
  126834. */
  126835. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  126836. /**
  126837. * get a component based an its component id as defined in layout.components
  126838. * @param id the id of the component
  126839. * @returns the component correlates to the id or undefined if not found
  126840. */
  126841. getComponent(id: string): WebXRControllerComponent;
  126842. /**
  126843. * Get the list of components available in this motion controller
  126844. * @returns an array of strings correlating to available components
  126845. */
  126846. getComponentIds(): string[];
  126847. /**
  126848. * Get the first component of specific type
  126849. * @param type type of component to find
  126850. * @return a controller component or null if not found
  126851. */
  126852. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  126853. /**
  126854. * Get the main (Select) component of this controller as defined in the layout
  126855. * @returns the main component of this controller
  126856. */
  126857. getMainComponent(): WebXRControllerComponent;
  126858. /**
  126859. * Loads the model correlating to this controller
  126860. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  126861. * @returns A promise fulfilled with the result of the model loading
  126862. */
  126863. loadModel(): Promise<boolean>;
  126864. /**
  126865. * Update this model using the current XRFrame
  126866. * @param xrFrame the current xr frame to use and update the model
  126867. */
  126868. updateFromXRFrame(xrFrame: XRFrame): void;
  126869. /**
  126870. * Backwards compatibility due to a deeply-integrated typo
  126871. */
  126872. get handness(): XREye;
  126873. /**
  126874. * Pulse (vibrate) this controller
  126875. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  126876. * Consecutive calls to this function will cancel the last pulse call
  126877. *
  126878. * @param value the strength of the pulse in 0.0...1.0 range
  126879. * @param duration Duration of the pulse in milliseconds
  126880. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  126881. * @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
  126882. */
  126883. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  126884. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126885. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126886. /**
  126887. * Moves the axis on the controller mesh based on its current state
  126888. * @param axis the index of the axis
  126889. * @param axisValue the value of the axis which determines the meshes new position
  126890. * @hidden
  126891. */
  126892. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  126893. /**
  126894. * Update the model itself with the current frame data
  126895. * @param xrFrame the frame to use for updating the model mesh
  126896. */
  126897. protected updateModel(xrFrame: XRFrame): void;
  126898. /**
  126899. * Get the filename and path for this controller's model
  126900. * @returns a map of filename and path
  126901. */
  126902. protected abstract _getFilenameAndPath(): {
  126903. filename: string;
  126904. path: string;
  126905. };
  126906. /**
  126907. * This function is called before the mesh is loaded. It checks for loading constraints.
  126908. * For example, this function can check if the GLB loader is available
  126909. * If this function returns false, the generic controller will be loaded instead
  126910. * @returns Is the client ready to load the mesh
  126911. */
  126912. protected abstract _getModelLoadingConstraints(): boolean;
  126913. /**
  126914. * This function will be called after the model was successfully loaded and can be used
  126915. * for mesh transformations before it is available for the user
  126916. * @param meshes the loaded meshes
  126917. */
  126918. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  126919. /**
  126920. * Set the root mesh for this controller. Important for the WebXR controller class
  126921. * @param meshes the loaded meshes
  126922. */
  126923. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  126924. /**
  126925. * A function executed each frame that updates the mesh (if needed)
  126926. * @param xrFrame the current xrFrame
  126927. */
  126928. protected abstract _updateModel(xrFrame: XRFrame): void;
  126929. private _getGenericFilenameAndPath;
  126930. private _getGenericParentMesh;
  126931. }
  126932. }
  126933. declare module BABYLON {
  126934. /**
  126935. * A generic trigger-only motion controller for WebXR
  126936. */
  126937. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  126938. /**
  126939. * Static version of the profile id of this controller
  126940. */
  126941. static ProfileId: string;
  126942. profileId: string;
  126943. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  126944. protected _getFilenameAndPath(): {
  126945. filename: string;
  126946. path: string;
  126947. };
  126948. protected _getModelLoadingConstraints(): boolean;
  126949. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  126950. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126951. protected _updateModel(): void;
  126952. }
  126953. }
  126954. declare module BABYLON {
  126955. /**
  126956. * Class containing static functions to help procedurally build meshes
  126957. */
  126958. export class SphereBuilder {
  126959. /**
  126960. * Creates a sphere mesh
  126961. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126962. * * 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`)
  126963. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126964. * * 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
  126965. * * 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)
  126966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126969. * @param name defines the name of the mesh
  126970. * @param options defines the options used to create the mesh
  126971. * @param scene defines the hosting scene
  126972. * @returns the sphere mesh
  126973. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126974. */
  126975. static CreateSphere(name: string, options: {
  126976. segments?: number;
  126977. diameter?: number;
  126978. diameterX?: number;
  126979. diameterY?: number;
  126980. diameterZ?: number;
  126981. arc?: number;
  126982. slice?: number;
  126983. sideOrientation?: number;
  126984. frontUVs?: Vector4;
  126985. backUVs?: Vector4;
  126986. updatable?: boolean;
  126987. }, scene?: Nullable<Scene>): Mesh;
  126988. }
  126989. }
  126990. declare module BABYLON {
  126991. /**
  126992. * A profiled motion controller has its profile loaded from an online repository.
  126993. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  126994. */
  126995. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  126996. private _repositoryUrl;
  126997. private _buttonMeshMapping;
  126998. private _touchDots;
  126999. /**
  127000. * The profile ID of this controller. Will be populated when the controller initializes.
  127001. */
  127002. profileId: string;
  127003. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127004. dispose(): void;
  127005. protected _getFilenameAndPath(): {
  127006. filename: string;
  127007. path: string;
  127008. };
  127009. protected _getModelLoadingConstraints(): boolean;
  127010. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127011. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127012. protected _updateModel(_xrFrame: XRFrame): void;
  127013. }
  127014. }
  127015. declare module BABYLON {
  127016. /**
  127017. * A construction function type to create a new controller based on an xrInput object
  127018. */
  127019. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127020. /**
  127021. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127022. *
  127023. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127024. * it should be replaced with auto-loaded controllers.
  127025. *
  127026. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127027. */
  127028. export class WebXRMotionControllerManager {
  127029. private static _AvailableControllers;
  127030. private static _Fallbacks;
  127031. private static _ProfileLoadingPromises;
  127032. private static _ProfilesList;
  127033. /**
  127034. * The base URL of the online controller repository. Can be changed at any time.
  127035. */
  127036. static BaseRepositoryUrl: string;
  127037. /**
  127038. * Which repository gets priority - local or online
  127039. */
  127040. static PrioritizeOnlineRepository: boolean;
  127041. /**
  127042. * Use the online repository, or use only locally-defined controllers
  127043. */
  127044. static UseOnlineRepository: boolean;
  127045. /**
  127046. * Clear the cache used for profile loading and reload when requested again
  127047. */
  127048. static ClearProfilesCache(): void;
  127049. /**
  127050. * Register the default fallbacks.
  127051. * This function is called automatically when this file is imported.
  127052. */
  127053. static DefaultFallbacks(): void;
  127054. /**
  127055. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  127056. * @param profileId the profile to which a fallback needs to be found
  127057. * @return an array with corresponding fallback profiles
  127058. */
  127059. static FindFallbackWithProfileId(profileId: string): string[];
  127060. /**
  127061. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  127062. * The order of search:
  127063. *
  127064. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  127065. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  127066. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  127067. * 4) return the generic trigger controller if none were found
  127068. *
  127069. * @param xrInput the xrInput to which a new controller is initialized
  127070. * @param scene the scene to which the model will be added
  127071. * @param forceProfile force a certain profile for this controller
  127072. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  127073. */
  127074. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  127075. /**
  127076. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  127077. *
  127078. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  127079. *
  127080. * @param type the profile type to register
  127081. * @param constructFunction the function to be called when loading this profile
  127082. */
  127083. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  127084. /**
  127085. * Register a fallback to a specific profile.
  127086. * @param profileId the profileId that will receive the fallbacks
  127087. * @param fallbacks A list of fallback profiles
  127088. */
  127089. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  127090. /**
  127091. * Will update the list of profiles available in the repository
  127092. * @return a promise that resolves to a map of profiles available online
  127093. */
  127094. static UpdateProfilesList(): Promise<{
  127095. [profile: string]: string;
  127096. }>;
  127097. private static _LoadProfileFromRepository;
  127098. private static _LoadProfilesFromAvailableControllers;
  127099. }
  127100. }
  127101. declare module BABYLON {
  127102. /**
  127103. * Configuration options for the WebXR controller creation
  127104. */
  127105. export interface IWebXRControllerOptions {
  127106. /**
  127107. * Should the controller mesh be animated when a user interacts with it
  127108. * The pressed buttons / thumbstick and touchpad animations will be disabled
  127109. */
  127110. disableMotionControllerAnimation?: boolean;
  127111. /**
  127112. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  127113. */
  127114. doNotLoadControllerMesh?: boolean;
  127115. /**
  127116. * Force a specific controller type for this controller.
  127117. * This can be used when creating your own profile or when testing different controllers
  127118. */
  127119. forceControllerProfile?: string;
  127120. /**
  127121. * Defines a rendering group ID for meshes that will be loaded.
  127122. * This is for the default controllers only.
  127123. */
  127124. renderingGroupId?: number;
  127125. }
  127126. /**
  127127. * Represents an XR controller
  127128. */
  127129. export class WebXRInputSource {
  127130. private _scene;
  127131. /** The underlying input source for the controller */
  127132. inputSource: XRInputSource;
  127133. private _options;
  127134. private _tmpVector;
  127135. private _uniqueId;
  127136. /**
  127137. * 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
  127138. */
  127139. grip?: AbstractMesh;
  127140. /**
  127141. * If available, this is the gamepad object related to this controller.
  127142. * Using this object it is possible to get click events and trackpad changes of the
  127143. * webxr controller that is currently being used.
  127144. */
  127145. motionController?: WebXRAbstractMotionController;
  127146. /**
  127147. * Event that fires when the controller is removed/disposed.
  127148. * The object provided as event data is this controller, after associated assets were disposed.
  127149. * uniqueId is still available.
  127150. */
  127151. onDisposeObservable: Observable<WebXRInputSource>;
  127152. /**
  127153. * Will be triggered when the mesh associated with the motion controller is done loading.
  127154. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  127155. * A shortened version of controller -> motion controller -> on mesh loaded.
  127156. */
  127157. onMeshLoadedObservable: Observable<AbstractMesh>;
  127158. /**
  127159. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  127160. */
  127161. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  127162. /**
  127163. * Pointer which can be used to select objects or attach a visible laser to
  127164. */
  127165. pointer: AbstractMesh;
  127166. /**
  127167. * Creates the input source object
  127168. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  127169. * @param _scene the scene which the controller should be associated to
  127170. * @param inputSource the underlying input source for the controller
  127171. * @param _options options for this controller creation
  127172. */
  127173. constructor(_scene: Scene,
  127174. /** The underlying input source for the controller */
  127175. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127176. /**
  127177. * Get this controllers unique id
  127178. */
  127179. get uniqueId(): string;
  127180. /**
  127181. * Disposes of the object
  127182. */
  127183. dispose(): void;
  127184. /**
  127185. * Gets a world space ray coming from the pointer or grip
  127186. * @param result the resulting ray
  127187. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127188. */
  127189. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127190. /**
  127191. * Updates the controller pose based on the given XRFrame
  127192. * @param xrFrame xr frame to update the pose with
  127193. * @param referenceSpace reference space to use
  127194. */
  127195. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127196. }
  127197. }
  127198. declare module BABYLON {
  127199. /**
  127200. * The schema for initialization options of the XR Input class
  127201. */
  127202. export interface IWebXRInputOptions {
  127203. /**
  127204. * If set to true no model will be automatically loaded
  127205. */
  127206. doNotLoadControllerMeshes?: boolean;
  127207. /**
  127208. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127209. * If not found, the xr input profile data will be used.
  127210. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127211. */
  127212. forceInputProfile?: string;
  127213. /**
  127214. * Do not send a request to the controller repository to load the profile.
  127215. *
  127216. * Instead, use the controllers available in babylon itself.
  127217. */
  127218. disableOnlineControllerRepository?: boolean;
  127219. /**
  127220. * A custom URL for the controllers repository
  127221. */
  127222. customControllersRepositoryURL?: string;
  127223. /**
  127224. * Should the controller model's components not move according to the user input
  127225. */
  127226. disableControllerAnimation?: boolean;
  127227. /**
  127228. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127229. */
  127230. controllerOptions?: IWebXRControllerOptions;
  127231. }
  127232. /**
  127233. * XR input used to track XR inputs such as controllers/rays
  127234. */
  127235. export class WebXRInput implements IDisposable {
  127236. /**
  127237. * the xr session manager for this session
  127238. */
  127239. xrSessionManager: WebXRSessionManager;
  127240. /**
  127241. * the WebXR camera for this session. Mainly used for teleportation
  127242. */
  127243. xrCamera: WebXRCamera;
  127244. private readonly options;
  127245. /**
  127246. * XR controllers being tracked
  127247. */
  127248. controllers: Array<WebXRInputSource>;
  127249. private _frameObserver;
  127250. private _sessionEndedObserver;
  127251. private _sessionInitObserver;
  127252. /**
  127253. * Event when a controller has been connected/added
  127254. */
  127255. onControllerAddedObservable: Observable<WebXRInputSource>;
  127256. /**
  127257. * Event when a controller has been removed/disconnected
  127258. */
  127259. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127260. /**
  127261. * Initializes the WebXRInput
  127262. * @param xrSessionManager the xr session manager for this session
  127263. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127264. * @param options = initialization options for this xr input
  127265. */
  127266. constructor(
  127267. /**
  127268. * the xr session manager for this session
  127269. */
  127270. xrSessionManager: WebXRSessionManager,
  127271. /**
  127272. * the WebXR camera for this session. Mainly used for teleportation
  127273. */
  127274. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127275. private _onInputSourcesChange;
  127276. private _addAndRemoveControllers;
  127277. /**
  127278. * Disposes of the object
  127279. */
  127280. dispose(): void;
  127281. }
  127282. }
  127283. declare module BABYLON {
  127284. /**
  127285. * This is the base class for all WebXR features.
  127286. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127287. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127288. */
  127289. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127290. protected _xrSessionManager: WebXRSessionManager;
  127291. private _attached;
  127292. private _removeOnDetach;
  127293. /**
  127294. * Should auto-attach be disabled?
  127295. */
  127296. disableAutoAttach: boolean;
  127297. /**
  127298. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127299. */
  127300. xrNativeFeatureName: string;
  127301. /**
  127302. * Construct a new (abstract) WebXR feature
  127303. * @param _xrSessionManager the xr session manager for this feature
  127304. */
  127305. constructor(_xrSessionManager: WebXRSessionManager);
  127306. /**
  127307. * Is this feature attached
  127308. */
  127309. get attached(): boolean;
  127310. /**
  127311. * attach this feature
  127312. *
  127313. * @param force should attachment be forced (even when already attached)
  127314. * @returns true if successful, false is failed or already attached
  127315. */
  127316. attach(force?: boolean): boolean;
  127317. /**
  127318. * detach this feature.
  127319. *
  127320. * @returns true if successful, false if failed or already detached
  127321. */
  127322. detach(): boolean;
  127323. /**
  127324. * Dispose this feature and all of the resources attached
  127325. */
  127326. dispose(): void;
  127327. /**
  127328. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127329. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127330. *
  127331. * @returns whether or not the feature is compatible in this environment
  127332. */
  127333. isCompatible(): boolean;
  127334. /**
  127335. * This is used to register callbacks that will automatically be removed when detach is called.
  127336. * @param observable the observable to which the observer will be attached
  127337. * @param callback the callback to register
  127338. */
  127339. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127340. /**
  127341. * Code in this function will be executed on each xrFrame received from the browser.
  127342. * This function will not execute after the feature is detached.
  127343. * @param _xrFrame the current frame
  127344. */
  127345. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127346. }
  127347. }
  127348. declare module BABYLON {
  127349. /**
  127350. * Renders a layer on top of an existing scene
  127351. */
  127352. export class UtilityLayerRenderer implements IDisposable {
  127353. /** the original scene that will be rendered on top of */
  127354. originalScene: Scene;
  127355. private _pointerCaptures;
  127356. private _lastPointerEvents;
  127357. private static _DefaultUtilityLayer;
  127358. private static _DefaultKeepDepthUtilityLayer;
  127359. private _sharedGizmoLight;
  127360. private _renderCamera;
  127361. /**
  127362. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127363. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127364. * @returns the camera that is used when rendering the utility layer
  127365. */
  127366. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127367. /**
  127368. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127369. * @param cam the camera that should be used when rendering the utility layer
  127370. */
  127371. setRenderCamera(cam: Nullable<Camera>): void;
  127372. /**
  127373. * @hidden
  127374. * Light which used by gizmos to get light shading
  127375. */
  127376. _getSharedGizmoLight(): HemisphericLight;
  127377. /**
  127378. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127379. */
  127380. pickUtilitySceneFirst: boolean;
  127381. /**
  127382. * 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)
  127383. */
  127384. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127385. /**
  127386. * 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)
  127387. */
  127388. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127389. /**
  127390. * The scene that is rendered on top of the original scene
  127391. */
  127392. utilityLayerScene: Scene;
  127393. /**
  127394. * If the utility layer should automatically be rendered on top of existing scene
  127395. */
  127396. shouldRender: boolean;
  127397. /**
  127398. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127399. */
  127400. onlyCheckPointerDownEvents: boolean;
  127401. /**
  127402. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127403. */
  127404. processAllEvents: boolean;
  127405. /**
  127406. * Observable raised when the pointer move from the utility layer scene to the main scene
  127407. */
  127408. onPointerOutObservable: Observable<number>;
  127409. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127410. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127411. private _afterRenderObserver;
  127412. private _sceneDisposeObserver;
  127413. private _originalPointerObserver;
  127414. /**
  127415. * Instantiates a UtilityLayerRenderer
  127416. * @param originalScene the original scene that will be rendered on top of
  127417. * @param handleEvents boolean indicating if the utility layer should handle events
  127418. */
  127419. constructor(
  127420. /** the original scene that will be rendered on top of */
  127421. originalScene: Scene, handleEvents?: boolean);
  127422. private _notifyObservers;
  127423. /**
  127424. * Renders the utility layers scene on top of the original scene
  127425. */
  127426. render(): void;
  127427. /**
  127428. * Disposes of the renderer
  127429. */
  127430. dispose(): void;
  127431. private _updateCamera;
  127432. }
  127433. }
  127434. declare module BABYLON {
  127435. /**
  127436. * Options interface for the pointer selection module
  127437. */
  127438. export interface IWebXRControllerPointerSelectionOptions {
  127439. /**
  127440. * if provided, this scene will be used to render meshes.
  127441. */
  127442. customUtilityLayerScene?: Scene;
  127443. /**
  127444. * 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)
  127445. * If not disabled, the last picked point will be used to execute a pointer up event
  127446. * If disabled, pointer up event will be triggered right after the pointer down event.
  127447. * Used in screen and gaze target ray mode only
  127448. */
  127449. disablePointerUpOnTouchOut: boolean;
  127450. /**
  127451. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  127452. */
  127453. forceGazeMode: boolean;
  127454. /**
  127455. * 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
  127456. * to start a new countdown to the pointer down event.
  127457. * Defaults to 1.
  127458. */
  127459. gazeModePointerMovedFactor?: number;
  127460. /**
  127461. * Different button type to use instead of the main component
  127462. */
  127463. overrideButtonId?: string;
  127464. /**
  127465. * use this rendering group id for the meshes (optional)
  127466. */
  127467. renderingGroupId?: number;
  127468. /**
  127469. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  127470. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  127471. * 3000 means 3 seconds between pointing at something and selecting it
  127472. */
  127473. timeToSelect?: number;
  127474. /**
  127475. * Should meshes created here be added to a utility layer or the main scene
  127476. */
  127477. useUtilityLayer?: boolean;
  127478. /**
  127479. * Optional WebXR camera to be used for gaze selection
  127480. */
  127481. gazeCamera?: WebXRCamera;
  127482. /**
  127483. * the xr input to use with this pointer selection
  127484. */
  127485. xrInput: WebXRInput;
  127486. }
  127487. /**
  127488. * A module that will enable pointer selection for motion controllers of XR Input Sources
  127489. */
  127490. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  127491. private readonly _options;
  127492. private static _idCounter;
  127493. private _attachController;
  127494. private _controllers;
  127495. private _scene;
  127496. private _tmpVectorForPickCompare;
  127497. /**
  127498. * The module's name
  127499. */
  127500. static readonly Name: string;
  127501. /**
  127502. * The (Babylon) version of this module.
  127503. * This is an integer representing the implementation version.
  127504. * This number does not correspond to the WebXR specs version
  127505. */
  127506. static readonly Version: number;
  127507. /**
  127508. * Disable lighting on the laser pointer (so it will always be visible)
  127509. */
  127510. disablePointerLighting: boolean;
  127511. /**
  127512. * Disable lighting on the selection mesh (so it will always be visible)
  127513. */
  127514. disableSelectionMeshLighting: boolean;
  127515. /**
  127516. * Should the laser pointer be displayed
  127517. */
  127518. displayLaserPointer: boolean;
  127519. /**
  127520. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  127521. */
  127522. displaySelectionMesh: boolean;
  127523. /**
  127524. * This color will be set to the laser pointer when selection is triggered
  127525. */
  127526. laserPointerPickedColor: Color3;
  127527. /**
  127528. * Default color of the laser pointer
  127529. */
  127530. laserPointerDefaultColor: Color3;
  127531. /**
  127532. * default color of the selection ring
  127533. */
  127534. selectionMeshDefaultColor: Color3;
  127535. /**
  127536. * This color will be applied to the selection ring when selection is triggered
  127537. */
  127538. selectionMeshPickedColor: Color3;
  127539. /**
  127540. * Optional filter to be used for ray selection. This predicate shares behavior with
  127541. * scene.pointerMovePredicate which takes priority if it is also assigned.
  127542. */
  127543. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127544. /**
  127545. * constructs a new background remover module
  127546. * @param _xrSessionManager the session manager for this module
  127547. * @param _options read-only options to be used in this module
  127548. */
  127549. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  127550. /**
  127551. * attach this feature
  127552. * Will usually be called by the features manager
  127553. *
  127554. * @returns true if successful.
  127555. */
  127556. attach(): boolean;
  127557. /**
  127558. * detach this feature.
  127559. * Will usually be called by the features manager
  127560. *
  127561. * @returns true if successful.
  127562. */
  127563. detach(): boolean;
  127564. /**
  127565. * Will get the mesh under a specific pointer.
  127566. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  127567. * @param controllerId the controllerId to check
  127568. * @returns The mesh under pointer or null if no mesh is under the pointer
  127569. */
  127570. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  127571. /**
  127572. * Get the xr controller that correlates to the pointer id in the pointer event
  127573. *
  127574. * @param id the pointer id to search for
  127575. * @returns the controller that correlates to this id or null if not found
  127576. */
  127577. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  127578. protected _onXRFrame(_xrFrame: XRFrame): void;
  127579. private _attachGazeMode;
  127580. private _attachScreenRayMode;
  127581. private _attachTrackedPointerRayMode;
  127582. private _convertNormalToDirectionOfRay;
  127583. private _detachController;
  127584. private _generateNewMeshPair;
  127585. private _pickingMoved;
  127586. private _updatePointerDistance;
  127587. /** @hidden */
  127588. get lasterPointerDefaultColor(): Color3;
  127589. }
  127590. }
  127591. declare module BABYLON {
  127592. /**
  127593. * Button which can be used to enter a different mode of XR
  127594. */
  127595. export class WebXREnterExitUIButton {
  127596. /** button element */
  127597. element: HTMLElement;
  127598. /** XR initialization options for the button */
  127599. sessionMode: XRSessionMode;
  127600. /** Reference space type */
  127601. referenceSpaceType: XRReferenceSpaceType;
  127602. /**
  127603. * Creates a WebXREnterExitUIButton
  127604. * @param element button element
  127605. * @param sessionMode XR initialization session mode
  127606. * @param referenceSpaceType the type of reference space to be used
  127607. */
  127608. constructor(
  127609. /** button element */
  127610. element: HTMLElement,
  127611. /** XR initialization options for the button */
  127612. sessionMode: XRSessionMode,
  127613. /** Reference space type */
  127614. referenceSpaceType: XRReferenceSpaceType);
  127615. /**
  127616. * Extendable function which can be used to update the button's visuals when the state changes
  127617. * @param activeButton the current active button in the UI
  127618. */
  127619. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  127620. }
  127621. /**
  127622. * Options to create the webXR UI
  127623. */
  127624. export class WebXREnterExitUIOptions {
  127625. /**
  127626. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  127627. */
  127628. customButtons?: Array<WebXREnterExitUIButton>;
  127629. /**
  127630. * A reference space type to use when creating the default button.
  127631. * Default is local-floor
  127632. */
  127633. referenceSpaceType?: XRReferenceSpaceType;
  127634. /**
  127635. * Context to enter xr with
  127636. */
  127637. renderTarget?: Nullable<WebXRRenderTarget>;
  127638. /**
  127639. * A session mode to use when creating the default button.
  127640. * Default is immersive-vr
  127641. */
  127642. sessionMode?: XRSessionMode;
  127643. /**
  127644. * A list of optional features to init the session with
  127645. */
  127646. optionalFeatures?: string[];
  127647. /**
  127648. * A list of optional features to init the session with
  127649. */
  127650. requiredFeatures?: string[];
  127651. }
  127652. /**
  127653. * UI to allow the user to enter/exit XR mode
  127654. */
  127655. export class WebXREnterExitUI implements IDisposable {
  127656. private scene;
  127657. /** version of the options passed to this UI */
  127658. options: WebXREnterExitUIOptions;
  127659. private _activeButton;
  127660. private _buttons;
  127661. private _overlay;
  127662. /**
  127663. * Fired every time the active button is changed.
  127664. *
  127665. * When xr is entered via a button that launches xr that button will be the callback parameter
  127666. *
  127667. * When exiting xr the callback parameter will be null)
  127668. */
  127669. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  127670. /**
  127671. *
  127672. * @param scene babylon scene object to use
  127673. * @param options (read-only) version of the options passed to this UI
  127674. */
  127675. private constructor();
  127676. /**
  127677. * Creates UI to allow the user to enter/exit XR mode
  127678. * @param scene the scene to add the ui to
  127679. * @param helper the xr experience helper to enter/exit xr with
  127680. * @param options options to configure the UI
  127681. * @returns the created ui
  127682. */
  127683. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  127684. /**
  127685. * Disposes of the XR UI component
  127686. */
  127687. dispose(): void;
  127688. private _updateButtons;
  127689. }
  127690. }
  127691. declare module BABYLON {
  127692. /**
  127693. * Class containing static functions to help procedurally build meshes
  127694. */
  127695. export class LinesBuilder {
  127696. /**
  127697. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127698. * * 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
  127699. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127700. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127701. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127702. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127703. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127704. * * 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
  127705. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127708. * @param name defines the name of the new line system
  127709. * @param options defines the options used to create the line system
  127710. * @param scene defines the hosting scene
  127711. * @returns a new line system mesh
  127712. */
  127713. static CreateLineSystem(name: string, options: {
  127714. lines: Vector3[][];
  127715. updatable?: boolean;
  127716. instance?: Nullable<LinesMesh>;
  127717. colors?: Nullable<Color4[][]>;
  127718. useVertexAlpha?: boolean;
  127719. }, scene: Nullable<Scene>): LinesMesh;
  127720. /**
  127721. * Creates a line mesh
  127722. * 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
  127723. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127724. * * The parameter `points` is an array successive Vector3
  127725. * * 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
  127726. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127727. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127728. * * When updating an instance, remember that only point positions can change, not the number of points
  127729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127731. * @param name defines the name of the new line system
  127732. * @param options defines the options used to create the line system
  127733. * @param scene defines the hosting scene
  127734. * @returns a new line mesh
  127735. */
  127736. static CreateLines(name: string, options: {
  127737. points: Vector3[];
  127738. updatable?: boolean;
  127739. instance?: Nullable<LinesMesh>;
  127740. colors?: Color4[];
  127741. useVertexAlpha?: boolean;
  127742. }, scene?: Nullable<Scene>): LinesMesh;
  127743. /**
  127744. * Creates a dashed line mesh
  127745. * * 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
  127746. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127747. * * The parameter `points` is an array successive Vector3
  127748. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127749. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127750. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127751. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  127752. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127753. * * When updating an instance, remember that only point positions can change, not the number of points
  127754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127755. * @param name defines the name of the mesh
  127756. * @param options defines the options used to create the mesh
  127757. * @param scene defines the hosting scene
  127758. * @returns the dashed line mesh
  127759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127760. */
  127761. static CreateDashedLines(name: string, options: {
  127762. points: Vector3[];
  127763. dashSize?: number;
  127764. gapSize?: number;
  127765. dashNb?: number;
  127766. updatable?: boolean;
  127767. instance?: LinesMesh;
  127768. useVertexAlpha?: boolean;
  127769. }, scene?: Nullable<Scene>): LinesMesh;
  127770. }
  127771. }
  127772. declare module BABYLON {
  127773. /**
  127774. * Construction options for a timer
  127775. */
  127776. export interface ITimerOptions<T> {
  127777. /**
  127778. * Time-to-end
  127779. */
  127780. timeout: number;
  127781. /**
  127782. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  127783. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  127784. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  127785. */
  127786. contextObservable: Observable<T>;
  127787. /**
  127788. * Optional parameters when adding an observer to the observable
  127789. */
  127790. observableParameters?: {
  127791. mask?: number;
  127792. insertFirst?: boolean;
  127793. scope?: any;
  127794. };
  127795. /**
  127796. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  127797. */
  127798. breakCondition?: (data?: ITimerData<T>) => boolean;
  127799. /**
  127800. * Will be triggered when the time condition has met
  127801. */
  127802. onEnded?: (data: ITimerData<any>) => void;
  127803. /**
  127804. * Will be triggered when the break condition has met (prematurely ended)
  127805. */
  127806. onAborted?: (data: ITimerData<any>) => void;
  127807. /**
  127808. * Optional function to execute on each tick (or count)
  127809. */
  127810. onTick?: (data: ITimerData<any>) => void;
  127811. }
  127812. /**
  127813. * An interface defining the data sent by the timer
  127814. */
  127815. export interface ITimerData<T> {
  127816. /**
  127817. * When did it start
  127818. */
  127819. startTime: number;
  127820. /**
  127821. * Time now
  127822. */
  127823. currentTime: number;
  127824. /**
  127825. * Time passed since started
  127826. */
  127827. deltaTime: number;
  127828. /**
  127829. * How much is completed, in [0.0...1.0].
  127830. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  127831. */
  127832. completeRate: number;
  127833. /**
  127834. * What the registered observable sent in the last count
  127835. */
  127836. payload: T;
  127837. }
  127838. /**
  127839. * The current state of the timer
  127840. */
  127841. export enum TimerState {
  127842. /**
  127843. * Timer initialized, not yet started
  127844. */
  127845. INIT = 0,
  127846. /**
  127847. * Timer started and counting
  127848. */
  127849. STARTED = 1,
  127850. /**
  127851. * Timer ended (whether aborted or time reached)
  127852. */
  127853. ENDED = 2
  127854. }
  127855. /**
  127856. * A simple version of the timer. Will take options and start the timer immediately after calling it
  127857. *
  127858. * @param options options with which to initialize this timer
  127859. */
  127860. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  127861. /**
  127862. * An advanced implementation of a timer class
  127863. */
  127864. export class AdvancedTimer<T = any> implements IDisposable {
  127865. /**
  127866. * Will notify each time the timer calculates the remaining time
  127867. */
  127868. onEachCountObservable: Observable<ITimerData<T>>;
  127869. /**
  127870. * Will trigger when the timer was aborted due to the break condition
  127871. */
  127872. onTimerAbortedObservable: Observable<ITimerData<T>>;
  127873. /**
  127874. * Will trigger when the timer ended successfully
  127875. */
  127876. onTimerEndedObservable: Observable<ITimerData<T>>;
  127877. /**
  127878. * Will trigger when the timer state has changed
  127879. */
  127880. onStateChangedObservable: Observable<TimerState>;
  127881. private _observer;
  127882. private _contextObservable;
  127883. private _observableParameters;
  127884. private _startTime;
  127885. private _timer;
  127886. private _state;
  127887. private _breakCondition;
  127888. private _timeToEnd;
  127889. private _breakOnNextTick;
  127890. /**
  127891. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  127892. * @param options construction options for this advanced timer
  127893. */
  127894. constructor(options: ITimerOptions<T>);
  127895. /**
  127896. * set a breaking condition for this timer. Default is to never break during count
  127897. * @param predicate the new break condition. Returns true to break, false otherwise
  127898. */
  127899. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  127900. /**
  127901. * Reset ALL associated observables in this advanced timer
  127902. */
  127903. clearObservables(): void;
  127904. /**
  127905. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  127906. *
  127907. * @param timeToEnd how much time to measure until timer ended
  127908. */
  127909. start(timeToEnd?: number): void;
  127910. /**
  127911. * Will force a stop on the next tick.
  127912. */
  127913. stop(): void;
  127914. /**
  127915. * Dispose this timer, clearing all resources
  127916. */
  127917. dispose(): void;
  127918. private _setState;
  127919. private _tick;
  127920. private _stop;
  127921. }
  127922. }
  127923. declare module BABYLON {
  127924. /**
  127925. * The options container for the teleportation module
  127926. */
  127927. export interface IWebXRTeleportationOptions {
  127928. /**
  127929. * if provided, this scene will be used to render meshes.
  127930. */
  127931. customUtilityLayerScene?: Scene;
  127932. /**
  127933. * Values to configure the default target mesh
  127934. */
  127935. defaultTargetMeshOptions?: {
  127936. /**
  127937. * Fill color of the teleportation area
  127938. */
  127939. teleportationFillColor?: string;
  127940. /**
  127941. * Border color for the teleportation area
  127942. */
  127943. teleportationBorderColor?: string;
  127944. /**
  127945. * Disable the mesh's animation sequence
  127946. */
  127947. disableAnimation?: boolean;
  127948. /**
  127949. * Disable lighting on the material or the ring and arrow
  127950. */
  127951. disableLighting?: boolean;
  127952. /**
  127953. * Override the default material of the torus and arrow
  127954. */
  127955. torusArrowMaterial?: Material;
  127956. };
  127957. /**
  127958. * A list of meshes to use as floor meshes.
  127959. * Meshes can be added and removed after initializing the feature using the
  127960. * addFloorMesh and removeFloorMesh functions
  127961. * If empty, rotation will still work
  127962. */
  127963. floorMeshes?: AbstractMesh[];
  127964. /**
  127965. * use this rendering group id for the meshes (optional)
  127966. */
  127967. renderingGroupId?: number;
  127968. /**
  127969. * Should teleportation move only to snap points
  127970. */
  127971. snapPointsOnly?: boolean;
  127972. /**
  127973. * An array of points to which the teleportation will snap to.
  127974. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  127975. */
  127976. snapPositions?: Vector3[];
  127977. /**
  127978. * How close should the teleportation ray be in order to snap to position.
  127979. * Default to 0.8 units (meters)
  127980. */
  127981. snapToPositionRadius?: number;
  127982. /**
  127983. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  127984. * If you want to support rotation, make sure your mesh has a direction indicator.
  127985. *
  127986. * When left untouched, the default mesh will be initialized.
  127987. */
  127988. teleportationTargetMesh?: AbstractMesh;
  127989. /**
  127990. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  127991. */
  127992. timeToTeleport?: number;
  127993. /**
  127994. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  127995. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  127996. */
  127997. useMainComponentOnly?: boolean;
  127998. /**
  127999. * Should meshes created here be added to a utility layer or the main scene
  128000. */
  128001. useUtilityLayer?: boolean;
  128002. /**
  128003. * Babylon XR Input class for controller
  128004. */
  128005. xrInput: WebXRInput;
  128006. }
  128007. /**
  128008. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128009. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128010. * the input of the attached controllers.
  128011. */
  128012. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128013. private _options;
  128014. private _controllers;
  128015. private _currentTeleportationControllerId;
  128016. private _floorMeshes;
  128017. private _quadraticBezierCurve;
  128018. private _selectionFeature;
  128019. private _snapToPositions;
  128020. private _snappedToPoint;
  128021. private _teleportationRingMaterial?;
  128022. private _tmpRay;
  128023. private _tmpVector;
  128024. /**
  128025. * The module's name
  128026. */
  128027. static readonly Name: string;
  128028. /**
  128029. * The (Babylon) version of this module.
  128030. * This is an integer representing the implementation version.
  128031. * This number does not correspond to the webxr specs version
  128032. */
  128033. static readonly Version: number;
  128034. /**
  128035. * Is movement backwards enabled
  128036. */
  128037. backwardsMovementEnabled: boolean;
  128038. /**
  128039. * Distance to travel when moving backwards
  128040. */
  128041. backwardsTeleportationDistance: number;
  128042. /**
  128043. * The distance from the user to the inspection point in the direction of the controller
  128044. * A higher number will allow the user to move further
  128045. * defaults to 5 (meters, in xr units)
  128046. */
  128047. parabolicCheckRadius: number;
  128048. /**
  128049. * Should the module support parabolic ray on top of direct ray
  128050. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  128051. * Very helpful when moving between floors / different heights
  128052. */
  128053. parabolicRayEnabled: boolean;
  128054. /**
  128055. * How much rotation should be applied when rotating right and left
  128056. */
  128057. rotationAngle: number;
  128058. /**
  128059. * Is rotation enabled when moving forward?
  128060. * Disabling this feature will prevent the user from deciding the direction when teleporting
  128061. */
  128062. rotationEnabled: boolean;
  128063. /**
  128064. * constructs a new anchor system
  128065. * @param _xrSessionManager an instance of WebXRSessionManager
  128066. * @param _options configuration object for this feature
  128067. */
  128068. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  128069. /**
  128070. * Get the snapPointsOnly flag
  128071. */
  128072. get snapPointsOnly(): boolean;
  128073. /**
  128074. * Sets the snapPointsOnly flag
  128075. * @param snapToPoints should teleportation be exclusively to snap points
  128076. */
  128077. set snapPointsOnly(snapToPoints: boolean);
  128078. /**
  128079. * Add a new mesh to the floor meshes array
  128080. * @param mesh the mesh to use as floor mesh
  128081. */
  128082. addFloorMesh(mesh: AbstractMesh): void;
  128083. /**
  128084. * Add a new snap-to point to fix teleportation to this position
  128085. * @param newSnapPoint The new Snap-To point
  128086. */
  128087. addSnapPoint(newSnapPoint: Vector3): void;
  128088. attach(): boolean;
  128089. detach(): boolean;
  128090. dispose(): void;
  128091. /**
  128092. * Remove a mesh from the floor meshes array
  128093. * @param mesh the mesh to remove
  128094. */
  128095. removeFloorMesh(mesh: AbstractMesh): void;
  128096. /**
  128097. * Remove a mesh from the floor meshes array using its name
  128098. * @param name the mesh name to remove
  128099. */
  128100. removeFloorMeshByName(name: string): void;
  128101. /**
  128102. * 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
  128103. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  128104. * @returns was the point found and removed or not
  128105. */
  128106. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  128107. /**
  128108. * This function sets a selection feature that will be disabled when
  128109. * the forward ray is shown and will be reattached when hidden.
  128110. * This is used to remove the selection rays when moving.
  128111. * @param selectionFeature the feature to disable when forward movement is enabled
  128112. */
  128113. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  128114. protected _onXRFrame(_xrFrame: XRFrame): void;
  128115. private _attachController;
  128116. private _createDefaultTargetMesh;
  128117. private _detachController;
  128118. private _findClosestSnapPointWithRadius;
  128119. private _setTargetMeshPosition;
  128120. private _setTargetMeshVisibility;
  128121. private _showParabolicPath;
  128122. private _teleportForward;
  128123. }
  128124. }
  128125. declare module BABYLON {
  128126. /**
  128127. * Options for the default xr helper
  128128. */
  128129. export class WebXRDefaultExperienceOptions {
  128130. /**
  128131. * Enable or disable default UI to enter XR
  128132. */
  128133. disableDefaultUI?: boolean;
  128134. /**
  128135. * Should teleportation not initialize. defaults to false.
  128136. */
  128137. disableTeleportation?: boolean;
  128138. /**
  128139. * Floor meshes that will be used for teleport
  128140. */
  128141. floorMeshes?: Array<AbstractMesh>;
  128142. /**
  128143. * If set to true, the first frame will not be used to reset position
  128144. * The first frame is mainly used when copying transformation from the old camera
  128145. * Mainly used in AR
  128146. */
  128147. ignoreNativeCameraTransformation?: boolean;
  128148. /**
  128149. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  128150. */
  128151. inputOptions?: IWebXRInputOptions;
  128152. /**
  128153. * optional configuration for the output canvas
  128154. */
  128155. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  128156. /**
  128157. * optional UI options. This can be used among other to change session mode and reference space type
  128158. */
  128159. uiOptions?: WebXREnterExitUIOptions;
  128160. /**
  128161. * When loading teleportation and pointer select, use stable versions instead of latest.
  128162. */
  128163. useStablePlugins?: boolean;
  128164. /**
  128165. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  128166. */
  128167. renderingGroupId?: number;
  128168. /**
  128169. * A list of optional features to init the session with
  128170. * If set to true, all features we support will be added
  128171. */
  128172. optionalFeatures?: boolean | string[];
  128173. }
  128174. /**
  128175. * Default experience which provides a similar setup to the previous webVRExperience
  128176. */
  128177. export class WebXRDefaultExperience {
  128178. /**
  128179. * Base experience
  128180. */
  128181. baseExperience: WebXRExperienceHelper;
  128182. /**
  128183. * Enables ui for entering/exiting xr
  128184. */
  128185. enterExitUI: WebXREnterExitUI;
  128186. /**
  128187. * Input experience extension
  128188. */
  128189. input: WebXRInput;
  128190. /**
  128191. * Enables laser pointer and selection
  128192. */
  128193. pointerSelection: WebXRControllerPointerSelection;
  128194. /**
  128195. * Default target xr should render to
  128196. */
  128197. renderTarget: WebXRRenderTarget;
  128198. /**
  128199. * Enables teleportation
  128200. */
  128201. teleportation: WebXRMotionControllerTeleportation;
  128202. private constructor();
  128203. /**
  128204. * Creates the default xr experience
  128205. * @param scene scene
  128206. * @param options options for basic configuration
  128207. * @returns resulting WebXRDefaultExperience
  128208. */
  128209. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128210. /**
  128211. * DIsposes of the experience helper
  128212. */
  128213. dispose(): void;
  128214. }
  128215. }
  128216. declare module BABYLON {
  128217. /**
  128218. * Options to modify the vr teleportation behavior.
  128219. */
  128220. export interface VRTeleportationOptions {
  128221. /**
  128222. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128223. */
  128224. floorMeshName?: string;
  128225. /**
  128226. * A list of meshes to be used as the teleportation floor. (default: empty)
  128227. */
  128228. floorMeshes?: Mesh[];
  128229. /**
  128230. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128231. */
  128232. teleportationMode?: number;
  128233. /**
  128234. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128235. */
  128236. teleportationTime?: number;
  128237. /**
  128238. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128239. */
  128240. teleportationSpeed?: number;
  128241. /**
  128242. * The easing function used in the animation or null for Linear. (default CircleEase)
  128243. */
  128244. easingFunction?: EasingFunction;
  128245. }
  128246. /**
  128247. * Options to modify the vr experience helper's behavior.
  128248. */
  128249. export interface VRExperienceHelperOptions extends WebVROptions {
  128250. /**
  128251. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128252. */
  128253. createDeviceOrientationCamera?: boolean;
  128254. /**
  128255. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128256. */
  128257. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128258. /**
  128259. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128260. */
  128261. laserToggle?: boolean;
  128262. /**
  128263. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128264. */
  128265. floorMeshes?: Mesh[];
  128266. /**
  128267. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128268. */
  128269. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128270. /**
  128271. * Defines if WebXR should be used instead of WebVR (if available)
  128272. */
  128273. useXR?: boolean;
  128274. }
  128275. /**
  128276. * Event containing information after VR has been entered
  128277. */
  128278. export class OnAfterEnteringVRObservableEvent {
  128279. /**
  128280. * If entering vr was successful
  128281. */
  128282. success: boolean;
  128283. }
  128284. /**
  128285. * Helps to quickly add VR support to an existing scene.
  128286. * See https://doc.babylonjs.com/how_to/webvr_helper
  128287. */
  128288. export class VRExperienceHelper {
  128289. /** Options to modify the vr experience helper's behavior. */
  128290. webVROptions: VRExperienceHelperOptions;
  128291. private _scene;
  128292. private _position;
  128293. private _btnVR;
  128294. private _btnVRDisplayed;
  128295. private _webVRsupported;
  128296. private _webVRready;
  128297. private _webVRrequesting;
  128298. private _webVRpresenting;
  128299. private _hasEnteredVR;
  128300. private _fullscreenVRpresenting;
  128301. private _inputElement;
  128302. private _webVRCamera;
  128303. private _vrDeviceOrientationCamera;
  128304. private _deviceOrientationCamera;
  128305. private _existingCamera;
  128306. private _onKeyDown;
  128307. private _onVrDisplayPresentChange;
  128308. private _onVRDisplayChanged;
  128309. private _onVRRequestPresentStart;
  128310. private _onVRRequestPresentComplete;
  128311. /**
  128312. * 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)
  128313. */
  128314. enableGazeEvenWhenNoPointerLock: boolean;
  128315. /**
  128316. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128317. */
  128318. exitVROnDoubleTap: boolean;
  128319. /**
  128320. * Observable raised right before entering VR.
  128321. */
  128322. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128323. /**
  128324. * Observable raised when entering VR has completed.
  128325. */
  128326. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128327. /**
  128328. * Observable raised when exiting VR.
  128329. */
  128330. onExitingVRObservable: Observable<VRExperienceHelper>;
  128331. /**
  128332. * Observable raised when controller mesh is loaded.
  128333. */
  128334. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128335. /** Return this.onEnteringVRObservable
  128336. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128337. */
  128338. get onEnteringVR(): Observable<VRExperienceHelper>;
  128339. /** Return this.onExitingVRObservable
  128340. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128341. */
  128342. get onExitingVR(): Observable<VRExperienceHelper>;
  128343. /** Return this.onControllerMeshLoadedObservable
  128344. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128345. */
  128346. get onControllerMeshLoaded(): Observable<WebVRController>;
  128347. private _rayLength;
  128348. private _useCustomVRButton;
  128349. private _teleportationRequested;
  128350. private _teleportActive;
  128351. private _floorMeshName;
  128352. private _floorMeshesCollection;
  128353. private _teleportationMode;
  128354. private _teleportationTime;
  128355. private _teleportationSpeed;
  128356. private _teleportationEasing;
  128357. private _rotationAllowed;
  128358. private _teleportBackwardsVector;
  128359. private _teleportationTarget;
  128360. private _isDefaultTeleportationTarget;
  128361. private _postProcessMove;
  128362. private _teleportationFillColor;
  128363. private _teleportationBorderColor;
  128364. private _rotationAngle;
  128365. private _haloCenter;
  128366. private _cameraGazer;
  128367. private _padSensibilityUp;
  128368. private _padSensibilityDown;
  128369. private _leftController;
  128370. private _rightController;
  128371. private _gazeColor;
  128372. private _laserColor;
  128373. private _pickedLaserColor;
  128374. private _pickedGazeColor;
  128375. /**
  128376. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128377. */
  128378. onNewMeshSelected: Observable<AbstractMesh>;
  128379. /**
  128380. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128381. * This observable will provide the mesh and the controller used to select the mesh
  128382. */
  128383. onMeshSelectedWithController: Observable<{
  128384. mesh: AbstractMesh;
  128385. controller: WebVRController;
  128386. }>;
  128387. /**
  128388. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128389. */
  128390. onNewMeshPicked: Observable<PickingInfo>;
  128391. private _circleEase;
  128392. /**
  128393. * Observable raised before camera teleportation
  128394. */
  128395. onBeforeCameraTeleport: Observable<Vector3>;
  128396. /**
  128397. * Observable raised after camera teleportation
  128398. */
  128399. onAfterCameraTeleport: Observable<Vector3>;
  128400. /**
  128401. * Observable raised when current selected mesh gets unselected
  128402. */
  128403. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128404. private _raySelectionPredicate;
  128405. /**
  128406. * To be optionaly changed by user to define custom ray selection
  128407. */
  128408. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128409. /**
  128410. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128411. */
  128412. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128413. /**
  128414. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128415. */
  128416. teleportationEnabled: boolean;
  128417. private _defaultHeight;
  128418. private _teleportationInitialized;
  128419. private _interactionsEnabled;
  128420. private _interactionsRequested;
  128421. private _displayGaze;
  128422. private _displayLaserPointer;
  128423. /**
  128424. * The mesh used to display where the user is going to teleport.
  128425. */
  128426. get teleportationTarget(): Mesh;
  128427. /**
  128428. * Sets the mesh to be used to display where the user is going to teleport.
  128429. */
  128430. set teleportationTarget(value: Mesh);
  128431. /**
  128432. * 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
  128433. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  128434. * See https://doc.babylonjs.com/resources/baking_transformations
  128435. */
  128436. get gazeTrackerMesh(): Mesh;
  128437. set gazeTrackerMesh(value: Mesh);
  128438. /**
  128439. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  128440. */
  128441. updateGazeTrackerScale: boolean;
  128442. /**
  128443. * If the gaze trackers color should be updated when selecting meshes
  128444. */
  128445. updateGazeTrackerColor: boolean;
  128446. /**
  128447. * If the controller laser color should be updated when selecting meshes
  128448. */
  128449. updateControllerLaserColor: boolean;
  128450. /**
  128451. * The gaze tracking mesh corresponding to the left controller
  128452. */
  128453. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  128454. /**
  128455. * The gaze tracking mesh corresponding to the right controller
  128456. */
  128457. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  128458. /**
  128459. * If the ray of the gaze should be displayed.
  128460. */
  128461. get displayGaze(): boolean;
  128462. /**
  128463. * Sets if the ray of the gaze should be displayed.
  128464. */
  128465. set displayGaze(value: boolean);
  128466. /**
  128467. * If the ray of the LaserPointer should be displayed.
  128468. */
  128469. get displayLaserPointer(): boolean;
  128470. /**
  128471. * Sets if the ray of the LaserPointer should be displayed.
  128472. */
  128473. set displayLaserPointer(value: boolean);
  128474. /**
  128475. * The deviceOrientationCamera used as the camera when not in VR.
  128476. */
  128477. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  128478. /**
  128479. * Based on the current WebVR support, returns the current VR camera used.
  128480. */
  128481. get currentVRCamera(): Nullable<Camera>;
  128482. /**
  128483. * The webVRCamera which is used when in VR.
  128484. */
  128485. get webVRCamera(): WebVRFreeCamera;
  128486. /**
  128487. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  128488. */
  128489. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  128490. /**
  128491. * The html button that is used to trigger entering into VR.
  128492. */
  128493. get vrButton(): Nullable<HTMLButtonElement>;
  128494. private get _teleportationRequestInitiated();
  128495. /**
  128496. * Defines whether or not Pointer lock should be requested when switching to
  128497. * full screen.
  128498. */
  128499. requestPointerLockOnFullScreen: boolean;
  128500. /**
  128501. * If asking to force XR, this will be populated with the default xr experience
  128502. */
  128503. xr: WebXRDefaultExperience;
  128504. /**
  128505. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  128506. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  128507. */
  128508. xrTestDone: boolean;
  128509. /**
  128510. * Instantiates a VRExperienceHelper.
  128511. * Helps to quickly add VR support to an existing scene.
  128512. * @param scene The scene the VRExperienceHelper belongs to.
  128513. * @param webVROptions Options to modify the vr experience helper's behavior.
  128514. */
  128515. constructor(scene: Scene,
  128516. /** Options to modify the vr experience helper's behavior. */
  128517. webVROptions?: VRExperienceHelperOptions);
  128518. private completeVRInit;
  128519. private _onDefaultMeshLoaded;
  128520. private _onResize;
  128521. private _onFullscreenChange;
  128522. /**
  128523. * Gets a value indicating if we are currently in VR mode.
  128524. */
  128525. get isInVRMode(): boolean;
  128526. private onVrDisplayPresentChange;
  128527. private onVRDisplayChanged;
  128528. private moveButtonToBottomRight;
  128529. private displayVRButton;
  128530. private updateButtonVisibility;
  128531. private _cachedAngularSensibility;
  128532. /**
  128533. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  128534. * Otherwise, will use the fullscreen API.
  128535. */
  128536. enterVR(): void;
  128537. /**
  128538. * Attempt to exit VR, or fullscreen.
  128539. */
  128540. exitVR(): void;
  128541. /**
  128542. * The position of the vr experience helper.
  128543. */
  128544. get position(): Vector3;
  128545. /**
  128546. * Sets the position of the vr experience helper.
  128547. */
  128548. set position(value: Vector3);
  128549. /**
  128550. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  128551. */
  128552. enableInteractions(): void;
  128553. private get _noControllerIsActive();
  128554. private beforeRender;
  128555. private _isTeleportationFloor;
  128556. /**
  128557. * Adds a floor mesh to be used for teleportation.
  128558. * @param floorMesh the mesh to be used for teleportation.
  128559. */
  128560. addFloorMesh(floorMesh: Mesh): void;
  128561. /**
  128562. * Removes a floor mesh from being used for teleportation.
  128563. * @param floorMesh the mesh to be removed.
  128564. */
  128565. removeFloorMesh(floorMesh: Mesh): void;
  128566. /**
  128567. * Enables interactions and teleportation using the VR controllers and gaze.
  128568. * @param vrTeleportationOptions options to modify teleportation behavior.
  128569. */
  128570. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  128571. private _onNewGamepadConnected;
  128572. private _tryEnableInteractionOnController;
  128573. private _onNewGamepadDisconnected;
  128574. private _enableInteractionOnController;
  128575. private _checkTeleportWithRay;
  128576. private _checkRotate;
  128577. private _checkTeleportBackwards;
  128578. private _enableTeleportationOnController;
  128579. private _createTeleportationCircles;
  128580. private _displayTeleportationTarget;
  128581. private _hideTeleportationTarget;
  128582. private _rotateCamera;
  128583. private _moveTeleportationSelectorTo;
  128584. private _workingVector;
  128585. private _workingQuaternion;
  128586. private _workingMatrix;
  128587. /**
  128588. * Time Constant Teleportation Mode
  128589. */
  128590. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  128591. /**
  128592. * Speed Constant Teleportation Mode
  128593. */
  128594. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  128595. /**
  128596. * Teleports the users feet to the desired location
  128597. * @param location The location where the user's feet should be placed
  128598. */
  128599. teleportCamera(location: Vector3): void;
  128600. private _convertNormalToDirectionOfRay;
  128601. private _castRayAndSelectObject;
  128602. private _notifySelectedMeshUnselected;
  128603. /**
  128604. * Permanently set new colors for the laser pointer
  128605. * @param color the new laser color
  128606. * @param pickedColor the new laser color when picked mesh detected
  128607. */
  128608. setLaserColor(color: Color3, pickedColor?: Color3): void;
  128609. /**
  128610. * Set lighting enabled / disabled on the laser pointer of both controllers
  128611. * @param enabled should the lighting be enabled on the laser pointer
  128612. */
  128613. setLaserLightingState(enabled?: boolean): void;
  128614. /**
  128615. * Permanently set new colors for the gaze pointer
  128616. * @param color the new gaze color
  128617. * @param pickedColor the new gaze color when picked mesh detected
  128618. */
  128619. setGazeColor(color: Color3, pickedColor?: Color3): void;
  128620. /**
  128621. * Sets the color of the laser ray from the vr controllers.
  128622. * @param color new color for the ray.
  128623. */
  128624. changeLaserColor(color: Color3): void;
  128625. /**
  128626. * Sets the color of the ray from the vr headsets gaze.
  128627. * @param color new color for the ray.
  128628. */
  128629. changeGazeColor(color: Color3): void;
  128630. /**
  128631. * Exits VR and disposes of the vr experience helper
  128632. */
  128633. dispose(): void;
  128634. /**
  128635. * Gets the name of the VRExperienceHelper class
  128636. * @returns "VRExperienceHelper"
  128637. */
  128638. getClassName(): string;
  128639. }
  128640. }
  128641. declare module BABYLON {
  128642. /**
  128643. * Contains an array of blocks representing the octree
  128644. */
  128645. export interface IOctreeContainer<T> {
  128646. /**
  128647. * Blocks within the octree
  128648. */
  128649. blocks: Array<OctreeBlock<T>>;
  128650. }
  128651. /**
  128652. * Class used to store a cell in an octree
  128653. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128654. */
  128655. export class OctreeBlock<T> {
  128656. /**
  128657. * Gets the content of the current block
  128658. */
  128659. entries: T[];
  128660. /**
  128661. * Gets the list of block children
  128662. */
  128663. blocks: Array<OctreeBlock<T>>;
  128664. private _depth;
  128665. private _maxDepth;
  128666. private _capacity;
  128667. private _minPoint;
  128668. private _maxPoint;
  128669. private _boundingVectors;
  128670. private _creationFunc;
  128671. /**
  128672. * Creates a new block
  128673. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  128674. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  128675. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128676. * @param depth defines the current depth of this block in the octree
  128677. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  128678. * @param creationFunc defines a callback to call when an element is added to the block
  128679. */
  128680. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  128681. /**
  128682. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128683. */
  128684. get capacity(): number;
  128685. /**
  128686. * Gets the minimum vector (in world space) of the block's bounding box
  128687. */
  128688. get minPoint(): Vector3;
  128689. /**
  128690. * Gets the maximum vector (in world space) of the block's bounding box
  128691. */
  128692. get maxPoint(): Vector3;
  128693. /**
  128694. * Add a new element to this block
  128695. * @param entry defines the element to add
  128696. */
  128697. addEntry(entry: T): void;
  128698. /**
  128699. * Remove an element from this block
  128700. * @param entry defines the element to remove
  128701. */
  128702. removeEntry(entry: T): void;
  128703. /**
  128704. * Add an array of elements to this block
  128705. * @param entries defines the array of elements to add
  128706. */
  128707. addEntries(entries: T[]): void;
  128708. /**
  128709. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  128710. * @param frustumPlanes defines the frustum planes to test
  128711. * @param selection defines the array to store current content if selection is positive
  128712. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128713. */
  128714. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128715. /**
  128716. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  128717. * @param sphereCenter defines the bounding sphere center
  128718. * @param sphereRadius defines the bounding sphere radius
  128719. * @param selection defines the array to store current content if selection is positive
  128720. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128721. */
  128722. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128723. /**
  128724. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  128725. * @param ray defines the ray to test with
  128726. * @param selection defines the array to store current content if selection is positive
  128727. */
  128728. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  128729. /**
  128730. * Subdivide the content into child blocks (this block will then be empty)
  128731. */
  128732. createInnerBlocks(): void;
  128733. /**
  128734. * @hidden
  128735. */
  128736. 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;
  128737. }
  128738. }
  128739. declare module BABYLON {
  128740. /**
  128741. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  128742. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128743. */
  128744. export class Octree<T> {
  128745. /** 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.) */
  128746. maxDepth: number;
  128747. /**
  128748. * Blocks within the octree containing objects
  128749. */
  128750. blocks: Array<OctreeBlock<T>>;
  128751. /**
  128752. * Content stored in the octree
  128753. */
  128754. dynamicContent: T[];
  128755. private _maxBlockCapacity;
  128756. private _selectionContent;
  128757. private _creationFunc;
  128758. /**
  128759. * Creates a octree
  128760. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128761. * @param creationFunc function to be used to instatiate the octree
  128762. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  128763. * @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.)
  128764. */
  128765. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  128766. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  128767. maxDepth?: number);
  128768. /**
  128769. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  128770. * @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);
  128771. * @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);
  128772. * @param entries meshes to be added to the octree blocks
  128773. */
  128774. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  128775. /**
  128776. * Adds a mesh to the octree
  128777. * @param entry Mesh to add to the octree
  128778. */
  128779. addMesh(entry: T): void;
  128780. /**
  128781. * Remove an element from the octree
  128782. * @param entry defines the element to remove
  128783. */
  128784. removeMesh(entry: T): void;
  128785. /**
  128786. * Selects an array of meshes within the frustum
  128787. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  128788. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  128789. * @returns array of meshes within the frustum
  128790. */
  128791. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  128792. /**
  128793. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  128794. * @param sphereCenter defines the bounding sphere center
  128795. * @param sphereRadius defines the bounding sphere radius
  128796. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128797. * @returns an array of objects that intersect the sphere
  128798. */
  128799. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  128800. /**
  128801. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  128802. * @param ray defines the ray to test with
  128803. * @returns array of intersected objects
  128804. */
  128805. intersectsRay(ray: Ray): SmartArray<T>;
  128806. /**
  128807. * Adds a mesh into the octree block if it intersects the block
  128808. */
  128809. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  128810. /**
  128811. * Adds a submesh into the octree block if it intersects the block
  128812. */
  128813. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  128814. }
  128815. }
  128816. declare module BABYLON {
  128817. interface Scene {
  128818. /**
  128819. * @hidden
  128820. * Backing Filed
  128821. */
  128822. _selectionOctree: Octree<AbstractMesh>;
  128823. /**
  128824. * Gets the octree used to boost mesh selection (picking)
  128825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128826. */
  128827. selectionOctree: Octree<AbstractMesh>;
  128828. /**
  128829. * Creates or updates the octree used to boost selection (picking)
  128830. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128831. * @param maxCapacity defines the maximum capacity per leaf
  128832. * @param maxDepth defines the maximum depth of the octree
  128833. * @returns an octree of AbstractMesh
  128834. */
  128835. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  128836. }
  128837. interface AbstractMesh {
  128838. /**
  128839. * @hidden
  128840. * Backing Field
  128841. */
  128842. _submeshesOctree: Octree<SubMesh>;
  128843. /**
  128844. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  128845. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  128846. * @param maxCapacity defines the maximum size of each block (64 by default)
  128847. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  128848. * @returns the new octree
  128849. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  128850. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128851. */
  128852. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  128853. }
  128854. /**
  128855. * Defines the octree scene component responsible to manage any octrees
  128856. * in a given scene.
  128857. */
  128858. export class OctreeSceneComponent {
  128859. /**
  128860. * The component name help to identify the component in the list of scene components.
  128861. */
  128862. readonly name: string;
  128863. /**
  128864. * The scene the component belongs to.
  128865. */
  128866. scene: Scene;
  128867. /**
  128868. * Indicates if the meshes have been checked to make sure they are isEnabled()
  128869. */
  128870. readonly checksIsEnabled: boolean;
  128871. /**
  128872. * Creates a new instance of the component for the given scene
  128873. * @param scene Defines the scene to register the component in
  128874. */
  128875. constructor(scene: Scene);
  128876. /**
  128877. * Registers the component in a given scene
  128878. */
  128879. register(): void;
  128880. /**
  128881. * Return the list of active meshes
  128882. * @returns the list of active meshes
  128883. */
  128884. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  128885. /**
  128886. * Return the list of active sub meshes
  128887. * @param mesh The mesh to get the candidates sub meshes from
  128888. * @returns the list of active sub meshes
  128889. */
  128890. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  128891. private _tempRay;
  128892. /**
  128893. * Return the list of sub meshes intersecting with a given local ray
  128894. * @param mesh defines the mesh to find the submesh for
  128895. * @param localRay defines the ray in local space
  128896. * @returns the list of intersecting sub meshes
  128897. */
  128898. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  128899. /**
  128900. * Return the list of sub meshes colliding with a collider
  128901. * @param mesh defines the mesh to find the submesh for
  128902. * @param collider defines the collider to evaluate the collision against
  128903. * @returns the list of colliding sub meshes
  128904. */
  128905. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  128906. /**
  128907. * Rebuilds the elements related to this component in case of
  128908. * context lost for instance.
  128909. */
  128910. rebuild(): void;
  128911. /**
  128912. * Disposes the component and the associated ressources.
  128913. */
  128914. dispose(): void;
  128915. }
  128916. }
  128917. declare module BABYLON {
  128918. /**
  128919. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  128920. */
  128921. export class Gizmo implements IDisposable {
  128922. /** The utility layer the gizmo will be added to */
  128923. gizmoLayer: UtilityLayerRenderer;
  128924. /**
  128925. * The root mesh of the gizmo
  128926. */
  128927. _rootMesh: Mesh;
  128928. private _attachedMesh;
  128929. private _attachedNode;
  128930. /**
  128931. * Ratio for the scale of the gizmo (Default: 1)
  128932. */
  128933. scaleRatio: number;
  128934. /**
  128935. * If a custom mesh has been set (Default: false)
  128936. */
  128937. protected _customMeshSet: boolean;
  128938. /**
  128939. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  128940. * * When set, interactions will be enabled
  128941. */
  128942. get attachedMesh(): Nullable<AbstractMesh>;
  128943. set attachedMesh(value: Nullable<AbstractMesh>);
  128944. /**
  128945. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  128946. * * When set, interactions will be enabled
  128947. */
  128948. get attachedNode(): Nullable<Node>;
  128949. set attachedNode(value: Nullable<Node>);
  128950. /**
  128951. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  128952. * @param mesh The mesh to replace the default mesh of the gizmo
  128953. */
  128954. setCustomMesh(mesh: Mesh): void;
  128955. /**
  128956. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  128957. */
  128958. updateGizmoRotationToMatchAttachedMesh: boolean;
  128959. /**
  128960. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  128961. */
  128962. updateGizmoPositionToMatchAttachedMesh: boolean;
  128963. /**
  128964. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  128965. */
  128966. updateScale: boolean;
  128967. protected _interactionsEnabled: boolean;
  128968. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128969. private _beforeRenderObserver;
  128970. private _tempVector;
  128971. /**
  128972. * Creates a gizmo
  128973. * @param gizmoLayer The utility layer the gizmo will be added to
  128974. */
  128975. constructor(
  128976. /** The utility layer the gizmo will be added to */
  128977. gizmoLayer?: UtilityLayerRenderer);
  128978. /**
  128979. * Updates the gizmo to match the attached mesh's position/rotation
  128980. */
  128981. protected _update(): void;
  128982. /**
  128983. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  128984. * @param value Node, TransformNode or mesh
  128985. */
  128986. protected _matrixChanged(): void;
  128987. /**
  128988. * Disposes of the gizmo
  128989. */
  128990. dispose(): void;
  128991. }
  128992. }
  128993. declare module BABYLON {
  128994. /**
  128995. * Single plane drag gizmo
  128996. */
  128997. export class PlaneDragGizmo extends Gizmo {
  128998. /**
  128999. * Drag behavior responsible for the gizmos dragging interactions
  129000. */
  129001. dragBehavior: PointerDragBehavior;
  129002. private _pointerObserver;
  129003. /**
  129004. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129005. */
  129006. snapDistance: number;
  129007. /**
  129008. * Event that fires each time the gizmo snaps to a new location.
  129009. * * snapDistance is the the change in distance
  129010. */
  129011. onSnapObservable: Observable<{
  129012. snapDistance: number;
  129013. }>;
  129014. private _plane;
  129015. private _coloredMaterial;
  129016. private _hoverMaterial;
  129017. private _isEnabled;
  129018. private _parent;
  129019. /** @hidden */
  129020. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129021. /** @hidden */
  129022. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129023. /**
  129024. * Creates a PlaneDragGizmo
  129025. * @param gizmoLayer The utility layer the gizmo will be added to
  129026. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129027. * @param color The color of the gizmo
  129028. */
  129029. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129030. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129031. /**
  129032. * If the gizmo is enabled
  129033. */
  129034. set isEnabled(value: boolean);
  129035. get isEnabled(): boolean;
  129036. /**
  129037. * Disposes of the gizmo
  129038. */
  129039. dispose(): void;
  129040. }
  129041. }
  129042. declare module BABYLON {
  129043. /**
  129044. * Gizmo that enables dragging a mesh along 3 axis
  129045. */
  129046. export class PositionGizmo extends Gizmo {
  129047. /**
  129048. * Internal gizmo used for interactions on the x axis
  129049. */
  129050. xGizmo: AxisDragGizmo;
  129051. /**
  129052. * Internal gizmo used for interactions on the y axis
  129053. */
  129054. yGizmo: AxisDragGizmo;
  129055. /**
  129056. * Internal gizmo used for interactions on the z axis
  129057. */
  129058. zGizmo: AxisDragGizmo;
  129059. /**
  129060. * Internal gizmo used for interactions on the yz plane
  129061. */
  129062. xPlaneGizmo: PlaneDragGizmo;
  129063. /**
  129064. * Internal gizmo used for interactions on the xz plane
  129065. */
  129066. yPlaneGizmo: PlaneDragGizmo;
  129067. /**
  129068. * Internal gizmo used for interactions on the xy plane
  129069. */
  129070. zPlaneGizmo: PlaneDragGizmo;
  129071. /**
  129072. * private variables
  129073. */
  129074. private _meshAttached;
  129075. private _nodeAttached;
  129076. private _updateGizmoRotationToMatchAttachedMesh;
  129077. private _snapDistance;
  129078. private _scaleRatio;
  129079. /** Fires an event when any of it's sub gizmos are dragged */
  129080. onDragStartObservable: Observable<unknown>;
  129081. /** Fires an event when any of it's sub gizmos are released from dragging */
  129082. onDragEndObservable: Observable<unknown>;
  129083. /**
  129084. * If set to true, planar drag is enabled
  129085. */
  129086. private _planarGizmoEnabled;
  129087. get attachedMesh(): Nullable<AbstractMesh>;
  129088. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129089. get attachedNode(): Nullable<Node>;
  129090. set attachedNode(node: Nullable<Node>);
  129091. /**
  129092. * Creates a PositionGizmo
  129093. * @param gizmoLayer The utility layer the gizmo will be added to
  129094. @param thickness display gizmo axis thickness
  129095. */
  129096. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  129097. /**
  129098. * If the planar drag gizmo is enabled
  129099. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  129100. */
  129101. set planarGizmoEnabled(value: boolean);
  129102. get planarGizmoEnabled(): boolean;
  129103. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129104. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129105. /**
  129106. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129107. */
  129108. set snapDistance(value: number);
  129109. get snapDistance(): number;
  129110. /**
  129111. * Ratio for the scale of the gizmo (Default: 1)
  129112. */
  129113. set scaleRatio(value: number);
  129114. get scaleRatio(): number;
  129115. /**
  129116. * Disposes of the gizmo
  129117. */
  129118. dispose(): void;
  129119. /**
  129120. * CustomMeshes are not supported by this gizmo
  129121. * @param mesh The mesh to replace the default mesh of the gizmo
  129122. */
  129123. setCustomMesh(mesh: Mesh): void;
  129124. }
  129125. }
  129126. declare module BABYLON {
  129127. /**
  129128. * Single axis drag gizmo
  129129. */
  129130. export class AxisDragGizmo extends Gizmo {
  129131. /**
  129132. * Drag behavior responsible for the gizmos dragging interactions
  129133. */
  129134. dragBehavior: PointerDragBehavior;
  129135. private _pointerObserver;
  129136. /**
  129137. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129138. */
  129139. snapDistance: number;
  129140. /**
  129141. * Event that fires each time the gizmo snaps to a new location.
  129142. * * snapDistance is the the change in distance
  129143. */
  129144. onSnapObservable: Observable<{
  129145. snapDistance: number;
  129146. }>;
  129147. private _isEnabled;
  129148. private _parent;
  129149. private _arrow;
  129150. private _coloredMaterial;
  129151. private _hoverMaterial;
  129152. /** @hidden */
  129153. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  129154. /** @hidden */
  129155. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129156. /**
  129157. * Creates an AxisDragGizmo
  129158. * @param gizmoLayer The utility layer the gizmo will be added to
  129159. * @param dragAxis The axis which the gizmo will be able to drag on
  129160. * @param color The color of the gizmo
  129161. * @param thickness display gizmo axis thickness
  129162. */
  129163. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  129164. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129165. /**
  129166. * If the gizmo is enabled
  129167. */
  129168. set isEnabled(value: boolean);
  129169. get isEnabled(): boolean;
  129170. /**
  129171. * Disposes of the gizmo
  129172. */
  129173. dispose(): void;
  129174. }
  129175. }
  129176. declare module BABYLON.Debug {
  129177. /**
  129178. * The Axes viewer will show 3 axes in a specific point in space
  129179. */
  129180. export class AxesViewer {
  129181. private _xAxis;
  129182. private _yAxis;
  129183. private _zAxis;
  129184. private _scaleLinesFactor;
  129185. private _instanced;
  129186. /**
  129187. * Gets the hosting scene
  129188. */
  129189. scene: Scene;
  129190. /**
  129191. * Gets or sets a number used to scale line length
  129192. */
  129193. scaleLines: number;
  129194. /** Gets the node hierarchy used to render x-axis */
  129195. get xAxis(): TransformNode;
  129196. /** Gets the node hierarchy used to render y-axis */
  129197. get yAxis(): TransformNode;
  129198. /** Gets the node hierarchy used to render z-axis */
  129199. get zAxis(): TransformNode;
  129200. /**
  129201. * Creates a new AxesViewer
  129202. * @param scene defines the hosting scene
  129203. * @param scaleLines defines a number used to scale line length (1 by default)
  129204. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129205. * @param xAxis defines the node hierarchy used to render the x-axis
  129206. * @param yAxis defines the node hierarchy used to render the y-axis
  129207. * @param zAxis defines the node hierarchy used to render the z-axis
  129208. */
  129209. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129210. /**
  129211. * Force the viewer to update
  129212. * @param position defines the position of the viewer
  129213. * @param xaxis defines the x axis of the viewer
  129214. * @param yaxis defines the y axis of the viewer
  129215. * @param zaxis defines the z axis of the viewer
  129216. */
  129217. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129218. /**
  129219. * Creates an instance of this axes viewer.
  129220. * @returns a new axes viewer with instanced meshes
  129221. */
  129222. createInstance(): AxesViewer;
  129223. /** Releases resources */
  129224. dispose(): void;
  129225. private static _SetRenderingGroupId;
  129226. }
  129227. }
  129228. declare module BABYLON.Debug {
  129229. /**
  129230. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129231. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129232. */
  129233. export class BoneAxesViewer extends AxesViewer {
  129234. /**
  129235. * Gets or sets the target mesh where to display the axes viewer
  129236. */
  129237. mesh: Nullable<Mesh>;
  129238. /**
  129239. * Gets or sets the target bone where to display the axes viewer
  129240. */
  129241. bone: Nullable<Bone>;
  129242. /** Gets current position */
  129243. pos: Vector3;
  129244. /** Gets direction of X axis */
  129245. xaxis: Vector3;
  129246. /** Gets direction of Y axis */
  129247. yaxis: Vector3;
  129248. /** Gets direction of Z axis */
  129249. zaxis: Vector3;
  129250. /**
  129251. * Creates a new BoneAxesViewer
  129252. * @param scene defines the hosting scene
  129253. * @param bone defines the target bone
  129254. * @param mesh defines the target mesh
  129255. * @param scaleLines defines a scaling factor for line length (1 by default)
  129256. */
  129257. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129258. /**
  129259. * Force the viewer to update
  129260. */
  129261. update(): void;
  129262. /** Releases resources */
  129263. dispose(): void;
  129264. }
  129265. }
  129266. declare module BABYLON {
  129267. /**
  129268. * Interface used to define scene explorer extensibility option
  129269. */
  129270. export interface IExplorerExtensibilityOption {
  129271. /**
  129272. * Define the option label
  129273. */
  129274. label: string;
  129275. /**
  129276. * Defines the action to execute on click
  129277. */
  129278. action: (entity: any) => void;
  129279. }
  129280. /**
  129281. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129282. */
  129283. export interface IExplorerExtensibilityGroup {
  129284. /**
  129285. * Defines a predicate to test if a given type mut be extended
  129286. */
  129287. predicate: (entity: any) => boolean;
  129288. /**
  129289. * Gets the list of options added to a type
  129290. */
  129291. entries: IExplorerExtensibilityOption[];
  129292. }
  129293. /**
  129294. * Interface used to define the options to use to create the Inspector
  129295. */
  129296. export interface IInspectorOptions {
  129297. /**
  129298. * Display in overlay mode (default: false)
  129299. */
  129300. overlay?: boolean;
  129301. /**
  129302. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129303. */
  129304. globalRoot?: HTMLElement;
  129305. /**
  129306. * Display the Scene explorer
  129307. */
  129308. showExplorer?: boolean;
  129309. /**
  129310. * Display the property inspector
  129311. */
  129312. showInspector?: boolean;
  129313. /**
  129314. * Display in embed mode (both panes on the right)
  129315. */
  129316. embedMode?: boolean;
  129317. /**
  129318. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129319. */
  129320. handleResize?: boolean;
  129321. /**
  129322. * Allow the panes to popup (default: true)
  129323. */
  129324. enablePopup?: boolean;
  129325. /**
  129326. * Allow the panes to be closed by users (default: true)
  129327. */
  129328. enableClose?: boolean;
  129329. /**
  129330. * Optional list of extensibility entries
  129331. */
  129332. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129333. /**
  129334. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129335. */
  129336. inspectorURL?: string;
  129337. /**
  129338. * Optional initial tab (default to DebugLayerTab.Properties)
  129339. */
  129340. initialTab?: DebugLayerTab;
  129341. }
  129342. interface Scene {
  129343. /**
  129344. * @hidden
  129345. * Backing field
  129346. */
  129347. _debugLayer: DebugLayer;
  129348. /**
  129349. * Gets the debug layer (aka Inspector) associated with the scene
  129350. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129351. */
  129352. debugLayer: DebugLayer;
  129353. }
  129354. /**
  129355. * Enum of inspector action tab
  129356. */
  129357. export enum DebugLayerTab {
  129358. /**
  129359. * Properties tag (default)
  129360. */
  129361. Properties = 0,
  129362. /**
  129363. * Debug tab
  129364. */
  129365. Debug = 1,
  129366. /**
  129367. * Statistics tab
  129368. */
  129369. Statistics = 2,
  129370. /**
  129371. * Tools tab
  129372. */
  129373. Tools = 3,
  129374. /**
  129375. * Settings tab
  129376. */
  129377. Settings = 4
  129378. }
  129379. /**
  129380. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129381. * what is happening in your scene
  129382. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129383. */
  129384. export class DebugLayer {
  129385. /**
  129386. * Define the url to get the inspector script from.
  129387. * By default it uses the babylonjs CDN.
  129388. * @ignoreNaming
  129389. */
  129390. static InspectorURL: string;
  129391. private _scene;
  129392. private BJSINSPECTOR;
  129393. private _onPropertyChangedObservable?;
  129394. /**
  129395. * Observable triggered when a property is changed through the inspector.
  129396. */
  129397. get onPropertyChangedObservable(): any;
  129398. /**
  129399. * Instantiates a new debug layer.
  129400. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129401. * what is happening in your scene
  129402. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129403. * @param scene Defines the scene to inspect
  129404. */
  129405. constructor(scene: Scene);
  129406. /** Creates the inspector window. */
  129407. private _createInspector;
  129408. /**
  129409. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129410. * @param entity defines the entity to select
  129411. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129412. */
  129413. select(entity: any, lineContainerTitles?: string | string[]): void;
  129414. /** Get the inspector from bundle or global */
  129415. private _getGlobalInspector;
  129416. /**
  129417. * Get if the inspector is visible or not.
  129418. * @returns true if visible otherwise, false
  129419. */
  129420. isVisible(): boolean;
  129421. /**
  129422. * Hide the inspector and close its window.
  129423. */
  129424. hide(): void;
  129425. /**
  129426. * Update the scene in the inspector
  129427. */
  129428. setAsActiveScene(): void;
  129429. /**
  129430. * Launch the debugLayer.
  129431. * @param config Define the configuration of the inspector
  129432. * @return a promise fulfilled when the debug layer is visible
  129433. */
  129434. show(config?: IInspectorOptions): Promise<DebugLayer>;
  129435. }
  129436. }
  129437. declare module BABYLON {
  129438. /**
  129439. * Class containing static functions to help procedurally build meshes
  129440. */
  129441. export class BoxBuilder {
  129442. /**
  129443. * Creates a box mesh
  129444. * * The parameter `size` sets the size (float) of each box side (default 1)
  129445. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129446. * * 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)
  129447. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129451. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129452. * @param name defines the name of the mesh
  129453. * @param options defines the options used to create the mesh
  129454. * @param scene defines the hosting scene
  129455. * @returns the box mesh
  129456. */
  129457. static CreateBox(name: string, options: {
  129458. size?: number;
  129459. width?: number;
  129460. height?: number;
  129461. depth?: number;
  129462. faceUV?: Vector4[];
  129463. faceColors?: Color4[];
  129464. sideOrientation?: number;
  129465. frontUVs?: Vector4;
  129466. backUVs?: Vector4;
  129467. wrap?: boolean;
  129468. topBaseAt?: number;
  129469. bottomBaseAt?: number;
  129470. updatable?: boolean;
  129471. }, scene?: Nullable<Scene>): Mesh;
  129472. }
  129473. }
  129474. declare module BABYLON.Debug {
  129475. /**
  129476. * Used to show the physics impostor around the specific mesh
  129477. */
  129478. export class PhysicsViewer {
  129479. /** @hidden */
  129480. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  129481. /** @hidden */
  129482. protected _meshes: Array<Nullable<AbstractMesh>>;
  129483. /** @hidden */
  129484. protected _scene: Nullable<Scene>;
  129485. /** @hidden */
  129486. protected _numMeshes: number;
  129487. /** @hidden */
  129488. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  129489. private _renderFunction;
  129490. private _utilityLayer;
  129491. private _debugBoxMesh;
  129492. private _debugSphereMesh;
  129493. private _debugCylinderMesh;
  129494. private _debugMaterial;
  129495. private _debugMeshMeshes;
  129496. /**
  129497. * Creates a new PhysicsViewer
  129498. * @param scene defines the hosting scene
  129499. */
  129500. constructor(scene: Scene);
  129501. /** @hidden */
  129502. protected _updateDebugMeshes(): void;
  129503. /**
  129504. * Renders a specified physic impostor
  129505. * @param impostor defines the impostor to render
  129506. * @param targetMesh defines the mesh represented by the impostor
  129507. * @returns the new debug mesh used to render the impostor
  129508. */
  129509. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  129510. /**
  129511. * Hides a specified physic impostor
  129512. * @param impostor defines the impostor to hide
  129513. */
  129514. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  129515. private _getDebugMaterial;
  129516. private _getDebugBoxMesh;
  129517. private _getDebugSphereMesh;
  129518. private _getDebugCylinderMesh;
  129519. private _getDebugMeshMesh;
  129520. private _getDebugMesh;
  129521. /** Releases all resources */
  129522. dispose(): void;
  129523. }
  129524. }
  129525. declare module BABYLON {
  129526. /**
  129527. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129528. * in order to better appreciate the issue one might have.
  129529. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129530. */
  129531. export class RayHelper {
  129532. /**
  129533. * Defines the ray we are currently tryin to visualize.
  129534. */
  129535. ray: Nullable<Ray>;
  129536. private _renderPoints;
  129537. private _renderLine;
  129538. private _renderFunction;
  129539. private _scene;
  129540. private _updateToMeshFunction;
  129541. private _attachedToMesh;
  129542. private _meshSpaceDirection;
  129543. private _meshSpaceOrigin;
  129544. /**
  129545. * Helper function to create a colored helper in a scene in one line.
  129546. * @param ray Defines the ray we are currently tryin to visualize
  129547. * @param scene Defines the scene the ray is used in
  129548. * @param color Defines the color we want to see the ray in
  129549. * @returns The newly created ray helper.
  129550. */
  129551. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  129552. /**
  129553. * Instantiate a new ray helper.
  129554. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129555. * in order to better appreciate the issue one might have.
  129556. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129557. * @param ray Defines the ray we are currently tryin to visualize
  129558. */
  129559. constructor(ray: Ray);
  129560. /**
  129561. * Shows the ray we are willing to debug.
  129562. * @param scene Defines the scene the ray needs to be rendered in
  129563. * @param color Defines the color the ray needs to be rendered in
  129564. */
  129565. show(scene: Scene, color?: Color3): void;
  129566. /**
  129567. * Hides the ray we are debugging.
  129568. */
  129569. hide(): void;
  129570. private _render;
  129571. /**
  129572. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  129573. * @param mesh Defines the mesh we want the helper attached to
  129574. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  129575. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  129576. * @param length Defines the length of the ray
  129577. */
  129578. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  129579. /**
  129580. * Detach the ray helper from the mesh it has previously been attached to.
  129581. */
  129582. detachFromMesh(): void;
  129583. private _updateToMesh;
  129584. /**
  129585. * Dispose the helper and release its associated resources.
  129586. */
  129587. dispose(): void;
  129588. }
  129589. }
  129590. declare module BABYLON {
  129591. /**
  129592. * Defines the options associated with the creation of a SkeletonViewer.
  129593. */
  129594. export interface ISkeletonViewerOptions {
  129595. /** Should the system pause animations before building the Viewer? */
  129596. pauseAnimations: boolean;
  129597. /** Should the system return the skeleton to rest before building? */
  129598. returnToRest: boolean;
  129599. /** public Display Mode of the Viewer */
  129600. displayMode: number;
  129601. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129602. displayOptions: ISkeletonViewerDisplayOptions;
  129603. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129604. computeBonesUsingShaders: boolean;
  129605. }
  129606. /**
  129607. * Defines how to display the various bone meshes for the viewer.
  129608. */
  129609. export interface ISkeletonViewerDisplayOptions {
  129610. /** How far down to start tapering the bone spurs */
  129611. midStep?: number;
  129612. /** How big is the midStep? */
  129613. midStepFactor?: number;
  129614. /** Base for the Sphere Size */
  129615. sphereBaseSize?: number;
  129616. /** The ratio of the sphere to the longest bone in units */
  129617. sphereScaleUnit?: number;
  129618. /** Ratio for the Sphere Size */
  129619. sphereFactor?: number;
  129620. }
  129621. }
  129622. declare module BABYLON {
  129623. /**
  129624. * Class containing static functions to help procedurally build meshes
  129625. */
  129626. export class RibbonBuilder {
  129627. /**
  129628. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129629. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129630. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129631. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129632. * * 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
  129633. * * 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
  129634. * * 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
  129635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129637. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129638. * * 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
  129639. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129640. * * 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
  129641. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129643. * @param name defines the name of the mesh
  129644. * @param options defines the options used to create the mesh
  129645. * @param scene defines the hosting scene
  129646. * @returns the ribbon mesh
  129647. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129648. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129649. */
  129650. static CreateRibbon(name: string, options: {
  129651. pathArray: Vector3[][];
  129652. closeArray?: boolean;
  129653. closePath?: boolean;
  129654. offset?: number;
  129655. updatable?: boolean;
  129656. sideOrientation?: number;
  129657. frontUVs?: Vector4;
  129658. backUVs?: Vector4;
  129659. instance?: Mesh;
  129660. invertUV?: boolean;
  129661. uvs?: Vector2[];
  129662. colors?: Color4[];
  129663. }, scene?: Nullable<Scene>): Mesh;
  129664. }
  129665. }
  129666. declare module BABYLON {
  129667. /**
  129668. * Class containing static functions to help procedurally build meshes
  129669. */
  129670. export class ShapeBuilder {
  129671. /**
  129672. * 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.
  129673. * * 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.
  129674. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129675. * * 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.
  129676. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129677. * * 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
  129678. * * 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
  129679. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129684. * @param name defines the name of the mesh
  129685. * @param options defines the options used to create the mesh
  129686. * @param scene defines the hosting scene
  129687. * @returns the extruded shape mesh
  129688. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129690. */
  129691. static ExtrudeShape(name: string, options: {
  129692. shape: Vector3[];
  129693. path: Vector3[];
  129694. scale?: number;
  129695. rotation?: number;
  129696. cap?: number;
  129697. updatable?: boolean;
  129698. sideOrientation?: number;
  129699. frontUVs?: Vector4;
  129700. backUVs?: Vector4;
  129701. instance?: Mesh;
  129702. invertUV?: boolean;
  129703. }, scene?: Nullable<Scene>): Mesh;
  129704. /**
  129705. * Creates an custom extruded shape mesh.
  129706. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129707. * * 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.
  129708. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129709. * * 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
  129710. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129711. * * 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
  129712. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129713. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129714. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129715. * * 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
  129716. * * 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
  129717. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129720. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129722. * @param name defines the name of the mesh
  129723. * @param options defines the options used to create the mesh
  129724. * @param scene defines the hosting scene
  129725. * @returns the custom extruded shape mesh
  129726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129727. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129729. */
  129730. static ExtrudeShapeCustom(name: string, options: {
  129731. shape: Vector3[];
  129732. path: Vector3[];
  129733. scaleFunction?: any;
  129734. rotationFunction?: any;
  129735. ribbonCloseArray?: boolean;
  129736. ribbonClosePath?: boolean;
  129737. cap?: number;
  129738. updatable?: boolean;
  129739. sideOrientation?: number;
  129740. frontUVs?: Vector4;
  129741. backUVs?: Vector4;
  129742. instance?: Mesh;
  129743. invertUV?: boolean;
  129744. }, scene?: Nullable<Scene>): Mesh;
  129745. private static _ExtrudeShapeGeneric;
  129746. }
  129747. }
  129748. declare module BABYLON.Debug {
  129749. /**
  129750. * Class used to render a debug view of a given skeleton
  129751. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  129752. */
  129753. export class SkeletonViewer {
  129754. /** defines the skeleton to render */
  129755. skeleton: Skeleton;
  129756. /** defines the mesh attached to the skeleton */
  129757. mesh: AbstractMesh;
  129758. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129759. autoUpdateBonesMatrices: boolean;
  129760. /** defines the rendering group id to use with the viewer */
  129761. renderingGroupId: number;
  129762. /** is the options for the viewer */
  129763. options: Partial<ISkeletonViewerOptions>;
  129764. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  129765. static readonly DISPLAY_LINES: number;
  129766. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  129767. static readonly DISPLAY_SPHERES: number;
  129768. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  129769. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  129770. /** If SkeletonViewer scene scope. */
  129771. private _scene;
  129772. /** Gets or sets the color used to render the skeleton */
  129773. color: Color3;
  129774. /** Array of the points of the skeleton fo the line view. */
  129775. private _debugLines;
  129776. /** The SkeletonViewers Mesh. */
  129777. private _debugMesh;
  129778. /** If SkeletonViewer is enabled. */
  129779. private _isEnabled;
  129780. /** If SkeletonViewer is ready. */
  129781. private _ready;
  129782. /** SkeletonViewer render observable. */
  129783. private _obs;
  129784. /** The Utility Layer to render the gizmos in. */
  129785. private _utilityLayer;
  129786. /** Gets the Scene. */
  129787. get scene(): Scene;
  129788. /** Gets the utilityLayer. */
  129789. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  129790. /** Checks Ready Status. */
  129791. get isReady(): Boolean;
  129792. /** Sets Ready Status. */
  129793. set ready(value: boolean);
  129794. /** Gets the debugMesh */
  129795. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  129796. /** Sets the debugMesh */
  129797. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  129798. /** Gets the material */
  129799. get material(): StandardMaterial;
  129800. /** Sets the material */
  129801. set material(value: StandardMaterial);
  129802. /**
  129803. * Creates a new SkeletonViewer
  129804. * @param skeleton defines the skeleton to render
  129805. * @param mesh defines the mesh attached to the skeleton
  129806. * @param scene defines the hosting scene
  129807. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  129808. * @param renderingGroupId defines the rendering group id to use with the viewer
  129809. * @param options All of the extra constructor options for the SkeletonViewer
  129810. */
  129811. constructor(
  129812. /** defines the skeleton to render */
  129813. skeleton: Skeleton,
  129814. /** defines the mesh attached to the skeleton */
  129815. mesh: AbstractMesh,
  129816. /** The Scene scope*/
  129817. scene: Scene,
  129818. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129819. autoUpdateBonesMatrices?: boolean,
  129820. /** defines the rendering group id to use with the viewer */
  129821. renderingGroupId?: number,
  129822. /** is the options for the viewer */
  129823. options?: Partial<ISkeletonViewerOptions>);
  129824. /** The Dynamic bindings for the update functions */
  129825. private _bindObs;
  129826. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  129827. update(): void;
  129828. /** Gets or sets a boolean indicating if the viewer is enabled */
  129829. set isEnabled(value: boolean);
  129830. get isEnabled(): boolean;
  129831. private _getBonePosition;
  129832. private _getLinesForBonesWithLength;
  129833. private _getLinesForBonesNoLength;
  129834. /** function to revert the mesh and scene back to the initial state. */
  129835. private _revert;
  129836. /** function to build and bind sphere joint points and spur bone representations. */
  129837. private _buildSpheresAndSpurs;
  129838. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  129839. private _displayLinesUpdate;
  129840. /** Release associated resources */
  129841. dispose(): void;
  129842. }
  129843. }
  129844. declare module BABYLON {
  129845. /**
  129846. * Enum for Device Types
  129847. */
  129848. export enum DeviceType {
  129849. /** Generic */
  129850. Generic = 0,
  129851. /** Keyboard */
  129852. Keyboard = 1,
  129853. /** Mouse */
  129854. Mouse = 2,
  129855. /** Touch Pointers */
  129856. Touch = 3,
  129857. /** PS4 Dual Shock */
  129858. DualShock = 4,
  129859. /** Xbox */
  129860. Xbox = 5,
  129861. /** Switch Controller */
  129862. Switch = 6
  129863. }
  129864. /**
  129865. * Enum for All Pointers (Touch/Mouse)
  129866. */
  129867. export enum PointerInput {
  129868. /** Horizontal Axis */
  129869. Horizontal = 0,
  129870. /** Vertical Axis */
  129871. Vertical = 1,
  129872. /** Left Click or Touch */
  129873. LeftClick = 2,
  129874. /** Middle Click */
  129875. MiddleClick = 3,
  129876. /** Right Click */
  129877. RightClick = 4,
  129878. /** Browser Back */
  129879. BrowserBack = 5,
  129880. /** Browser Forward */
  129881. BrowserForward = 6
  129882. }
  129883. /**
  129884. * Enum for Dual Shock Gamepad
  129885. */
  129886. export enum DualShockInput {
  129887. /** Cross */
  129888. Cross = 0,
  129889. /** Circle */
  129890. Circle = 1,
  129891. /** Square */
  129892. Square = 2,
  129893. /** Triangle */
  129894. Triangle = 3,
  129895. /** L1 */
  129896. L1 = 4,
  129897. /** R1 */
  129898. R1 = 5,
  129899. /** L2 */
  129900. L2 = 6,
  129901. /** R2 */
  129902. R2 = 7,
  129903. /** Share */
  129904. Share = 8,
  129905. /** Options */
  129906. Options = 9,
  129907. /** L3 */
  129908. L3 = 10,
  129909. /** R3 */
  129910. R3 = 11,
  129911. /** DPadUp */
  129912. DPadUp = 12,
  129913. /** DPadDown */
  129914. DPadDown = 13,
  129915. /** DPadLeft */
  129916. DPadLeft = 14,
  129917. /** DRight */
  129918. DPadRight = 15,
  129919. /** Home */
  129920. Home = 16,
  129921. /** TouchPad */
  129922. TouchPad = 17,
  129923. /** LStickXAxis */
  129924. LStickXAxis = 18,
  129925. /** LStickYAxis */
  129926. LStickYAxis = 19,
  129927. /** RStickXAxis */
  129928. RStickXAxis = 20,
  129929. /** RStickYAxis */
  129930. RStickYAxis = 21
  129931. }
  129932. /**
  129933. * Enum for Xbox Gamepad
  129934. */
  129935. export enum XboxInput {
  129936. /** A */
  129937. A = 0,
  129938. /** B */
  129939. B = 1,
  129940. /** X */
  129941. X = 2,
  129942. /** Y */
  129943. Y = 3,
  129944. /** LB */
  129945. LB = 4,
  129946. /** RB */
  129947. RB = 5,
  129948. /** LT */
  129949. LT = 6,
  129950. /** RT */
  129951. RT = 7,
  129952. /** Back */
  129953. Back = 8,
  129954. /** Start */
  129955. Start = 9,
  129956. /** LS */
  129957. LS = 10,
  129958. /** RS */
  129959. RS = 11,
  129960. /** DPadUp */
  129961. DPadUp = 12,
  129962. /** DPadDown */
  129963. DPadDown = 13,
  129964. /** DPadLeft */
  129965. DPadLeft = 14,
  129966. /** DRight */
  129967. DPadRight = 15,
  129968. /** Home */
  129969. Home = 16,
  129970. /** LStickXAxis */
  129971. LStickXAxis = 17,
  129972. /** LStickYAxis */
  129973. LStickYAxis = 18,
  129974. /** RStickXAxis */
  129975. RStickXAxis = 19,
  129976. /** RStickYAxis */
  129977. RStickYAxis = 20
  129978. }
  129979. /**
  129980. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  129981. */
  129982. export enum SwitchInput {
  129983. /** B */
  129984. B = 0,
  129985. /** A */
  129986. A = 1,
  129987. /** Y */
  129988. Y = 2,
  129989. /** X */
  129990. X = 3,
  129991. /** L */
  129992. L = 4,
  129993. /** R */
  129994. R = 5,
  129995. /** ZL */
  129996. ZL = 6,
  129997. /** ZR */
  129998. ZR = 7,
  129999. /** Minus */
  130000. Minus = 8,
  130001. /** Plus */
  130002. Plus = 9,
  130003. /** LS */
  130004. LS = 10,
  130005. /** RS */
  130006. RS = 11,
  130007. /** DPadUp */
  130008. DPadUp = 12,
  130009. /** DPadDown */
  130010. DPadDown = 13,
  130011. /** DPadLeft */
  130012. DPadLeft = 14,
  130013. /** DRight */
  130014. DPadRight = 15,
  130015. /** Home */
  130016. Home = 16,
  130017. /** Capture */
  130018. Capture = 17,
  130019. /** LStickXAxis */
  130020. LStickXAxis = 18,
  130021. /** LStickYAxis */
  130022. LStickYAxis = 19,
  130023. /** RStickXAxis */
  130024. RStickXAxis = 20,
  130025. /** RStickYAxis */
  130026. RStickYAxis = 21
  130027. }
  130028. }
  130029. declare module BABYLON {
  130030. /**
  130031. * This class will take all inputs from Keyboard, Pointer, and
  130032. * any Gamepads and provide a polling system that all devices
  130033. * will use. This class assumes that there will only be one
  130034. * pointer device and one keyboard.
  130035. */
  130036. export class DeviceInputSystem implements IDisposable {
  130037. /**
  130038. * Callback to be triggered when a device is connected
  130039. */
  130040. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130041. /**
  130042. * Callback to be triggered when a device is disconnected
  130043. */
  130044. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130045. /**
  130046. * Callback to be triggered when event driven input is updated
  130047. */
  130048. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  130049. private _inputs;
  130050. private _gamepads;
  130051. private _keyboardActive;
  130052. private _pointerActive;
  130053. private _elementToAttachTo;
  130054. private _keyboardDownEvent;
  130055. private _keyboardUpEvent;
  130056. private _pointerMoveEvent;
  130057. private _pointerDownEvent;
  130058. private _pointerUpEvent;
  130059. private _gamepadConnectedEvent;
  130060. private _gamepadDisconnectedEvent;
  130061. private static _MAX_KEYCODES;
  130062. private static _MAX_POINTER_INPUTS;
  130063. private constructor();
  130064. /**
  130065. * Creates a new DeviceInputSystem instance
  130066. * @param engine Engine to pull input element from
  130067. * @returns The new instance
  130068. */
  130069. static Create(engine: Engine): DeviceInputSystem;
  130070. /**
  130071. * Checks for current device input value, given an id and input index
  130072. * @param deviceName Id of connected device
  130073. * @param inputIndex Index of device input
  130074. * @returns Current value of input
  130075. */
  130076. /**
  130077. * Checks for current device input value, given an id and input index
  130078. * @param deviceType Enum specifiying device type
  130079. * @param deviceSlot "Slot" or index that device is referenced in
  130080. * @param inputIndex Id of input to be checked
  130081. * @returns Current value of input
  130082. */
  130083. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  130084. /**
  130085. * Dispose of all the eventlisteners
  130086. */
  130087. dispose(): void;
  130088. /**
  130089. * Add device and inputs to device array
  130090. * @param deviceType Enum specifiying device type
  130091. * @param deviceSlot "Slot" or index that device is referenced in
  130092. * @param numberOfInputs Number of input entries to create for given device
  130093. */
  130094. private _registerDevice;
  130095. /**
  130096. * Given a specific device name, remove that device from the device map
  130097. * @param deviceType Enum specifiying device type
  130098. * @param deviceSlot "Slot" or index that device is referenced in
  130099. */
  130100. private _unregisterDevice;
  130101. /**
  130102. * Handle all actions that come from keyboard interaction
  130103. */
  130104. private _handleKeyActions;
  130105. /**
  130106. * Handle all actions that come from pointer interaction
  130107. */
  130108. private _handlePointerActions;
  130109. /**
  130110. * Handle all actions that come from gamepad interaction
  130111. */
  130112. private _handleGamepadActions;
  130113. /**
  130114. * Update all non-event based devices with each frame
  130115. * @param deviceType Enum specifiying device type
  130116. * @param deviceSlot "Slot" or index that device is referenced in
  130117. * @param inputIndex Id of input to be checked
  130118. */
  130119. private _updateDevice;
  130120. /**
  130121. * Gets DeviceType from the device name
  130122. * @param deviceName Name of Device from DeviceInputSystem
  130123. * @returns DeviceType enum value
  130124. */
  130125. private _getGamepadDeviceType;
  130126. }
  130127. }
  130128. declare module BABYLON {
  130129. /**
  130130. * Type to handle enforcement of inputs
  130131. */
  130132. 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;
  130133. }
  130134. declare module BABYLON {
  130135. /**
  130136. * Class that handles all input for a specific device
  130137. */
  130138. export class DeviceSource<T extends DeviceType> {
  130139. /** Type of device */
  130140. readonly deviceType: DeviceType;
  130141. /** "Slot" or index that device is referenced in */
  130142. readonly deviceSlot: number;
  130143. /**
  130144. * Observable to handle device input changes per device
  130145. */
  130146. readonly onInputChangedObservable: Observable<{
  130147. inputIndex: DeviceInput<T>;
  130148. previousState: Nullable<number>;
  130149. currentState: Nullable<number>;
  130150. }>;
  130151. private readonly _deviceInputSystem;
  130152. /**
  130153. * Default Constructor
  130154. * @param deviceInputSystem Reference to DeviceInputSystem
  130155. * @param deviceType Type of device
  130156. * @param deviceSlot "Slot" or index that device is referenced in
  130157. */
  130158. constructor(deviceInputSystem: DeviceInputSystem,
  130159. /** Type of device */
  130160. deviceType: DeviceType,
  130161. /** "Slot" or index that device is referenced in */
  130162. deviceSlot?: number);
  130163. /**
  130164. * Get input for specific input
  130165. * @param inputIndex index of specific input on device
  130166. * @returns Input value from DeviceInputSystem
  130167. */
  130168. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  130169. }
  130170. /**
  130171. * Class to keep track of devices
  130172. */
  130173. export class DeviceSourceManager implements IDisposable {
  130174. /**
  130175. * Observable to be triggered when before a device is connected
  130176. */
  130177. readonly onBeforeDeviceConnectedObservable: Observable<{
  130178. deviceType: DeviceType;
  130179. deviceSlot: number;
  130180. }>;
  130181. /**
  130182. * Observable to be triggered when before a device is disconnected
  130183. */
  130184. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  130185. deviceType: DeviceType;
  130186. deviceSlot: number;
  130187. }>;
  130188. /**
  130189. * Observable to be triggered when after a device is connected
  130190. */
  130191. readonly onAfterDeviceConnectedObservable: Observable<{
  130192. deviceType: DeviceType;
  130193. deviceSlot: number;
  130194. }>;
  130195. /**
  130196. * Observable to be triggered when after a device is disconnected
  130197. */
  130198. readonly onAfterDeviceDisconnectedObservable: Observable<{
  130199. deviceType: DeviceType;
  130200. deviceSlot: number;
  130201. }>;
  130202. private readonly _devices;
  130203. private readonly _firstDevice;
  130204. private readonly _deviceInputSystem;
  130205. /**
  130206. * Default Constructor
  130207. * @param engine engine to pull input element from
  130208. */
  130209. constructor(engine: Engine);
  130210. /**
  130211. * Gets a DeviceSource, given a type and slot
  130212. * @param deviceType Enum specifying device type
  130213. * @param deviceSlot "Slot" or index that device is referenced in
  130214. * @returns DeviceSource object
  130215. */
  130216. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  130217. /**
  130218. * Gets an array of DeviceSource objects for a given device type
  130219. * @param deviceType Enum specifying device type
  130220. * @returns Array of DeviceSource objects
  130221. */
  130222. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  130223. /**
  130224. * Dispose of DeviceInputSystem and other parts
  130225. */
  130226. dispose(): void;
  130227. /**
  130228. * Function to add device name to device list
  130229. * @param deviceType Enum specifying device type
  130230. * @param deviceSlot "Slot" or index that device is referenced in
  130231. */
  130232. private _addDevice;
  130233. /**
  130234. * Function to remove device name to device list
  130235. * @param deviceType Enum specifying device type
  130236. * @param deviceSlot "Slot" or index that device is referenced in
  130237. */
  130238. private _removeDevice;
  130239. /**
  130240. * Updates array storing first connected device of each type
  130241. * @param type Type of Device
  130242. */
  130243. private _updateFirstDevices;
  130244. }
  130245. }
  130246. declare module BABYLON {
  130247. /**
  130248. * Options to create the null engine
  130249. */
  130250. export class NullEngineOptions {
  130251. /**
  130252. * Render width (Default: 512)
  130253. */
  130254. renderWidth: number;
  130255. /**
  130256. * Render height (Default: 256)
  130257. */
  130258. renderHeight: number;
  130259. /**
  130260. * Texture size (Default: 512)
  130261. */
  130262. textureSize: number;
  130263. /**
  130264. * If delta time between frames should be constant
  130265. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130266. */
  130267. deterministicLockstep: boolean;
  130268. /**
  130269. * Maximum about of steps between frames (Default: 4)
  130270. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130271. */
  130272. lockstepMaxSteps: number;
  130273. /**
  130274. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  130275. */
  130276. useHighPrecisionMatrix?: boolean;
  130277. }
  130278. /**
  130279. * The null engine class provides support for headless version of babylon.js.
  130280. * This can be used in server side scenario or for testing purposes
  130281. */
  130282. export class NullEngine extends Engine {
  130283. private _options;
  130284. /**
  130285. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  130286. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130287. * @returns true if engine is in deterministic lock step mode
  130288. */
  130289. isDeterministicLockStep(): boolean;
  130290. /**
  130291. * Gets the max steps when engine is running in deterministic lock step
  130292. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130293. * @returns the max steps
  130294. */
  130295. getLockstepMaxSteps(): number;
  130296. /**
  130297. * Gets the current hardware scaling level.
  130298. * By default the hardware scaling level is computed from the window device ratio.
  130299. * 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.
  130300. * @returns a number indicating the current hardware scaling level
  130301. */
  130302. getHardwareScalingLevel(): number;
  130303. constructor(options?: NullEngineOptions);
  130304. /**
  130305. * Creates a vertex buffer
  130306. * @param vertices the data for the vertex buffer
  130307. * @returns the new WebGL static buffer
  130308. */
  130309. createVertexBuffer(vertices: FloatArray): DataBuffer;
  130310. /**
  130311. * Creates a new index buffer
  130312. * @param indices defines the content of the index buffer
  130313. * @param updatable defines if the index buffer must be updatable
  130314. * @returns a new webGL buffer
  130315. */
  130316. createIndexBuffer(indices: IndicesArray): DataBuffer;
  130317. /**
  130318. * Clear the current render buffer or the current render target (if any is set up)
  130319. * @param color defines the color to use
  130320. * @param backBuffer defines if the back buffer must be cleared
  130321. * @param depth defines if the depth buffer must be cleared
  130322. * @param stencil defines if the stencil buffer must be cleared
  130323. */
  130324. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130325. /**
  130326. * Gets the current render width
  130327. * @param useScreen defines if screen size must be used (or the current render target if any)
  130328. * @returns a number defining the current render width
  130329. */
  130330. getRenderWidth(useScreen?: boolean): number;
  130331. /**
  130332. * Gets the current render height
  130333. * @param useScreen defines if screen size must be used (or the current render target if any)
  130334. * @returns a number defining the current render height
  130335. */
  130336. getRenderHeight(useScreen?: boolean): number;
  130337. /**
  130338. * Set the WebGL's viewport
  130339. * @param viewport defines the viewport element to be used
  130340. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  130341. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  130342. */
  130343. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  130344. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  130345. /**
  130346. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  130347. * @param pipelineContext defines the pipeline context to use
  130348. * @param uniformsNames defines the list of uniform names
  130349. * @returns an array of webGL uniform locations
  130350. */
  130351. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130352. /**
  130353. * Gets the lsit of active attributes for a given webGL program
  130354. * @param pipelineContext defines the pipeline context to use
  130355. * @param attributesNames defines the list of attribute names to get
  130356. * @returns an array of indices indicating the offset of each attribute
  130357. */
  130358. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130359. /**
  130360. * Binds an effect to the webGL context
  130361. * @param effect defines the effect to bind
  130362. */
  130363. bindSamplers(effect: Effect): void;
  130364. /**
  130365. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130366. * @param effect defines the effect to activate
  130367. */
  130368. enableEffect(effect: Effect): void;
  130369. /**
  130370. * Set various states to the webGL context
  130371. * @param culling defines backface culling state
  130372. * @param zOffset defines the value to apply to zOffset (0 by default)
  130373. * @param force defines if states must be applied even if cache is up to date
  130374. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130375. */
  130376. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130377. /**
  130378. * Set the value of an uniform to an array of int32
  130379. * @param uniform defines the webGL uniform location where to store the value
  130380. * @param array defines the array of int32 to store
  130381. */
  130382. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130383. /**
  130384. * Set the value of an uniform to an array of int32 (stored as vec2)
  130385. * @param uniform defines the webGL uniform location where to store the value
  130386. * @param array defines the array of int32 to store
  130387. */
  130388. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130389. /**
  130390. * Set the value of an uniform to an array of int32 (stored as vec3)
  130391. * @param uniform defines the webGL uniform location where to store the value
  130392. * @param array defines the array of int32 to store
  130393. */
  130394. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130395. /**
  130396. * Set the value of an uniform to an array of int32 (stored as vec4)
  130397. * @param uniform defines the webGL uniform location where to store the value
  130398. * @param array defines the array of int32 to store
  130399. */
  130400. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130401. /**
  130402. * Set the value of an uniform to an array of float32
  130403. * @param uniform defines the webGL uniform location where to store the value
  130404. * @param array defines the array of float32 to store
  130405. */
  130406. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130407. /**
  130408. * Set the value of an uniform to an array of float32 (stored as vec2)
  130409. * @param uniform defines the webGL uniform location where to store the value
  130410. * @param array defines the array of float32 to store
  130411. */
  130412. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130413. /**
  130414. * Set the value of an uniform to an array of float32 (stored as vec3)
  130415. * @param uniform defines the webGL uniform location where to store the value
  130416. * @param array defines the array of float32 to store
  130417. */
  130418. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130419. /**
  130420. * Set the value of an uniform to an array of float32 (stored as vec4)
  130421. * @param uniform defines the webGL uniform location where to store the value
  130422. * @param array defines the array of float32 to store
  130423. */
  130424. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130425. /**
  130426. * Set the value of an uniform to an array of number
  130427. * @param uniform defines the webGL uniform location where to store the value
  130428. * @param array defines the array of number to store
  130429. */
  130430. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130431. /**
  130432. * Set the value of an uniform to an array of number (stored as vec2)
  130433. * @param uniform defines the webGL uniform location where to store the value
  130434. * @param array defines the array of number to store
  130435. */
  130436. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130437. /**
  130438. * Set the value of an uniform to an array of number (stored as vec3)
  130439. * @param uniform defines the webGL uniform location where to store the value
  130440. * @param array defines the array of number to store
  130441. */
  130442. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130443. /**
  130444. * Set the value of an uniform to an array of number (stored as vec4)
  130445. * @param uniform defines the webGL uniform location where to store the value
  130446. * @param array defines the array of number to store
  130447. */
  130448. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130449. /**
  130450. * Set the value of an uniform to an array of float32 (stored as matrices)
  130451. * @param uniform defines the webGL uniform location where to store the value
  130452. * @param matrices defines the array of float32 to store
  130453. */
  130454. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130455. /**
  130456. * Set the value of an uniform to a matrix (3x3)
  130457. * @param uniform defines the webGL uniform location where to store the value
  130458. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  130459. */
  130460. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130461. /**
  130462. * Set the value of an uniform to a matrix (2x2)
  130463. * @param uniform defines the webGL uniform location where to store the value
  130464. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  130465. */
  130466. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130467. /**
  130468. * Set the value of an uniform to a number (float)
  130469. * @param uniform defines the webGL uniform location where to store the value
  130470. * @param value defines the float number to store
  130471. */
  130472. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130473. /**
  130474. * Set the value of an uniform to a vec2
  130475. * @param uniform defines the webGL uniform location where to store the value
  130476. * @param x defines the 1st component of the value
  130477. * @param y defines the 2nd component of the value
  130478. */
  130479. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130480. /**
  130481. * Set the value of an uniform to a vec3
  130482. * @param uniform defines the webGL uniform location where to store the value
  130483. * @param x defines the 1st component of the value
  130484. * @param y defines the 2nd component of the value
  130485. * @param z defines the 3rd component of the value
  130486. */
  130487. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130488. /**
  130489. * Set the value of an uniform to a boolean
  130490. * @param uniform defines the webGL uniform location where to store the value
  130491. * @param bool defines the boolean to store
  130492. */
  130493. setBool(uniform: WebGLUniformLocation, bool: number): void;
  130494. /**
  130495. * Set the value of an uniform to a vec4
  130496. * @param uniform defines the webGL uniform location where to store the value
  130497. * @param x defines the 1st component of the value
  130498. * @param y defines the 2nd component of the value
  130499. * @param z defines the 3rd component of the value
  130500. * @param w defines the 4th component of the value
  130501. */
  130502. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130503. /**
  130504. * Sets the current alpha mode
  130505. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130506. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130507. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130508. */
  130509. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130510. /**
  130511. * Bind webGl buffers directly to the webGL context
  130512. * @param vertexBuffers defines the vertex buffer to bind
  130513. * @param indexBuffer defines the index buffer to bind
  130514. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  130515. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  130516. * @param effect defines the effect associated with the vertex buffer
  130517. */
  130518. bindBuffers(vertexBuffers: {
  130519. [key: string]: VertexBuffer;
  130520. }, indexBuffer: DataBuffer, effect: Effect): void;
  130521. /**
  130522. * Force the entire cache to be cleared
  130523. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  130524. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130525. */
  130526. wipeCaches(bruteForce?: boolean): void;
  130527. /**
  130528. * Send a draw order
  130529. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  130530. * @param indexStart defines the starting index
  130531. * @param indexCount defines the number of index to draw
  130532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130533. */
  130534. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  130535. /**
  130536. * Draw a list of indexed primitives
  130537. * @param fillMode defines the primitive to use
  130538. * @param indexStart defines the starting index
  130539. * @param indexCount defines the number of index to draw
  130540. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130541. */
  130542. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130543. /**
  130544. * Draw a list of unindexed primitives
  130545. * @param fillMode defines the primitive to use
  130546. * @param verticesStart defines the index of first vertex to draw
  130547. * @param verticesCount defines the count of vertices to draw
  130548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130549. */
  130550. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130551. /** @hidden */
  130552. _createTexture(): WebGLTexture;
  130553. /** @hidden */
  130554. _releaseTexture(texture: InternalTexture): void;
  130555. /**
  130556. * Usually called from Texture.ts.
  130557. * Passed information to create a WebGLTexture
  130558. * @param urlArg defines a value which contains one of the following:
  130559. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130560. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130561. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130562. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130563. * @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)
  130564. * @param scene needed for loading to the correct scene
  130565. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130566. * @param onLoad optional callback to be called upon successful completion
  130567. * @param onError optional callback to be called upon failure
  130568. * @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
  130569. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130570. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130571. * @param forcedExtension defines the extension to use to pick the right loader
  130572. * @param mimeType defines an optional mime type
  130573. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130574. */
  130575. 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;
  130576. /**
  130577. * Creates a new render target texture
  130578. * @param size defines the size of the texture
  130579. * @param options defines the options used to create the texture
  130580. * @returns a new render target texture stored in an InternalTexture
  130581. */
  130582. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130583. /**
  130584. * Update the sampling mode of a given texture
  130585. * @param samplingMode defines the required sampling mode
  130586. * @param texture defines the texture to update
  130587. */
  130588. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130589. /**
  130590. * Binds the frame buffer to the specified texture.
  130591. * @param texture The texture to render to or null for the default canvas
  130592. * @param faceIndex The face of the texture to render to in case of cube texture
  130593. * @param requiredWidth The width of the target to render to
  130594. * @param requiredHeight The height of the target to render to
  130595. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130596. * @param lodLevel defines le lod level to bind to the frame buffer
  130597. */
  130598. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130599. /**
  130600. * Unbind the current render target texture from the webGL context
  130601. * @param texture defines the render target texture to unbind
  130602. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130603. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130604. */
  130605. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130606. /**
  130607. * Creates a dynamic vertex buffer
  130608. * @param vertices the data for the dynamic vertex buffer
  130609. * @returns the new WebGL dynamic buffer
  130610. */
  130611. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  130612. /**
  130613. * Update the content of a dynamic texture
  130614. * @param texture defines the texture to update
  130615. * @param canvas defines the canvas containing the source
  130616. * @param invertY defines if data must be stored with Y axis inverted
  130617. * @param premulAlpha defines if alpha is stored as premultiplied
  130618. * @param format defines the format of the data
  130619. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130620. */
  130621. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  130622. /**
  130623. * Gets a boolean indicating if all created effects are ready
  130624. * @returns true if all effects are ready
  130625. */
  130626. areAllEffectsReady(): boolean;
  130627. /**
  130628. * @hidden
  130629. * Get the current error code of the webGL context
  130630. * @returns the error code
  130631. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  130632. */
  130633. getError(): number;
  130634. /** @hidden */
  130635. _getUnpackAlignement(): number;
  130636. /** @hidden */
  130637. _unpackFlipY(value: boolean): void;
  130638. /**
  130639. * Update a dynamic index buffer
  130640. * @param indexBuffer defines the target index buffer
  130641. * @param indices defines the data to update
  130642. * @param offset defines the offset in the target index buffer where update should start
  130643. */
  130644. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  130645. /**
  130646. * Updates a dynamic vertex buffer.
  130647. * @param vertexBuffer the vertex buffer to update
  130648. * @param vertices the data used to update the vertex buffer
  130649. * @param byteOffset the byte offset of the data (optional)
  130650. * @param byteLength the byte length of the data (optional)
  130651. */
  130652. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  130653. /** @hidden */
  130654. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  130655. /** @hidden */
  130656. _bindTexture(channel: number, texture: InternalTexture): void;
  130657. protected _deleteBuffer(buffer: WebGLBuffer): void;
  130658. /**
  130659. * 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
  130660. */
  130661. releaseEffects(): void;
  130662. displayLoadingUI(): void;
  130663. hideLoadingUI(): void;
  130664. /** @hidden */
  130665. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130666. /** @hidden */
  130667. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130668. /** @hidden */
  130669. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130670. /** @hidden */
  130671. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130672. }
  130673. }
  130674. declare module BABYLON {
  130675. /**
  130676. * @hidden
  130677. **/
  130678. export class _TimeToken {
  130679. _startTimeQuery: Nullable<WebGLQuery>;
  130680. _endTimeQuery: Nullable<WebGLQuery>;
  130681. _timeElapsedQuery: Nullable<WebGLQuery>;
  130682. _timeElapsedQueryEnded: boolean;
  130683. }
  130684. }
  130685. declare module BABYLON {
  130686. /** @hidden */
  130687. export class _OcclusionDataStorage {
  130688. /** @hidden */
  130689. occlusionInternalRetryCounter: number;
  130690. /** @hidden */
  130691. isOcclusionQueryInProgress: boolean;
  130692. /** @hidden */
  130693. isOccluded: boolean;
  130694. /** @hidden */
  130695. occlusionRetryCount: number;
  130696. /** @hidden */
  130697. occlusionType: number;
  130698. /** @hidden */
  130699. occlusionQueryAlgorithmType: number;
  130700. }
  130701. interface Engine {
  130702. /**
  130703. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  130704. * @return the new query
  130705. */
  130706. createQuery(): WebGLQuery;
  130707. /**
  130708. * Delete and release a webGL query
  130709. * @param query defines the query to delete
  130710. * @return the current engine
  130711. */
  130712. deleteQuery(query: WebGLQuery): Engine;
  130713. /**
  130714. * Check if a given query has resolved and got its value
  130715. * @param query defines the query to check
  130716. * @returns true if the query got its value
  130717. */
  130718. isQueryResultAvailable(query: WebGLQuery): boolean;
  130719. /**
  130720. * Gets the value of a given query
  130721. * @param query defines the query to check
  130722. * @returns the value of the query
  130723. */
  130724. getQueryResult(query: WebGLQuery): number;
  130725. /**
  130726. * Initiates an occlusion query
  130727. * @param algorithmType defines the algorithm to use
  130728. * @param query defines the query to use
  130729. * @returns the current engine
  130730. * @see https://doc.babylonjs.com/features/occlusionquery
  130731. */
  130732. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  130733. /**
  130734. * Ends an occlusion query
  130735. * @see https://doc.babylonjs.com/features/occlusionquery
  130736. * @param algorithmType defines the algorithm to use
  130737. * @returns the current engine
  130738. */
  130739. endOcclusionQuery(algorithmType: number): Engine;
  130740. /**
  130741. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  130742. * Please note that only one query can be issued at a time
  130743. * @returns a time token used to track the time span
  130744. */
  130745. startTimeQuery(): Nullable<_TimeToken>;
  130746. /**
  130747. * Ends a time query
  130748. * @param token defines the token used to measure the time span
  130749. * @returns the time spent (in ns)
  130750. */
  130751. endTimeQuery(token: _TimeToken): int;
  130752. /** @hidden */
  130753. _currentNonTimestampToken: Nullable<_TimeToken>;
  130754. /** @hidden */
  130755. _createTimeQuery(): WebGLQuery;
  130756. /** @hidden */
  130757. _deleteTimeQuery(query: WebGLQuery): void;
  130758. /** @hidden */
  130759. _getGlAlgorithmType(algorithmType: number): number;
  130760. /** @hidden */
  130761. _getTimeQueryResult(query: WebGLQuery): any;
  130762. /** @hidden */
  130763. _getTimeQueryAvailability(query: WebGLQuery): any;
  130764. }
  130765. interface AbstractMesh {
  130766. /**
  130767. * Backing filed
  130768. * @hidden
  130769. */
  130770. __occlusionDataStorage: _OcclusionDataStorage;
  130771. /**
  130772. * Access property
  130773. * @hidden
  130774. */
  130775. _occlusionDataStorage: _OcclusionDataStorage;
  130776. /**
  130777. * 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.
  130778. * The default value is -1 which means don't break the query and wait till the result
  130779. * @see https://doc.babylonjs.com/features/occlusionquery
  130780. */
  130781. occlusionRetryCount: number;
  130782. /**
  130783. * 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:
  130784. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  130785. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  130786. * * 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.
  130787. * @see https://doc.babylonjs.com/features/occlusionquery
  130788. */
  130789. occlusionType: number;
  130790. /**
  130791. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  130792. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  130793. * * 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.
  130794. * @see https://doc.babylonjs.com/features/occlusionquery
  130795. */
  130796. occlusionQueryAlgorithmType: number;
  130797. /**
  130798. * 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
  130799. * @see https://doc.babylonjs.com/features/occlusionquery
  130800. */
  130801. isOccluded: boolean;
  130802. /**
  130803. * Flag to check the progress status of the query
  130804. * @see https://doc.babylonjs.com/features/occlusionquery
  130805. */
  130806. isOcclusionQueryInProgress: boolean;
  130807. }
  130808. }
  130809. declare module BABYLON {
  130810. /** @hidden */
  130811. export var _forceTransformFeedbackToBundle: boolean;
  130812. interface Engine {
  130813. /**
  130814. * Creates a webGL transform feedback object
  130815. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  130816. * @returns the webGL transform feedback object
  130817. */
  130818. createTransformFeedback(): WebGLTransformFeedback;
  130819. /**
  130820. * Delete a webGL transform feedback object
  130821. * @param value defines the webGL transform feedback object to delete
  130822. */
  130823. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  130824. /**
  130825. * Bind a webGL transform feedback object to the webgl context
  130826. * @param value defines the webGL transform feedback object to bind
  130827. */
  130828. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  130829. /**
  130830. * Begins a transform feedback operation
  130831. * @param usePoints defines if points or triangles must be used
  130832. */
  130833. beginTransformFeedback(usePoints: boolean): void;
  130834. /**
  130835. * Ends a transform feedback operation
  130836. */
  130837. endTransformFeedback(): void;
  130838. /**
  130839. * Specify the varyings to use with transform feedback
  130840. * @param program defines the associated webGL program
  130841. * @param value defines the list of strings representing the varying names
  130842. */
  130843. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  130844. /**
  130845. * Bind a webGL buffer for a transform feedback operation
  130846. * @param value defines the webGL buffer to bind
  130847. */
  130848. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  130849. }
  130850. }
  130851. declare module BABYLON {
  130852. /**
  130853. * Class used to define an additional view for the engine
  130854. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130855. */
  130856. export class EngineView {
  130857. /** Defines the canvas where to render the view */
  130858. target: HTMLCanvasElement;
  130859. /** Defines an optional camera used to render the view (will use active camera else) */
  130860. camera?: Camera;
  130861. }
  130862. interface Engine {
  130863. /**
  130864. * Gets or sets the HTML element to use for attaching events
  130865. */
  130866. inputElement: Nullable<HTMLElement>;
  130867. /**
  130868. * Gets the current engine view
  130869. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130870. */
  130871. activeView: Nullable<EngineView>;
  130872. /** Gets or sets the list of views */
  130873. views: EngineView[];
  130874. /**
  130875. * Register a new child canvas
  130876. * @param canvas defines the canvas to register
  130877. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  130878. * @returns the associated view
  130879. */
  130880. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  130881. /**
  130882. * Remove a registered child canvas
  130883. * @param canvas defines the canvas to remove
  130884. * @returns the current engine
  130885. */
  130886. unRegisterView(canvas: HTMLCanvasElement): Engine;
  130887. }
  130888. }
  130889. declare module BABYLON {
  130890. interface Engine {
  130891. /** @hidden */
  130892. _excludedCompressedTextures: string[];
  130893. /** @hidden */
  130894. _textureFormatInUse: string;
  130895. /**
  130896. * Gets the list of texture formats supported
  130897. */
  130898. readonly texturesSupported: Array<string>;
  130899. /**
  130900. * Gets the texture format in use
  130901. */
  130902. readonly textureFormatInUse: Nullable<string>;
  130903. /**
  130904. * Set the compressed texture extensions or file names to skip.
  130905. *
  130906. * @param skippedFiles defines the list of those texture files you want to skip
  130907. * Example: [".dds", ".env", "myfile.png"]
  130908. */
  130909. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  130910. /**
  130911. * Set the compressed texture format to use, based on the formats you have, and the formats
  130912. * supported by the hardware / browser.
  130913. *
  130914. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  130915. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  130916. * to API arguments needed to compressed textures. This puts the burden on the container
  130917. * generator to house the arcane code for determining these for current & future formats.
  130918. *
  130919. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  130920. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  130921. *
  130922. * Note: The result of this call is not taken into account when a texture is base64.
  130923. *
  130924. * @param formatsAvailable defines the list of those format families you have created
  130925. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  130926. *
  130927. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  130928. * @returns The extension selected.
  130929. */
  130930. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  130931. }
  130932. }
  130933. declare module BABYLON {
  130934. /**
  130935. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  130936. */
  130937. export interface CubeMapInfo {
  130938. /**
  130939. * The pixel array for the front face.
  130940. * This is stored in format, left to right, up to down format.
  130941. */
  130942. front: Nullable<ArrayBufferView>;
  130943. /**
  130944. * The pixel array for the back face.
  130945. * This is stored in format, left to right, up to down format.
  130946. */
  130947. back: Nullable<ArrayBufferView>;
  130948. /**
  130949. * The pixel array for the left face.
  130950. * This is stored in format, left to right, up to down format.
  130951. */
  130952. left: Nullable<ArrayBufferView>;
  130953. /**
  130954. * The pixel array for the right face.
  130955. * This is stored in format, left to right, up to down format.
  130956. */
  130957. right: Nullable<ArrayBufferView>;
  130958. /**
  130959. * The pixel array for the up face.
  130960. * This is stored in format, left to right, up to down format.
  130961. */
  130962. up: Nullable<ArrayBufferView>;
  130963. /**
  130964. * The pixel array for the down face.
  130965. * This is stored in format, left to right, up to down format.
  130966. */
  130967. down: Nullable<ArrayBufferView>;
  130968. /**
  130969. * The size of the cubemap stored.
  130970. *
  130971. * Each faces will be size * size pixels.
  130972. */
  130973. size: number;
  130974. /**
  130975. * The format of the texture.
  130976. *
  130977. * RGBA, RGB.
  130978. */
  130979. format: number;
  130980. /**
  130981. * The type of the texture data.
  130982. *
  130983. * UNSIGNED_INT, FLOAT.
  130984. */
  130985. type: number;
  130986. /**
  130987. * Specifies whether the texture is in gamma space.
  130988. */
  130989. gammaSpace: boolean;
  130990. }
  130991. /**
  130992. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  130993. */
  130994. export class PanoramaToCubeMapTools {
  130995. private static FACE_LEFT;
  130996. private static FACE_RIGHT;
  130997. private static FACE_FRONT;
  130998. private static FACE_BACK;
  130999. private static FACE_DOWN;
  131000. private static FACE_UP;
  131001. /**
  131002. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131003. *
  131004. * @param float32Array The source data.
  131005. * @param inputWidth The width of the input panorama.
  131006. * @param inputHeight The height of the input panorama.
  131007. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131008. * @return The cubemap data
  131009. */
  131010. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131011. private static CreateCubemapTexture;
  131012. private static CalcProjectionSpherical;
  131013. }
  131014. }
  131015. declare module BABYLON {
  131016. /**
  131017. * Helper class dealing with the extraction of spherical polynomial dataArray
  131018. * from a cube map.
  131019. */
  131020. export class CubeMapToSphericalPolynomialTools {
  131021. private static FileFaces;
  131022. /**
  131023. * Converts a texture to the according Spherical Polynomial data.
  131024. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131025. *
  131026. * @param texture The texture to extract the information from.
  131027. * @return The Spherical Polynomial data.
  131028. */
  131029. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  131030. /**
  131031. * Converts a cubemap to the according Spherical Polynomial data.
  131032. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131033. *
  131034. * @param cubeInfo The Cube map to extract the information from.
  131035. * @return The Spherical Polynomial data.
  131036. */
  131037. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  131038. }
  131039. }
  131040. declare module BABYLON {
  131041. interface BaseTexture {
  131042. /**
  131043. * Get the polynomial representation of the texture data.
  131044. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  131045. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  131046. */
  131047. sphericalPolynomial: Nullable<SphericalPolynomial>;
  131048. }
  131049. }
  131050. declare module BABYLON {
  131051. /** @hidden */
  131052. export var rgbdEncodePixelShader: {
  131053. name: string;
  131054. shader: string;
  131055. };
  131056. }
  131057. declare module BABYLON {
  131058. /** @hidden */
  131059. export var rgbdDecodePixelShader: {
  131060. name: string;
  131061. shader: string;
  131062. };
  131063. }
  131064. declare module BABYLON {
  131065. /**
  131066. * Raw texture data and descriptor sufficient for WebGL texture upload
  131067. */
  131068. export interface EnvironmentTextureInfo {
  131069. /**
  131070. * Version of the environment map
  131071. */
  131072. version: number;
  131073. /**
  131074. * Width of image
  131075. */
  131076. width: number;
  131077. /**
  131078. * Irradiance information stored in the file.
  131079. */
  131080. irradiance: any;
  131081. /**
  131082. * Specular information stored in the file.
  131083. */
  131084. specular: any;
  131085. }
  131086. /**
  131087. * Defines One Image in the file. It requires only the position in the file
  131088. * as well as the length.
  131089. */
  131090. interface BufferImageData {
  131091. /**
  131092. * Length of the image data.
  131093. */
  131094. length: number;
  131095. /**
  131096. * Position of the data from the null terminator delimiting the end of the JSON.
  131097. */
  131098. position: number;
  131099. }
  131100. /**
  131101. * Defines the specular data enclosed in the file.
  131102. * This corresponds to the version 1 of the data.
  131103. */
  131104. export interface EnvironmentTextureSpecularInfoV1 {
  131105. /**
  131106. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  131107. */
  131108. specularDataPosition?: number;
  131109. /**
  131110. * This contains all the images data needed to reconstruct the cubemap.
  131111. */
  131112. mipmaps: Array<BufferImageData>;
  131113. /**
  131114. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  131115. */
  131116. lodGenerationScale: number;
  131117. }
  131118. /**
  131119. * Sets of helpers addressing the serialization and deserialization of environment texture
  131120. * stored in a BabylonJS env file.
  131121. * Those files are usually stored as .env files.
  131122. */
  131123. export class EnvironmentTextureTools {
  131124. /**
  131125. * Magic number identifying the env file.
  131126. */
  131127. private static _MagicBytes;
  131128. /**
  131129. * Gets the environment info from an env file.
  131130. * @param data The array buffer containing the .env bytes.
  131131. * @returns the environment file info (the json header) if successfully parsed.
  131132. */
  131133. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  131134. /**
  131135. * Creates an environment texture from a loaded cube texture.
  131136. * @param texture defines the cube texture to convert in env file
  131137. * @return a promise containing the environment data if succesfull.
  131138. */
  131139. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  131140. /**
  131141. * Creates a JSON representation of the spherical data.
  131142. * @param texture defines the texture containing the polynomials
  131143. * @return the JSON representation of the spherical info
  131144. */
  131145. private static _CreateEnvTextureIrradiance;
  131146. /**
  131147. * Creates the ArrayBufferViews used for initializing environment texture image data.
  131148. * @param data the image data
  131149. * @param info parameters that determine what views will be created for accessing the underlying buffer
  131150. * @return the views described by info providing access to the underlying buffer
  131151. */
  131152. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  131153. /**
  131154. * Uploads the texture info contained in the env file to the GPU.
  131155. * @param texture defines the internal texture to upload to
  131156. * @param data defines the data to load
  131157. * @param info defines the texture info retrieved through the GetEnvInfo method
  131158. * @returns a promise
  131159. */
  131160. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  131161. private static _OnImageReadyAsync;
  131162. /**
  131163. * Uploads the levels of image data to the GPU.
  131164. * @param texture defines the internal texture to upload to
  131165. * @param imageData defines the array buffer views of image data [mipmap][face]
  131166. * @returns a promise
  131167. */
  131168. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  131169. /**
  131170. * Uploads spherical polynomials information to the texture.
  131171. * @param texture defines the texture we are trying to upload the information to
  131172. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  131173. */
  131174. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  131175. /** @hidden */
  131176. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131177. }
  131178. }
  131179. declare module BABYLON {
  131180. /**
  131181. * Class used to inline functions in shader code
  131182. */
  131183. export class ShaderCodeInliner {
  131184. private static readonly _RegexpFindFunctionNameAndType;
  131185. private _sourceCode;
  131186. private _functionDescr;
  131187. private _numMaxIterations;
  131188. /** Gets or sets the token used to mark the functions to inline */
  131189. inlineToken: string;
  131190. /** Gets or sets the debug mode */
  131191. debug: boolean;
  131192. /** Gets the code after the inlining process */
  131193. get code(): string;
  131194. /**
  131195. * Initializes the inliner
  131196. * @param sourceCode shader code source to inline
  131197. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  131198. */
  131199. constructor(sourceCode: string, numMaxIterations?: number);
  131200. /**
  131201. * Start the processing of the shader code
  131202. */
  131203. processCode(): void;
  131204. private _collectFunctions;
  131205. private _processInlining;
  131206. private _extractBetweenMarkers;
  131207. private _skipWhitespaces;
  131208. private _removeComments;
  131209. private _replaceFunctionCallsByCode;
  131210. private _findBackward;
  131211. private _escapeRegExp;
  131212. private _replaceNames;
  131213. }
  131214. }
  131215. declare module BABYLON {
  131216. /**
  131217. * Container for accessors for natively-stored mesh data buffers.
  131218. */
  131219. class NativeDataBuffer extends DataBuffer {
  131220. /**
  131221. * Accessor value used to identify/retrieve a natively-stored index buffer.
  131222. */
  131223. nativeIndexBuffer?: any;
  131224. /**
  131225. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  131226. */
  131227. nativeVertexBuffer?: any;
  131228. }
  131229. /** @hidden */
  131230. class NativeTexture extends InternalTexture {
  131231. getInternalTexture(): InternalTexture;
  131232. getViewCount(): number;
  131233. }
  131234. /** @hidden */
  131235. export class NativeEngine extends Engine {
  131236. private readonly _native;
  131237. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  131238. private readonly INVALID_HANDLE;
  131239. getHardwareScalingLevel(): number;
  131240. constructor();
  131241. dispose(): void;
  131242. /**
  131243. * Can be used to override the current requestAnimationFrame requester.
  131244. * @hidden
  131245. */
  131246. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  131247. /**
  131248. * Override default engine behavior.
  131249. * @param color
  131250. * @param backBuffer
  131251. * @param depth
  131252. * @param stencil
  131253. */
  131254. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  131255. /**
  131256. * Gets host document
  131257. * @returns the host document object
  131258. */
  131259. getHostDocument(): Nullable<Document>;
  131260. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131261. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  131262. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  131263. recordVertexArrayObject(vertexBuffers: {
  131264. [key: string]: VertexBuffer;
  131265. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  131266. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131267. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131268. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131269. /**
  131270. * Draw a list of indexed primitives
  131271. * @param fillMode defines the primitive to use
  131272. * @param indexStart defines the starting index
  131273. * @param indexCount defines the number of index to draw
  131274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131275. */
  131276. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131277. /**
  131278. * Draw a list of unindexed primitives
  131279. * @param fillMode defines the primitive to use
  131280. * @param verticesStart defines the index of first vertex to draw
  131281. * @param verticesCount defines the count of vertices to draw
  131282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131283. */
  131284. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131285. createPipelineContext(): IPipelineContext;
  131286. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  131287. /** @hidden */
  131288. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131289. /** @hidden */
  131290. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131291. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131292. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131293. protected _setProgram(program: WebGLProgram): void;
  131294. _releaseEffect(effect: Effect): void;
  131295. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131296. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  131297. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131298. bindSamplers(effect: Effect): void;
  131299. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  131300. getRenderWidth(useScreen?: boolean): number;
  131301. getRenderHeight(useScreen?: boolean): number;
  131302. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  131303. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131304. /**
  131305. * Set the z offset to apply to current rendering
  131306. * @param value defines the offset to apply
  131307. */
  131308. setZOffset(value: number): void;
  131309. /**
  131310. * Gets the current value of the zOffset
  131311. * @returns the current zOffset state
  131312. */
  131313. getZOffset(): number;
  131314. /**
  131315. * Enable or disable depth buffering
  131316. * @param enable defines the state to set
  131317. */
  131318. setDepthBuffer(enable: boolean): void;
  131319. /**
  131320. * Gets a boolean indicating if depth writing is enabled
  131321. * @returns the current depth writing state
  131322. */
  131323. getDepthWrite(): boolean;
  131324. /**
  131325. * Enable or disable depth writing
  131326. * @param enable defines the state to set
  131327. */
  131328. setDepthWrite(enable: boolean): void;
  131329. /**
  131330. * Enable or disable color writing
  131331. * @param enable defines the state to set
  131332. */
  131333. setColorWrite(enable: boolean): void;
  131334. /**
  131335. * Gets a boolean indicating if color writing is enabled
  131336. * @returns the current color writing state
  131337. */
  131338. getColorWrite(): boolean;
  131339. /**
  131340. * Sets alpha constants used by some alpha blending modes
  131341. * @param r defines the red component
  131342. * @param g defines the green component
  131343. * @param b defines the blue component
  131344. * @param a defines the alpha component
  131345. */
  131346. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  131347. /**
  131348. * Sets the current alpha mode
  131349. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  131350. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131351. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131352. */
  131353. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131354. /**
  131355. * Gets the current alpha mode
  131356. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131357. * @returns the current alpha mode
  131358. */
  131359. getAlphaMode(): number;
  131360. setInt(uniform: WebGLUniformLocation, int: number): void;
  131361. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131362. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131363. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131364. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131365. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131366. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131367. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131368. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131369. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131370. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131371. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131372. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131373. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131374. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131375. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131376. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131377. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131378. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131379. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131380. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  131381. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  131382. wipeCaches(bruteForce?: boolean): void;
  131383. _createTexture(): WebGLTexture;
  131384. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  131385. /**
  131386. * Usually called from Texture.ts.
  131387. * Passed information to create a WebGLTexture
  131388. * @param url defines a value which contains one of the following:
  131389. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131390. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131391. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131392. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131393. * @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)
  131394. * @param scene needed for loading to the correct scene
  131395. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131396. * @param onLoad optional callback to be called upon successful completion
  131397. * @param onError optional callback to be called upon failure
  131398. * @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
  131399. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131400. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131401. * @param forcedExtension defines the extension to use to pick the right loader
  131402. * @param mimeType defines an optional mime type
  131403. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131404. */
  131405. 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;
  131406. /**
  131407. * Creates a cube texture
  131408. * @param rootUrl defines the url where the files to load is located
  131409. * @param scene defines the current scene
  131410. * @param files defines the list of files to load (1 per face)
  131411. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  131412. * @param onLoad defines an optional callback raised when the texture is loaded
  131413. * @param onError defines an optional callback raised if there is an issue to load the texture
  131414. * @param format defines the format of the data
  131415. * @param forcedExtension defines the extension to use to pick the right loader
  131416. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  131417. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131418. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131419. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  131420. * @returns the cube texture as an InternalTexture
  131421. */
  131422. 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;
  131423. private _getSamplingFilter;
  131424. private static _GetNativeTextureFormat;
  131425. createRenderTargetTexture(size: number | {
  131426. width: number;
  131427. height: number;
  131428. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  131429. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131430. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131431. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131432. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  131433. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  131434. /**
  131435. * Updates a dynamic vertex buffer.
  131436. * @param vertexBuffer the vertex buffer to update
  131437. * @param data the data used to update the vertex buffer
  131438. * @param byteOffset the byte offset of the data (optional)
  131439. * @param byteLength the byte length of the data (optional)
  131440. */
  131441. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  131442. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  131443. private _updateAnisotropicLevel;
  131444. private _getAddressMode;
  131445. /** @hidden */
  131446. _bindTexture(channel: number, texture: InternalTexture): void;
  131447. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  131448. releaseEffects(): void;
  131449. /** @hidden */
  131450. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131451. /** @hidden */
  131452. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131453. /** @hidden */
  131454. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131455. /** @hidden */
  131456. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131457. }
  131458. }
  131459. declare module BABYLON {
  131460. /**
  131461. * Gather the list of clipboard event types as constants.
  131462. */
  131463. export class ClipboardEventTypes {
  131464. /**
  131465. * The clipboard event is fired when a copy command is active (pressed).
  131466. */
  131467. static readonly COPY: number;
  131468. /**
  131469. * The clipboard event is fired when a cut command is active (pressed).
  131470. */
  131471. static readonly CUT: number;
  131472. /**
  131473. * The clipboard event is fired when a paste command is active (pressed).
  131474. */
  131475. static readonly PASTE: number;
  131476. }
  131477. /**
  131478. * This class is used to store clipboard related info for the onClipboardObservable event.
  131479. */
  131480. export class ClipboardInfo {
  131481. /**
  131482. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131483. */
  131484. type: number;
  131485. /**
  131486. * Defines the related dom event
  131487. */
  131488. event: ClipboardEvent;
  131489. /**
  131490. *Creates an instance of ClipboardInfo.
  131491. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  131492. * @param event Defines the related dom event
  131493. */
  131494. constructor(
  131495. /**
  131496. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131497. */
  131498. type: number,
  131499. /**
  131500. * Defines the related dom event
  131501. */
  131502. event: ClipboardEvent);
  131503. /**
  131504. * Get the clipboard event's type from the keycode.
  131505. * @param keyCode Defines the keyCode for the current keyboard event.
  131506. * @return {number}
  131507. */
  131508. static GetTypeFromCharacter(keyCode: number): number;
  131509. }
  131510. }
  131511. declare module BABYLON {
  131512. /**
  131513. * Google Daydream controller
  131514. */
  131515. export class DaydreamController extends WebVRController {
  131516. /**
  131517. * Base Url for the controller model.
  131518. */
  131519. static MODEL_BASE_URL: string;
  131520. /**
  131521. * File name for the controller model.
  131522. */
  131523. static MODEL_FILENAME: string;
  131524. /**
  131525. * Gamepad Id prefix used to identify Daydream Controller.
  131526. */
  131527. static readonly GAMEPAD_ID_PREFIX: string;
  131528. /**
  131529. * Creates a new DaydreamController from a gamepad
  131530. * @param vrGamepad the gamepad that the controller should be created from
  131531. */
  131532. constructor(vrGamepad: any);
  131533. /**
  131534. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131535. * @param scene scene in which to add meshes
  131536. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131537. */
  131538. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131539. /**
  131540. * Called once for each button that changed state since the last frame
  131541. * @param buttonIdx Which button index changed
  131542. * @param state New state of the button
  131543. * @param changes Which properties on the state changed since last frame
  131544. */
  131545. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131546. }
  131547. }
  131548. declare module BABYLON {
  131549. /**
  131550. * Gear VR Controller
  131551. */
  131552. export class GearVRController extends WebVRController {
  131553. /**
  131554. * Base Url for the controller model.
  131555. */
  131556. static MODEL_BASE_URL: string;
  131557. /**
  131558. * File name for the controller model.
  131559. */
  131560. static MODEL_FILENAME: string;
  131561. /**
  131562. * Gamepad Id prefix used to identify this controller.
  131563. */
  131564. static readonly GAMEPAD_ID_PREFIX: string;
  131565. private readonly _buttonIndexToObservableNameMap;
  131566. /**
  131567. * Creates a new GearVRController from a gamepad
  131568. * @param vrGamepad the gamepad that the controller should be created from
  131569. */
  131570. constructor(vrGamepad: any);
  131571. /**
  131572. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131573. * @param scene scene in which to add meshes
  131574. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131575. */
  131576. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131577. /**
  131578. * Called once for each button that changed state since the last frame
  131579. * @param buttonIdx Which button index changed
  131580. * @param state New state of the button
  131581. * @param changes Which properties on the state changed since last frame
  131582. */
  131583. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131584. }
  131585. }
  131586. declare module BABYLON {
  131587. /**
  131588. * Generic Controller
  131589. */
  131590. export class GenericController extends WebVRController {
  131591. /**
  131592. * Base Url for the controller model.
  131593. */
  131594. static readonly MODEL_BASE_URL: string;
  131595. /**
  131596. * File name for the controller model.
  131597. */
  131598. static readonly MODEL_FILENAME: string;
  131599. /**
  131600. * Creates a new GenericController from a gamepad
  131601. * @param vrGamepad the gamepad that the controller should be created from
  131602. */
  131603. constructor(vrGamepad: any);
  131604. /**
  131605. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131606. * @param scene scene in which to add meshes
  131607. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131608. */
  131609. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131610. /**
  131611. * Called once for each button that changed state since the last frame
  131612. * @param buttonIdx Which button index changed
  131613. * @param state New state of the button
  131614. * @param changes Which properties on the state changed since last frame
  131615. */
  131616. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131617. }
  131618. }
  131619. declare module BABYLON {
  131620. /**
  131621. * Oculus Touch Controller
  131622. */
  131623. export class OculusTouchController extends WebVRController {
  131624. /**
  131625. * Base Url for the controller model.
  131626. */
  131627. static MODEL_BASE_URL: string;
  131628. /**
  131629. * File name for the left controller model.
  131630. */
  131631. static MODEL_LEFT_FILENAME: string;
  131632. /**
  131633. * File name for the right controller model.
  131634. */
  131635. static MODEL_RIGHT_FILENAME: string;
  131636. /**
  131637. * Base Url for the Quest controller model.
  131638. */
  131639. static QUEST_MODEL_BASE_URL: string;
  131640. /**
  131641. * @hidden
  131642. * If the controllers are running on a device that needs the updated Quest controller models
  131643. */
  131644. static _IsQuest: boolean;
  131645. /**
  131646. * Fired when the secondary trigger on this controller is modified
  131647. */
  131648. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  131649. /**
  131650. * Fired when the thumb rest on this controller is modified
  131651. */
  131652. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  131653. /**
  131654. * Creates a new OculusTouchController from a gamepad
  131655. * @param vrGamepad the gamepad that the controller should be created from
  131656. */
  131657. constructor(vrGamepad: any);
  131658. /**
  131659. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131660. * @param scene scene in which to add meshes
  131661. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131662. */
  131663. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131664. /**
  131665. * Fired when the A button on this controller is modified
  131666. */
  131667. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131668. /**
  131669. * Fired when the B button on this controller is modified
  131670. */
  131671. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131672. /**
  131673. * Fired when the X button on this controller is modified
  131674. */
  131675. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131676. /**
  131677. * Fired when the Y button on this controller is modified
  131678. */
  131679. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131680. /**
  131681. * Called once for each button that changed state since the last frame
  131682. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  131683. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  131684. * 2) secondary trigger (same)
  131685. * 3) A (right) X (left), touch, pressed = value
  131686. * 4) B / Y
  131687. * 5) thumb rest
  131688. * @param buttonIdx Which button index changed
  131689. * @param state New state of the button
  131690. * @param changes Which properties on the state changed since last frame
  131691. */
  131692. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131693. }
  131694. }
  131695. declare module BABYLON {
  131696. /**
  131697. * Vive Controller
  131698. */
  131699. export class ViveController extends WebVRController {
  131700. /**
  131701. * Base Url for the controller model.
  131702. */
  131703. static MODEL_BASE_URL: string;
  131704. /**
  131705. * File name for the controller model.
  131706. */
  131707. static MODEL_FILENAME: string;
  131708. /**
  131709. * Creates a new ViveController from a gamepad
  131710. * @param vrGamepad the gamepad that the controller should be created from
  131711. */
  131712. constructor(vrGamepad: any);
  131713. /**
  131714. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131715. * @param scene scene in which to add meshes
  131716. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131717. */
  131718. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131719. /**
  131720. * Fired when the left button on this controller is modified
  131721. */
  131722. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131723. /**
  131724. * Fired when the right button on this controller is modified
  131725. */
  131726. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131727. /**
  131728. * Fired when the menu button on this controller is modified
  131729. */
  131730. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131731. /**
  131732. * Called once for each button that changed state since the last frame
  131733. * Vive mapping:
  131734. * 0: touchpad
  131735. * 1: trigger
  131736. * 2: left AND right buttons
  131737. * 3: menu button
  131738. * @param buttonIdx Which button index changed
  131739. * @param state New state of the button
  131740. * @param changes Which properties on the state changed since last frame
  131741. */
  131742. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131743. }
  131744. }
  131745. declare module BABYLON {
  131746. /**
  131747. * Defines the WindowsMotionController object that the state of the windows motion controller
  131748. */
  131749. export class WindowsMotionController extends WebVRController {
  131750. /**
  131751. * The base url used to load the left and right controller models
  131752. */
  131753. static MODEL_BASE_URL: string;
  131754. /**
  131755. * The name of the left controller model file
  131756. */
  131757. static MODEL_LEFT_FILENAME: string;
  131758. /**
  131759. * The name of the right controller model file
  131760. */
  131761. static MODEL_RIGHT_FILENAME: string;
  131762. /**
  131763. * The controller name prefix for this controller type
  131764. */
  131765. static readonly GAMEPAD_ID_PREFIX: string;
  131766. /**
  131767. * The controller id pattern for this controller type
  131768. */
  131769. private static readonly GAMEPAD_ID_PATTERN;
  131770. private _loadedMeshInfo;
  131771. protected readonly _mapping: {
  131772. buttons: string[];
  131773. buttonMeshNames: {
  131774. trigger: string;
  131775. menu: string;
  131776. grip: string;
  131777. thumbstick: string;
  131778. trackpad: string;
  131779. };
  131780. buttonObservableNames: {
  131781. trigger: string;
  131782. menu: string;
  131783. grip: string;
  131784. thumbstick: string;
  131785. trackpad: string;
  131786. };
  131787. axisMeshNames: string[];
  131788. pointingPoseMeshName: string;
  131789. };
  131790. /**
  131791. * Fired when the trackpad on this controller is clicked
  131792. */
  131793. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131794. /**
  131795. * Fired when the trackpad on this controller is modified
  131796. */
  131797. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131798. /**
  131799. * The current x and y values of this controller's trackpad
  131800. */
  131801. trackpad: StickValues;
  131802. /**
  131803. * Creates a new WindowsMotionController from a gamepad
  131804. * @param vrGamepad the gamepad that the controller should be created from
  131805. */
  131806. constructor(vrGamepad: any);
  131807. /**
  131808. * Fired when the trigger on this controller is modified
  131809. */
  131810. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131811. /**
  131812. * Fired when the menu button on this controller is modified
  131813. */
  131814. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131815. /**
  131816. * Fired when the grip button on this controller is modified
  131817. */
  131818. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131819. /**
  131820. * Fired when the thumbstick button on this controller is modified
  131821. */
  131822. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131823. /**
  131824. * Fired when the touchpad button on this controller is modified
  131825. */
  131826. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131827. /**
  131828. * Fired when the touchpad values on this controller are modified
  131829. */
  131830. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  131831. protected _updateTrackpad(): void;
  131832. /**
  131833. * Called once per frame by the engine.
  131834. */
  131835. update(): void;
  131836. /**
  131837. * Called once for each button that changed state since the last frame
  131838. * @param buttonIdx Which button index changed
  131839. * @param state New state of the button
  131840. * @param changes Which properties on the state changed since last frame
  131841. */
  131842. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131843. /**
  131844. * Moves the buttons on the controller mesh based on their current state
  131845. * @param buttonName the name of the button to move
  131846. * @param buttonValue the value of the button which determines the buttons new position
  131847. */
  131848. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  131849. /**
  131850. * Moves the axis on the controller mesh based on its current state
  131851. * @param axis the index of the axis
  131852. * @param axisValue the value of the axis which determines the meshes new position
  131853. * @hidden
  131854. */
  131855. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  131856. /**
  131857. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131858. * @param scene scene in which to add meshes
  131859. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131860. */
  131861. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  131862. /**
  131863. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  131864. * can be transformed by button presses and axes values, based on this._mapping.
  131865. *
  131866. * @param scene scene in which the meshes exist
  131867. * @param meshes list of meshes that make up the controller model to process
  131868. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  131869. */
  131870. private processModel;
  131871. private createMeshInfo;
  131872. /**
  131873. * Gets the ray of the controller in the direction the controller is pointing
  131874. * @param length the length the resulting ray should be
  131875. * @returns a ray in the direction the controller is pointing
  131876. */
  131877. getForwardRay(length?: number): Ray;
  131878. /**
  131879. * Disposes of the controller
  131880. */
  131881. dispose(): void;
  131882. }
  131883. /**
  131884. * This class represents a new windows motion controller in XR.
  131885. */
  131886. export class XRWindowsMotionController extends WindowsMotionController {
  131887. /**
  131888. * Changing the original WIndowsMotionController mapping to fir the new mapping
  131889. */
  131890. protected readonly _mapping: {
  131891. buttons: string[];
  131892. buttonMeshNames: {
  131893. trigger: string;
  131894. menu: string;
  131895. grip: string;
  131896. thumbstick: string;
  131897. trackpad: string;
  131898. };
  131899. buttonObservableNames: {
  131900. trigger: string;
  131901. menu: string;
  131902. grip: string;
  131903. thumbstick: string;
  131904. trackpad: string;
  131905. };
  131906. axisMeshNames: string[];
  131907. pointingPoseMeshName: string;
  131908. };
  131909. /**
  131910. * Construct a new XR-Based windows motion controller
  131911. *
  131912. * @param gamepadInfo the gamepad object from the browser
  131913. */
  131914. constructor(gamepadInfo: any);
  131915. /**
  131916. * holds the thumbstick values (X,Y)
  131917. */
  131918. thumbstickValues: StickValues;
  131919. /**
  131920. * Fired when the thumbstick on this controller is clicked
  131921. */
  131922. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  131923. /**
  131924. * Fired when the thumbstick on this controller is modified
  131925. */
  131926. onThumbstickValuesChangedObservable: Observable<StickValues>;
  131927. /**
  131928. * Fired when the touchpad button on this controller is modified
  131929. */
  131930. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131931. /**
  131932. * Fired when the touchpad values on this controller are modified
  131933. */
  131934. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131935. /**
  131936. * Fired when the thumbstick button on this controller is modified
  131937. * here to prevent breaking changes
  131938. */
  131939. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131940. /**
  131941. * updating the thumbstick(!) and not the trackpad.
  131942. * This is named this way due to the difference between WebVR and XR and to avoid
  131943. * changing the parent class.
  131944. */
  131945. protected _updateTrackpad(): void;
  131946. /**
  131947. * Disposes the class with joy
  131948. */
  131949. dispose(): void;
  131950. }
  131951. }
  131952. declare module BABYLON {
  131953. /**
  131954. * Class containing static functions to help procedurally build meshes
  131955. */
  131956. export class PolyhedronBuilder {
  131957. /**
  131958. * Creates a polyhedron mesh
  131959. * * 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
  131960. * * The parameter `size` (positive float, default 1) sets the polygon size
  131961. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  131962. * * 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`
  131963. * * 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
  131964. * * 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)`)
  131965. * * 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
  131966. * * 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
  131967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131970. * @param name defines the name of the mesh
  131971. * @param options defines the options used to create the mesh
  131972. * @param scene defines the hosting scene
  131973. * @returns the polyhedron mesh
  131974. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  131975. */
  131976. static CreatePolyhedron(name: string, options: {
  131977. type?: number;
  131978. size?: number;
  131979. sizeX?: number;
  131980. sizeY?: number;
  131981. sizeZ?: number;
  131982. custom?: any;
  131983. faceUV?: Vector4[];
  131984. faceColors?: Color4[];
  131985. flat?: boolean;
  131986. updatable?: boolean;
  131987. sideOrientation?: number;
  131988. frontUVs?: Vector4;
  131989. backUVs?: Vector4;
  131990. }, scene?: Nullable<Scene>): Mesh;
  131991. }
  131992. }
  131993. declare module BABYLON {
  131994. /**
  131995. * Gizmo that enables scaling a mesh along 3 axis
  131996. */
  131997. export class ScaleGizmo extends Gizmo {
  131998. /**
  131999. * Internal gizmo used for interactions on the x axis
  132000. */
  132001. xGizmo: AxisScaleGizmo;
  132002. /**
  132003. * Internal gizmo used for interactions on the y axis
  132004. */
  132005. yGizmo: AxisScaleGizmo;
  132006. /**
  132007. * Internal gizmo used for interactions on the z axis
  132008. */
  132009. zGizmo: AxisScaleGizmo;
  132010. /**
  132011. * Internal gizmo used to scale all axis equally
  132012. */
  132013. uniformScaleGizmo: AxisScaleGizmo;
  132014. private _meshAttached;
  132015. private _nodeAttached;
  132016. private _updateGizmoRotationToMatchAttachedMesh;
  132017. private _snapDistance;
  132018. private _scaleRatio;
  132019. private _uniformScalingMesh;
  132020. private _octahedron;
  132021. private _sensitivity;
  132022. /** Fires an event when any of it's sub gizmos are dragged */
  132023. onDragStartObservable: Observable<unknown>;
  132024. /** Fires an event when any of it's sub gizmos are released from dragging */
  132025. onDragEndObservable: Observable<unknown>;
  132026. get attachedMesh(): Nullable<AbstractMesh>;
  132027. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132028. get attachedNode(): Nullable<Node>;
  132029. set attachedNode(node: Nullable<Node>);
  132030. /**
  132031. * Creates a ScaleGizmo
  132032. * @param gizmoLayer The utility layer the gizmo will be added to
  132033. * @param thickness display gizmo axis thickness
  132034. */
  132035. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  132036. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132037. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132038. /**
  132039. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132040. */
  132041. set snapDistance(value: number);
  132042. get snapDistance(): number;
  132043. /**
  132044. * Ratio for the scale of the gizmo (Default: 1)
  132045. */
  132046. set scaleRatio(value: number);
  132047. get scaleRatio(): number;
  132048. /**
  132049. * Sensitivity factor for dragging (Default: 1)
  132050. */
  132051. set sensitivity(value: number);
  132052. get sensitivity(): number;
  132053. /**
  132054. * Disposes of the gizmo
  132055. */
  132056. dispose(): void;
  132057. }
  132058. }
  132059. declare module BABYLON {
  132060. /**
  132061. * Single axis scale gizmo
  132062. */
  132063. export class AxisScaleGizmo extends Gizmo {
  132064. /**
  132065. * Drag behavior responsible for the gizmos dragging interactions
  132066. */
  132067. dragBehavior: PointerDragBehavior;
  132068. private _pointerObserver;
  132069. /**
  132070. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132071. */
  132072. snapDistance: number;
  132073. /**
  132074. * Event that fires each time the gizmo snaps to a new location.
  132075. * * snapDistance is the the change in distance
  132076. */
  132077. onSnapObservable: Observable<{
  132078. snapDistance: number;
  132079. }>;
  132080. /**
  132081. * If the scaling operation should be done on all axis (default: false)
  132082. */
  132083. uniformScaling: boolean;
  132084. /**
  132085. * Custom sensitivity value for the drag strength
  132086. */
  132087. sensitivity: number;
  132088. private _isEnabled;
  132089. private _parent;
  132090. private _arrow;
  132091. private _coloredMaterial;
  132092. private _hoverMaterial;
  132093. /**
  132094. * Creates an AxisScaleGizmo
  132095. * @param gizmoLayer The utility layer the gizmo will be added to
  132096. * @param dragAxis The axis which the gizmo will be able to scale on
  132097. * @param color The color of the gizmo
  132098. * @param thickness display gizmo axis thickness
  132099. */
  132100. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  132101. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132102. /**
  132103. * If the gizmo is enabled
  132104. */
  132105. set isEnabled(value: boolean);
  132106. get isEnabled(): boolean;
  132107. /**
  132108. * Disposes of the gizmo
  132109. */
  132110. dispose(): void;
  132111. /**
  132112. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  132113. * @param mesh The mesh to replace the default mesh of the gizmo
  132114. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  132115. */
  132116. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  132117. }
  132118. }
  132119. declare module BABYLON {
  132120. /**
  132121. * Bounding box gizmo
  132122. */
  132123. export class BoundingBoxGizmo extends Gizmo {
  132124. private _lineBoundingBox;
  132125. private _rotateSpheresParent;
  132126. private _scaleBoxesParent;
  132127. private _boundingDimensions;
  132128. private _renderObserver;
  132129. private _pointerObserver;
  132130. private _scaleDragSpeed;
  132131. private _tmpQuaternion;
  132132. private _tmpVector;
  132133. private _tmpRotationMatrix;
  132134. /**
  132135. * 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)
  132136. */
  132137. ignoreChildren: boolean;
  132138. /**
  132139. * 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)
  132140. */
  132141. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  132142. /**
  132143. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  132144. */
  132145. rotationSphereSize: number;
  132146. /**
  132147. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  132148. */
  132149. scaleBoxSize: number;
  132150. /**
  132151. * 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)
  132152. */
  132153. fixedDragMeshScreenSize: boolean;
  132154. /**
  132155. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  132156. */
  132157. fixedDragMeshScreenSizeDistanceFactor: number;
  132158. /**
  132159. * Fired when a rotation sphere or scale box is dragged
  132160. */
  132161. onDragStartObservable: Observable<{}>;
  132162. /**
  132163. * Fired when a scale box is dragged
  132164. */
  132165. onScaleBoxDragObservable: Observable<{}>;
  132166. /**
  132167. * Fired when a scale box drag is ended
  132168. */
  132169. onScaleBoxDragEndObservable: Observable<{}>;
  132170. /**
  132171. * Fired when a rotation sphere is dragged
  132172. */
  132173. onRotationSphereDragObservable: Observable<{}>;
  132174. /**
  132175. * Fired when a rotation sphere drag is ended
  132176. */
  132177. onRotationSphereDragEndObservable: Observable<{}>;
  132178. /**
  132179. * 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)
  132180. */
  132181. scalePivot: Nullable<Vector3>;
  132182. /**
  132183. * Mesh used as a pivot to rotate the attached node
  132184. */
  132185. private _anchorMesh;
  132186. private _existingMeshScale;
  132187. private _dragMesh;
  132188. private pointerDragBehavior;
  132189. private coloredMaterial;
  132190. private hoverColoredMaterial;
  132191. /**
  132192. * Sets the color of the bounding box gizmo
  132193. * @param color the color to set
  132194. */
  132195. setColor(color: Color3): void;
  132196. /**
  132197. * Creates an BoundingBoxGizmo
  132198. * @param gizmoLayer The utility layer the gizmo will be added to
  132199. * @param color The color of the gizmo
  132200. */
  132201. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  132202. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  132203. private _selectNode;
  132204. /**
  132205. * Updates the bounding box information for the Gizmo
  132206. */
  132207. updateBoundingBox(): void;
  132208. private _updateRotationSpheres;
  132209. private _updateScaleBoxes;
  132210. /**
  132211. * Enables rotation on the specified axis and disables rotation on the others
  132212. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  132213. */
  132214. setEnabledRotationAxis(axis: string): void;
  132215. /**
  132216. * Enables/disables scaling
  132217. * @param enable if scaling should be enabled
  132218. * @param homogeneousScaling defines if scaling should only be homogeneous
  132219. */
  132220. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  132221. private _updateDummy;
  132222. /**
  132223. * Enables a pointer drag behavior on the bounding box of the gizmo
  132224. */
  132225. enableDragBehavior(): void;
  132226. /**
  132227. * Disposes of the gizmo
  132228. */
  132229. dispose(): void;
  132230. /**
  132231. * 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)
  132232. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  132233. * @returns the bounding box mesh with the passed in mesh as a child
  132234. */
  132235. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  132236. /**
  132237. * CustomMeshes are not supported by this gizmo
  132238. * @param mesh The mesh to replace the default mesh of the gizmo
  132239. */
  132240. setCustomMesh(mesh: Mesh): void;
  132241. }
  132242. }
  132243. declare module BABYLON {
  132244. /**
  132245. * Single plane rotation gizmo
  132246. */
  132247. export class PlaneRotationGizmo extends Gizmo {
  132248. /**
  132249. * Drag behavior responsible for the gizmos dragging interactions
  132250. */
  132251. dragBehavior: PointerDragBehavior;
  132252. private _pointerObserver;
  132253. /**
  132254. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  132255. */
  132256. snapDistance: number;
  132257. /**
  132258. * Event that fires each time the gizmo snaps to a new location.
  132259. * * snapDistance is the the change in distance
  132260. */
  132261. onSnapObservable: Observable<{
  132262. snapDistance: number;
  132263. }>;
  132264. private _isEnabled;
  132265. private _parent;
  132266. /**
  132267. * Creates a PlaneRotationGizmo
  132268. * @param gizmoLayer The utility layer the gizmo will be added to
  132269. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  132270. * @param color The color of the gizmo
  132271. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132272. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132273. * @param thickness display gizmo axis thickness
  132274. */
  132275. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  132276. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132277. /**
  132278. * If the gizmo is enabled
  132279. */
  132280. set isEnabled(value: boolean);
  132281. get isEnabled(): boolean;
  132282. /**
  132283. * Disposes of the gizmo
  132284. */
  132285. dispose(): void;
  132286. }
  132287. }
  132288. declare module BABYLON {
  132289. /**
  132290. * Gizmo that enables rotating a mesh along 3 axis
  132291. */
  132292. export class RotationGizmo extends Gizmo {
  132293. /**
  132294. * Internal gizmo used for interactions on the x axis
  132295. */
  132296. xGizmo: PlaneRotationGizmo;
  132297. /**
  132298. * Internal gizmo used for interactions on the y axis
  132299. */
  132300. yGizmo: PlaneRotationGizmo;
  132301. /**
  132302. * Internal gizmo used for interactions on the z axis
  132303. */
  132304. zGizmo: PlaneRotationGizmo;
  132305. /** Fires an event when any of it's sub gizmos are dragged */
  132306. onDragStartObservable: Observable<unknown>;
  132307. /** Fires an event when any of it's sub gizmos are released from dragging */
  132308. onDragEndObservable: Observable<unknown>;
  132309. private _meshAttached;
  132310. private _nodeAttached;
  132311. get attachedMesh(): Nullable<AbstractMesh>;
  132312. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132313. get attachedNode(): Nullable<Node>;
  132314. set attachedNode(node: Nullable<Node>);
  132315. /**
  132316. * Creates a RotationGizmo
  132317. * @param gizmoLayer The utility layer the gizmo will be added to
  132318. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132319. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132320. * @param thickness display gizmo axis thickness
  132321. */
  132322. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  132323. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132324. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132325. /**
  132326. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132327. */
  132328. set snapDistance(value: number);
  132329. get snapDistance(): number;
  132330. /**
  132331. * Ratio for the scale of the gizmo (Default: 1)
  132332. */
  132333. set scaleRatio(value: number);
  132334. get scaleRatio(): number;
  132335. /**
  132336. * Disposes of the gizmo
  132337. */
  132338. dispose(): void;
  132339. /**
  132340. * CustomMeshes are not supported by this gizmo
  132341. * @param mesh The mesh to replace the default mesh of the gizmo
  132342. */
  132343. setCustomMesh(mesh: Mesh): void;
  132344. }
  132345. }
  132346. declare module BABYLON {
  132347. /**
  132348. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  132349. */
  132350. export class GizmoManager implements IDisposable {
  132351. private scene;
  132352. /**
  132353. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  132354. */
  132355. gizmos: {
  132356. positionGizmo: Nullable<PositionGizmo>;
  132357. rotationGizmo: Nullable<RotationGizmo>;
  132358. scaleGizmo: Nullable<ScaleGizmo>;
  132359. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  132360. };
  132361. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  132362. clearGizmoOnEmptyPointerEvent: boolean;
  132363. /** Fires an event when the manager is attached to a mesh */
  132364. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  132365. private _gizmosEnabled;
  132366. private _pointerObserver;
  132367. private _attachedMesh;
  132368. private _boundingBoxColor;
  132369. private _defaultUtilityLayer;
  132370. private _defaultKeepDepthUtilityLayer;
  132371. private _thickness;
  132372. /**
  132373. * When bounding box gizmo is enabled, this can be used to track drag/end events
  132374. */
  132375. boundingBoxDragBehavior: SixDofDragBehavior;
  132376. /**
  132377. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  132378. */
  132379. attachableMeshes: Nullable<Array<AbstractMesh>>;
  132380. /**
  132381. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  132382. */
  132383. usePointerToAttachGizmos: boolean;
  132384. /**
  132385. * Utility layer that the bounding box gizmo belongs to
  132386. */
  132387. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  132388. /**
  132389. * Utility layer that all gizmos besides bounding box belong to
  132390. */
  132391. get utilityLayer(): UtilityLayerRenderer;
  132392. /**
  132393. * Instatiates a gizmo manager
  132394. * @param scene the scene to overlay the gizmos on top of
  132395. * @param thickness display gizmo axis thickness
  132396. */
  132397. constructor(scene: Scene, thickness?: number);
  132398. /**
  132399. * Attaches a set of gizmos to the specified mesh
  132400. * @param mesh The mesh the gizmo's should be attached to
  132401. */
  132402. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132403. /**
  132404. * If the position gizmo is enabled
  132405. */
  132406. set positionGizmoEnabled(value: boolean);
  132407. get positionGizmoEnabled(): boolean;
  132408. /**
  132409. * If the rotation gizmo is enabled
  132410. */
  132411. set rotationGizmoEnabled(value: boolean);
  132412. get rotationGizmoEnabled(): boolean;
  132413. /**
  132414. * If the scale gizmo is enabled
  132415. */
  132416. set scaleGizmoEnabled(value: boolean);
  132417. get scaleGizmoEnabled(): boolean;
  132418. /**
  132419. * If the boundingBox gizmo is enabled
  132420. */
  132421. set boundingBoxGizmoEnabled(value: boolean);
  132422. get boundingBoxGizmoEnabled(): boolean;
  132423. /**
  132424. * Disposes of the gizmo manager
  132425. */
  132426. dispose(): void;
  132427. }
  132428. }
  132429. declare module BABYLON {
  132430. /**
  132431. * A directional light is defined by a direction (what a surprise!).
  132432. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  132433. * 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.
  132434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132435. */
  132436. export class DirectionalLight extends ShadowLight {
  132437. private _shadowFrustumSize;
  132438. /**
  132439. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  132440. */
  132441. get shadowFrustumSize(): number;
  132442. /**
  132443. * Specifies a fix frustum size for the shadow generation.
  132444. */
  132445. set shadowFrustumSize(value: number);
  132446. private _shadowOrthoScale;
  132447. /**
  132448. * Gets the shadow projection scale against the optimal computed one.
  132449. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132450. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132451. */
  132452. get shadowOrthoScale(): number;
  132453. /**
  132454. * Sets the shadow projection scale against the optimal computed one.
  132455. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132456. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132457. */
  132458. set shadowOrthoScale(value: number);
  132459. /**
  132460. * Automatically compute the projection matrix to best fit (including all the casters)
  132461. * on each frame.
  132462. */
  132463. autoUpdateExtends: boolean;
  132464. /**
  132465. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  132466. * on each frame. autoUpdateExtends must be set to true for this to work
  132467. */
  132468. autoCalcShadowZBounds: boolean;
  132469. private _orthoLeft;
  132470. private _orthoRight;
  132471. private _orthoTop;
  132472. private _orthoBottom;
  132473. /**
  132474. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  132475. * The directional light is emitted from everywhere in the given direction.
  132476. * It can cast shadows.
  132477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132478. * @param name The friendly name of the light
  132479. * @param direction The direction of the light
  132480. * @param scene The scene the light belongs to
  132481. */
  132482. constructor(name: string, direction: Vector3, scene: Scene);
  132483. /**
  132484. * Returns the string "DirectionalLight".
  132485. * @return The class name
  132486. */
  132487. getClassName(): string;
  132488. /**
  132489. * Returns the integer 1.
  132490. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132491. */
  132492. getTypeID(): number;
  132493. /**
  132494. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  132495. * Returns the DirectionalLight Shadow projection matrix.
  132496. */
  132497. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132498. /**
  132499. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  132500. * Returns the DirectionalLight Shadow projection matrix.
  132501. */
  132502. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  132503. /**
  132504. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  132505. * Returns the DirectionalLight Shadow projection matrix.
  132506. */
  132507. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132508. protected _buildUniformLayout(): void;
  132509. /**
  132510. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  132511. * @param effect The effect to update
  132512. * @param lightIndex The index of the light in the effect to update
  132513. * @returns The directional light
  132514. */
  132515. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  132516. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  132517. /**
  132518. * Gets the minZ used for shadow according to both the scene and the light.
  132519. *
  132520. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132521. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132522. * @param activeCamera The camera we are returning the min for
  132523. * @returns the depth min z
  132524. */
  132525. getDepthMinZ(activeCamera: Camera): number;
  132526. /**
  132527. * Gets the maxZ used for shadow according to both the scene and the light.
  132528. *
  132529. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132530. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132531. * @param activeCamera The camera we are returning the max for
  132532. * @returns the depth max z
  132533. */
  132534. getDepthMaxZ(activeCamera: Camera): number;
  132535. /**
  132536. * Prepares the list of defines specific to the light type.
  132537. * @param defines the list of defines
  132538. * @param lightIndex defines the index of the light for the effect
  132539. */
  132540. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132541. }
  132542. }
  132543. declare module BABYLON {
  132544. /**
  132545. * Class containing static functions to help procedurally build meshes
  132546. */
  132547. export class HemisphereBuilder {
  132548. /**
  132549. * Creates a hemisphere mesh
  132550. * @param name defines the name of the mesh
  132551. * @param options defines the options used to create the mesh
  132552. * @param scene defines the hosting scene
  132553. * @returns the hemisphere mesh
  132554. */
  132555. static CreateHemisphere(name: string, options: {
  132556. segments?: number;
  132557. diameter?: number;
  132558. sideOrientation?: number;
  132559. }, scene: any): Mesh;
  132560. }
  132561. }
  132562. declare module BABYLON {
  132563. /**
  132564. * A spot light is defined by a position, a direction, an angle, and an exponent.
  132565. * These values define a cone of light starting from the position, emitting toward the direction.
  132566. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  132567. * and the exponent defines the speed of the decay of the light with distance (reach).
  132568. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132569. */
  132570. export class SpotLight extends ShadowLight {
  132571. private _angle;
  132572. private _innerAngle;
  132573. private _cosHalfAngle;
  132574. private _lightAngleScale;
  132575. private _lightAngleOffset;
  132576. /**
  132577. * Gets the cone angle of the spot light in Radians.
  132578. */
  132579. get angle(): number;
  132580. /**
  132581. * Sets the cone angle of the spot light in Radians.
  132582. */
  132583. set angle(value: number);
  132584. /**
  132585. * Only used in gltf falloff mode, this defines the angle where
  132586. * the directional falloff will start before cutting at angle which could be seen
  132587. * as outer angle.
  132588. */
  132589. get innerAngle(): number;
  132590. /**
  132591. * Only used in gltf falloff mode, this defines the angle where
  132592. * the directional falloff will start before cutting at angle which could be seen
  132593. * as outer angle.
  132594. */
  132595. set innerAngle(value: number);
  132596. private _shadowAngleScale;
  132597. /**
  132598. * Allows scaling the angle of the light for shadow generation only.
  132599. */
  132600. get shadowAngleScale(): number;
  132601. /**
  132602. * Allows scaling the angle of the light for shadow generation only.
  132603. */
  132604. set shadowAngleScale(value: number);
  132605. /**
  132606. * The light decay speed with the distance from the emission spot.
  132607. */
  132608. exponent: number;
  132609. private _projectionTextureMatrix;
  132610. /**
  132611. * Allows reading the projecton texture
  132612. */
  132613. get projectionTextureMatrix(): Matrix;
  132614. protected _projectionTextureLightNear: number;
  132615. /**
  132616. * Gets the near clip of the Spotlight for texture projection.
  132617. */
  132618. get projectionTextureLightNear(): number;
  132619. /**
  132620. * Sets the near clip of the Spotlight for texture projection.
  132621. */
  132622. set projectionTextureLightNear(value: number);
  132623. protected _projectionTextureLightFar: number;
  132624. /**
  132625. * Gets the far clip of the Spotlight for texture projection.
  132626. */
  132627. get projectionTextureLightFar(): number;
  132628. /**
  132629. * Sets the far clip of the Spotlight for texture projection.
  132630. */
  132631. set projectionTextureLightFar(value: number);
  132632. protected _projectionTextureUpDirection: Vector3;
  132633. /**
  132634. * Gets the Up vector of the Spotlight for texture projection.
  132635. */
  132636. get projectionTextureUpDirection(): Vector3;
  132637. /**
  132638. * Sets the Up vector of the Spotlight for texture projection.
  132639. */
  132640. set projectionTextureUpDirection(value: Vector3);
  132641. private _projectionTexture;
  132642. /**
  132643. * Gets the projection texture of the light.
  132644. */
  132645. get projectionTexture(): Nullable<BaseTexture>;
  132646. /**
  132647. * Sets the projection texture of the light.
  132648. */
  132649. set projectionTexture(value: Nullable<BaseTexture>);
  132650. private _projectionTextureViewLightDirty;
  132651. private _projectionTextureProjectionLightDirty;
  132652. private _projectionTextureDirty;
  132653. private _projectionTextureViewTargetVector;
  132654. private _projectionTextureViewLightMatrix;
  132655. private _projectionTextureProjectionLightMatrix;
  132656. private _projectionTextureScalingMatrix;
  132657. /**
  132658. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  132659. * It can cast shadows.
  132660. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132661. * @param name The light friendly name
  132662. * @param position The position of the spot light in the scene
  132663. * @param direction The direction of the light in the scene
  132664. * @param angle The cone angle of the light in Radians
  132665. * @param exponent The light decay speed with the distance from the emission spot
  132666. * @param scene The scene the lights belongs to
  132667. */
  132668. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  132669. /**
  132670. * Returns the string "SpotLight".
  132671. * @returns the class name
  132672. */
  132673. getClassName(): string;
  132674. /**
  132675. * Returns the integer 2.
  132676. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132677. */
  132678. getTypeID(): number;
  132679. /**
  132680. * Overrides the direction setter to recompute the projection texture view light Matrix.
  132681. */
  132682. protected _setDirection(value: Vector3): void;
  132683. /**
  132684. * Overrides the position setter to recompute the projection texture view light Matrix.
  132685. */
  132686. protected _setPosition(value: Vector3): void;
  132687. /**
  132688. * 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.
  132689. * Returns the SpotLight.
  132690. */
  132691. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132692. protected _computeProjectionTextureViewLightMatrix(): void;
  132693. protected _computeProjectionTextureProjectionLightMatrix(): void;
  132694. /**
  132695. * Main function for light texture projection matrix computing.
  132696. */
  132697. protected _computeProjectionTextureMatrix(): void;
  132698. protected _buildUniformLayout(): void;
  132699. private _computeAngleValues;
  132700. /**
  132701. * Sets the passed Effect "effect" with the Light textures.
  132702. * @param effect The effect to update
  132703. * @param lightIndex The index of the light in the effect to update
  132704. * @returns The light
  132705. */
  132706. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  132707. /**
  132708. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  132709. * @param effect The effect to update
  132710. * @param lightIndex The index of the light in the effect to update
  132711. * @returns The spot light
  132712. */
  132713. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  132714. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  132715. /**
  132716. * Disposes the light and the associated resources.
  132717. */
  132718. dispose(): void;
  132719. /**
  132720. * Prepares the list of defines specific to the light type.
  132721. * @param defines the list of defines
  132722. * @param lightIndex defines the index of the light for the effect
  132723. */
  132724. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132725. }
  132726. }
  132727. declare module BABYLON {
  132728. /**
  132729. * Gizmo that enables viewing a light
  132730. */
  132731. export class LightGizmo extends Gizmo {
  132732. private _lightMesh;
  132733. private _material;
  132734. private _cachedPosition;
  132735. private _cachedForward;
  132736. private _attachedMeshParent;
  132737. /**
  132738. * Creates a LightGizmo
  132739. * @param gizmoLayer The utility layer the gizmo will be added to
  132740. */
  132741. constructor(gizmoLayer?: UtilityLayerRenderer);
  132742. private _light;
  132743. /**
  132744. * The light that the gizmo is attached to
  132745. */
  132746. set light(light: Nullable<Light>);
  132747. get light(): Nullable<Light>;
  132748. /**
  132749. * Gets the material used to render the light gizmo
  132750. */
  132751. get material(): StandardMaterial;
  132752. /**
  132753. * @hidden
  132754. * Updates the gizmo to match the attached mesh's position/rotation
  132755. */
  132756. protected _update(): void;
  132757. private static _Scale;
  132758. /**
  132759. * Creates the lines for a light mesh
  132760. */
  132761. private static _CreateLightLines;
  132762. /**
  132763. * Disposes of the light gizmo
  132764. */
  132765. dispose(): void;
  132766. private static _CreateHemisphericLightMesh;
  132767. private static _CreatePointLightMesh;
  132768. private static _CreateSpotLightMesh;
  132769. private static _CreateDirectionalLightMesh;
  132770. }
  132771. }
  132772. declare module BABYLON {
  132773. /** @hidden */
  132774. export var backgroundFragmentDeclaration: {
  132775. name: string;
  132776. shader: string;
  132777. };
  132778. }
  132779. declare module BABYLON {
  132780. /** @hidden */
  132781. export var backgroundUboDeclaration: {
  132782. name: string;
  132783. shader: string;
  132784. };
  132785. }
  132786. declare module BABYLON {
  132787. /** @hidden */
  132788. export var backgroundPixelShader: {
  132789. name: string;
  132790. shader: string;
  132791. };
  132792. }
  132793. declare module BABYLON {
  132794. /** @hidden */
  132795. export var backgroundVertexDeclaration: {
  132796. name: string;
  132797. shader: string;
  132798. };
  132799. }
  132800. declare module BABYLON {
  132801. /** @hidden */
  132802. export var backgroundVertexShader: {
  132803. name: string;
  132804. shader: string;
  132805. };
  132806. }
  132807. declare module BABYLON {
  132808. /**
  132809. * Background material used to create an efficient environement around your scene.
  132810. */
  132811. export class BackgroundMaterial extends PushMaterial {
  132812. /**
  132813. * Standard reflectance value at parallel view angle.
  132814. */
  132815. static StandardReflectance0: number;
  132816. /**
  132817. * Standard reflectance value at grazing angle.
  132818. */
  132819. static StandardReflectance90: number;
  132820. protected _primaryColor: Color3;
  132821. /**
  132822. * Key light Color (multiply against the environement texture)
  132823. */
  132824. primaryColor: Color3;
  132825. protected __perceptualColor: Nullable<Color3>;
  132826. /**
  132827. * Experimental Internal Use Only.
  132828. *
  132829. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  132830. * This acts as a helper to set the primary color to a more "human friendly" value.
  132831. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  132832. * output color as close as possible from the chosen value.
  132833. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  132834. * part of lighting setup.)
  132835. */
  132836. get _perceptualColor(): Nullable<Color3>;
  132837. set _perceptualColor(value: Nullable<Color3>);
  132838. protected _primaryColorShadowLevel: float;
  132839. /**
  132840. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  132841. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  132842. */
  132843. get primaryColorShadowLevel(): float;
  132844. set primaryColorShadowLevel(value: float);
  132845. protected _primaryColorHighlightLevel: float;
  132846. /**
  132847. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  132848. * The primary color is used at the level chosen to define what the white area would look.
  132849. */
  132850. get primaryColorHighlightLevel(): float;
  132851. set primaryColorHighlightLevel(value: float);
  132852. protected _reflectionTexture: Nullable<BaseTexture>;
  132853. /**
  132854. * Reflection Texture used in the material.
  132855. * Should be author in a specific way for the best result (refer to the documentation).
  132856. */
  132857. reflectionTexture: Nullable<BaseTexture>;
  132858. protected _reflectionBlur: float;
  132859. /**
  132860. * Reflection Texture level of blur.
  132861. *
  132862. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  132863. * texture twice.
  132864. */
  132865. reflectionBlur: float;
  132866. protected _diffuseTexture: Nullable<BaseTexture>;
  132867. /**
  132868. * Diffuse Texture used in the material.
  132869. * Should be author in a specific way for the best result (refer to the documentation).
  132870. */
  132871. diffuseTexture: Nullable<BaseTexture>;
  132872. protected _shadowLights: Nullable<IShadowLight[]>;
  132873. /**
  132874. * Specify the list of lights casting shadow on the material.
  132875. * All scene shadow lights will be included if null.
  132876. */
  132877. shadowLights: Nullable<IShadowLight[]>;
  132878. protected _shadowLevel: float;
  132879. /**
  132880. * Helps adjusting the shadow to a softer level if required.
  132881. * 0 means black shadows and 1 means no shadows.
  132882. */
  132883. shadowLevel: float;
  132884. protected _sceneCenter: Vector3;
  132885. /**
  132886. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  132887. * It is usually zero but might be interesting to modify according to your setup.
  132888. */
  132889. sceneCenter: Vector3;
  132890. protected _opacityFresnel: boolean;
  132891. /**
  132892. * This helps specifying that the material is falling off to the sky box at grazing angle.
  132893. * This helps ensuring a nice transition when the camera goes under the ground.
  132894. */
  132895. opacityFresnel: boolean;
  132896. protected _reflectionFresnel: boolean;
  132897. /**
  132898. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  132899. * This helps adding a mirror texture on the ground.
  132900. */
  132901. reflectionFresnel: boolean;
  132902. protected _reflectionFalloffDistance: number;
  132903. /**
  132904. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  132905. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  132906. */
  132907. reflectionFalloffDistance: number;
  132908. protected _reflectionAmount: number;
  132909. /**
  132910. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  132911. */
  132912. reflectionAmount: number;
  132913. protected _reflectionReflectance0: number;
  132914. /**
  132915. * This specifies the weight of the reflection at grazing angle.
  132916. */
  132917. reflectionReflectance0: number;
  132918. protected _reflectionReflectance90: number;
  132919. /**
  132920. * This specifies the weight of the reflection at a perpendicular point of view.
  132921. */
  132922. reflectionReflectance90: number;
  132923. /**
  132924. * Sets the reflection reflectance fresnel values according to the default standard
  132925. * empirically know to work well :-)
  132926. */
  132927. set reflectionStandardFresnelWeight(value: number);
  132928. protected _useRGBColor: boolean;
  132929. /**
  132930. * Helps to directly use the maps channels instead of their level.
  132931. */
  132932. useRGBColor: boolean;
  132933. protected _enableNoise: boolean;
  132934. /**
  132935. * This helps reducing the banding effect that could occur on the background.
  132936. */
  132937. enableNoise: boolean;
  132938. /**
  132939. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132940. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  132941. * Recommended to be keep at 1.0 except for special cases.
  132942. */
  132943. get fovMultiplier(): number;
  132944. set fovMultiplier(value: number);
  132945. private _fovMultiplier;
  132946. /**
  132947. * Enable the FOV adjustment feature controlled by fovMultiplier.
  132948. */
  132949. useEquirectangularFOV: boolean;
  132950. private _maxSimultaneousLights;
  132951. /**
  132952. * Number of Simultaneous lights allowed on the material.
  132953. */
  132954. maxSimultaneousLights: int;
  132955. private _shadowOnly;
  132956. /**
  132957. * Make the material only render shadows
  132958. */
  132959. shadowOnly: boolean;
  132960. /**
  132961. * Default configuration related to image processing available in the Background Material.
  132962. */
  132963. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132964. /**
  132965. * Keep track of the image processing observer to allow dispose and replace.
  132966. */
  132967. private _imageProcessingObserver;
  132968. /**
  132969. * Attaches a new image processing configuration to the PBR Material.
  132970. * @param configuration (if null the scene configuration will be use)
  132971. */
  132972. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132973. /**
  132974. * Gets the image processing configuration used either in this material.
  132975. */
  132976. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  132977. /**
  132978. * Sets the Default image processing configuration used either in the this material.
  132979. *
  132980. * If sets to null, the scene one is in use.
  132981. */
  132982. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  132983. /**
  132984. * Gets wether the color curves effect is enabled.
  132985. */
  132986. get cameraColorCurvesEnabled(): boolean;
  132987. /**
  132988. * Sets wether the color curves effect is enabled.
  132989. */
  132990. set cameraColorCurvesEnabled(value: boolean);
  132991. /**
  132992. * Gets wether the color grading effect is enabled.
  132993. */
  132994. get cameraColorGradingEnabled(): boolean;
  132995. /**
  132996. * Gets wether the color grading effect is enabled.
  132997. */
  132998. set cameraColorGradingEnabled(value: boolean);
  132999. /**
  133000. * Gets wether tonemapping is enabled or not.
  133001. */
  133002. get cameraToneMappingEnabled(): boolean;
  133003. /**
  133004. * Sets wether tonemapping is enabled or not
  133005. */
  133006. set cameraToneMappingEnabled(value: boolean);
  133007. /**
  133008. * The camera exposure used on this material.
  133009. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133010. * This corresponds to a photographic exposure.
  133011. */
  133012. get cameraExposure(): float;
  133013. /**
  133014. * The camera exposure used on this material.
  133015. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133016. * This corresponds to a photographic exposure.
  133017. */
  133018. set cameraExposure(value: float);
  133019. /**
  133020. * Gets The camera contrast used on this material.
  133021. */
  133022. get cameraContrast(): float;
  133023. /**
  133024. * Sets The camera contrast used on this material.
  133025. */
  133026. set cameraContrast(value: float);
  133027. /**
  133028. * Gets the Color Grading 2D Lookup Texture.
  133029. */
  133030. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133031. /**
  133032. * Sets the Color Grading 2D Lookup Texture.
  133033. */
  133034. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133035. /**
  133036. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133037. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133038. * 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;
  133039. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133040. */
  133041. get cameraColorCurves(): Nullable<ColorCurves>;
  133042. /**
  133043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133045. * 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;
  133046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133047. */
  133048. set cameraColorCurves(value: Nullable<ColorCurves>);
  133049. /**
  133050. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  133051. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  133052. */
  133053. switchToBGR: boolean;
  133054. private _renderTargets;
  133055. private _reflectionControls;
  133056. private _white;
  133057. private _primaryShadowColor;
  133058. private _primaryHighlightColor;
  133059. /**
  133060. * Instantiates a Background Material in the given scene
  133061. * @param name The friendly name of the material
  133062. * @param scene The scene to add the material to
  133063. */
  133064. constructor(name: string, scene: Scene);
  133065. /**
  133066. * Gets a boolean indicating that current material needs to register RTT
  133067. */
  133068. get hasRenderTargetTextures(): boolean;
  133069. /**
  133070. * The entire material has been created in order to prevent overdraw.
  133071. * @returns false
  133072. */
  133073. needAlphaTesting(): boolean;
  133074. /**
  133075. * The entire material has been created in order to prevent overdraw.
  133076. * @returns true if blending is enable
  133077. */
  133078. needAlphaBlending(): boolean;
  133079. /**
  133080. * Checks wether the material is ready to be rendered for a given mesh.
  133081. * @param mesh The mesh to render
  133082. * @param subMesh The submesh to check against
  133083. * @param useInstances Specify wether or not the material is used with instances
  133084. * @returns true if all the dependencies are ready (Textures, Effects...)
  133085. */
  133086. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133087. /**
  133088. * Compute the primary color according to the chosen perceptual color.
  133089. */
  133090. private _computePrimaryColorFromPerceptualColor;
  133091. /**
  133092. * Compute the highlights and shadow colors according to their chosen levels.
  133093. */
  133094. private _computePrimaryColors;
  133095. /**
  133096. * Build the uniform buffer used in the material.
  133097. */
  133098. buildUniformLayout(): void;
  133099. /**
  133100. * Unbind the material.
  133101. */
  133102. unbind(): void;
  133103. /**
  133104. * Bind only the world matrix to the material.
  133105. * @param world The world matrix to bind.
  133106. */
  133107. bindOnlyWorldMatrix(world: Matrix): void;
  133108. /**
  133109. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  133110. * @param world The world matrix to bind.
  133111. * @param subMesh The submesh to bind for.
  133112. */
  133113. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133114. /**
  133115. * Checks to see if a texture is used in the material.
  133116. * @param texture - Base texture to use.
  133117. * @returns - Boolean specifying if a texture is used in the material.
  133118. */
  133119. hasTexture(texture: BaseTexture): boolean;
  133120. /**
  133121. * Dispose the material.
  133122. * @param forceDisposeEffect Force disposal of the associated effect.
  133123. * @param forceDisposeTextures Force disposal of the associated textures.
  133124. */
  133125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133126. /**
  133127. * Clones the material.
  133128. * @param name The cloned name.
  133129. * @returns The cloned material.
  133130. */
  133131. clone(name: string): BackgroundMaterial;
  133132. /**
  133133. * Serializes the current material to its JSON representation.
  133134. * @returns The JSON representation.
  133135. */
  133136. serialize(): any;
  133137. /**
  133138. * Gets the class name of the material
  133139. * @returns "BackgroundMaterial"
  133140. */
  133141. getClassName(): string;
  133142. /**
  133143. * Parse a JSON input to create back a background material.
  133144. * @param source The JSON data to parse
  133145. * @param scene The scene to create the parsed material in
  133146. * @param rootUrl The root url of the assets the material depends upon
  133147. * @returns the instantiated BackgroundMaterial.
  133148. */
  133149. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  133150. }
  133151. }
  133152. declare module BABYLON {
  133153. /**
  133154. * Represents the different options available during the creation of
  133155. * a Environment helper.
  133156. *
  133157. * This can control the default ground, skybox and image processing setup of your scene.
  133158. */
  133159. export interface IEnvironmentHelperOptions {
  133160. /**
  133161. * Specifies whether or not to create a ground.
  133162. * True by default.
  133163. */
  133164. createGround: boolean;
  133165. /**
  133166. * Specifies the ground size.
  133167. * 15 by default.
  133168. */
  133169. groundSize: number;
  133170. /**
  133171. * The texture used on the ground for the main color.
  133172. * Comes from the BabylonJS CDN by default.
  133173. *
  133174. * Remarks: Can be either a texture or a url.
  133175. */
  133176. groundTexture: string | BaseTexture;
  133177. /**
  133178. * The color mixed in the ground texture by default.
  133179. * BabylonJS clearColor by default.
  133180. */
  133181. groundColor: Color3;
  133182. /**
  133183. * Specifies the ground opacity.
  133184. * 1 by default.
  133185. */
  133186. groundOpacity: number;
  133187. /**
  133188. * Enables the ground to receive shadows.
  133189. * True by default.
  133190. */
  133191. enableGroundShadow: boolean;
  133192. /**
  133193. * Helps preventing the shadow to be fully black on the ground.
  133194. * 0.5 by default.
  133195. */
  133196. groundShadowLevel: number;
  133197. /**
  133198. * Creates a mirror texture attach to the ground.
  133199. * false by default.
  133200. */
  133201. enableGroundMirror: boolean;
  133202. /**
  133203. * Specifies the ground mirror size ratio.
  133204. * 0.3 by default as the default kernel is 64.
  133205. */
  133206. groundMirrorSizeRatio: number;
  133207. /**
  133208. * Specifies the ground mirror blur kernel size.
  133209. * 64 by default.
  133210. */
  133211. groundMirrorBlurKernel: number;
  133212. /**
  133213. * Specifies the ground mirror visibility amount.
  133214. * 1 by default
  133215. */
  133216. groundMirrorAmount: number;
  133217. /**
  133218. * Specifies the ground mirror reflectance weight.
  133219. * This uses the standard weight of the background material to setup the fresnel effect
  133220. * of the mirror.
  133221. * 1 by default.
  133222. */
  133223. groundMirrorFresnelWeight: number;
  133224. /**
  133225. * Specifies the ground mirror Falloff distance.
  133226. * This can helps reducing the size of the reflection.
  133227. * 0 by Default.
  133228. */
  133229. groundMirrorFallOffDistance: number;
  133230. /**
  133231. * Specifies the ground mirror texture type.
  133232. * Unsigned Int by Default.
  133233. */
  133234. groundMirrorTextureType: number;
  133235. /**
  133236. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  133237. * the shown objects.
  133238. */
  133239. groundYBias: number;
  133240. /**
  133241. * Specifies whether or not to create a skybox.
  133242. * True by default.
  133243. */
  133244. createSkybox: boolean;
  133245. /**
  133246. * Specifies the skybox size.
  133247. * 20 by default.
  133248. */
  133249. skyboxSize: number;
  133250. /**
  133251. * The texture used on the skybox for the main color.
  133252. * Comes from the BabylonJS CDN by default.
  133253. *
  133254. * Remarks: Can be either a texture or a url.
  133255. */
  133256. skyboxTexture: string | BaseTexture;
  133257. /**
  133258. * The color mixed in the skybox texture by default.
  133259. * BabylonJS clearColor by default.
  133260. */
  133261. skyboxColor: Color3;
  133262. /**
  133263. * The background rotation around the Y axis of the scene.
  133264. * This helps aligning the key lights of your scene with the background.
  133265. * 0 by default.
  133266. */
  133267. backgroundYRotation: number;
  133268. /**
  133269. * Compute automatically the size of the elements to best fit with the scene.
  133270. */
  133271. sizeAuto: boolean;
  133272. /**
  133273. * Default position of the rootMesh if autoSize is not true.
  133274. */
  133275. rootPosition: Vector3;
  133276. /**
  133277. * Sets up the image processing in the scene.
  133278. * true by default.
  133279. */
  133280. setupImageProcessing: boolean;
  133281. /**
  133282. * The texture used as your environment texture in the scene.
  133283. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  133284. *
  133285. * Remarks: Can be either a texture or a url.
  133286. */
  133287. environmentTexture: string | BaseTexture;
  133288. /**
  133289. * The value of the exposure to apply to the scene.
  133290. * 0.6 by default if setupImageProcessing is true.
  133291. */
  133292. cameraExposure: number;
  133293. /**
  133294. * The value of the contrast to apply to the scene.
  133295. * 1.6 by default if setupImageProcessing is true.
  133296. */
  133297. cameraContrast: number;
  133298. /**
  133299. * Specifies whether or not tonemapping should be enabled in the scene.
  133300. * true by default if setupImageProcessing is true.
  133301. */
  133302. toneMappingEnabled: boolean;
  133303. }
  133304. /**
  133305. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  133306. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  133307. * It also helps with the default setup of your imageProcessing configuration.
  133308. */
  133309. export class EnvironmentHelper {
  133310. /**
  133311. * Default ground texture URL.
  133312. */
  133313. private static _groundTextureCDNUrl;
  133314. /**
  133315. * Default skybox texture URL.
  133316. */
  133317. private static _skyboxTextureCDNUrl;
  133318. /**
  133319. * Default environment texture URL.
  133320. */
  133321. private static _environmentTextureCDNUrl;
  133322. /**
  133323. * Creates the default options for the helper.
  133324. */
  133325. private static _getDefaultOptions;
  133326. private _rootMesh;
  133327. /**
  133328. * Gets the root mesh created by the helper.
  133329. */
  133330. get rootMesh(): Mesh;
  133331. private _skybox;
  133332. /**
  133333. * Gets the skybox created by the helper.
  133334. */
  133335. get skybox(): Nullable<Mesh>;
  133336. private _skyboxTexture;
  133337. /**
  133338. * Gets the skybox texture created by the helper.
  133339. */
  133340. get skyboxTexture(): Nullable<BaseTexture>;
  133341. private _skyboxMaterial;
  133342. /**
  133343. * Gets the skybox material created by the helper.
  133344. */
  133345. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  133346. private _ground;
  133347. /**
  133348. * Gets the ground mesh created by the helper.
  133349. */
  133350. get ground(): Nullable<Mesh>;
  133351. private _groundTexture;
  133352. /**
  133353. * Gets the ground texture created by the helper.
  133354. */
  133355. get groundTexture(): Nullable<BaseTexture>;
  133356. private _groundMirror;
  133357. /**
  133358. * Gets the ground mirror created by the helper.
  133359. */
  133360. get groundMirror(): Nullable<MirrorTexture>;
  133361. /**
  133362. * Gets the ground mirror render list to helps pushing the meshes
  133363. * you wish in the ground reflection.
  133364. */
  133365. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  133366. private _groundMaterial;
  133367. /**
  133368. * Gets the ground material created by the helper.
  133369. */
  133370. get groundMaterial(): Nullable<BackgroundMaterial>;
  133371. /**
  133372. * Stores the creation options.
  133373. */
  133374. private readonly _scene;
  133375. private _options;
  133376. /**
  133377. * This observable will be notified with any error during the creation of the environment,
  133378. * mainly texture creation errors.
  133379. */
  133380. onErrorObservable: Observable<{
  133381. message?: string;
  133382. exception?: any;
  133383. }>;
  133384. /**
  133385. * constructor
  133386. * @param options Defines the options we want to customize the helper
  133387. * @param scene The scene to add the material to
  133388. */
  133389. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  133390. /**
  133391. * Updates the background according to the new options
  133392. * @param options
  133393. */
  133394. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  133395. /**
  133396. * Sets the primary color of all the available elements.
  133397. * @param color the main color to affect to the ground and the background
  133398. */
  133399. setMainColor(color: Color3): void;
  133400. /**
  133401. * Setup the image processing according to the specified options.
  133402. */
  133403. private _setupImageProcessing;
  133404. /**
  133405. * Setup the environment texture according to the specified options.
  133406. */
  133407. private _setupEnvironmentTexture;
  133408. /**
  133409. * Setup the background according to the specified options.
  133410. */
  133411. private _setupBackground;
  133412. /**
  133413. * Get the scene sizes according to the setup.
  133414. */
  133415. private _getSceneSize;
  133416. /**
  133417. * Setup the ground according to the specified options.
  133418. */
  133419. private _setupGround;
  133420. /**
  133421. * Setup the ground material according to the specified options.
  133422. */
  133423. private _setupGroundMaterial;
  133424. /**
  133425. * Setup the ground diffuse texture according to the specified options.
  133426. */
  133427. private _setupGroundDiffuseTexture;
  133428. /**
  133429. * Setup the ground mirror texture according to the specified options.
  133430. */
  133431. private _setupGroundMirrorTexture;
  133432. /**
  133433. * Setup the ground to receive the mirror texture.
  133434. */
  133435. private _setupMirrorInGroundMaterial;
  133436. /**
  133437. * Setup the skybox according to the specified options.
  133438. */
  133439. private _setupSkybox;
  133440. /**
  133441. * Setup the skybox material according to the specified options.
  133442. */
  133443. private _setupSkyboxMaterial;
  133444. /**
  133445. * Setup the skybox reflection texture according to the specified options.
  133446. */
  133447. private _setupSkyboxReflectionTexture;
  133448. private _errorHandler;
  133449. /**
  133450. * Dispose all the elements created by the Helper.
  133451. */
  133452. dispose(): void;
  133453. }
  133454. }
  133455. declare module BABYLON {
  133456. /**
  133457. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  133458. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  133459. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  133460. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133461. */
  133462. export class PhotoDome extends TransformNode {
  133463. /**
  133464. * Define the image as a Monoscopic panoramic 360 image.
  133465. */
  133466. static readonly MODE_MONOSCOPIC: number;
  133467. /**
  133468. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133469. */
  133470. static readonly MODE_TOPBOTTOM: number;
  133471. /**
  133472. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133473. */
  133474. static readonly MODE_SIDEBYSIDE: number;
  133475. private _useDirectMapping;
  133476. /**
  133477. * The texture being displayed on the sphere
  133478. */
  133479. protected _photoTexture: Texture;
  133480. /**
  133481. * Gets or sets the texture being displayed on the sphere
  133482. */
  133483. get photoTexture(): Texture;
  133484. set photoTexture(value: Texture);
  133485. /**
  133486. * Observable raised when an error occured while loading the 360 image
  133487. */
  133488. onLoadErrorObservable: Observable<string>;
  133489. /**
  133490. * The skybox material
  133491. */
  133492. protected _material: BackgroundMaterial;
  133493. /**
  133494. * The surface used for the skybox
  133495. */
  133496. protected _mesh: Mesh;
  133497. /**
  133498. * Gets the mesh used for the skybox.
  133499. */
  133500. get mesh(): Mesh;
  133501. /**
  133502. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133503. * Also see the options.resolution property.
  133504. */
  133505. get fovMultiplier(): number;
  133506. set fovMultiplier(value: number);
  133507. private _imageMode;
  133508. /**
  133509. * Gets or set the current video mode for the video. It can be:
  133510. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  133511. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133512. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133513. */
  133514. get imageMode(): number;
  133515. set imageMode(value: number);
  133516. /**
  133517. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  133518. * @param name Element's name, child elements will append suffixes for their own names.
  133519. * @param urlsOfPhoto defines the url of the photo to display
  133520. * @param options defines an object containing optional or exposed sub element properties
  133521. * @param onError defines a callback called when an error occured while loading the texture
  133522. */
  133523. constructor(name: string, urlOfPhoto: string, options: {
  133524. resolution?: number;
  133525. size?: number;
  133526. useDirectMapping?: boolean;
  133527. faceForward?: boolean;
  133528. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  133529. private _onBeforeCameraRenderObserver;
  133530. private _changeImageMode;
  133531. /**
  133532. * Releases resources associated with this node.
  133533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133535. */
  133536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133537. }
  133538. }
  133539. declare module BABYLON {
  133540. /**
  133541. * Class used to host RGBD texture specific utilities
  133542. */
  133543. export class RGBDTextureTools {
  133544. /**
  133545. * Expand the RGBD Texture from RGBD to Half Float if possible.
  133546. * @param texture the texture to expand.
  133547. */
  133548. static ExpandRGBDTexture(texture: Texture): void;
  133549. }
  133550. }
  133551. declare module BABYLON {
  133552. /**
  133553. * Class used to host texture specific utilities
  133554. */
  133555. export class BRDFTextureTools {
  133556. /**
  133557. * Prevents texture cache collision
  133558. */
  133559. private static _instanceNumber;
  133560. /**
  133561. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  133562. * @param scene defines the hosting scene
  133563. * @returns the environment BRDF texture
  133564. */
  133565. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  133566. private static _environmentBRDFBase64Texture;
  133567. }
  133568. }
  133569. declare module BABYLON {
  133570. /**
  133571. * @hidden
  133572. */
  133573. export interface IMaterialClearCoatDefines {
  133574. CLEARCOAT: boolean;
  133575. CLEARCOAT_DEFAULTIOR: boolean;
  133576. CLEARCOAT_TEXTURE: boolean;
  133577. CLEARCOAT_TEXTUREDIRECTUV: number;
  133578. CLEARCOAT_BUMP: boolean;
  133579. CLEARCOAT_BUMPDIRECTUV: number;
  133580. CLEARCOAT_TINT: boolean;
  133581. CLEARCOAT_TINT_TEXTURE: boolean;
  133582. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133583. /** @hidden */
  133584. _areTexturesDirty: boolean;
  133585. }
  133586. /**
  133587. * Define the code related to the clear coat parameters of the pbr material.
  133588. */
  133589. export class PBRClearCoatConfiguration {
  133590. /**
  133591. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133592. * The default fits with a polyurethane material.
  133593. */
  133594. private static readonly _DefaultIndexOfRefraction;
  133595. private _isEnabled;
  133596. /**
  133597. * Defines if the clear coat is enabled in the material.
  133598. */
  133599. isEnabled: boolean;
  133600. /**
  133601. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  133602. */
  133603. intensity: number;
  133604. /**
  133605. * Defines the clear coat layer roughness.
  133606. */
  133607. roughness: number;
  133608. private _indexOfRefraction;
  133609. /**
  133610. * Defines the index of refraction of the clear coat.
  133611. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133612. * The default fits with a polyurethane material.
  133613. * Changing the default value is more performance intensive.
  133614. */
  133615. indexOfRefraction: number;
  133616. private _texture;
  133617. /**
  133618. * Stores the clear coat values in a texture.
  133619. */
  133620. texture: Nullable<BaseTexture>;
  133621. private _bumpTexture;
  133622. /**
  133623. * Define the clear coat specific bump texture.
  133624. */
  133625. bumpTexture: Nullable<BaseTexture>;
  133626. private _isTintEnabled;
  133627. /**
  133628. * Defines if the clear coat tint is enabled in the material.
  133629. */
  133630. isTintEnabled: boolean;
  133631. /**
  133632. * Defines the clear coat tint of the material.
  133633. * This is only use if tint is enabled
  133634. */
  133635. tintColor: Color3;
  133636. /**
  133637. * Defines the distance at which the tint color should be found in the
  133638. * clear coat media.
  133639. * This is only use if tint is enabled
  133640. */
  133641. tintColorAtDistance: number;
  133642. /**
  133643. * Defines the clear coat layer thickness.
  133644. * This is only use if tint is enabled
  133645. */
  133646. tintThickness: number;
  133647. private _tintTexture;
  133648. /**
  133649. * Stores the clear tint values in a texture.
  133650. * rgb is tint
  133651. * a is a thickness factor
  133652. */
  133653. tintTexture: Nullable<BaseTexture>;
  133654. /** @hidden */
  133655. private _internalMarkAllSubMeshesAsTexturesDirty;
  133656. /** @hidden */
  133657. _markAllSubMeshesAsTexturesDirty(): void;
  133658. /**
  133659. * Instantiate a new istance of clear coat configuration.
  133660. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133661. */
  133662. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133663. /**
  133664. * Gets wehter the submesh is ready to be used or not.
  133665. * @param defines the list of "defines" to update.
  133666. * @param scene defines the scene the material belongs to.
  133667. * @param engine defines the engine the material belongs to.
  133668. * @param disableBumpMap defines wether the material disables bump or not.
  133669. * @returns - boolean indicating that the submesh is ready or not.
  133670. */
  133671. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  133672. /**
  133673. * Checks to see if a texture is used in the material.
  133674. * @param defines the list of "defines" to update.
  133675. * @param scene defines the scene to the material belongs to.
  133676. */
  133677. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  133678. /**
  133679. * Binds the material data.
  133680. * @param uniformBuffer defines the Uniform buffer to fill in.
  133681. * @param scene defines the scene the material belongs to.
  133682. * @param engine defines the engine the material belongs to.
  133683. * @param disableBumpMap defines wether the material disables bump or not.
  133684. * @param isFrozen defines wether the material is frozen or not.
  133685. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133686. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133687. */
  133688. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  133689. /**
  133690. * Checks to see if a texture is used in the material.
  133691. * @param texture - Base texture to use.
  133692. * @returns - Boolean specifying if a texture is used in the material.
  133693. */
  133694. hasTexture(texture: BaseTexture): boolean;
  133695. /**
  133696. * Returns an array of the actively used textures.
  133697. * @param activeTextures Array of BaseTextures
  133698. */
  133699. getActiveTextures(activeTextures: BaseTexture[]): void;
  133700. /**
  133701. * Returns the animatable textures.
  133702. * @param animatables Array of animatable textures.
  133703. */
  133704. getAnimatables(animatables: IAnimatable[]): void;
  133705. /**
  133706. * Disposes the resources of the material.
  133707. * @param forceDisposeTextures - Forces the disposal of all textures.
  133708. */
  133709. dispose(forceDisposeTextures?: boolean): void;
  133710. /**
  133711. * Get the current class name of the texture useful for serialization or dynamic coding.
  133712. * @returns "PBRClearCoatConfiguration"
  133713. */
  133714. getClassName(): string;
  133715. /**
  133716. * Add fallbacks to the effect fallbacks list.
  133717. * @param defines defines the Base texture to use.
  133718. * @param fallbacks defines the current fallback list.
  133719. * @param currentRank defines the current fallback rank.
  133720. * @returns the new fallback rank.
  133721. */
  133722. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133723. /**
  133724. * Add the required uniforms to the current list.
  133725. * @param uniforms defines the current uniform list.
  133726. */
  133727. static AddUniforms(uniforms: string[]): void;
  133728. /**
  133729. * Add the required samplers to the current list.
  133730. * @param samplers defines the current sampler list.
  133731. */
  133732. static AddSamplers(samplers: string[]): void;
  133733. /**
  133734. * Add the required uniforms to the current buffer.
  133735. * @param uniformBuffer defines the current uniform buffer.
  133736. */
  133737. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133738. /**
  133739. * Makes a duplicate of the current configuration into another one.
  133740. * @param clearCoatConfiguration define the config where to copy the info
  133741. */
  133742. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  133743. /**
  133744. * Serializes this clear coat configuration.
  133745. * @returns - An object with the serialized config.
  133746. */
  133747. serialize(): any;
  133748. /**
  133749. * Parses a anisotropy Configuration from a serialized object.
  133750. * @param source - Serialized object.
  133751. * @param scene Defines the scene we are parsing for
  133752. * @param rootUrl Defines the rootUrl to load from
  133753. */
  133754. parse(source: any, scene: Scene, rootUrl: string): void;
  133755. }
  133756. }
  133757. declare module BABYLON {
  133758. /**
  133759. * @hidden
  133760. */
  133761. export interface IMaterialAnisotropicDefines {
  133762. ANISOTROPIC: boolean;
  133763. ANISOTROPIC_TEXTURE: boolean;
  133764. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133765. MAINUV1: boolean;
  133766. _areTexturesDirty: boolean;
  133767. _needUVs: boolean;
  133768. }
  133769. /**
  133770. * Define the code related to the anisotropic parameters of the pbr material.
  133771. */
  133772. export class PBRAnisotropicConfiguration {
  133773. private _isEnabled;
  133774. /**
  133775. * Defines if the anisotropy is enabled in the material.
  133776. */
  133777. isEnabled: boolean;
  133778. /**
  133779. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  133780. */
  133781. intensity: number;
  133782. /**
  133783. * Defines if the effect is along the tangents, bitangents or in between.
  133784. * By default, the effect is "strectching" the highlights along the tangents.
  133785. */
  133786. direction: Vector2;
  133787. private _texture;
  133788. /**
  133789. * Stores the anisotropy values in a texture.
  133790. * rg is direction (like normal from -1 to 1)
  133791. * b is a intensity
  133792. */
  133793. texture: Nullable<BaseTexture>;
  133794. /** @hidden */
  133795. private _internalMarkAllSubMeshesAsTexturesDirty;
  133796. /** @hidden */
  133797. _markAllSubMeshesAsTexturesDirty(): void;
  133798. /**
  133799. * Instantiate a new istance of anisotropy configuration.
  133800. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133801. */
  133802. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133803. /**
  133804. * Specifies that the submesh is ready to be used.
  133805. * @param defines the list of "defines" to update.
  133806. * @param scene defines the scene the material belongs to.
  133807. * @returns - boolean indicating that the submesh is ready or not.
  133808. */
  133809. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  133810. /**
  133811. * Checks to see if a texture is used in the material.
  133812. * @param defines the list of "defines" to update.
  133813. * @param mesh the mesh we are preparing the defines for.
  133814. * @param scene defines the scene the material belongs to.
  133815. */
  133816. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  133817. /**
  133818. * Binds the material data.
  133819. * @param uniformBuffer defines the Uniform buffer to fill in.
  133820. * @param scene defines the scene the material belongs to.
  133821. * @param isFrozen defines wether the material is frozen or not.
  133822. */
  133823. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133824. /**
  133825. * Checks to see if a texture is used in the material.
  133826. * @param texture - Base texture to use.
  133827. * @returns - Boolean specifying if a texture is used in the material.
  133828. */
  133829. hasTexture(texture: BaseTexture): boolean;
  133830. /**
  133831. * Returns an array of the actively used textures.
  133832. * @param activeTextures Array of BaseTextures
  133833. */
  133834. getActiveTextures(activeTextures: BaseTexture[]): void;
  133835. /**
  133836. * Returns the animatable textures.
  133837. * @param animatables Array of animatable textures.
  133838. */
  133839. getAnimatables(animatables: IAnimatable[]): void;
  133840. /**
  133841. * Disposes the resources of the material.
  133842. * @param forceDisposeTextures - Forces the disposal of all textures.
  133843. */
  133844. dispose(forceDisposeTextures?: boolean): void;
  133845. /**
  133846. * Get the current class name of the texture useful for serialization or dynamic coding.
  133847. * @returns "PBRAnisotropicConfiguration"
  133848. */
  133849. getClassName(): string;
  133850. /**
  133851. * Add fallbacks to the effect fallbacks list.
  133852. * @param defines defines the Base texture to use.
  133853. * @param fallbacks defines the current fallback list.
  133854. * @param currentRank defines the current fallback rank.
  133855. * @returns the new fallback rank.
  133856. */
  133857. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133858. /**
  133859. * Add the required uniforms to the current list.
  133860. * @param uniforms defines the current uniform list.
  133861. */
  133862. static AddUniforms(uniforms: string[]): void;
  133863. /**
  133864. * Add the required uniforms to the current buffer.
  133865. * @param uniformBuffer defines the current uniform buffer.
  133866. */
  133867. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133868. /**
  133869. * Add the required samplers to the current list.
  133870. * @param samplers defines the current sampler list.
  133871. */
  133872. static AddSamplers(samplers: string[]): void;
  133873. /**
  133874. * Makes a duplicate of the current configuration into another one.
  133875. * @param anisotropicConfiguration define the config where to copy the info
  133876. */
  133877. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  133878. /**
  133879. * Serializes this anisotropy configuration.
  133880. * @returns - An object with the serialized config.
  133881. */
  133882. serialize(): any;
  133883. /**
  133884. * Parses a anisotropy Configuration from a serialized object.
  133885. * @param source - Serialized object.
  133886. * @param scene Defines the scene we are parsing for
  133887. * @param rootUrl Defines the rootUrl to load from
  133888. */
  133889. parse(source: any, scene: Scene, rootUrl: string): void;
  133890. }
  133891. }
  133892. declare module BABYLON {
  133893. /**
  133894. * @hidden
  133895. */
  133896. export interface IMaterialBRDFDefines {
  133897. BRDF_V_HEIGHT_CORRELATED: boolean;
  133898. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133899. SPHERICAL_HARMONICS: boolean;
  133900. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133901. /** @hidden */
  133902. _areMiscDirty: boolean;
  133903. }
  133904. /**
  133905. * Define the code related to the BRDF parameters of the pbr material.
  133906. */
  133907. export class PBRBRDFConfiguration {
  133908. /**
  133909. * Default value used for the energy conservation.
  133910. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133911. */
  133912. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  133913. /**
  133914. * Default value used for the Smith Visibility Height Correlated mode.
  133915. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133916. */
  133917. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  133918. /**
  133919. * Default value used for the IBL diffuse part.
  133920. * This can help switching back to the polynomials mode globally which is a tiny bit
  133921. * less GPU intensive at the drawback of a lower quality.
  133922. */
  133923. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  133924. /**
  133925. * Default value used for activating energy conservation for the specular workflow.
  133926. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133927. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133928. */
  133929. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  133930. private _useEnergyConservation;
  133931. /**
  133932. * Defines if the material uses energy conservation.
  133933. */
  133934. useEnergyConservation: boolean;
  133935. private _useSmithVisibilityHeightCorrelated;
  133936. /**
  133937. * LEGACY Mode set to false
  133938. * Defines if the material uses height smith correlated visibility term.
  133939. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  133940. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  133941. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  133942. * Not relying on height correlated will also disable energy conservation.
  133943. */
  133944. useSmithVisibilityHeightCorrelated: boolean;
  133945. private _useSphericalHarmonics;
  133946. /**
  133947. * LEGACY Mode set to false
  133948. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  133949. * diffuse part of the IBL.
  133950. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  133951. * to the ground truth.
  133952. */
  133953. useSphericalHarmonics: boolean;
  133954. private _useSpecularGlossinessInputEnergyConservation;
  133955. /**
  133956. * Defines if the material uses energy conservation, when the specular workflow is active.
  133957. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133958. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133959. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  133960. */
  133961. useSpecularGlossinessInputEnergyConservation: boolean;
  133962. /** @hidden */
  133963. private _internalMarkAllSubMeshesAsMiscDirty;
  133964. /** @hidden */
  133965. _markAllSubMeshesAsMiscDirty(): void;
  133966. /**
  133967. * Instantiate a new istance of clear coat configuration.
  133968. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  133969. */
  133970. constructor(markAllSubMeshesAsMiscDirty: () => void);
  133971. /**
  133972. * Checks to see if a texture is used in the material.
  133973. * @param defines the list of "defines" to update.
  133974. */
  133975. prepareDefines(defines: IMaterialBRDFDefines): void;
  133976. /**
  133977. * Get the current class name of the texture useful for serialization or dynamic coding.
  133978. * @returns "PBRClearCoatConfiguration"
  133979. */
  133980. getClassName(): string;
  133981. /**
  133982. * Makes a duplicate of the current configuration into another one.
  133983. * @param brdfConfiguration define the config where to copy the info
  133984. */
  133985. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  133986. /**
  133987. * Serializes this BRDF configuration.
  133988. * @returns - An object with the serialized config.
  133989. */
  133990. serialize(): any;
  133991. /**
  133992. * Parses a anisotropy Configuration from a serialized object.
  133993. * @param source - Serialized object.
  133994. * @param scene Defines the scene we are parsing for
  133995. * @param rootUrl Defines the rootUrl to load from
  133996. */
  133997. parse(source: any, scene: Scene, rootUrl: string): void;
  133998. }
  133999. }
  134000. declare module BABYLON {
  134001. /**
  134002. * @hidden
  134003. */
  134004. export interface IMaterialSheenDefines {
  134005. SHEEN: boolean;
  134006. SHEEN_TEXTURE: boolean;
  134007. SHEEN_TEXTUREDIRECTUV: number;
  134008. SHEEN_LINKWITHALBEDO: boolean;
  134009. SHEEN_ROUGHNESS: boolean;
  134010. SHEEN_ALBEDOSCALING: boolean;
  134011. /** @hidden */
  134012. _areTexturesDirty: boolean;
  134013. }
  134014. /**
  134015. * Define the code related to the Sheen parameters of the pbr material.
  134016. */
  134017. export class PBRSheenConfiguration {
  134018. private _isEnabled;
  134019. /**
  134020. * Defines if the material uses sheen.
  134021. */
  134022. isEnabled: boolean;
  134023. private _linkSheenWithAlbedo;
  134024. /**
  134025. * Defines if the sheen is linked to the sheen color.
  134026. */
  134027. linkSheenWithAlbedo: boolean;
  134028. /**
  134029. * Defines the sheen intensity.
  134030. */
  134031. intensity: number;
  134032. /**
  134033. * Defines the sheen color.
  134034. */
  134035. color: Color3;
  134036. private _texture;
  134037. /**
  134038. * Stores the sheen tint values in a texture.
  134039. * rgb is tint
  134040. * a is a intensity or roughness if roughness has been defined
  134041. */
  134042. texture: Nullable<BaseTexture>;
  134043. private _roughness;
  134044. /**
  134045. * Defines the sheen roughness.
  134046. * It is not taken into account if linkSheenWithAlbedo is true.
  134047. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  134048. */
  134049. roughness: Nullable<number>;
  134050. private _albedoScaling;
  134051. /**
  134052. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  134053. * It allows the strength of the sheen effect to not depend on the base color of the material,
  134054. * making it easier to setup and tweak the effect
  134055. */
  134056. albedoScaling: boolean;
  134057. /** @hidden */
  134058. private _internalMarkAllSubMeshesAsTexturesDirty;
  134059. /** @hidden */
  134060. _markAllSubMeshesAsTexturesDirty(): void;
  134061. /**
  134062. * Instantiate a new istance of clear coat configuration.
  134063. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134064. */
  134065. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134066. /**
  134067. * Specifies that the submesh is ready to be used.
  134068. * @param defines the list of "defines" to update.
  134069. * @param scene defines the scene the material belongs to.
  134070. * @returns - boolean indicating that the submesh is ready or not.
  134071. */
  134072. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  134073. /**
  134074. * Checks to see if a texture is used in the material.
  134075. * @param defines the list of "defines" to update.
  134076. * @param scene defines the scene the material belongs to.
  134077. */
  134078. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  134079. /**
  134080. * Binds the material data.
  134081. * @param uniformBuffer defines the Uniform buffer to fill in.
  134082. * @param scene defines the scene the material belongs to.
  134083. * @param isFrozen defines wether the material is frozen or not.
  134084. */
  134085. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134086. /**
  134087. * Checks to see if a texture is used in the material.
  134088. * @param texture - Base texture to use.
  134089. * @returns - Boolean specifying if a texture is used in the material.
  134090. */
  134091. hasTexture(texture: BaseTexture): boolean;
  134092. /**
  134093. * Returns an array of the actively used textures.
  134094. * @param activeTextures Array of BaseTextures
  134095. */
  134096. getActiveTextures(activeTextures: BaseTexture[]): void;
  134097. /**
  134098. * Returns the animatable textures.
  134099. * @param animatables Array of animatable textures.
  134100. */
  134101. getAnimatables(animatables: IAnimatable[]): void;
  134102. /**
  134103. * Disposes the resources of the material.
  134104. * @param forceDisposeTextures - Forces the disposal of all textures.
  134105. */
  134106. dispose(forceDisposeTextures?: boolean): void;
  134107. /**
  134108. * Get the current class name of the texture useful for serialization or dynamic coding.
  134109. * @returns "PBRSheenConfiguration"
  134110. */
  134111. getClassName(): string;
  134112. /**
  134113. * Add fallbacks to the effect fallbacks list.
  134114. * @param defines defines the Base texture to use.
  134115. * @param fallbacks defines the current fallback list.
  134116. * @param currentRank defines the current fallback rank.
  134117. * @returns the new fallback rank.
  134118. */
  134119. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134120. /**
  134121. * Add the required uniforms to the current list.
  134122. * @param uniforms defines the current uniform list.
  134123. */
  134124. static AddUniforms(uniforms: string[]): void;
  134125. /**
  134126. * Add the required uniforms to the current buffer.
  134127. * @param uniformBuffer defines the current uniform buffer.
  134128. */
  134129. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134130. /**
  134131. * Add the required samplers to the current list.
  134132. * @param samplers defines the current sampler list.
  134133. */
  134134. static AddSamplers(samplers: string[]): void;
  134135. /**
  134136. * Makes a duplicate of the current configuration into another one.
  134137. * @param sheenConfiguration define the config where to copy the info
  134138. */
  134139. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  134140. /**
  134141. * Serializes this BRDF configuration.
  134142. * @returns - An object with the serialized config.
  134143. */
  134144. serialize(): any;
  134145. /**
  134146. * Parses a anisotropy Configuration from a serialized object.
  134147. * @param source - Serialized object.
  134148. * @param scene Defines the scene we are parsing for
  134149. * @param rootUrl Defines the rootUrl to load from
  134150. */
  134151. parse(source: any, scene: Scene, rootUrl: string): void;
  134152. }
  134153. }
  134154. declare module BABYLON {
  134155. /**
  134156. * @hidden
  134157. */
  134158. export interface IMaterialSubSurfaceDefines {
  134159. SUBSURFACE: boolean;
  134160. SS_REFRACTION: boolean;
  134161. SS_TRANSLUCENCY: boolean;
  134162. SS_SCATTERING: boolean;
  134163. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134164. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134165. SS_REFRACTIONMAP_3D: boolean;
  134166. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134167. SS_LODINREFRACTIONALPHA: boolean;
  134168. SS_GAMMAREFRACTION: boolean;
  134169. SS_RGBDREFRACTION: boolean;
  134170. SS_LINEARSPECULARREFRACTION: boolean;
  134171. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134172. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134173. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134174. /** @hidden */
  134175. _areTexturesDirty: boolean;
  134176. }
  134177. /**
  134178. * Define the code related to the sub surface parameters of the pbr material.
  134179. */
  134180. export class PBRSubSurfaceConfiguration {
  134181. private _isRefractionEnabled;
  134182. /**
  134183. * Defines if the refraction is enabled in the material.
  134184. */
  134185. isRefractionEnabled: boolean;
  134186. private _isTranslucencyEnabled;
  134187. /**
  134188. * Defines if the translucency is enabled in the material.
  134189. */
  134190. isTranslucencyEnabled: boolean;
  134191. private _isScatteringEnabled;
  134192. /**
  134193. * Defines if the sub surface scattering is enabled in the material.
  134194. */
  134195. isScatteringEnabled: boolean;
  134196. private _scatteringDiffusionProfileIndex;
  134197. /**
  134198. * Diffusion profile for subsurface scattering.
  134199. * Useful for better scattering in the skins or foliages.
  134200. */
  134201. get scatteringDiffusionProfile(): Nullable<Color3>;
  134202. set scatteringDiffusionProfile(c: Nullable<Color3>);
  134203. /**
  134204. * Defines the refraction intensity of the material.
  134205. * The refraction when enabled replaces the Diffuse part of the material.
  134206. * The intensity helps transitionning between diffuse and refraction.
  134207. */
  134208. refractionIntensity: number;
  134209. /**
  134210. * Defines the translucency intensity of the material.
  134211. * When translucency has been enabled, this defines how much of the "translucency"
  134212. * is addded to the diffuse part of the material.
  134213. */
  134214. translucencyIntensity: number;
  134215. /**
  134216. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  134217. */
  134218. useAlbedoToTintRefraction: boolean;
  134219. private _thicknessTexture;
  134220. /**
  134221. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  134222. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  134223. * 0 would mean minimumThickness
  134224. * 1 would mean maximumThickness
  134225. * The other channels might be use as a mask to vary the different effects intensity.
  134226. */
  134227. thicknessTexture: Nullable<BaseTexture>;
  134228. private _refractionTexture;
  134229. /**
  134230. * Defines the texture to use for refraction.
  134231. */
  134232. refractionTexture: Nullable<BaseTexture>;
  134233. private _indexOfRefraction;
  134234. /**
  134235. * Index of refraction of the material base layer.
  134236. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134237. *
  134238. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134239. *
  134240. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134241. */
  134242. indexOfRefraction: number;
  134243. private _volumeIndexOfRefraction;
  134244. /**
  134245. * Index of refraction of the material's volume.
  134246. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134247. *
  134248. * This ONLY impacts refraction. If not provided or given a non-valid value,
  134249. * the volume will use the same IOR as the surface.
  134250. */
  134251. get volumeIndexOfRefraction(): number;
  134252. set volumeIndexOfRefraction(value: number);
  134253. private _invertRefractionY;
  134254. /**
  134255. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134256. */
  134257. invertRefractionY: boolean;
  134258. private _linkRefractionWithTransparency;
  134259. /**
  134260. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134261. * Materials half opaque for instance using refraction could benefit from this control.
  134262. */
  134263. linkRefractionWithTransparency: boolean;
  134264. /**
  134265. * Defines the minimum thickness stored in the thickness map.
  134266. * If no thickness map is defined, this value will be used to simulate thickness.
  134267. */
  134268. minimumThickness: number;
  134269. /**
  134270. * Defines the maximum thickness stored in the thickness map.
  134271. */
  134272. maximumThickness: number;
  134273. /**
  134274. * Defines the volume tint of the material.
  134275. * This is used for both translucency and scattering.
  134276. */
  134277. tintColor: Color3;
  134278. /**
  134279. * Defines the distance at which the tint color should be found in the media.
  134280. * This is used for refraction only.
  134281. */
  134282. tintColorAtDistance: number;
  134283. /**
  134284. * Defines how far each channel transmit through the media.
  134285. * It is defined as a color to simplify it selection.
  134286. */
  134287. diffusionDistance: Color3;
  134288. private _useMaskFromThicknessTexture;
  134289. /**
  134290. * Stores the intensity of the different subsurface effects in the thickness texture.
  134291. * * the green channel is the translucency intensity.
  134292. * * the blue channel is the scattering intensity.
  134293. * * the alpha channel is the refraction intensity.
  134294. */
  134295. useMaskFromThicknessTexture: boolean;
  134296. private _scene;
  134297. /** @hidden */
  134298. private _internalMarkAllSubMeshesAsTexturesDirty;
  134299. private _internalMarkScenePrePassDirty;
  134300. /** @hidden */
  134301. _markAllSubMeshesAsTexturesDirty(): void;
  134302. /** @hidden */
  134303. _markScenePrePassDirty(): void;
  134304. /**
  134305. * Instantiate a new istance of sub surface configuration.
  134306. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134307. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  134308. * @param scene The scene
  134309. */
  134310. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  134311. /**
  134312. * Gets wehter the submesh is ready to be used or not.
  134313. * @param defines the list of "defines" to update.
  134314. * @param scene defines the scene the material belongs to.
  134315. * @returns - boolean indicating that the submesh is ready or not.
  134316. */
  134317. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  134318. /**
  134319. * Checks to see if a texture is used in the material.
  134320. * @param defines the list of "defines" to update.
  134321. * @param scene defines the scene to the material belongs to.
  134322. */
  134323. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  134324. /**
  134325. * Binds the material data.
  134326. * @param uniformBuffer defines the Uniform buffer to fill in.
  134327. * @param scene defines the scene the material belongs to.
  134328. * @param engine defines the engine the material belongs to.
  134329. * @param isFrozen defines whether the material is frozen or not.
  134330. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  134331. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  134332. */
  134333. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  134334. /**
  134335. * Unbinds the material from the mesh.
  134336. * @param activeEffect defines the effect that should be unbound from.
  134337. * @returns true if unbound, otherwise false
  134338. */
  134339. unbind(activeEffect: Effect): boolean;
  134340. /**
  134341. * Returns the texture used for refraction or null if none is used.
  134342. * @param scene defines the scene the material belongs to.
  134343. * @returns - Refraction texture if present. If no refraction texture and refraction
  134344. * is linked with transparency, returns environment texture. Otherwise, returns null.
  134345. */
  134346. private _getRefractionTexture;
  134347. /**
  134348. * Returns true if alpha blending should be disabled.
  134349. */
  134350. get disableAlphaBlending(): boolean;
  134351. /**
  134352. * Fills the list of render target textures.
  134353. * @param renderTargets the list of render targets to update
  134354. */
  134355. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  134356. /**
  134357. * Checks to see if a texture is used in the material.
  134358. * @param texture - Base texture to use.
  134359. * @returns - Boolean specifying if a texture is used in the material.
  134360. */
  134361. hasTexture(texture: BaseTexture): boolean;
  134362. /**
  134363. * Gets a boolean indicating that current material needs to register RTT
  134364. * @returns true if this uses a render target otherwise false.
  134365. */
  134366. hasRenderTargetTextures(): boolean;
  134367. /**
  134368. * Returns an array of the actively used textures.
  134369. * @param activeTextures Array of BaseTextures
  134370. */
  134371. getActiveTextures(activeTextures: BaseTexture[]): void;
  134372. /**
  134373. * Returns the animatable textures.
  134374. * @param animatables Array of animatable textures.
  134375. */
  134376. getAnimatables(animatables: IAnimatable[]): void;
  134377. /**
  134378. * Disposes the resources of the material.
  134379. * @param forceDisposeTextures - Forces the disposal of all textures.
  134380. */
  134381. dispose(forceDisposeTextures?: boolean): void;
  134382. /**
  134383. * Get the current class name of the texture useful for serialization or dynamic coding.
  134384. * @returns "PBRSubSurfaceConfiguration"
  134385. */
  134386. getClassName(): string;
  134387. /**
  134388. * Add fallbacks to the effect fallbacks list.
  134389. * @param defines defines the Base texture to use.
  134390. * @param fallbacks defines the current fallback list.
  134391. * @param currentRank defines the current fallback rank.
  134392. * @returns the new fallback rank.
  134393. */
  134394. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134395. /**
  134396. * Add the required uniforms to the current list.
  134397. * @param uniforms defines the current uniform list.
  134398. */
  134399. static AddUniforms(uniforms: string[]): void;
  134400. /**
  134401. * Add the required samplers to the current list.
  134402. * @param samplers defines the current sampler list.
  134403. */
  134404. static AddSamplers(samplers: string[]): void;
  134405. /**
  134406. * Add the required uniforms to the current buffer.
  134407. * @param uniformBuffer defines the current uniform buffer.
  134408. */
  134409. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134410. /**
  134411. * Makes a duplicate of the current configuration into another one.
  134412. * @param configuration define the config where to copy the info
  134413. */
  134414. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  134415. /**
  134416. * Serializes this Sub Surface configuration.
  134417. * @returns - An object with the serialized config.
  134418. */
  134419. serialize(): any;
  134420. /**
  134421. * Parses a anisotropy Configuration from a serialized object.
  134422. * @param source - Serialized object.
  134423. * @param scene Defines the scene we are parsing for
  134424. * @param rootUrl Defines the rootUrl to load from
  134425. */
  134426. parse(source: any, scene: Scene, rootUrl: string): void;
  134427. }
  134428. }
  134429. declare module BABYLON {
  134430. /** @hidden */
  134431. export var pbrFragmentDeclaration: {
  134432. name: string;
  134433. shader: string;
  134434. };
  134435. }
  134436. declare module BABYLON {
  134437. /** @hidden */
  134438. export var pbrUboDeclaration: {
  134439. name: string;
  134440. shader: string;
  134441. };
  134442. }
  134443. declare module BABYLON {
  134444. /** @hidden */
  134445. export var pbrFragmentExtraDeclaration: {
  134446. name: string;
  134447. shader: string;
  134448. };
  134449. }
  134450. declare module BABYLON {
  134451. /** @hidden */
  134452. export var pbrFragmentSamplersDeclaration: {
  134453. name: string;
  134454. shader: string;
  134455. };
  134456. }
  134457. declare module BABYLON {
  134458. /** @hidden */
  134459. export var importanceSampling: {
  134460. name: string;
  134461. shader: string;
  134462. };
  134463. }
  134464. declare module BABYLON {
  134465. /** @hidden */
  134466. export var pbrHelperFunctions: {
  134467. name: string;
  134468. shader: string;
  134469. };
  134470. }
  134471. declare module BABYLON {
  134472. /** @hidden */
  134473. export var harmonicsFunctions: {
  134474. name: string;
  134475. shader: string;
  134476. };
  134477. }
  134478. declare module BABYLON {
  134479. /** @hidden */
  134480. export var pbrDirectLightingSetupFunctions: {
  134481. name: string;
  134482. shader: string;
  134483. };
  134484. }
  134485. declare module BABYLON {
  134486. /** @hidden */
  134487. export var pbrDirectLightingFalloffFunctions: {
  134488. name: string;
  134489. shader: string;
  134490. };
  134491. }
  134492. declare module BABYLON {
  134493. /** @hidden */
  134494. export var pbrBRDFFunctions: {
  134495. name: string;
  134496. shader: string;
  134497. };
  134498. }
  134499. declare module BABYLON {
  134500. /** @hidden */
  134501. export var hdrFilteringFunctions: {
  134502. name: string;
  134503. shader: string;
  134504. };
  134505. }
  134506. declare module BABYLON {
  134507. /** @hidden */
  134508. export var pbrDirectLightingFunctions: {
  134509. name: string;
  134510. shader: string;
  134511. };
  134512. }
  134513. declare module BABYLON {
  134514. /** @hidden */
  134515. export var pbrIBLFunctions: {
  134516. name: string;
  134517. shader: string;
  134518. };
  134519. }
  134520. declare module BABYLON {
  134521. /** @hidden */
  134522. export var pbrBlockAlbedoOpacity: {
  134523. name: string;
  134524. shader: string;
  134525. };
  134526. }
  134527. declare module BABYLON {
  134528. /** @hidden */
  134529. export var pbrBlockReflectivity: {
  134530. name: string;
  134531. shader: string;
  134532. };
  134533. }
  134534. declare module BABYLON {
  134535. /** @hidden */
  134536. export var pbrBlockAmbientOcclusion: {
  134537. name: string;
  134538. shader: string;
  134539. };
  134540. }
  134541. declare module BABYLON {
  134542. /** @hidden */
  134543. export var pbrBlockAlphaFresnel: {
  134544. name: string;
  134545. shader: string;
  134546. };
  134547. }
  134548. declare module BABYLON {
  134549. /** @hidden */
  134550. export var pbrBlockAnisotropic: {
  134551. name: string;
  134552. shader: string;
  134553. };
  134554. }
  134555. declare module BABYLON {
  134556. /** @hidden */
  134557. export var pbrBlockReflection: {
  134558. name: string;
  134559. shader: string;
  134560. };
  134561. }
  134562. declare module BABYLON {
  134563. /** @hidden */
  134564. export var pbrBlockSheen: {
  134565. name: string;
  134566. shader: string;
  134567. };
  134568. }
  134569. declare module BABYLON {
  134570. /** @hidden */
  134571. export var pbrBlockClearcoat: {
  134572. name: string;
  134573. shader: string;
  134574. };
  134575. }
  134576. declare module BABYLON {
  134577. /** @hidden */
  134578. export var pbrBlockSubSurface: {
  134579. name: string;
  134580. shader: string;
  134581. };
  134582. }
  134583. declare module BABYLON {
  134584. /** @hidden */
  134585. export var pbrBlockNormalGeometric: {
  134586. name: string;
  134587. shader: string;
  134588. };
  134589. }
  134590. declare module BABYLON {
  134591. /** @hidden */
  134592. export var pbrBlockNormalFinal: {
  134593. name: string;
  134594. shader: string;
  134595. };
  134596. }
  134597. declare module BABYLON {
  134598. /** @hidden */
  134599. export var pbrBlockLightmapInit: {
  134600. name: string;
  134601. shader: string;
  134602. };
  134603. }
  134604. declare module BABYLON {
  134605. /** @hidden */
  134606. export var pbrBlockGeometryInfo: {
  134607. name: string;
  134608. shader: string;
  134609. };
  134610. }
  134611. declare module BABYLON {
  134612. /** @hidden */
  134613. export var pbrBlockReflectance0: {
  134614. name: string;
  134615. shader: string;
  134616. };
  134617. }
  134618. declare module BABYLON {
  134619. /** @hidden */
  134620. export var pbrBlockReflectance: {
  134621. name: string;
  134622. shader: string;
  134623. };
  134624. }
  134625. declare module BABYLON {
  134626. /** @hidden */
  134627. export var pbrBlockDirectLighting: {
  134628. name: string;
  134629. shader: string;
  134630. };
  134631. }
  134632. declare module BABYLON {
  134633. /** @hidden */
  134634. export var pbrBlockFinalLitComponents: {
  134635. name: string;
  134636. shader: string;
  134637. };
  134638. }
  134639. declare module BABYLON {
  134640. /** @hidden */
  134641. export var pbrBlockFinalUnlitComponents: {
  134642. name: string;
  134643. shader: string;
  134644. };
  134645. }
  134646. declare module BABYLON {
  134647. /** @hidden */
  134648. export var pbrBlockFinalColorComposition: {
  134649. name: string;
  134650. shader: string;
  134651. };
  134652. }
  134653. declare module BABYLON {
  134654. /** @hidden */
  134655. export var pbrBlockImageProcessing: {
  134656. name: string;
  134657. shader: string;
  134658. };
  134659. }
  134660. declare module BABYLON {
  134661. /** @hidden */
  134662. export var pbrDebug: {
  134663. name: string;
  134664. shader: string;
  134665. };
  134666. }
  134667. declare module BABYLON {
  134668. /** @hidden */
  134669. export var pbrPixelShader: {
  134670. name: string;
  134671. shader: string;
  134672. };
  134673. }
  134674. declare module BABYLON {
  134675. /** @hidden */
  134676. export var pbrVertexDeclaration: {
  134677. name: string;
  134678. shader: string;
  134679. };
  134680. }
  134681. declare module BABYLON {
  134682. /** @hidden */
  134683. export var pbrVertexShader: {
  134684. name: string;
  134685. shader: string;
  134686. };
  134687. }
  134688. declare module BABYLON {
  134689. /**
  134690. * Manages the defines for the PBR Material.
  134691. * @hidden
  134692. */
  134693. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  134694. PBR: boolean;
  134695. NUM_SAMPLES: string;
  134696. REALTIME_FILTERING: boolean;
  134697. MAINUV1: boolean;
  134698. MAINUV2: boolean;
  134699. UV1: boolean;
  134700. UV2: boolean;
  134701. ALBEDO: boolean;
  134702. GAMMAALBEDO: boolean;
  134703. ALBEDODIRECTUV: number;
  134704. VERTEXCOLOR: boolean;
  134705. DETAIL: boolean;
  134706. DETAILDIRECTUV: number;
  134707. DETAIL_NORMALBLENDMETHOD: number;
  134708. AMBIENT: boolean;
  134709. AMBIENTDIRECTUV: number;
  134710. AMBIENTINGRAYSCALE: boolean;
  134711. OPACITY: boolean;
  134712. VERTEXALPHA: boolean;
  134713. OPACITYDIRECTUV: number;
  134714. OPACITYRGB: boolean;
  134715. ALPHATEST: boolean;
  134716. DEPTHPREPASS: boolean;
  134717. ALPHABLEND: boolean;
  134718. ALPHAFROMALBEDO: boolean;
  134719. ALPHATESTVALUE: string;
  134720. SPECULAROVERALPHA: boolean;
  134721. RADIANCEOVERALPHA: boolean;
  134722. ALPHAFRESNEL: boolean;
  134723. LINEARALPHAFRESNEL: boolean;
  134724. PREMULTIPLYALPHA: boolean;
  134725. EMISSIVE: boolean;
  134726. EMISSIVEDIRECTUV: number;
  134727. REFLECTIVITY: boolean;
  134728. REFLECTIVITYDIRECTUV: number;
  134729. SPECULARTERM: boolean;
  134730. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  134731. MICROSURFACEAUTOMATIC: boolean;
  134732. LODBASEDMICROSFURACE: boolean;
  134733. MICROSURFACEMAP: boolean;
  134734. MICROSURFACEMAPDIRECTUV: number;
  134735. METALLICWORKFLOW: boolean;
  134736. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  134737. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  134738. METALLNESSSTOREINMETALMAPBLUE: boolean;
  134739. AOSTOREINMETALMAPRED: boolean;
  134740. METALLIC_REFLECTANCE: boolean;
  134741. METALLIC_REFLECTANCEDIRECTUV: number;
  134742. ENVIRONMENTBRDF: boolean;
  134743. ENVIRONMENTBRDF_RGBD: boolean;
  134744. NORMAL: boolean;
  134745. TANGENT: boolean;
  134746. BUMP: boolean;
  134747. BUMPDIRECTUV: number;
  134748. OBJECTSPACE_NORMALMAP: boolean;
  134749. PARALLAX: boolean;
  134750. PARALLAXOCCLUSION: boolean;
  134751. NORMALXYSCALE: boolean;
  134752. LIGHTMAP: boolean;
  134753. LIGHTMAPDIRECTUV: number;
  134754. USELIGHTMAPASSHADOWMAP: boolean;
  134755. GAMMALIGHTMAP: boolean;
  134756. RGBDLIGHTMAP: boolean;
  134757. REFLECTION: boolean;
  134758. REFLECTIONMAP_3D: boolean;
  134759. REFLECTIONMAP_SPHERICAL: boolean;
  134760. REFLECTIONMAP_PLANAR: boolean;
  134761. REFLECTIONMAP_CUBIC: boolean;
  134762. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  134763. REFLECTIONMAP_PROJECTION: boolean;
  134764. REFLECTIONMAP_SKYBOX: boolean;
  134765. REFLECTIONMAP_EXPLICIT: boolean;
  134766. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  134767. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  134768. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  134769. INVERTCUBICMAP: boolean;
  134770. USESPHERICALFROMREFLECTIONMAP: boolean;
  134771. USEIRRADIANCEMAP: boolean;
  134772. SPHERICAL_HARMONICS: boolean;
  134773. USESPHERICALINVERTEX: boolean;
  134774. REFLECTIONMAP_OPPOSITEZ: boolean;
  134775. LODINREFLECTIONALPHA: boolean;
  134776. GAMMAREFLECTION: boolean;
  134777. RGBDREFLECTION: boolean;
  134778. LINEARSPECULARREFLECTION: boolean;
  134779. RADIANCEOCCLUSION: boolean;
  134780. HORIZONOCCLUSION: boolean;
  134781. INSTANCES: boolean;
  134782. THIN_INSTANCES: boolean;
  134783. PREPASS: boolean;
  134784. SCENE_MRT_COUNT: number;
  134785. NUM_BONE_INFLUENCERS: number;
  134786. BonesPerMesh: number;
  134787. BONETEXTURE: boolean;
  134788. NONUNIFORMSCALING: boolean;
  134789. MORPHTARGETS: boolean;
  134790. MORPHTARGETS_NORMAL: boolean;
  134791. MORPHTARGETS_TANGENT: boolean;
  134792. MORPHTARGETS_UV: boolean;
  134793. NUM_MORPH_INFLUENCERS: number;
  134794. IMAGEPROCESSING: boolean;
  134795. VIGNETTE: boolean;
  134796. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134797. VIGNETTEBLENDMODEOPAQUE: boolean;
  134798. TONEMAPPING: boolean;
  134799. TONEMAPPING_ACES: boolean;
  134800. CONTRAST: boolean;
  134801. COLORCURVES: boolean;
  134802. COLORGRADING: boolean;
  134803. COLORGRADING3D: boolean;
  134804. SAMPLER3DGREENDEPTH: boolean;
  134805. SAMPLER3DBGRMAP: boolean;
  134806. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134807. EXPOSURE: boolean;
  134808. MULTIVIEW: boolean;
  134809. USEPHYSICALLIGHTFALLOFF: boolean;
  134810. USEGLTFLIGHTFALLOFF: boolean;
  134811. TWOSIDEDLIGHTING: boolean;
  134812. SHADOWFLOAT: boolean;
  134813. CLIPPLANE: boolean;
  134814. CLIPPLANE2: boolean;
  134815. CLIPPLANE3: boolean;
  134816. CLIPPLANE4: boolean;
  134817. CLIPPLANE5: boolean;
  134818. CLIPPLANE6: boolean;
  134819. POINTSIZE: boolean;
  134820. FOG: boolean;
  134821. LOGARITHMICDEPTH: boolean;
  134822. FORCENORMALFORWARD: boolean;
  134823. SPECULARAA: boolean;
  134824. CLEARCOAT: boolean;
  134825. CLEARCOAT_DEFAULTIOR: boolean;
  134826. CLEARCOAT_TEXTURE: boolean;
  134827. CLEARCOAT_TEXTUREDIRECTUV: number;
  134828. CLEARCOAT_BUMP: boolean;
  134829. CLEARCOAT_BUMPDIRECTUV: number;
  134830. CLEARCOAT_TINT: boolean;
  134831. CLEARCOAT_TINT_TEXTURE: boolean;
  134832. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134833. ANISOTROPIC: boolean;
  134834. ANISOTROPIC_TEXTURE: boolean;
  134835. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134836. BRDF_V_HEIGHT_CORRELATED: boolean;
  134837. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134838. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134839. SHEEN: boolean;
  134840. SHEEN_TEXTURE: boolean;
  134841. SHEEN_TEXTUREDIRECTUV: number;
  134842. SHEEN_LINKWITHALBEDO: boolean;
  134843. SHEEN_ROUGHNESS: boolean;
  134844. SHEEN_ALBEDOSCALING: boolean;
  134845. SUBSURFACE: boolean;
  134846. SS_REFRACTION: boolean;
  134847. SS_TRANSLUCENCY: boolean;
  134848. SS_SCATTERING: boolean;
  134849. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134850. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134851. SS_REFRACTIONMAP_3D: boolean;
  134852. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134853. SS_LODINREFRACTIONALPHA: boolean;
  134854. SS_GAMMAREFRACTION: boolean;
  134855. SS_RGBDREFRACTION: boolean;
  134856. SS_LINEARSPECULARREFRACTION: boolean;
  134857. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134858. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134859. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134860. UNLIT: boolean;
  134861. DEBUGMODE: number;
  134862. /**
  134863. * Initializes the PBR Material defines.
  134864. */
  134865. constructor();
  134866. /**
  134867. * Resets the PBR Material defines.
  134868. */
  134869. reset(): void;
  134870. }
  134871. /**
  134872. * The Physically based material base class of BJS.
  134873. *
  134874. * This offers the main features of a standard PBR material.
  134875. * For more information, please refer to the documentation :
  134876. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134877. */
  134878. export abstract class PBRBaseMaterial extends PushMaterial {
  134879. /**
  134880. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134881. */
  134882. static readonly PBRMATERIAL_OPAQUE: number;
  134883. /**
  134884. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134885. */
  134886. static readonly PBRMATERIAL_ALPHATEST: number;
  134887. /**
  134888. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134889. */
  134890. static readonly PBRMATERIAL_ALPHABLEND: number;
  134891. /**
  134892. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134893. * They are also discarded below the alpha cutoff threshold to improve performances.
  134894. */
  134895. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134896. /**
  134897. * Defines the default value of how much AO map is occluding the analytical lights
  134898. * (point spot...).
  134899. */
  134900. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134901. /**
  134902. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  134903. */
  134904. static readonly LIGHTFALLOFF_PHYSICAL: number;
  134905. /**
  134906. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  134907. * to enhance interoperability with other engines.
  134908. */
  134909. static readonly LIGHTFALLOFF_GLTF: number;
  134910. /**
  134911. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  134912. * to enhance interoperability with other materials.
  134913. */
  134914. static readonly LIGHTFALLOFF_STANDARD: number;
  134915. /**
  134916. * Intensity of the direct lights e.g. the four lights available in your scene.
  134917. * This impacts both the direct diffuse and specular highlights.
  134918. */
  134919. protected _directIntensity: number;
  134920. /**
  134921. * Intensity of the emissive part of the material.
  134922. * This helps controlling the emissive effect without modifying the emissive color.
  134923. */
  134924. protected _emissiveIntensity: number;
  134925. /**
  134926. * Intensity of the environment e.g. how much the environment will light the object
  134927. * either through harmonics for rough material or through the refelction for shiny ones.
  134928. */
  134929. protected _environmentIntensity: number;
  134930. /**
  134931. * This is a special control allowing the reduction of the specular highlights coming from the
  134932. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134933. */
  134934. protected _specularIntensity: number;
  134935. /**
  134936. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  134937. */
  134938. private _lightingInfos;
  134939. /**
  134940. * Debug Control allowing disabling the bump map on this material.
  134941. */
  134942. protected _disableBumpMap: boolean;
  134943. /**
  134944. * AKA Diffuse Texture in standard nomenclature.
  134945. */
  134946. protected _albedoTexture: Nullable<BaseTexture>;
  134947. /**
  134948. * AKA Occlusion Texture in other nomenclature.
  134949. */
  134950. protected _ambientTexture: Nullable<BaseTexture>;
  134951. /**
  134952. * AKA Occlusion Texture Intensity in other nomenclature.
  134953. */
  134954. protected _ambientTextureStrength: number;
  134955. /**
  134956. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134957. * 1 means it completely occludes it
  134958. * 0 mean it has no impact
  134959. */
  134960. protected _ambientTextureImpactOnAnalyticalLights: number;
  134961. /**
  134962. * Stores the alpha values in a texture.
  134963. */
  134964. protected _opacityTexture: Nullable<BaseTexture>;
  134965. /**
  134966. * Stores the reflection values in a texture.
  134967. */
  134968. protected _reflectionTexture: Nullable<BaseTexture>;
  134969. /**
  134970. * Stores the emissive values in a texture.
  134971. */
  134972. protected _emissiveTexture: Nullable<BaseTexture>;
  134973. /**
  134974. * AKA Specular texture in other nomenclature.
  134975. */
  134976. protected _reflectivityTexture: Nullable<BaseTexture>;
  134977. /**
  134978. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134979. */
  134980. protected _metallicTexture: Nullable<BaseTexture>;
  134981. /**
  134982. * Specifies the metallic scalar of the metallic/roughness workflow.
  134983. * Can also be used to scale the metalness values of the metallic texture.
  134984. */
  134985. protected _metallic: Nullable<number>;
  134986. /**
  134987. * Specifies the roughness scalar of the metallic/roughness workflow.
  134988. * Can also be used to scale the roughness values of the metallic texture.
  134989. */
  134990. protected _roughness: Nullable<number>;
  134991. /**
  134992. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134993. * By default the indexOfrefraction is used to compute F0;
  134994. *
  134995. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134996. *
  134997. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134998. * F90 = metallicReflectanceColor;
  134999. */
  135000. protected _metallicF0Factor: number;
  135001. /**
  135002. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135003. * By default the F90 is always 1;
  135004. *
  135005. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135006. *
  135007. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135008. * F90 = metallicReflectanceColor;
  135009. */
  135010. protected _metallicReflectanceColor: Color3;
  135011. /**
  135012. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135013. * This is multiply against the scalar values defined in the material.
  135014. */
  135015. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  135016. /**
  135017. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135018. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135019. */
  135020. protected _microSurfaceTexture: Nullable<BaseTexture>;
  135021. /**
  135022. * Stores surface normal data used to displace a mesh in a texture.
  135023. */
  135024. protected _bumpTexture: Nullable<BaseTexture>;
  135025. /**
  135026. * Stores the pre-calculated light information of a mesh in a texture.
  135027. */
  135028. protected _lightmapTexture: Nullable<BaseTexture>;
  135029. /**
  135030. * The color of a material in ambient lighting.
  135031. */
  135032. protected _ambientColor: Color3;
  135033. /**
  135034. * AKA Diffuse Color in other nomenclature.
  135035. */
  135036. protected _albedoColor: Color3;
  135037. /**
  135038. * AKA Specular Color in other nomenclature.
  135039. */
  135040. protected _reflectivityColor: Color3;
  135041. /**
  135042. * The color applied when light is reflected from a material.
  135043. */
  135044. protected _reflectionColor: Color3;
  135045. /**
  135046. * The color applied when light is emitted from a material.
  135047. */
  135048. protected _emissiveColor: Color3;
  135049. /**
  135050. * AKA Glossiness in other nomenclature.
  135051. */
  135052. protected _microSurface: number;
  135053. /**
  135054. * Specifies that the material will use the light map as a show map.
  135055. */
  135056. protected _useLightmapAsShadowmap: boolean;
  135057. /**
  135058. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135059. * makes the reflect vector face the model (under horizon).
  135060. */
  135061. protected _useHorizonOcclusion: boolean;
  135062. /**
  135063. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135064. * too much the area relying on ambient texture to define their ambient occlusion.
  135065. */
  135066. protected _useRadianceOcclusion: boolean;
  135067. /**
  135068. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135069. */
  135070. protected _useAlphaFromAlbedoTexture: boolean;
  135071. /**
  135072. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  135073. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135074. */
  135075. protected _useSpecularOverAlpha: boolean;
  135076. /**
  135077. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135078. */
  135079. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135080. /**
  135081. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135082. */
  135083. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  135084. /**
  135085. * Specifies if the metallic texture contains the roughness information in its green channel.
  135086. */
  135087. protected _useRoughnessFromMetallicTextureGreen: boolean;
  135088. /**
  135089. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135090. */
  135091. protected _useMetallnessFromMetallicTextureBlue: boolean;
  135092. /**
  135093. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135094. */
  135095. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  135096. /**
  135097. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135098. */
  135099. protected _useAmbientInGrayScale: boolean;
  135100. /**
  135101. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135102. * The material will try to infer what glossiness each pixel should be.
  135103. */
  135104. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  135105. /**
  135106. * Defines the falloff type used in this material.
  135107. * It by default is Physical.
  135108. */
  135109. protected _lightFalloff: number;
  135110. /**
  135111. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135112. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135113. */
  135114. protected _useRadianceOverAlpha: boolean;
  135115. /**
  135116. * Allows using an object space normal map (instead of tangent space).
  135117. */
  135118. protected _useObjectSpaceNormalMap: boolean;
  135119. /**
  135120. * Allows using the bump map in parallax mode.
  135121. */
  135122. protected _useParallax: boolean;
  135123. /**
  135124. * Allows using the bump map in parallax occlusion mode.
  135125. */
  135126. protected _useParallaxOcclusion: boolean;
  135127. /**
  135128. * Controls the scale bias of the parallax mode.
  135129. */
  135130. protected _parallaxScaleBias: number;
  135131. /**
  135132. * If sets to true, disables all the lights affecting the material.
  135133. */
  135134. protected _disableLighting: boolean;
  135135. /**
  135136. * Number of Simultaneous lights allowed on the material.
  135137. */
  135138. protected _maxSimultaneousLights: number;
  135139. /**
  135140. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135141. */
  135142. protected _invertNormalMapX: boolean;
  135143. /**
  135144. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135145. */
  135146. protected _invertNormalMapY: boolean;
  135147. /**
  135148. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135149. */
  135150. protected _twoSidedLighting: boolean;
  135151. /**
  135152. * Defines the alpha limits in alpha test mode.
  135153. */
  135154. protected _alphaCutOff: number;
  135155. /**
  135156. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135157. */
  135158. protected _forceAlphaTest: boolean;
  135159. /**
  135160. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135161. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135162. */
  135163. protected _useAlphaFresnel: boolean;
  135164. /**
  135165. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135166. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135167. */
  135168. protected _useLinearAlphaFresnel: boolean;
  135169. /**
  135170. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  135171. * from cos thetav and roughness:
  135172. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  135173. */
  135174. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  135175. /**
  135176. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135177. */
  135178. protected _forceIrradianceInFragment: boolean;
  135179. private _realTimeFiltering;
  135180. /**
  135181. * Enables realtime filtering on the texture.
  135182. */
  135183. get realTimeFiltering(): boolean;
  135184. set realTimeFiltering(b: boolean);
  135185. private _realTimeFilteringQuality;
  135186. /**
  135187. * Quality switch for realtime filtering
  135188. */
  135189. get realTimeFilteringQuality(): number;
  135190. set realTimeFilteringQuality(n: number);
  135191. /**
  135192. * Can this material render to several textures at once
  135193. */
  135194. get canRenderToMRT(): boolean;
  135195. /**
  135196. * Force normal to face away from face.
  135197. */
  135198. protected _forceNormalForward: boolean;
  135199. /**
  135200. * Enables specular anti aliasing in the PBR shader.
  135201. * It will both interacts on the Geometry for analytical and IBL lighting.
  135202. * It also prefilter the roughness map based on the bump values.
  135203. */
  135204. protected _enableSpecularAntiAliasing: boolean;
  135205. /**
  135206. * Default configuration related to image processing available in the PBR Material.
  135207. */
  135208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135209. /**
  135210. * Keep track of the image processing observer to allow dispose and replace.
  135211. */
  135212. private _imageProcessingObserver;
  135213. /**
  135214. * Attaches a new image processing configuration to the PBR Material.
  135215. * @param configuration
  135216. */
  135217. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135218. /**
  135219. * Stores the available render targets.
  135220. */
  135221. private _renderTargets;
  135222. /**
  135223. * Sets the global ambient color for the material used in lighting calculations.
  135224. */
  135225. private _globalAmbientColor;
  135226. /**
  135227. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  135228. */
  135229. private _useLogarithmicDepth;
  135230. /**
  135231. * If set to true, no lighting calculations will be applied.
  135232. */
  135233. private _unlit;
  135234. private _debugMode;
  135235. /**
  135236. * @hidden
  135237. * This is reserved for the inspector.
  135238. * Defines the material debug mode.
  135239. * It helps seeing only some components of the material while troubleshooting.
  135240. */
  135241. debugMode: number;
  135242. /**
  135243. * @hidden
  135244. * This is reserved for the inspector.
  135245. * Specify from where on screen the debug mode should start.
  135246. * The value goes from -1 (full screen) to 1 (not visible)
  135247. * It helps with side by side comparison against the final render
  135248. * This defaults to -1
  135249. */
  135250. private debugLimit;
  135251. /**
  135252. * @hidden
  135253. * This is reserved for the inspector.
  135254. * As the default viewing range might not be enough (if the ambient is really small for instance)
  135255. * You can use the factor to better multiply the final value.
  135256. */
  135257. private debugFactor;
  135258. /**
  135259. * Defines the clear coat layer parameters for the material.
  135260. */
  135261. readonly clearCoat: PBRClearCoatConfiguration;
  135262. /**
  135263. * Defines the anisotropic parameters for the material.
  135264. */
  135265. readonly anisotropy: PBRAnisotropicConfiguration;
  135266. /**
  135267. * Defines the BRDF parameters for the material.
  135268. */
  135269. readonly brdf: PBRBRDFConfiguration;
  135270. /**
  135271. * Defines the Sheen parameters for the material.
  135272. */
  135273. readonly sheen: PBRSheenConfiguration;
  135274. /**
  135275. * Defines the SubSurface parameters for the material.
  135276. */
  135277. readonly subSurface: PBRSubSurfaceConfiguration;
  135278. /**
  135279. * Defines the detail map parameters for the material.
  135280. */
  135281. readonly detailMap: DetailMapConfiguration;
  135282. protected _rebuildInParallel: boolean;
  135283. /**
  135284. * Instantiates a new PBRMaterial instance.
  135285. *
  135286. * @param name The material name
  135287. * @param scene The scene the material will be use in.
  135288. */
  135289. constructor(name: string, scene: Scene);
  135290. /**
  135291. * Gets a boolean indicating that current material needs to register RTT
  135292. */
  135293. get hasRenderTargetTextures(): boolean;
  135294. /**
  135295. * Gets the name of the material class.
  135296. */
  135297. getClassName(): string;
  135298. /**
  135299. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135300. */
  135301. get useLogarithmicDepth(): boolean;
  135302. /**
  135303. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135304. */
  135305. set useLogarithmicDepth(value: boolean);
  135306. /**
  135307. * Returns true if alpha blending should be disabled.
  135308. */
  135309. protected get _disableAlphaBlending(): boolean;
  135310. /**
  135311. * Specifies whether or not this material should be rendered in alpha blend mode.
  135312. */
  135313. needAlphaBlending(): boolean;
  135314. /**
  135315. * Specifies whether or not this material should be rendered in alpha test mode.
  135316. */
  135317. needAlphaTesting(): boolean;
  135318. /**
  135319. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  135320. */
  135321. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  135322. /**
  135323. * Gets the texture used for the alpha test.
  135324. */
  135325. getAlphaTestTexture(): Nullable<BaseTexture>;
  135326. /**
  135327. * Specifies that the submesh is ready to be used.
  135328. * @param mesh - BJS mesh.
  135329. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  135330. * @param useInstances - Specifies that instances should be used.
  135331. * @returns - boolean indicating that the submesh is ready or not.
  135332. */
  135333. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135334. /**
  135335. * Specifies if the material uses metallic roughness workflow.
  135336. * @returns boolean specifiying if the material uses metallic roughness workflow.
  135337. */
  135338. isMetallicWorkflow(): boolean;
  135339. private _prepareEffect;
  135340. private _prepareDefines;
  135341. /**
  135342. * Force shader compilation
  135343. */
  135344. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  135345. /**
  135346. * Initializes the uniform buffer layout for the shader.
  135347. */
  135348. buildUniformLayout(): void;
  135349. /**
  135350. * Unbinds the material from the mesh
  135351. */
  135352. unbind(): void;
  135353. /**
  135354. * Binds the submesh data.
  135355. * @param world - The world matrix.
  135356. * @param mesh - The BJS mesh.
  135357. * @param subMesh - A submesh of the BJS mesh.
  135358. */
  135359. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135360. /**
  135361. * Returns the animatable textures.
  135362. * @returns - Array of animatable textures.
  135363. */
  135364. getAnimatables(): IAnimatable[];
  135365. /**
  135366. * Returns the texture used for reflections.
  135367. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  135368. */
  135369. private _getReflectionTexture;
  135370. /**
  135371. * Returns an array of the actively used textures.
  135372. * @returns - Array of BaseTextures
  135373. */
  135374. getActiveTextures(): BaseTexture[];
  135375. /**
  135376. * Checks to see if a texture is used in the material.
  135377. * @param texture - Base texture to use.
  135378. * @returns - Boolean specifying if a texture is used in the material.
  135379. */
  135380. hasTexture(texture: BaseTexture): boolean;
  135381. /**
  135382. * Sets the required values to the prepass renderer.
  135383. * @param prePassRenderer defines the prepass renderer to setup
  135384. */
  135385. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  135386. /**
  135387. * Disposes the resources of the material.
  135388. * @param forceDisposeEffect - Forces the disposal of effects.
  135389. * @param forceDisposeTextures - Forces the disposal of all textures.
  135390. */
  135391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135392. }
  135393. }
  135394. declare module BABYLON {
  135395. /**
  135396. * The Physically based material of BJS.
  135397. *
  135398. * This offers the main features of a standard PBR material.
  135399. * For more information, please refer to the documentation :
  135400. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135401. */
  135402. export class PBRMaterial extends PBRBaseMaterial {
  135403. /**
  135404. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135405. */
  135406. static readonly PBRMATERIAL_OPAQUE: number;
  135407. /**
  135408. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135409. */
  135410. static readonly PBRMATERIAL_ALPHATEST: number;
  135411. /**
  135412. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135413. */
  135414. static readonly PBRMATERIAL_ALPHABLEND: number;
  135415. /**
  135416. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135417. * They are also discarded below the alpha cutoff threshold to improve performances.
  135418. */
  135419. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135420. /**
  135421. * Defines the default value of how much AO map is occluding the analytical lights
  135422. * (point spot...).
  135423. */
  135424. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135425. /**
  135426. * Intensity of the direct lights e.g. the four lights available in your scene.
  135427. * This impacts both the direct diffuse and specular highlights.
  135428. */
  135429. directIntensity: number;
  135430. /**
  135431. * Intensity of the emissive part of the material.
  135432. * This helps controlling the emissive effect without modifying the emissive color.
  135433. */
  135434. emissiveIntensity: number;
  135435. /**
  135436. * Intensity of the environment e.g. how much the environment will light the object
  135437. * either through harmonics for rough material or through the refelction for shiny ones.
  135438. */
  135439. environmentIntensity: number;
  135440. /**
  135441. * This is a special control allowing the reduction of the specular highlights coming from the
  135442. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135443. */
  135444. specularIntensity: number;
  135445. /**
  135446. * Debug Control allowing disabling the bump map on this material.
  135447. */
  135448. disableBumpMap: boolean;
  135449. /**
  135450. * AKA Diffuse Texture in standard nomenclature.
  135451. */
  135452. albedoTexture: BaseTexture;
  135453. /**
  135454. * AKA Occlusion Texture in other nomenclature.
  135455. */
  135456. ambientTexture: BaseTexture;
  135457. /**
  135458. * AKA Occlusion Texture Intensity in other nomenclature.
  135459. */
  135460. ambientTextureStrength: number;
  135461. /**
  135462. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135463. * 1 means it completely occludes it
  135464. * 0 mean it has no impact
  135465. */
  135466. ambientTextureImpactOnAnalyticalLights: number;
  135467. /**
  135468. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  135469. */
  135470. opacityTexture: BaseTexture;
  135471. /**
  135472. * Stores the reflection values in a texture.
  135473. */
  135474. reflectionTexture: Nullable<BaseTexture>;
  135475. /**
  135476. * Stores the emissive values in a texture.
  135477. */
  135478. emissiveTexture: BaseTexture;
  135479. /**
  135480. * AKA Specular texture in other nomenclature.
  135481. */
  135482. reflectivityTexture: BaseTexture;
  135483. /**
  135484. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135485. */
  135486. metallicTexture: BaseTexture;
  135487. /**
  135488. * Specifies the metallic scalar of the metallic/roughness workflow.
  135489. * Can also be used to scale the metalness values of the metallic texture.
  135490. */
  135491. metallic: Nullable<number>;
  135492. /**
  135493. * Specifies the roughness scalar of the metallic/roughness workflow.
  135494. * Can also be used to scale the roughness values of the metallic texture.
  135495. */
  135496. roughness: Nullable<number>;
  135497. /**
  135498. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135499. * By default the indexOfrefraction is used to compute F0;
  135500. *
  135501. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135502. *
  135503. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135504. * F90 = metallicReflectanceColor;
  135505. */
  135506. metallicF0Factor: number;
  135507. /**
  135508. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135509. * By default the F90 is always 1;
  135510. *
  135511. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135512. *
  135513. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135514. * F90 = metallicReflectanceColor;
  135515. */
  135516. metallicReflectanceColor: Color3;
  135517. /**
  135518. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135519. * This is multiply against the scalar values defined in the material.
  135520. */
  135521. metallicReflectanceTexture: Nullable<BaseTexture>;
  135522. /**
  135523. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135524. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135525. */
  135526. microSurfaceTexture: BaseTexture;
  135527. /**
  135528. * Stores surface normal data used to displace a mesh in a texture.
  135529. */
  135530. bumpTexture: BaseTexture;
  135531. /**
  135532. * Stores the pre-calculated light information of a mesh in a texture.
  135533. */
  135534. lightmapTexture: BaseTexture;
  135535. /**
  135536. * Stores the refracted light information in a texture.
  135537. */
  135538. get refractionTexture(): Nullable<BaseTexture>;
  135539. set refractionTexture(value: Nullable<BaseTexture>);
  135540. /**
  135541. * The color of a material in ambient lighting.
  135542. */
  135543. ambientColor: Color3;
  135544. /**
  135545. * AKA Diffuse Color in other nomenclature.
  135546. */
  135547. albedoColor: Color3;
  135548. /**
  135549. * AKA Specular Color in other nomenclature.
  135550. */
  135551. reflectivityColor: Color3;
  135552. /**
  135553. * The color reflected from the material.
  135554. */
  135555. reflectionColor: Color3;
  135556. /**
  135557. * The color emitted from the material.
  135558. */
  135559. emissiveColor: Color3;
  135560. /**
  135561. * AKA Glossiness in other nomenclature.
  135562. */
  135563. microSurface: number;
  135564. /**
  135565. * Index of refraction of the material base layer.
  135566. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135567. *
  135568. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135569. *
  135570. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135571. */
  135572. get indexOfRefraction(): number;
  135573. set indexOfRefraction(value: number);
  135574. /**
  135575. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135576. */
  135577. get invertRefractionY(): boolean;
  135578. set invertRefractionY(value: boolean);
  135579. /**
  135580. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135581. * Materials half opaque for instance using refraction could benefit from this control.
  135582. */
  135583. get linkRefractionWithTransparency(): boolean;
  135584. set linkRefractionWithTransparency(value: boolean);
  135585. /**
  135586. * If true, the light map contains occlusion information instead of lighting info.
  135587. */
  135588. useLightmapAsShadowmap: boolean;
  135589. /**
  135590. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135591. */
  135592. useAlphaFromAlbedoTexture: boolean;
  135593. /**
  135594. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135595. */
  135596. forceAlphaTest: boolean;
  135597. /**
  135598. * Defines the alpha limits in alpha test mode.
  135599. */
  135600. alphaCutOff: number;
  135601. /**
  135602. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  135603. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135604. */
  135605. useSpecularOverAlpha: boolean;
  135606. /**
  135607. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135608. */
  135609. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135610. /**
  135611. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135612. */
  135613. useRoughnessFromMetallicTextureAlpha: boolean;
  135614. /**
  135615. * Specifies if the metallic texture contains the roughness information in its green channel.
  135616. */
  135617. useRoughnessFromMetallicTextureGreen: boolean;
  135618. /**
  135619. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135620. */
  135621. useMetallnessFromMetallicTextureBlue: boolean;
  135622. /**
  135623. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135624. */
  135625. useAmbientOcclusionFromMetallicTextureRed: boolean;
  135626. /**
  135627. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135628. */
  135629. useAmbientInGrayScale: boolean;
  135630. /**
  135631. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135632. * The material will try to infer what glossiness each pixel should be.
  135633. */
  135634. useAutoMicroSurfaceFromReflectivityMap: boolean;
  135635. /**
  135636. * BJS is using an harcoded light falloff based on a manually sets up range.
  135637. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135638. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135639. */
  135640. get usePhysicalLightFalloff(): boolean;
  135641. /**
  135642. * BJS is using an harcoded light falloff based on a manually sets up range.
  135643. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135644. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135645. */
  135646. set usePhysicalLightFalloff(value: boolean);
  135647. /**
  135648. * In order to support the falloff compatibility with gltf, a special mode has been added
  135649. * to reproduce the gltf light falloff.
  135650. */
  135651. get useGLTFLightFalloff(): boolean;
  135652. /**
  135653. * In order to support the falloff compatibility with gltf, a special mode has been added
  135654. * to reproduce the gltf light falloff.
  135655. */
  135656. set useGLTFLightFalloff(value: boolean);
  135657. /**
  135658. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135659. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135660. */
  135661. useRadianceOverAlpha: boolean;
  135662. /**
  135663. * Allows using an object space normal map (instead of tangent space).
  135664. */
  135665. useObjectSpaceNormalMap: boolean;
  135666. /**
  135667. * Allows using the bump map in parallax mode.
  135668. */
  135669. useParallax: boolean;
  135670. /**
  135671. * Allows using the bump map in parallax occlusion mode.
  135672. */
  135673. useParallaxOcclusion: boolean;
  135674. /**
  135675. * Controls the scale bias of the parallax mode.
  135676. */
  135677. parallaxScaleBias: number;
  135678. /**
  135679. * If sets to true, disables all the lights affecting the material.
  135680. */
  135681. disableLighting: boolean;
  135682. /**
  135683. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135684. */
  135685. forceIrradianceInFragment: boolean;
  135686. /**
  135687. * Number of Simultaneous lights allowed on the material.
  135688. */
  135689. maxSimultaneousLights: number;
  135690. /**
  135691. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  135692. */
  135693. invertNormalMapX: boolean;
  135694. /**
  135695. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  135696. */
  135697. invertNormalMapY: boolean;
  135698. /**
  135699. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135700. */
  135701. twoSidedLighting: boolean;
  135702. /**
  135703. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135704. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135705. */
  135706. useAlphaFresnel: boolean;
  135707. /**
  135708. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135709. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135710. */
  135711. useLinearAlphaFresnel: boolean;
  135712. /**
  135713. * Let user defines the brdf lookup texture used for IBL.
  135714. * A default 8bit version is embedded but you could point at :
  135715. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  135716. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  135717. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  135718. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  135719. */
  135720. environmentBRDFTexture: Nullable<BaseTexture>;
  135721. /**
  135722. * Force normal to face away from face.
  135723. */
  135724. forceNormalForward: boolean;
  135725. /**
  135726. * Enables specular anti aliasing in the PBR shader.
  135727. * It will both interacts on the Geometry for analytical and IBL lighting.
  135728. * It also prefilter the roughness map based on the bump values.
  135729. */
  135730. enableSpecularAntiAliasing: boolean;
  135731. /**
  135732. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135733. * makes the reflect vector face the model (under horizon).
  135734. */
  135735. useHorizonOcclusion: boolean;
  135736. /**
  135737. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135738. * too much the area relying on ambient texture to define their ambient occlusion.
  135739. */
  135740. useRadianceOcclusion: boolean;
  135741. /**
  135742. * If set to true, no lighting calculations will be applied.
  135743. */
  135744. unlit: boolean;
  135745. /**
  135746. * Gets the image processing configuration used either in this material.
  135747. */
  135748. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  135749. /**
  135750. * Sets the Default image processing configuration used either in the this material.
  135751. *
  135752. * If sets to null, the scene one is in use.
  135753. */
  135754. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  135755. /**
  135756. * Gets wether the color curves effect is enabled.
  135757. */
  135758. get cameraColorCurvesEnabled(): boolean;
  135759. /**
  135760. * Sets wether the color curves effect is enabled.
  135761. */
  135762. set cameraColorCurvesEnabled(value: boolean);
  135763. /**
  135764. * Gets wether the color grading effect is enabled.
  135765. */
  135766. get cameraColorGradingEnabled(): boolean;
  135767. /**
  135768. * Gets wether the color grading effect is enabled.
  135769. */
  135770. set cameraColorGradingEnabled(value: boolean);
  135771. /**
  135772. * Gets wether tonemapping is enabled or not.
  135773. */
  135774. get cameraToneMappingEnabled(): boolean;
  135775. /**
  135776. * Sets wether tonemapping is enabled or not
  135777. */
  135778. set cameraToneMappingEnabled(value: boolean);
  135779. /**
  135780. * The camera exposure used on this material.
  135781. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135782. * This corresponds to a photographic exposure.
  135783. */
  135784. get cameraExposure(): number;
  135785. /**
  135786. * The camera exposure used on this material.
  135787. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135788. * This corresponds to a photographic exposure.
  135789. */
  135790. set cameraExposure(value: number);
  135791. /**
  135792. * Gets The camera contrast used on this material.
  135793. */
  135794. get cameraContrast(): number;
  135795. /**
  135796. * Sets The camera contrast used on this material.
  135797. */
  135798. set cameraContrast(value: number);
  135799. /**
  135800. * Gets the Color Grading 2D Lookup Texture.
  135801. */
  135802. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135803. /**
  135804. * Sets the Color Grading 2D Lookup Texture.
  135805. */
  135806. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135807. /**
  135808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135810. * 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;
  135811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135812. */
  135813. get cameraColorCurves(): Nullable<ColorCurves>;
  135814. /**
  135815. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135816. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135817. * 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;
  135818. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135819. */
  135820. set cameraColorCurves(value: Nullable<ColorCurves>);
  135821. /**
  135822. * Instantiates a new PBRMaterial instance.
  135823. *
  135824. * @param name The material name
  135825. * @param scene The scene the material will be use in.
  135826. */
  135827. constructor(name: string, scene: Scene);
  135828. /**
  135829. * Returns the name of this material class.
  135830. */
  135831. getClassName(): string;
  135832. /**
  135833. * Makes a duplicate of the current material.
  135834. * @param name - name to use for the new material.
  135835. */
  135836. clone(name: string): PBRMaterial;
  135837. /**
  135838. * Serializes this PBR Material.
  135839. * @returns - An object with the serialized material.
  135840. */
  135841. serialize(): any;
  135842. /**
  135843. * Parses a PBR Material from a serialized object.
  135844. * @param source - Serialized object.
  135845. * @param scene - BJS scene instance.
  135846. * @param rootUrl - url for the scene object
  135847. * @returns - PBRMaterial
  135848. */
  135849. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  135850. }
  135851. }
  135852. declare module BABYLON {
  135853. /**
  135854. * Direct draw surface info
  135855. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  135856. */
  135857. export interface DDSInfo {
  135858. /**
  135859. * Width of the texture
  135860. */
  135861. width: number;
  135862. /**
  135863. * Width of the texture
  135864. */
  135865. height: number;
  135866. /**
  135867. * Number of Mipmaps for the texture
  135868. * @see https://en.wikipedia.org/wiki/Mipmap
  135869. */
  135870. mipmapCount: number;
  135871. /**
  135872. * If the textures format is a known fourCC format
  135873. * @see https://www.fourcc.org/
  135874. */
  135875. isFourCC: boolean;
  135876. /**
  135877. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  135878. */
  135879. isRGB: boolean;
  135880. /**
  135881. * If the texture is a lumincance format
  135882. */
  135883. isLuminance: boolean;
  135884. /**
  135885. * If this is a cube texture
  135886. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  135887. */
  135888. isCube: boolean;
  135889. /**
  135890. * If the texture is a compressed format eg. FOURCC_DXT1
  135891. */
  135892. isCompressed: boolean;
  135893. /**
  135894. * The dxgiFormat of the texture
  135895. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  135896. */
  135897. dxgiFormat: number;
  135898. /**
  135899. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  135900. */
  135901. textureType: number;
  135902. /**
  135903. * Sphericle polynomial created for the dds texture
  135904. */
  135905. sphericalPolynomial?: SphericalPolynomial;
  135906. }
  135907. /**
  135908. * Class used to provide DDS decompression tools
  135909. */
  135910. export class DDSTools {
  135911. /**
  135912. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  135913. */
  135914. static StoreLODInAlphaChannel: boolean;
  135915. /**
  135916. * Gets DDS information from an array buffer
  135917. * @param data defines the array buffer view to read data from
  135918. * @returns the DDS information
  135919. */
  135920. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  135921. private static _FloatView;
  135922. private static _Int32View;
  135923. private static _ToHalfFloat;
  135924. private static _FromHalfFloat;
  135925. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  135926. private static _GetHalfFloatRGBAArrayBuffer;
  135927. private static _GetFloatRGBAArrayBuffer;
  135928. private static _GetFloatAsUIntRGBAArrayBuffer;
  135929. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  135930. private static _GetRGBAArrayBuffer;
  135931. private static _ExtractLongWordOrder;
  135932. private static _GetRGBArrayBuffer;
  135933. private static _GetLuminanceArrayBuffer;
  135934. /**
  135935. * Uploads DDS Levels to a Babylon Texture
  135936. * @hidden
  135937. */
  135938. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  135939. }
  135940. interface ThinEngine {
  135941. /**
  135942. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  135943. * @param rootUrl defines the url where the file to load is located
  135944. * @param scene defines the current scene
  135945. * @param lodScale defines scale to apply to the mip map selection
  135946. * @param lodOffset defines offset to apply to the mip map selection
  135947. * @param onLoad defines an optional callback raised when the texture is loaded
  135948. * @param onError defines an optional callback raised if there is an issue to load the texture
  135949. * @param format defines the format of the data
  135950. * @param forcedExtension defines the extension to use to pick the right loader
  135951. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  135952. * @returns the cube texture as an InternalTexture
  135953. */
  135954. 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;
  135955. }
  135956. }
  135957. declare module BABYLON {
  135958. /**
  135959. * Implementation of the DDS Texture Loader.
  135960. * @hidden
  135961. */
  135962. export class _DDSTextureLoader implements IInternalTextureLoader {
  135963. /**
  135964. * Defines wether the loader supports cascade loading the different faces.
  135965. */
  135966. readonly supportCascades: boolean;
  135967. /**
  135968. * This returns if the loader support the current file information.
  135969. * @param extension defines the file extension of the file being loaded
  135970. * @returns true if the loader can load the specified file
  135971. */
  135972. canLoad(extension: string): boolean;
  135973. /**
  135974. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135975. * @param data contains the texture data
  135976. * @param texture defines the BabylonJS internal texture
  135977. * @param createPolynomials will be true if polynomials have been requested
  135978. * @param onLoad defines the callback to trigger once the texture is ready
  135979. * @param onError defines the callback to trigger in case of error
  135980. */
  135981. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135982. /**
  135983. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135984. * @param data contains the texture data
  135985. * @param texture defines the BabylonJS internal texture
  135986. * @param callback defines the method to call once ready to upload
  135987. */
  135988. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  135989. }
  135990. }
  135991. declare module BABYLON {
  135992. /**
  135993. * Implementation of the ENV Texture Loader.
  135994. * @hidden
  135995. */
  135996. export class _ENVTextureLoader implements IInternalTextureLoader {
  135997. /**
  135998. * Defines wether the loader supports cascade loading the different faces.
  135999. */
  136000. readonly supportCascades: boolean;
  136001. /**
  136002. * This returns if the loader support the current file information.
  136003. * @param extension defines the file extension of the file being loaded
  136004. * @returns true if the loader can load the specified file
  136005. */
  136006. canLoad(extension: string): boolean;
  136007. /**
  136008. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136009. * @param data contains the texture data
  136010. * @param texture defines the BabylonJS internal texture
  136011. * @param createPolynomials will be true if polynomials have been requested
  136012. * @param onLoad defines the callback to trigger once the texture is ready
  136013. * @param onError defines the callback to trigger in case of error
  136014. */
  136015. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136016. /**
  136017. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136018. * @param data contains the texture data
  136019. * @param texture defines the BabylonJS internal texture
  136020. * @param callback defines the method to call once ready to upload
  136021. */
  136022. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136023. }
  136024. }
  136025. declare module BABYLON {
  136026. /**
  136027. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136028. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136029. */
  136030. export class KhronosTextureContainer {
  136031. /** contents of the KTX container file */
  136032. data: ArrayBufferView;
  136033. private static HEADER_LEN;
  136034. private static COMPRESSED_2D;
  136035. private static COMPRESSED_3D;
  136036. private static TEX_2D;
  136037. private static TEX_3D;
  136038. /**
  136039. * Gets the openGL type
  136040. */
  136041. glType: number;
  136042. /**
  136043. * Gets the openGL type size
  136044. */
  136045. glTypeSize: number;
  136046. /**
  136047. * Gets the openGL format
  136048. */
  136049. glFormat: number;
  136050. /**
  136051. * Gets the openGL internal format
  136052. */
  136053. glInternalFormat: number;
  136054. /**
  136055. * Gets the base internal format
  136056. */
  136057. glBaseInternalFormat: number;
  136058. /**
  136059. * Gets image width in pixel
  136060. */
  136061. pixelWidth: number;
  136062. /**
  136063. * Gets image height in pixel
  136064. */
  136065. pixelHeight: number;
  136066. /**
  136067. * Gets image depth in pixels
  136068. */
  136069. pixelDepth: number;
  136070. /**
  136071. * Gets the number of array elements
  136072. */
  136073. numberOfArrayElements: number;
  136074. /**
  136075. * Gets the number of faces
  136076. */
  136077. numberOfFaces: number;
  136078. /**
  136079. * Gets the number of mipmap levels
  136080. */
  136081. numberOfMipmapLevels: number;
  136082. /**
  136083. * Gets the bytes of key value data
  136084. */
  136085. bytesOfKeyValueData: number;
  136086. /**
  136087. * Gets the load type
  136088. */
  136089. loadType: number;
  136090. /**
  136091. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  136092. */
  136093. isInvalid: boolean;
  136094. /**
  136095. * Creates a new KhronosTextureContainer
  136096. * @param data contents of the KTX container file
  136097. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  136098. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  136099. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  136100. */
  136101. constructor(
  136102. /** contents of the KTX container file */
  136103. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  136104. /**
  136105. * Uploads KTX content to a Babylon Texture.
  136106. * It is assumed that the texture has already been created & is currently bound
  136107. * @hidden
  136108. */
  136109. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  136110. private _upload2DCompressedLevels;
  136111. /**
  136112. * Checks if the given data starts with a KTX file identifier.
  136113. * @param data the data to check
  136114. * @returns true if the data is a KTX file or false otherwise
  136115. */
  136116. static IsValid(data: ArrayBufferView): boolean;
  136117. }
  136118. }
  136119. declare module BABYLON {
  136120. /**
  136121. * Class for loading KTX2 files
  136122. * !!! Experimental Extension Subject to Changes !!!
  136123. * @hidden
  136124. */
  136125. export class KhronosTextureContainer2 {
  136126. private static _ModulePromise;
  136127. private static _TranscodeFormat;
  136128. constructor(engine: ThinEngine);
  136129. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  136130. private _determineTranscodeFormat;
  136131. /**
  136132. * Checks if the given data starts with a KTX2 file identifier.
  136133. * @param data the data to check
  136134. * @returns true if the data is a KTX2 file or false otherwise
  136135. */
  136136. static IsValid(data: ArrayBufferView): boolean;
  136137. }
  136138. }
  136139. declare module BABYLON {
  136140. /**
  136141. * Implementation of the KTX Texture Loader.
  136142. * @hidden
  136143. */
  136144. export class _KTXTextureLoader implements IInternalTextureLoader {
  136145. /**
  136146. * Defines wether the loader supports cascade loading the different faces.
  136147. */
  136148. readonly supportCascades: boolean;
  136149. /**
  136150. * This returns if the loader support the current file information.
  136151. * @param extension defines the file extension of the file being loaded
  136152. * @param mimeType defines the optional mime type of the file being loaded
  136153. * @returns true if the loader can load the specified file
  136154. */
  136155. canLoad(extension: string, mimeType?: string): boolean;
  136156. /**
  136157. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136158. * @param data contains the texture data
  136159. * @param texture defines the BabylonJS internal texture
  136160. * @param createPolynomials will be true if polynomials have been requested
  136161. * @param onLoad defines the callback to trigger once the texture is ready
  136162. * @param onError defines the callback to trigger in case of error
  136163. */
  136164. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136165. /**
  136166. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136167. * @param data contains the texture data
  136168. * @param texture defines the BabylonJS internal texture
  136169. * @param callback defines the method to call once ready to upload
  136170. */
  136171. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  136172. }
  136173. }
  136174. declare module BABYLON {
  136175. /** @hidden */
  136176. export var _forceSceneHelpersToBundle: boolean;
  136177. interface Scene {
  136178. /**
  136179. * Creates a default light for the scene.
  136180. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  136181. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  136182. */
  136183. createDefaultLight(replace?: boolean): void;
  136184. /**
  136185. * Creates a default camera for the scene.
  136186. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  136187. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136188. * @param replace has default false, when true replaces the active camera in the scene
  136189. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  136190. */
  136191. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136192. /**
  136193. * Creates a default camera and a default light.
  136194. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  136195. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136196. * @param replace has the default false, when true replaces the active camera/light in the scene
  136197. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  136198. */
  136199. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136200. /**
  136201. * Creates a new sky box
  136202. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  136203. * @param environmentTexture defines the texture to use as environment texture
  136204. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  136205. * @param scale defines the overall scale of the skybox
  136206. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  136207. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  136208. * @returns a new mesh holding the sky box
  136209. */
  136210. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  136211. /**
  136212. * Creates a new environment
  136213. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  136214. * @param options defines the options you can use to configure the environment
  136215. * @returns the new EnvironmentHelper
  136216. */
  136217. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  136218. /**
  136219. * Creates a new VREXperienceHelper
  136220. * @see https://doc.babylonjs.com/how_to/webvr_helper
  136221. * @param webVROptions defines the options used to create the new VREXperienceHelper
  136222. * @returns a new VREXperienceHelper
  136223. */
  136224. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  136225. /**
  136226. * Creates a new WebXRDefaultExperience
  136227. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  136228. * @param options experience options
  136229. * @returns a promise for a new WebXRDefaultExperience
  136230. */
  136231. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  136232. }
  136233. }
  136234. declare module BABYLON {
  136235. /**
  136236. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  136237. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  136238. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  136239. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  136240. */
  136241. export class VideoDome extends TransformNode {
  136242. /**
  136243. * Define the video source as a Monoscopic panoramic 360 video.
  136244. */
  136245. static readonly MODE_MONOSCOPIC: number;
  136246. /**
  136247. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136248. */
  136249. static readonly MODE_TOPBOTTOM: number;
  136250. /**
  136251. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136252. */
  136253. static readonly MODE_SIDEBYSIDE: number;
  136254. private _halfDome;
  136255. private _useDirectMapping;
  136256. /**
  136257. * The video texture being displayed on the sphere
  136258. */
  136259. protected _videoTexture: VideoTexture;
  136260. /**
  136261. * Gets the video texture being displayed on the sphere
  136262. */
  136263. get videoTexture(): VideoTexture;
  136264. /**
  136265. * The skybox material
  136266. */
  136267. protected _material: BackgroundMaterial;
  136268. /**
  136269. * The surface used for the video dome
  136270. */
  136271. protected _mesh: Mesh;
  136272. /**
  136273. * Gets the mesh used for the video dome.
  136274. */
  136275. get mesh(): Mesh;
  136276. /**
  136277. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  136278. */
  136279. private _halfDomeMask;
  136280. /**
  136281. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  136282. * Also see the options.resolution property.
  136283. */
  136284. get fovMultiplier(): number;
  136285. set fovMultiplier(value: number);
  136286. private _videoMode;
  136287. /**
  136288. * Gets or set the current video mode for the video. It can be:
  136289. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  136290. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136291. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136292. */
  136293. get videoMode(): number;
  136294. set videoMode(value: number);
  136295. /**
  136296. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  136297. *
  136298. */
  136299. get halfDome(): boolean;
  136300. /**
  136301. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  136302. */
  136303. set halfDome(enabled: boolean);
  136304. /**
  136305. * Oberserver used in Stereoscopic VR Mode.
  136306. */
  136307. private _onBeforeCameraRenderObserver;
  136308. /**
  136309. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  136310. * @param name Element's name, child elements will append suffixes for their own names.
  136311. * @param urlsOrVideo defines the url(s) or the video element to use
  136312. * @param options An object containing optional or exposed sub element properties
  136313. */
  136314. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  136315. resolution?: number;
  136316. clickToPlay?: boolean;
  136317. autoPlay?: boolean;
  136318. loop?: boolean;
  136319. size?: number;
  136320. poster?: string;
  136321. faceForward?: boolean;
  136322. useDirectMapping?: boolean;
  136323. halfDomeMode?: boolean;
  136324. }, scene: Scene);
  136325. private _changeVideoMode;
  136326. /**
  136327. * Releases resources associated with this node.
  136328. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  136329. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  136330. */
  136331. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  136332. }
  136333. }
  136334. declare module BABYLON {
  136335. /**
  136336. * This class can be used to get instrumentation data from a Babylon engine
  136337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136338. */
  136339. export class EngineInstrumentation implements IDisposable {
  136340. /**
  136341. * Define the instrumented engine.
  136342. */
  136343. engine: Engine;
  136344. private _captureGPUFrameTime;
  136345. private _gpuFrameTimeToken;
  136346. private _gpuFrameTime;
  136347. private _captureShaderCompilationTime;
  136348. private _shaderCompilationTime;
  136349. private _onBeginFrameObserver;
  136350. private _onEndFrameObserver;
  136351. private _onBeforeShaderCompilationObserver;
  136352. private _onAfterShaderCompilationObserver;
  136353. /**
  136354. * Gets the perf counter used for GPU frame time
  136355. */
  136356. get gpuFrameTimeCounter(): PerfCounter;
  136357. /**
  136358. * Gets the GPU frame time capture status
  136359. */
  136360. get captureGPUFrameTime(): boolean;
  136361. /**
  136362. * Enable or disable the GPU frame time capture
  136363. */
  136364. set captureGPUFrameTime(value: boolean);
  136365. /**
  136366. * Gets the perf counter used for shader compilation time
  136367. */
  136368. get shaderCompilationTimeCounter(): PerfCounter;
  136369. /**
  136370. * Gets the shader compilation time capture status
  136371. */
  136372. get captureShaderCompilationTime(): boolean;
  136373. /**
  136374. * Enable or disable the shader compilation time capture
  136375. */
  136376. set captureShaderCompilationTime(value: boolean);
  136377. /**
  136378. * Instantiates a new engine instrumentation.
  136379. * This class can be used to get instrumentation data from a Babylon engine
  136380. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136381. * @param engine Defines the engine to instrument
  136382. */
  136383. constructor(
  136384. /**
  136385. * Define the instrumented engine.
  136386. */
  136387. engine: Engine);
  136388. /**
  136389. * Dispose and release associated resources.
  136390. */
  136391. dispose(): void;
  136392. }
  136393. }
  136394. declare module BABYLON {
  136395. /**
  136396. * This class can be used to get instrumentation data from a Babylon engine
  136397. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136398. */
  136399. export class SceneInstrumentation implements IDisposable {
  136400. /**
  136401. * Defines the scene to instrument
  136402. */
  136403. scene: Scene;
  136404. private _captureActiveMeshesEvaluationTime;
  136405. private _activeMeshesEvaluationTime;
  136406. private _captureRenderTargetsRenderTime;
  136407. private _renderTargetsRenderTime;
  136408. private _captureFrameTime;
  136409. private _frameTime;
  136410. private _captureRenderTime;
  136411. private _renderTime;
  136412. private _captureInterFrameTime;
  136413. private _interFrameTime;
  136414. private _captureParticlesRenderTime;
  136415. private _particlesRenderTime;
  136416. private _captureSpritesRenderTime;
  136417. private _spritesRenderTime;
  136418. private _capturePhysicsTime;
  136419. private _physicsTime;
  136420. private _captureAnimationsTime;
  136421. private _animationsTime;
  136422. private _captureCameraRenderTime;
  136423. private _cameraRenderTime;
  136424. private _onBeforeActiveMeshesEvaluationObserver;
  136425. private _onAfterActiveMeshesEvaluationObserver;
  136426. private _onBeforeRenderTargetsRenderObserver;
  136427. private _onAfterRenderTargetsRenderObserver;
  136428. private _onAfterRenderObserver;
  136429. private _onBeforeDrawPhaseObserver;
  136430. private _onAfterDrawPhaseObserver;
  136431. private _onBeforeAnimationsObserver;
  136432. private _onBeforeParticlesRenderingObserver;
  136433. private _onAfterParticlesRenderingObserver;
  136434. private _onBeforeSpritesRenderingObserver;
  136435. private _onAfterSpritesRenderingObserver;
  136436. private _onBeforePhysicsObserver;
  136437. private _onAfterPhysicsObserver;
  136438. private _onAfterAnimationsObserver;
  136439. private _onBeforeCameraRenderObserver;
  136440. private _onAfterCameraRenderObserver;
  136441. /**
  136442. * Gets the perf counter used for active meshes evaluation time
  136443. */
  136444. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  136445. /**
  136446. * Gets the active meshes evaluation time capture status
  136447. */
  136448. get captureActiveMeshesEvaluationTime(): boolean;
  136449. /**
  136450. * Enable or disable the active meshes evaluation time capture
  136451. */
  136452. set captureActiveMeshesEvaluationTime(value: boolean);
  136453. /**
  136454. * Gets the perf counter used for render targets render time
  136455. */
  136456. get renderTargetsRenderTimeCounter(): PerfCounter;
  136457. /**
  136458. * Gets the render targets render time capture status
  136459. */
  136460. get captureRenderTargetsRenderTime(): boolean;
  136461. /**
  136462. * Enable or disable the render targets render time capture
  136463. */
  136464. set captureRenderTargetsRenderTime(value: boolean);
  136465. /**
  136466. * Gets the perf counter used for particles render time
  136467. */
  136468. get particlesRenderTimeCounter(): PerfCounter;
  136469. /**
  136470. * Gets the particles render time capture status
  136471. */
  136472. get captureParticlesRenderTime(): boolean;
  136473. /**
  136474. * Enable or disable the particles render time capture
  136475. */
  136476. set captureParticlesRenderTime(value: boolean);
  136477. /**
  136478. * Gets the perf counter used for sprites render time
  136479. */
  136480. get spritesRenderTimeCounter(): PerfCounter;
  136481. /**
  136482. * Gets the sprites render time capture status
  136483. */
  136484. get captureSpritesRenderTime(): boolean;
  136485. /**
  136486. * Enable or disable the sprites render time capture
  136487. */
  136488. set captureSpritesRenderTime(value: boolean);
  136489. /**
  136490. * Gets the perf counter used for physics time
  136491. */
  136492. get physicsTimeCounter(): PerfCounter;
  136493. /**
  136494. * Gets the physics time capture status
  136495. */
  136496. get capturePhysicsTime(): boolean;
  136497. /**
  136498. * Enable or disable the physics time capture
  136499. */
  136500. set capturePhysicsTime(value: boolean);
  136501. /**
  136502. * Gets the perf counter used for animations time
  136503. */
  136504. get animationsTimeCounter(): PerfCounter;
  136505. /**
  136506. * Gets the animations time capture status
  136507. */
  136508. get captureAnimationsTime(): boolean;
  136509. /**
  136510. * Enable or disable the animations time capture
  136511. */
  136512. set captureAnimationsTime(value: boolean);
  136513. /**
  136514. * Gets the perf counter used for frame time capture
  136515. */
  136516. get frameTimeCounter(): PerfCounter;
  136517. /**
  136518. * Gets the frame time capture status
  136519. */
  136520. get captureFrameTime(): boolean;
  136521. /**
  136522. * Enable or disable the frame time capture
  136523. */
  136524. set captureFrameTime(value: boolean);
  136525. /**
  136526. * Gets the perf counter used for inter-frames time capture
  136527. */
  136528. get interFrameTimeCounter(): PerfCounter;
  136529. /**
  136530. * Gets the inter-frames time capture status
  136531. */
  136532. get captureInterFrameTime(): boolean;
  136533. /**
  136534. * Enable or disable the inter-frames time capture
  136535. */
  136536. set captureInterFrameTime(value: boolean);
  136537. /**
  136538. * Gets the perf counter used for render time capture
  136539. */
  136540. get renderTimeCounter(): PerfCounter;
  136541. /**
  136542. * Gets the render time capture status
  136543. */
  136544. get captureRenderTime(): boolean;
  136545. /**
  136546. * Enable or disable the render time capture
  136547. */
  136548. set captureRenderTime(value: boolean);
  136549. /**
  136550. * Gets the perf counter used for camera render time capture
  136551. */
  136552. get cameraRenderTimeCounter(): PerfCounter;
  136553. /**
  136554. * Gets the camera render time capture status
  136555. */
  136556. get captureCameraRenderTime(): boolean;
  136557. /**
  136558. * Enable or disable the camera render time capture
  136559. */
  136560. set captureCameraRenderTime(value: boolean);
  136561. /**
  136562. * Gets the perf counter used for draw calls
  136563. */
  136564. get drawCallsCounter(): PerfCounter;
  136565. /**
  136566. * Instantiates a new scene instrumentation.
  136567. * This class can be used to get instrumentation data from a Babylon engine
  136568. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136569. * @param scene Defines the scene to instrument
  136570. */
  136571. constructor(
  136572. /**
  136573. * Defines the scene to instrument
  136574. */
  136575. scene: Scene);
  136576. /**
  136577. * Dispose and release associated resources.
  136578. */
  136579. dispose(): void;
  136580. }
  136581. }
  136582. declare module BABYLON {
  136583. /** @hidden */
  136584. export var glowMapGenerationPixelShader: {
  136585. name: string;
  136586. shader: string;
  136587. };
  136588. }
  136589. declare module BABYLON {
  136590. /** @hidden */
  136591. export var glowMapGenerationVertexShader: {
  136592. name: string;
  136593. shader: string;
  136594. };
  136595. }
  136596. declare module BABYLON {
  136597. /**
  136598. * Effect layer options. This helps customizing the behaviour
  136599. * of the effect layer.
  136600. */
  136601. export interface IEffectLayerOptions {
  136602. /**
  136603. * Multiplication factor apply to the canvas size to compute the render target size
  136604. * used to generated the objects (the smaller the faster).
  136605. */
  136606. mainTextureRatio: number;
  136607. /**
  136608. * Enforces a fixed size texture to ensure effect stability across devices.
  136609. */
  136610. mainTextureFixedSize?: number;
  136611. /**
  136612. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  136613. */
  136614. alphaBlendingMode: number;
  136615. /**
  136616. * The camera attached to the layer.
  136617. */
  136618. camera: Nullable<Camera>;
  136619. /**
  136620. * The rendering group to draw the layer in.
  136621. */
  136622. renderingGroupId: number;
  136623. }
  136624. /**
  136625. * The effect layer Helps adding post process effect blended with the main pass.
  136626. *
  136627. * This can be for instance use to generate glow or higlight effects on the scene.
  136628. *
  136629. * The effect layer class can not be used directly and is intented to inherited from to be
  136630. * customized per effects.
  136631. */
  136632. export abstract class EffectLayer {
  136633. private _vertexBuffers;
  136634. private _indexBuffer;
  136635. private _cachedDefines;
  136636. private _effectLayerMapGenerationEffect;
  136637. private _effectLayerOptions;
  136638. private _mergeEffect;
  136639. protected _scene: Scene;
  136640. protected _engine: Engine;
  136641. protected _maxSize: number;
  136642. protected _mainTextureDesiredSize: ISize;
  136643. protected _mainTexture: RenderTargetTexture;
  136644. protected _shouldRender: boolean;
  136645. protected _postProcesses: PostProcess[];
  136646. protected _textures: BaseTexture[];
  136647. protected _emissiveTextureAndColor: {
  136648. texture: Nullable<BaseTexture>;
  136649. color: Color4;
  136650. };
  136651. /**
  136652. * The name of the layer
  136653. */
  136654. name: string;
  136655. /**
  136656. * The clear color of the texture used to generate the glow map.
  136657. */
  136658. neutralColor: Color4;
  136659. /**
  136660. * Specifies whether the highlight layer is enabled or not.
  136661. */
  136662. isEnabled: boolean;
  136663. /**
  136664. * Gets the camera attached to the layer.
  136665. */
  136666. get camera(): Nullable<Camera>;
  136667. /**
  136668. * Gets the rendering group id the layer should render in.
  136669. */
  136670. get renderingGroupId(): number;
  136671. set renderingGroupId(renderingGroupId: number);
  136672. /**
  136673. * An event triggered when the effect layer has been disposed.
  136674. */
  136675. onDisposeObservable: Observable<EffectLayer>;
  136676. /**
  136677. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  136678. */
  136679. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  136680. /**
  136681. * An event triggered when the generated texture is being merged in the scene.
  136682. */
  136683. onBeforeComposeObservable: Observable<EffectLayer>;
  136684. /**
  136685. * An event triggered when the mesh is rendered into the effect render target.
  136686. */
  136687. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  136688. /**
  136689. * An event triggered after the mesh has been rendered into the effect render target.
  136690. */
  136691. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  136692. /**
  136693. * An event triggered when the generated texture has been merged in the scene.
  136694. */
  136695. onAfterComposeObservable: Observable<EffectLayer>;
  136696. /**
  136697. * An event triggered when the efffect layer changes its size.
  136698. */
  136699. onSizeChangedObservable: Observable<EffectLayer>;
  136700. /** @hidden */
  136701. static _SceneComponentInitialization: (scene: Scene) => void;
  136702. /**
  136703. * Instantiates a new effect Layer and references it in the scene.
  136704. * @param name The name of the layer
  136705. * @param scene The scene to use the layer in
  136706. */
  136707. constructor(
  136708. /** The Friendly of the effect in the scene */
  136709. name: string, scene: Scene);
  136710. /**
  136711. * Get the effect name of the layer.
  136712. * @return The effect name
  136713. */
  136714. abstract getEffectName(): string;
  136715. /**
  136716. * Checks for the readiness of the element composing the layer.
  136717. * @param subMesh the mesh to check for
  136718. * @param useInstances specify whether or not to use instances to render the mesh
  136719. * @return true if ready otherwise, false
  136720. */
  136721. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136722. /**
  136723. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136724. * @returns true if the effect requires stencil during the main canvas render pass.
  136725. */
  136726. abstract needStencil(): boolean;
  136727. /**
  136728. * Create the merge effect. This is the shader use to blit the information back
  136729. * to the main canvas at the end of the scene rendering.
  136730. * @returns The effect containing the shader used to merge the effect on the main canvas
  136731. */
  136732. protected abstract _createMergeEffect(): Effect;
  136733. /**
  136734. * Creates the render target textures and post processes used in the effect layer.
  136735. */
  136736. protected abstract _createTextureAndPostProcesses(): void;
  136737. /**
  136738. * Implementation specific of rendering the generating effect on the main canvas.
  136739. * @param effect The effect used to render through
  136740. */
  136741. protected abstract _internalRender(effect: Effect): void;
  136742. /**
  136743. * Sets the required values for both the emissive texture and and the main color.
  136744. */
  136745. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136746. /**
  136747. * Free any resources and references associated to a mesh.
  136748. * Internal use
  136749. * @param mesh The mesh to free.
  136750. */
  136751. abstract _disposeMesh(mesh: Mesh): void;
  136752. /**
  136753. * Serializes this layer (Glow or Highlight for example)
  136754. * @returns a serialized layer object
  136755. */
  136756. abstract serialize?(): any;
  136757. /**
  136758. * Initializes the effect layer with the required options.
  136759. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  136760. */
  136761. protected _init(options: Partial<IEffectLayerOptions>): void;
  136762. /**
  136763. * Generates the index buffer of the full screen quad blending to the main canvas.
  136764. */
  136765. private _generateIndexBuffer;
  136766. /**
  136767. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  136768. */
  136769. private _generateVertexBuffer;
  136770. /**
  136771. * Sets the main texture desired size which is the closest power of two
  136772. * of the engine canvas size.
  136773. */
  136774. private _setMainTextureSize;
  136775. /**
  136776. * Creates the main texture for the effect layer.
  136777. */
  136778. protected _createMainTexture(): void;
  136779. /**
  136780. * Adds specific effects defines.
  136781. * @param defines The defines to add specifics to.
  136782. */
  136783. protected _addCustomEffectDefines(defines: string[]): void;
  136784. /**
  136785. * Checks for the readiness of the element composing the layer.
  136786. * @param subMesh the mesh to check for
  136787. * @param useInstances specify whether or not to use instances to render the mesh
  136788. * @param emissiveTexture the associated emissive texture used to generate the glow
  136789. * @return true if ready otherwise, false
  136790. */
  136791. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  136792. /**
  136793. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  136794. */
  136795. render(): void;
  136796. /**
  136797. * Determine if a given mesh will be used in the current effect.
  136798. * @param mesh mesh to test
  136799. * @returns true if the mesh will be used
  136800. */
  136801. hasMesh(mesh: AbstractMesh): boolean;
  136802. /**
  136803. * Returns true if the layer contains information to display, otherwise false.
  136804. * @returns true if the glow layer should be rendered
  136805. */
  136806. shouldRender(): boolean;
  136807. /**
  136808. * Returns true if the mesh should render, otherwise false.
  136809. * @param mesh The mesh to render
  136810. * @returns true if it should render otherwise false
  136811. */
  136812. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  136813. /**
  136814. * Returns true if the mesh can be rendered, otherwise false.
  136815. * @param mesh The mesh to render
  136816. * @param material The material used on the mesh
  136817. * @returns true if it can be rendered otherwise false
  136818. */
  136819. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136820. /**
  136821. * Returns true if the mesh should render, otherwise false.
  136822. * @param mesh The mesh to render
  136823. * @returns true if it should render otherwise false
  136824. */
  136825. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  136826. /**
  136827. * Renders the submesh passed in parameter to the generation map.
  136828. */
  136829. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  136830. /**
  136831. * Defines whether the current material of the mesh should be use to render the effect.
  136832. * @param mesh defines the current mesh to render
  136833. */
  136834. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136835. /**
  136836. * Rebuild the required buffers.
  136837. * @hidden Internal use only.
  136838. */
  136839. _rebuild(): void;
  136840. /**
  136841. * Dispose only the render target textures and post process.
  136842. */
  136843. private _disposeTextureAndPostProcesses;
  136844. /**
  136845. * Dispose the highlight layer and free resources.
  136846. */
  136847. dispose(): void;
  136848. /**
  136849. * Gets the class name of the effect layer
  136850. * @returns the string with the class name of the effect layer
  136851. */
  136852. getClassName(): string;
  136853. /**
  136854. * Creates an effect layer from parsed effect layer data
  136855. * @param parsedEffectLayer defines effect layer data
  136856. * @param scene defines the current scene
  136857. * @param rootUrl defines the root URL containing the effect layer information
  136858. * @returns a parsed effect Layer
  136859. */
  136860. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  136861. }
  136862. }
  136863. declare module BABYLON {
  136864. interface AbstractScene {
  136865. /**
  136866. * The list of effect layers (highlights/glow) added to the scene
  136867. * @see https://doc.babylonjs.com/how_to/highlight_layer
  136868. * @see https://doc.babylonjs.com/how_to/glow_layer
  136869. */
  136870. effectLayers: Array<EffectLayer>;
  136871. /**
  136872. * Removes the given effect layer from this scene.
  136873. * @param toRemove defines the effect layer to remove
  136874. * @returns the index of the removed effect layer
  136875. */
  136876. removeEffectLayer(toRemove: EffectLayer): number;
  136877. /**
  136878. * Adds the given effect layer to this scene
  136879. * @param newEffectLayer defines the effect layer to add
  136880. */
  136881. addEffectLayer(newEffectLayer: EffectLayer): void;
  136882. }
  136883. /**
  136884. * Defines the layer scene component responsible to manage any effect layers
  136885. * in a given scene.
  136886. */
  136887. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  136888. /**
  136889. * The component name helpfull to identify the component in the list of scene components.
  136890. */
  136891. readonly name: string;
  136892. /**
  136893. * The scene the component belongs to.
  136894. */
  136895. scene: Scene;
  136896. private _engine;
  136897. private _renderEffects;
  136898. private _needStencil;
  136899. private _previousStencilState;
  136900. /**
  136901. * Creates a new instance of the component for the given scene
  136902. * @param scene Defines the scene to register the component in
  136903. */
  136904. constructor(scene: Scene);
  136905. /**
  136906. * Registers the component in a given scene
  136907. */
  136908. register(): void;
  136909. /**
  136910. * Rebuilds the elements related to this component in case of
  136911. * context lost for instance.
  136912. */
  136913. rebuild(): void;
  136914. /**
  136915. * Serializes the component data to the specified json object
  136916. * @param serializationObject The object to serialize to
  136917. */
  136918. serialize(serializationObject: any): void;
  136919. /**
  136920. * Adds all the elements from the container to the scene
  136921. * @param container the container holding the elements
  136922. */
  136923. addFromContainer(container: AbstractScene): void;
  136924. /**
  136925. * Removes all the elements in the container from the scene
  136926. * @param container contains the elements to remove
  136927. * @param dispose if the removed element should be disposed (default: false)
  136928. */
  136929. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136930. /**
  136931. * Disposes the component and the associated ressources.
  136932. */
  136933. dispose(): void;
  136934. private _isReadyForMesh;
  136935. private _renderMainTexture;
  136936. private _setStencil;
  136937. private _setStencilBack;
  136938. private _draw;
  136939. private _drawCamera;
  136940. private _drawRenderingGroup;
  136941. }
  136942. }
  136943. declare module BABYLON {
  136944. /** @hidden */
  136945. export var glowMapMergePixelShader: {
  136946. name: string;
  136947. shader: string;
  136948. };
  136949. }
  136950. declare module BABYLON {
  136951. /** @hidden */
  136952. export var glowMapMergeVertexShader: {
  136953. name: string;
  136954. shader: string;
  136955. };
  136956. }
  136957. declare module BABYLON {
  136958. interface AbstractScene {
  136959. /**
  136960. * Return a the first highlight layer of the scene with a given name.
  136961. * @param name The name of the highlight layer to look for.
  136962. * @return The highlight layer if found otherwise null.
  136963. */
  136964. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  136965. }
  136966. /**
  136967. * Glow layer options. This helps customizing the behaviour
  136968. * of the glow layer.
  136969. */
  136970. export interface IGlowLayerOptions {
  136971. /**
  136972. * Multiplication factor apply to the canvas size to compute the render target size
  136973. * used to generated the glowing objects (the smaller the faster).
  136974. */
  136975. mainTextureRatio: number;
  136976. /**
  136977. * Enforces a fixed size texture to ensure resize independant blur.
  136978. */
  136979. mainTextureFixedSize?: number;
  136980. /**
  136981. * How big is the kernel of the blur texture.
  136982. */
  136983. blurKernelSize: number;
  136984. /**
  136985. * The camera attached to the layer.
  136986. */
  136987. camera: Nullable<Camera>;
  136988. /**
  136989. * Enable MSAA by chosing the number of samples.
  136990. */
  136991. mainTextureSamples?: number;
  136992. /**
  136993. * The rendering group to draw the layer in.
  136994. */
  136995. renderingGroupId: number;
  136996. }
  136997. /**
  136998. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  136999. *
  137000. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  137001. *
  137002. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  137003. */
  137004. export class GlowLayer extends EffectLayer {
  137005. /**
  137006. * Effect Name of the layer.
  137007. */
  137008. static readonly EffectName: string;
  137009. /**
  137010. * The default blur kernel size used for the glow.
  137011. */
  137012. static DefaultBlurKernelSize: number;
  137013. /**
  137014. * The default texture size ratio used for the glow.
  137015. */
  137016. static DefaultTextureRatio: number;
  137017. /**
  137018. * Sets the kernel size of the blur.
  137019. */
  137020. set blurKernelSize(value: number);
  137021. /**
  137022. * Gets the kernel size of the blur.
  137023. */
  137024. get blurKernelSize(): number;
  137025. /**
  137026. * Sets the glow intensity.
  137027. */
  137028. set intensity(value: number);
  137029. /**
  137030. * Gets the glow intensity.
  137031. */
  137032. get intensity(): number;
  137033. private _options;
  137034. private _intensity;
  137035. private _horizontalBlurPostprocess1;
  137036. private _verticalBlurPostprocess1;
  137037. private _horizontalBlurPostprocess2;
  137038. private _verticalBlurPostprocess2;
  137039. private _blurTexture1;
  137040. private _blurTexture2;
  137041. private _postProcesses1;
  137042. private _postProcesses2;
  137043. private _includedOnlyMeshes;
  137044. private _excludedMeshes;
  137045. private _meshesUsingTheirOwnMaterials;
  137046. /**
  137047. * Callback used to let the user override the color selection on a per mesh basis
  137048. */
  137049. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  137050. /**
  137051. * Callback used to let the user override the texture selection on a per mesh basis
  137052. */
  137053. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  137054. /**
  137055. * Instantiates a new glow Layer and references it to the scene.
  137056. * @param name The name of the layer
  137057. * @param scene The scene to use the layer in
  137058. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  137059. */
  137060. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  137061. /**
  137062. * Get the effect name of the layer.
  137063. * @return The effect name
  137064. */
  137065. getEffectName(): string;
  137066. /**
  137067. * Create the merge effect. This is the shader use to blit the information back
  137068. * to the main canvas at the end of the scene rendering.
  137069. */
  137070. protected _createMergeEffect(): Effect;
  137071. /**
  137072. * Creates the render target textures and post processes used in the glow layer.
  137073. */
  137074. protected _createTextureAndPostProcesses(): void;
  137075. /**
  137076. * Checks for the readiness of the element composing the layer.
  137077. * @param subMesh the mesh to check for
  137078. * @param useInstances specify wether or not to use instances to render the mesh
  137079. * @param emissiveTexture the associated emissive texture used to generate the glow
  137080. * @return true if ready otherwise, false
  137081. */
  137082. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137083. /**
  137084. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137085. */
  137086. needStencil(): boolean;
  137087. /**
  137088. * Returns true if the mesh can be rendered, otherwise false.
  137089. * @param mesh The mesh to render
  137090. * @param material The material used on the mesh
  137091. * @returns true if it can be rendered otherwise false
  137092. */
  137093. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137094. /**
  137095. * Implementation specific of rendering the generating effect on the main canvas.
  137096. * @param effect The effect used to render through
  137097. */
  137098. protected _internalRender(effect: Effect): void;
  137099. /**
  137100. * Sets the required values for both the emissive texture and and the main color.
  137101. */
  137102. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137103. /**
  137104. * Returns true if the mesh should render, otherwise false.
  137105. * @param mesh The mesh to render
  137106. * @returns true if it should render otherwise false
  137107. */
  137108. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137109. /**
  137110. * Adds specific effects defines.
  137111. * @param defines The defines to add specifics to.
  137112. */
  137113. protected _addCustomEffectDefines(defines: string[]): void;
  137114. /**
  137115. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  137116. * @param mesh The mesh to exclude from the glow layer
  137117. */
  137118. addExcludedMesh(mesh: Mesh): void;
  137119. /**
  137120. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  137121. * @param mesh The mesh to remove
  137122. */
  137123. removeExcludedMesh(mesh: Mesh): void;
  137124. /**
  137125. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  137126. * @param mesh The mesh to include in the glow layer
  137127. */
  137128. addIncludedOnlyMesh(mesh: Mesh): void;
  137129. /**
  137130. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  137131. * @param mesh The mesh to remove
  137132. */
  137133. removeIncludedOnlyMesh(mesh: Mesh): void;
  137134. /**
  137135. * Determine if a given mesh will be used in the glow layer
  137136. * @param mesh The mesh to test
  137137. * @returns true if the mesh will be highlighted by the current glow layer
  137138. */
  137139. hasMesh(mesh: AbstractMesh): boolean;
  137140. /**
  137141. * Defines whether the current material of the mesh should be use to render the effect.
  137142. * @param mesh defines the current mesh to render
  137143. */
  137144. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137145. /**
  137146. * Add a mesh to be rendered through its own material and not with emissive only.
  137147. * @param mesh The mesh for which we need to use its material
  137148. */
  137149. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  137150. /**
  137151. * Remove a mesh from being rendered through its own material and not with emissive only.
  137152. * @param mesh The mesh for which we need to not use its material
  137153. */
  137154. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  137155. /**
  137156. * Free any resources and references associated to a mesh.
  137157. * Internal use
  137158. * @param mesh The mesh to free.
  137159. * @hidden
  137160. */
  137161. _disposeMesh(mesh: Mesh): void;
  137162. /**
  137163. * Gets the class name of the effect layer
  137164. * @returns the string with the class name of the effect layer
  137165. */
  137166. getClassName(): string;
  137167. /**
  137168. * Serializes this glow layer
  137169. * @returns a serialized glow layer object
  137170. */
  137171. serialize(): any;
  137172. /**
  137173. * Creates a Glow Layer from parsed glow layer data
  137174. * @param parsedGlowLayer defines glow layer data
  137175. * @param scene defines the current scene
  137176. * @param rootUrl defines the root URL containing the glow layer information
  137177. * @returns a parsed Glow Layer
  137178. */
  137179. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  137180. }
  137181. }
  137182. declare module BABYLON {
  137183. /** @hidden */
  137184. export var glowBlurPostProcessPixelShader: {
  137185. name: string;
  137186. shader: string;
  137187. };
  137188. }
  137189. declare module BABYLON {
  137190. interface AbstractScene {
  137191. /**
  137192. * Return a the first highlight layer of the scene with a given name.
  137193. * @param name The name of the highlight layer to look for.
  137194. * @return The highlight layer if found otherwise null.
  137195. */
  137196. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  137197. }
  137198. /**
  137199. * Highlight layer options. This helps customizing the behaviour
  137200. * of the highlight layer.
  137201. */
  137202. export interface IHighlightLayerOptions {
  137203. /**
  137204. * Multiplication factor apply to the canvas size to compute the render target size
  137205. * used to generated the glowing objects (the smaller the faster).
  137206. */
  137207. mainTextureRatio: number;
  137208. /**
  137209. * Enforces a fixed size texture to ensure resize independant blur.
  137210. */
  137211. mainTextureFixedSize?: number;
  137212. /**
  137213. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  137214. * of the picture to blur (the smaller the faster).
  137215. */
  137216. blurTextureSizeRatio: number;
  137217. /**
  137218. * How big in texel of the blur texture is the vertical blur.
  137219. */
  137220. blurVerticalSize: number;
  137221. /**
  137222. * How big in texel of the blur texture is the horizontal blur.
  137223. */
  137224. blurHorizontalSize: number;
  137225. /**
  137226. * Alpha blending mode used to apply the blur. Default is combine.
  137227. */
  137228. alphaBlendingMode: number;
  137229. /**
  137230. * The camera attached to the layer.
  137231. */
  137232. camera: Nullable<Camera>;
  137233. /**
  137234. * Should we display highlight as a solid stroke?
  137235. */
  137236. isStroke?: boolean;
  137237. /**
  137238. * The rendering group to draw the layer in.
  137239. */
  137240. renderingGroupId: number;
  137241. }
  137242. /**
  137243. * The highlight layer Helps adding a glow effect around a mesh.
  137244. *
  137245. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  137246. * glowy meshes to your scene.
  137247. *
  137248. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  137249. */
  137250. export class HighlightLayer extends EffectLayer {
  137251. name: string;
  137252. /**
  137253. * Effect Name of the highlight layer.
  137254. */
  137255. static readonly EffectName: string;
  137256. /**
  137257. * The neutral color used during the preparation of the glow effect.
  137258. * This is black by default as the blend operation is a blend operation.
  137259. */
  137260. static NeutralColor: Color4;
  137261. /**
  137262. * Stencil value used for glowing meshes.
  137263. */
  137264. static GlowingMeshStencilReference: number;
  137265. /**
  137266. * Stencil value used for the other meshes in the scene.
  137267. */
  137268. static NormalMeshStencilReference: number;
  137269. /**
  137270. * Specifies whether or not the inner glow is ACTIVE in the layer.
  137271. */
  137272. innerGlow: boolean;
  137273. /**
  137274. * Specifies whether or not the outer glow is ACTIVE in the layer.
  137275. */
  137276. outerGlow: boolean;
  137277. /**
  137278. * Specifies the horizontal size of the blur.
  137279. */
  137280. set blurHorizontalSize(value: number);
  137281. /**
  137282. * Specifies the vertical size of the blur.
  137283. */
  137284. set blurVerticalSize(value: number);
  137285. /**
  137286. * Gets the horizontal size of the blur.
  137287. */
  137288. get blurHorizontalSize(): number;
  137289. /**
  137290. * Gets the vertical size of the blur.
  137291. */
  137292. get blurVerticalSize(): number;
  137293. /**
  137294. * An event triggered when the highlight layer is being blurred.
  137295. */
  137296. onBeforeBlurObservable: Observable<HighlightLayer>;
  137297. /**
  137298. * An event triggered when the highlight layer has been blurred.
  137299. */
  137300. onAfterBlurObservable: Observable<HighlightLayer>;
  137301. private _instanceGlowingMeshStencilReference;
  137302. private _options;
  137303. private _downSamplePostprocess;
  137304. private _horizontalBlurPostprocess;
  137305. private _verticalBlurPostprocess;
  137306. private _blurTexture;
  137307. private _meshes;
  137308. private _excludedMeshes;
  137309. /**
  137310. * Instantiates a new highlight Layer and references it to the scene..
  137311. * @param name The name of the layer
  137312. * @param scene The scene to use the layer in
  137313. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  137314. */
  137315. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  137316. /**
  137317. * Get the effect name of the layer.
  137318. * @return The effect name
  137319. */
  137320. getEffectName(): string;
  137321. /**
  137322. * Create the merge effect. This is the shader use to blit the information back
  137323. * to the main canvas at the end of the scene rendering.
  137324. */
  137325. protected _createMergeEffect(): Effect;
  137326. /**
  137327. * Creates the render target textures and post processes used in the highlight layer.
  137328. */
  137329. protected _createTextureAndPostProcesses(): void;
  137330. /**
  137331. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  137332. */
  137333. needStencil(): boolean;
  137334. /**
  137335. * Checks for the readiness of the element composing the layer.
  137336. * @param subMesh the mesh to check for
  137337. * @param useInstances specify wether or not to use instances to render the mesh
  137338. * @param emissiveTexture the associated emissive texture used to generate the glow
  137339. * @return true if ready otherwise, false
  137340. */
  137341. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137342. /**
  137343. * Implementation specific of rendering the generating effect on the main canvas.
  137344. * @param effect The effect used to render through
  137345. */
  137346. protected _internalRender(effect: Effect): void;
  137347. /**
  137348. * Returns true if the layer contains information to display, otherwise false.
  137349. */
  137350. shouldRender(): boolean;
  137351. /**
  137352. * Returns true if the mesh should render, otherwise false.
  137353. * @param mesh The mesh to render
  137354. * @returns true if it should render otherwise false
  137355. */
  137356. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137357. /**
  137358. * Returns true if the mesh can be rendered, otherwise false.
  137359. * @param mesh The mesh to render
  137360. * @param material The material used on the mesh
  137361. * @returns true if it can be rendered otherwise false
  137362. */
  137363. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137364. /**
  137365. * Adds specific effects defines.
  137366. * @param defines The defines to add specifics to.
  137367. */
  137368. protected _addCustomEffectDefines(defines: string[]): void;
  137369. /**
  137370. * Sets the required values for both the emissive texture and and the main color.
  137371. */
  137372. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137373. /**
  137374. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  137375. * @param mesh The mesh to exclude from the highlight layer
  137376. */
  137377. addExcludedMesh(mesh: Mesh): void;
  137378. /**
  137379. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  137380. * @param mesh The mesh to highlight
  137381. */
  137382. removeExcludedMesh(mesh: Mesh): void;
  137383. /**
  137384. * Determine if a given mesh will be highlighted by the current HighlightLayer
  137385. * @param mesh mesh to test
  137386. * @returns true if the mesh will be highlighted by the current HighlightLayer
  137387. */
  137388. hasMesh(mesh: AbstractMesh): boolean;
  137389. /**
  137390. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  137391. * @param mesh The mesh to highlight
  137392. * @param color The color of the highlight
  137393. * @param glowEmissiveOnly Extract the glow from the emissive texture
  137394. */
  137395. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  137396. /**
  137397. * Remove a mesh from the highlight layer in order to make it stop glowing.
  137398. * @param mesh The mesh to highlight
  137399. */
  137400. removeMesh(mesh: Mesh): void;
  137401. /**
  137402. * Remove all the meshes currently referenced in the highlight layer
  137403. */
  137404. removeAllMeshes(): void;
  137405. /**
  137406. * Force the stencil to the normal expected value for none glowing parts
  137407. */
  137408. private _defaultStencilReference;
  137409. /**
  137410. * Free any resources and references associated to a mesh.
  137411. * Internal use
  137412. * @param mesh The mesh to free.
  137413. * @hidden
  137414. */
  137415. _disposeMesh(mesh: Mesh): void;
  137416. /**
  137417. * Dispose the highlight layer and free resources.
  137418. */
  137419. dispose(): void;
  137420. /**
  137421. * Gets the class name of the effect layer
  137422. * @returns the string with the class name of the effect layer
  137423. */
  137424. getClassName(): string;
  137425. /**
  137426. * Serializes this Highlight layer
  137427. * @returns a serialized Highlight layer object
  137428. */
  137429. serialize(): any;
  137430. /**
  137431. * Creates a Highlight layer from parsed Highlight layer data
  137432. * @param parsedHightlightLayer defines the Highlight layer data
  137433. * @param scene defines the current scene
  137434. * @param rootUrl defines the root URL containing the Highlight layer information
  137435. * @returns a parsed Highlight layer
  137436. */
  137437. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  137438. }
  137439. }
  137440. declare module BABYLON {
  137441. interface AbstractScene {
  137442. /**
  137443. * The list of layers (background and foreground) of the scene
  137444. */
  137445. layers: Array<Layer>;
  137446. }
  137447. /**
  137448. * Defines the layer scene component responsible to manage any layers
  137449. * in a given scene.
  137450. */
  137451. export class LayerSceneComponent implements ISceneComponent {
  137452. /**
  137453. * The component name helpfull to identify the component in the list of scene components.
  137454. */
  137455. readonly name: string;
  137456. /**
  137457. * The scene the component belongs to.
  137458. */
  137459. scene: Scene;
  137460. private _engine;
  137461. /**
  137462. * Creates a new instance of the component for the given scene
  137463. * @param scene Defines the scene to register the component in
  137464. */
  137465. constructor(scene: Scene);
  137466. /**
  137467. * Registers the component in a given scene
  137468. */
  137469. register(): void;
  137470. /**
  137471. * Rebuilds the elements related to this component in case of
  137472. * context lost for instance.
  137473. */
  137474. rebuild(): void;
  137475. /**
  137476. * Disposes the component and the associated ressources.
  137477. */
  137478. dispose(): void;
  137479. private _draw;
  137480. private _drawCameraPredicate;
  137481. private _drawCameraBackground;
  137482. private _drawCameraForeground;
  137483. private _drawRenderTargetPredicate;
  137484. private _drawRenderTargetBackground;
  137485. private _drawRenderTargetForeground;
  137486. /**
  137487. * Adds all the elements from the container to the scene
  137488. * @param container the container holding the elements
  137489. */
  137490. addFromContainer(container: AbstractScene): void;
  137491. /**
  137492. * Removes all the elements in the container from the scene
  137493. * @param container contains the elements to remove
  137494. * @param dispose if the removed element should be disposed (default: false)
  137495. */
  137496. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137497. }
  137498. }
  137499. declare module BABYLON {
  137500. /** @hidden */
  137501. export var layerPixelShader: {
  137502. name: string;
  137503. shader: string;
  137504. };
  137505. }
  137506. declare module BABYLON {
  137507. /** @hidden */
  137508. export var layerVertexShader: {
  137509. name: string;
  137510. shader: string;
  137511. };
  137512. }
  137513. declare module BABYLON {
  137514. /**
  137515. * This represents a full screen 2d layer.
  137516. * This can be useful to display a picture in the background of your scene for instance.
  137517. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137518. */
  137519. export class Layer {
  137520. /**
  137521. * Define the name of the layer.
  137522. */
  137523. name: string;
  137524. /**
  137525. * Define the texture the layer should display.
  137526. */
  137527. texture: Nullable<Texture>;
  137528. /**
  137529. * Is the layer in background or foreground.
  137530. */
  137531. isBackground: boolean;
  137532. /**
  137533. * Define the color of the layer (instead of texture).
  137534. */
  137535. color: Color4;
  137536. /**
  137537. * Define the scale of the layer in order to zoom in out of the texture.
  137538. */
  137539. scale: Vector2;
  137540. /**
  137541. * Define an offset for the layer in order to shift the texture.
  137542. */
  137543. offset: Vector2;
  137544. /**
  137545. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  137546. */
  137547. alphaBlendingMode: number;
  137548. /**
  137549. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  137550. * Alpha test will not mix with the background color in case of transparency.
  137551. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  137552. */
  137553. alphaTest: boolean;
  137554. /**
  137555. * Define a mask to restrict the layer to only some of the scene cameras.
  137556. */
  137557. layerMask: number;
  137558. /**
  137559. * Define the list of render target the layer is visible into.
  137560. */
  137561. renderTargetTextures: RenderTargetTexture[];
  137562. /**
  137563. * Define if the layer is only used in renderTarget or if it also
  137564. * renders in the main frame buffer of the canvas.
  137565. */
  137566. renderOnlyInRenderTargetTextures: boolean;
  137567. private _scene;
  137568. private _vertexBuffers;
  137569. private _indexBuffer;
  137570. private _effect;
  137571. private _previousDefines;
  137572. /**
  137573. * An event triggered when the layer is disposed.
  137574. */
  137575. onDisposeObservable: Observable<Layer>;
  137576. private _onDisposeObserver;
  137577. /**
  137578. * Back compatibility with callback before the onDisposeObservable existed.
  137579. * The set callback will be triggered when the layer has been disposed.
  137580. */
  137581. set onDispose(callback: () => void);
  137582. /**
  137583. * An event triggered before rendering the scene
  137584. */
  137585. onBeforeRenderObservable: Observable<Layer>;
  137586. private _onBeforeRenderObserver;
  137587. /**
  137588. * Back compatibility with callback before the onBeforeRenderObservable existed.
  137589. * The set callback will be triggered just before rendering the layer.
  137590. */
  137591. set onBeforeRender(callback: () => void);
  137592. /**
  137593. * An event triggered after rendering the scene
  137594. */
  137595. onAfterRenderObservable: Observable<Layer>;
  137596. private _onAfterRenderObserver;
  137597. /**
  137598. * Back compatibility with callback before the onAfterRenderObservable existed.
  137599. * The set callback will be triggered just after rendering the layer.
  137600. */
  137601. set onAfterRender(callback: () => void);
  137602. /**
  137603. * Instantiates a new layer.
  137604. * This represents a full screen 2d layer.
  137605. * This can be useful to display a picture in the background of your scene for instance.
  137606. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137607. * @param name Define the name of the layer in the scene
  137608. * @param imgUrl Define the url of the texture to display in the layer
  137609. * @param scene Define the scene the layer belongs to
  137610. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  137611. * @param color Defines a color for the layer
  137612. */
  137613. constructor(
  137614. /**
  137615. * Define the name of the layer.
  137616. */
  137617. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  137618. private _createIndexBuffer;
  137619. /** @hidden */
  137620. _rebuild(): void;
  137621. /**
  137622. * Renders the layer in the scene.
  137623. */
  137624. render(): void;
  137625. /**
  137626. * Disposes and releases the associated ressources.
  137627. */
  137628. dispose(): void;
  137629. }
  137630. }
  137631. declare module BABYLON {
  137632. /** @hidden */
  137633. export var lensFlarePixelShader: {
  137634. name: string;
  137635. shader: string;
  137636. };
  137637. }
  137638. declare module BABYLON {
  137639. /** @hidden */
  137640. export var lensFlareVertexShader: {
  137641. name: string;
  137642. shader: string;
  137643. };
  137644. }
  137645. declare module BABYLON {
  137646. /**
  137647. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137648. * It is usually composed of several `lensFlare`.
  137649. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137650. */
  137651. export class LensFlareSystem {
  137652. /**
  137653. * Define the name of the lens flare system
  137654. */
  137655. name: string;
  137656. /**
  137657. * List of lens flares used in this system.
  137658. */
  137659. lensFlares: LensFlare[];
  137660. /**
  137661. * Define a limit from the border the lens flare can be visible.
  137662. */
  137663. borderLimit: number;
  137664. /**
  137665. * Define a viewport border we do not want to see the lens flare in.
  137666. */
  137667. viewportBorder: number;
  137668. /**
  137669. * Define a predicate which could limit the list of meshes able to occlude the effect.
  137670. */
  137671. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  137672. /**
  137673. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  137674. */
  137675. layerMask: number;
  137676. /**
  137677. * Define the id of the lens flare system in the scene.
  137678. * (equal to name by default)
  137679. */
  137680. id: string;
  137681. private _scene;
  137682. private _emitter;
  137683. private _vertexBuffers;
  137684. private _indexBuffer;
  137685. private _effect;
  137686. private _positionX;
  137687. private _positionY;
  137688. private _isEnabled;
  137689. /** @hidden */
  137690. static _SceneComponentInitialization: (scene: Scene) => void;
  137691. /**
  137692. * Instantiates a lens flare system.
  137693. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137694. * It is usually composed of several `lensFlare`.
  137695. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137696. * @param name Define the name of the lens flare system in the scene
  137697. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  137698. * @param scene Define the scene the lens flare system belongs to
  137699. */
  137700. constructor(
  137701. /**
  137702. * Define the name of the lens flare system
  137703. */
  137704. name: string, emitter: any, scene: Scene);
  137705. /**
  137706. * Define if the lens flare system is enabled.
  137707. */
  137708. get isEnabled(): boolean;
  137709. set isEnabled(value: boolean);
  137710. /**
  137711. * Get the scene the effects belongs to.
  137712. * @returns the scene holding the lens flare system
  137713. */
  137714. getScene(): Scene;
  137715. /**
  137716. * Get the emitter of the lens flare system.
  137717. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137718. * @returns the emitter of the lens flare system
  137719. */
  137720. getEmitter(): any;
  137721. /**
  137722. * Set the emitter of the lens flare system.
  137723. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137724. * @param newEmitter Define the new emitter of the system
  137725. */
  137726. setEmitter(newEmitter: any): void;
  137727. /**
  137728. * Get the lens flare system emitter position.
  137729. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  137730. * @returns the position
  137731. */
  137732. getEmitterPosition(): Vector3;
  137733. /**
  137734. * @hidden
  137735. */
  137736. computeEffectivePosition(globalViewport: Viewport): boolean;
  137737. /** @hidden */
  137738. _isVisible(): boolean;
  137739. /**
  137740. * @hidden
  137741. */
  137742. render(): boolean;
  137743. /**
  137744. * Dispose and release the lens flare with its associated resources.
  137745. */
  137746. dispose(): void;
  137747. /**
  137748. * Parse a lens flare system from a JSON repressentation
  137749. * @param parsedLensFlareSystem Define the JSON to parse
  137750. * @param scene Define the scene the parsed system should be instantiated in
  137751. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  137752. * @returns the parsed system
  137753. */
  137754. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  137755. /**
  137756. * Serialize the current Lens Flare System into a JSON representation.
  137757. * @returns the serialized JSON
  137758. */
  137759. serialize(): any;
  137760. }
  137761. }
  137762. declare module BABYLON {
  137763. /**
  137764. * This represents one of the lens effect in a `lensFlareSystem`.
  137765. * It controls one of the indiviual texture used in the effect.
  137766. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137767. */
  137768. export class LensFlare {
  137769. /**
  137770. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137771. */
  137772. size: number;
  137773. /**
  137774. * 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.
  137775. */
  137776. position: number;
  137777. /**
  137778. * Define the lens color.
  137779. */
  137780. color: Color3;
  137781. /**
  137782. * Define the lens texture.
  137783. */
  137784. texture: Nullable<Texture>;
  137785. /**
  137786. * Define the alpha mode to render this particular lens.
  137787. */
  137788. alphaMode: number;
  137789. private _system;
  137790. /**
  137791. * Creates a new Lens Flare.
  137792. * This represents one of the lens effect in a `lensFlareSystem`.
  137793. * It controls one of the indiviual texture used in the effect.
  137794. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137795. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  137796. * @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.
  137797. * @param color Define the lens color
  137798. * @param imgUrl Define the lens texture url
  137799. * @param system Define the `lensFlareSystem` this flare is part of
  137800. * @returns The newly created Lens Flare
  137801. */
  137802. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  137803. /**
  137804. * Instantiates a new Lens Flare.
  137805. * This represents one of the lens effect in a `lensFlareSystem`.
  137806. * It controls one of the indiviual texture used in the effect.
  137807. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137808. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  137809. * @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.
  137810. * @param color Define the lens color
  137811. * @param imgUrl Define the lens texture url
  137812. * @param system Define the `lensFlareSystem` this flare is part of
  137813. */
  137814. constructor(
  137815. /**
  137816. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137817. */
  137818. size: number,
  137819. /**
  137820. * 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.
  137821. */
  137822. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  137823. /**
  137824. * Dispose and release the lens flare with its associated resources.
  137825. */
  137826. dispose(): void;
  137827. }
  137828. }
  137829. declare module BABYLON {
  137830. interface AbstractScene {
  137831. /**
  137832. * The list of lens flare system added to the scene
  137833. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137834. */
  137835. lensFlareSystems: Array<LensFlareSystem>;
  137836. /**
  137837. * Removes the given lens flare system from this scene.
  137838. * @param toRemove The lens flare system to remove
  137839. * @returns The index of the removed lens flare system
  137840. */
  137841. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  137842. /**
  137843. * Adds the given lens flare system to this scene
  137844. * @param newLensFlareSystem The lens flare system to add
  137845. */
  137846. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  137847. /**
  137848. * Gets a lens flare system using its name
  137849. * @param name defines the name to look for
  137850. * @returns the lens flare system or null if not found
  137851. */
  137852. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  137853. /**
  137854. * Gets a lens flare system using its id
  137855. * @param id defines the id to look for
  137856. * @returns the lens flare system or null if not found
  137857. */
  137858. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  137859. }
  137860. /**
  137861. * Defines the lens flare scene component responsible to manage any lens flares
  137862. * in a given scene.
  137863. */
  137864. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  137865. /**
  137866. * The component name helpfull to identify the component in the list of scene components.
  137867. */
  137868. readonly name: string;
  137869. /**
  137870. * The scene the component belongs to.
  137871. */
  137872. scene: Scene;
  137873. /**
  137874. * Creates a new instance of the component for the given scene
  137875. * @param scene Defines the scene to register the component in
  137876. */
  137877. constructor(scene: Scene);
  137878. /**
  137879. * Registers the component in a given scene
  137880. */
  137881. register(): void;
  137882. /**
  137883. * Rebuilds the elements related to this component in case of
  137884. * context lost for instance.
  137885. */
  137886. rebuild(): void;
  137887. /**
  137888. * Adds all the elements from the container to the scene
  137889. * @param container the container holding the elements
  137890. */
  137891. addFromContainer(container: AbstractScene): void;
  137892. /**
  137893. * Removes all the elements in the container from the scene
  137894. * @param container contains the elements to remove
  137895. * @param dispose if the removed element should be disposed (default: false)
  137896. */
  137897. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137898. /**
  137899. * Serializes the component data to the specified json object
  137900. * @param serializationObject The object to serialize to
  137901. */
  137902. serialize(serializationObject: any): void;
  137903. /**
  137904. * Disposes the component and the associated ressources.
  137905. */
  137906. dispose(): void;
  137907. private _draw;
  137908. }
  137909. }
  137910. declare module BABYLON {
  137911. /** @hidden */
  137912. export var depthPixelShader: {
  137913. name: string;
  137914. shader: string;
  137915. };
  137916. }
  137917. declare module BABYLON {
  137918. /** @hidden */
  137919. export var depthVertexShader: {
  137920. name: string;
  137921. shader: string;
  137922. };
  137923. }
  137924. declare module BABYLON {
  137925. /**
  137926. * This represents a depth renderer in Babylon.
  137927. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  137928. */
  137929. export class DepthRenderer {
  137930. private _scene;
  137931. private _depthMap;
  137932. private _effect;
  137933. private readonly _storeNonLinearDepth;
  137934. private readonly _clearColor;
  137935. /** Get if the depth renderer is using packed depth or not */
  137936. readonly isPacked: boolean;
  137937. private _cachedDefines;
  137938. private _camera;
  137939. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  137940. enabled: boolean;
  137941. /**
  137942. * Specifiess that the depth renderer will only be used within
  137943. * the camera it is created for.
  137944. * This can help forcing its rendering during the camera processing.
  137945. */
  137946. useOnlyInActiveCamera: boolean;
  137947. /** @hidden */
  137948. static _SceneComponentInitialization: (scene: Scene) => void;
  137949. /**
  137950. * Instantiates a depth renderer
  137951. * @param scene The scene the renderer belongs to
  137952. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  137953. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  137954. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  137955. */
  137956. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  137957. /**
  137958. * Creates the depth rendering effect and checks if the effect is ready.
  137959. * @param subMesh The submesh to be used to render the depth map of
  137960. * @param useInstances If multiple world instances should be used
  137961. * @returns if the depth renderer is ready to render the depth map
  137962. */
  137963. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137964. /**
  137965. * Gets the texture which the depth map will be written to.
  137966. * @returns The depth map texture
  137967. */
  137968. getDepthMap(): RenderTargetTexture;
  137969. /**
  137970. * Disposes of the depth renderer.
  137971. */
  137972. dispose(): void;
  137973. }
  137974. }
  137975. declare module BABYLON {
  137976. /** @hidden */
  137977. export var minmaxReduxPixelShader: {
  137978. name: string;
  137979. shader: string;
  137980. };
  137981. }
  137982. declare module BABYLON {
  137983. /**
  137984. * This class computes a min/max reduction from a texture: it means it computes the minimum
  137985. * and maximum values from all values of the texture.
  137986. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  137987. * The source values are read from the red channel of the texture.
  137988. */
  137989. export class MinMaxReducer {
  137990. /**
  137991. * Observable triggered when the computation has been performed
  137992. */
  137993. onAfterReductionPerformed: Observable<{
  137994. min: number;
  137995. max: number;
  137996. }>;
  137997. protected _camera: Camera;
  137998. protected _sourceTexture: Nullable<RenderTargetTexture>;
  137999. protected _reductionSteps: Nullable<Array<PostProcess>>;
  138000. protected _postProcessManager: PostProcessManager;
  138001. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  138002. protected _forceFullscreenViewport: boolean;
  138003. /**
  138004. * Creates a min/max reducer
  138005. * @param camera The camera to use for the post processes
  138006. */
  138007. constructor(camera: Camera);
  138008. /**
  138009. * Gets the texture used to read the values from.
  138010. */
  138011. get sourceTexture(): Nullable<RenderTargetTexture>;
  138012. /**
  138013. * Sets the source texture to read the values from.
  138014. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  138015. * because in such textures '1' value must not be taken into account to compute the maximum
  138016. * as this value is used to clear the texture.
  138017. * Note that the computation is not activated by calling this function, you must call activate() for that!
  138018. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  138019. * @param depthRedux Indicates if the texture is a depth texture or not
  138020. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  138021. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138022. */
  138023. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138024. /**
  138025. * Defines the refresh rate of the computation.
  138026. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138027. */
  138028. get refreshRate(): number;
  138029. set refreshRate(value: number);
  138030. protected _activated: boolean;
  138031. /**
  138032. * Gets the activation status of the reducer
  138033. */
  138034. get activated(): boolean;
  138035. /**
  138036. * Activates the reduction computation.
  138037. * When activated, the observers registered in onAfterReductionPerformed are
  138038. * called after the compuation is performed
  138039. */
  138040. activate(): void;
  138041. /**
  138042. * Deactivates the reduction computation.
  138043. */
  138044. deactivate(): void;
  138045. /**
  138046. * Disposes the min/max reducer
  138047. * @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.
  138048. */
  138049. dispose(disposeAll?: boolean): void;
  138050. }
  138051. }
  138052. declare module BABYLON {
  138053. /**
  138054. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  138055. */
  138056. export class DepthReducer extends MinMaxReducer {
  138057. private _depthRenderer;
  138058. private _depthRendererId;
  138059. /**
  138060. * Gets the depth renderer used for the computation.
  138061. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  138062. */
  138063. get depthRenderer(): Nullable<DepthRenderer>;
  138064. /**
  138065. * Creates a depth reducer
  138066. * @param camera The camera used to render the depth texture
  138067. */
  138068. constructor(camera: Camera);
  138069. /**
  138070. * Sets the depth renderer to use to generate the depth map
  138071. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  138072. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  138073. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138074. */
  138075. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  138076. /** @hidden */
  138077. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138078. /**
  138079. * Activates the reduction computation.
  138080. * When activated, the observers registered in onAfterReductionPerformed are
  138081. * called after the compuation is performed
  138082. */
  138083. activate(): void;
  138084. /**
  138085. * Deactivates the reduction computation.
  138086. */
  138087. deactivate(): void;
  138088. /**
  138089. * Disposes the depth reducer
  138090. * @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.
  138091. */
  138092. dispose(disposeAll?: boolean): void;
  138093. }
  138094. }
  138095. declare module BABYLON {
  138096. /**
  138097. * A CSM implementation allowing casting shadows on large scenes.
  138098. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138099. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  138100. */
  138101. export class CascadedShadowGenerator extends ShadowGenerator {
  138102. private static readonly frustumCornersNDCSpace;
  138103. /**
  138104. * Name of the CSM class
  138105. */
  138106. static CLASSNAME: string;
  138107. /**
  138108. * Defines the default number of cascades used by the CSM.
  138109. */
  138110. static readonly DEFAULT_CASCADES_COUNT: number;
  138111. /**
  138112. * Defines the minimum number of cascades used by the CSM.
  138113. */
  138114. static readonly MIN_CASCADES_COUNT: number;
  138115. /**
  138116. * Defines the maximum number of cascades used by the CSM.
  138117. */
  138118. static readonly MAX_CASCADES_COUNT: number;
  138119. protected _validateFilter(filter: number): number;
  138120. /**
  138121. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  138122. */
  138123. penumbraDarkness: number;
  138124. private _numCascades;
  138125. /**
  138126. * Gets or set the number of cascades used by the CSM.
  138127. */
  138128. get numCascades(): number;
  138129. set numCascades(value: number);
  138130. /**
  138131. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  138132. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  138133. */
  138134. stabilizeCascades: boolean;
  138135. private _freezeShadowCastersBoundingInfo;
  138136. private _freezeShadowCastersBoundingInfoObservable;
  138137. /**
  138138. * Enables or disables the shadow casters bounding info computation.
  138139. * If your shadow casters don't move, you can disable this feature.
  138140. * If it is enabled, the bounding box computation is done every frame.
  138141. */
  138142. get freezeShadowCastersBoundingInfo(): boolean;
  138143. set freezeShadowCastersBoundingInfo(freeze: boolean);
  138144. private _scbiMin;
  138145. private _scbiMax;
  138146. protected _computeShadowCastersBoundingInfo(): void;
  138147. protected _shadowCastersBoundingInfo: BoundingInfo;
  138148. /**
  138149. * Gets or sets the shadow casters bounding info.
  138150. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  138151. * so that the system won't overwrite the bounds you provide
  138152. */
  138153. get shadowCastersBoundingInfo(): BoundingInfo;
  138154. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  138155. protected _breaksAreDirty: boolean;
  138156. protected _minDistance: number;
  138157. protected _maxDistance: number;
  138158. /**
  138159. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  138160. *
  138161. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  138162. * If you don't know these values, simply leave them to their defaults and don't call this function.
  138163. * @param min minimal distance for the breaks (default to 0.)
  138164. * @param max maximal distance for the breaks (default to 1.)
  138165. */
  138166. setMinMaxDistance(min: number, max: number): void;
  138167. /** Gets the minimal distance used in the cascade break computation */
  138168. get minDistance(): number;
  138169. /** Gets the maximal distance used in the cascade break computation */
  138170. get maxDistance(): number;
  138171. /**
  138172. * Gets the class name of that object
  138173. * @returns "CascadedShadowGenerator"
  138174. */
  138175. getClassName(): string;
  138176. private _cascadeMinExtents;
  138177. private _cascadeMaxExtents;
  138178. /**
  138179. * Gets a cascade minimum extents
  138180. * @param cascadeIndex index of the cascade
  138181. * @returns the minimum cascade extents
  138182. */
  138183. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  138184. /**
  138185. * Gets a cascade maximum extents
  138186. * @param cascadeIndex index of the cascade
  138187. * @returns the maximum cascade extents
  138188. */
  138189. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  138190. private _cascades;
  138191. private _currentLayer;
  138192. private _viewSpaceFrustumsZ;
  138193. private _viewMatrices;
  138194. private _projectionMatrices;
  138195. private _transformMatrices;
  138196. private _transformMatricesAsArray;
  138197. private _frustumLengths;
  138198. private _lightSizeUVCorrection;
  138199. private _depthCorrection;
  138200. private _frustumCornersWorldSpace;
  138201. private _frustumCenter;
  138202. private _shadowCameraPos;
  138203. private _shadowMaxZ;
  138204. /**
  138205. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  138206. * It defaults to camera.maxZ
  138207. */
  138208. get shadowMaxZ(): number;
  138209. /**
  138210. * Sets the shadow max z distance.
  138211. */
  138212. set shadowMaxZ(value: number);
  138213. protected _debug: boolean;
  138214. /**
  138215. * Gets or sets the debug flag.
  138216. * When enabled, the cascades are materialized by different colors on the screen.
  138217. */
  138218. get debug(): boolean;
  138219. set debug(dbg: boolean);
  138220. private _depthClamp;
  138221. /**
  138222. * Gets or sets the depth clamping value.
  138223. *
  138224. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  138225. * to account for the shadow casters far away.
  138226. *
  138227. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  138228. */
  138229. get depthClamp(): boolean;
  138230. set depthClamp(value: boolean);
  138231. private _cascadeBlendPercentage;
  138232. /**
  138233. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  138234. * It defaults to 0.1 (10% blending).
  138235. */
  138236. get cascadeBlendPercentage(): number;
  138237. set cascadeBlendPercentage(value: number);
  138238. private _lambda;
  138239. /**
  138240. * Gets or set the lambda parameter.
  138241. * This parameter is used to split the camera frustum and create the cascades.
  138242. * 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.
  138243. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  138244. */
  138245. get lambda(): number;
  138246. set lambda(value: number);
  138247. /**
  138248. * Gets the view matrix corresponding to a given cascade
  138249. * @param cascadeNum cascade to retrieve the view matrix from
  138250. * @returns the cascade view matrix
  138251. */
  138252. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  138253. /**
  138254. * Gets the projection matrix corresponding to a given cascade
  138255. * @param cascadeNum cascade to retrieve the projection matrix from
  138256. * @returns the cascade projection matrix
  138257. */
  138258. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  138259. /**
  138260. * Gets the transformation matrix corresponding to a given cascade
  138261. * @param cascadeNum cascade to retrieve the transformation matrix from
  138262. * @returns the cascade transformation matrix
  138263. */
  138264. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  138265. private _depthRenderer;
  138266. /**
  138267. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  138268. *
  138269. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  138270. *
  138271. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  138272. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  138273. * @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
  138274. */
  138275. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  138276. private _depthReducer;
  138277. private _autoCalcDepthBounds;
  138278. /**
  138279. * Gets or sets the autoCalcDepthBounds property.
  138280. *
  138281. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  138282. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  138283. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  138284. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  138285. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  138286. */
  138287. get autoCalcDepthBounds(): boolean;
  138288. set autoCalcDepthBounds(value: boolean);
  138289. /**
  138290. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  138291. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138292. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  138293. * for setting the refresh rate on the renderer yourself!
  138294. */
  138295. get autoCalcDepthBoundsRefreshRate(): number;
  138296. set autoCalcDepthBoundsRefreshRate(value: number);
  138297. /**
  138298. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  138299. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  138300. * you change the camera near/far planes!
  138301. */
  138302. splitFrustum(): void;
  138303. private _splitFrustum;
  138304. private _computeMatrices;
  138305. private _computeFrustumInWorldSpace;
  138306. private _computeCascadeFrustum;
  138307. /**
  138308. * Support test.
  138309. */
  138310. static get IsSupported(): boolean;
  138311. /** @hidden */
  138312. static _SceneComponentInitialization: (scene: Scene) => void;
  138313. /**
  138314. * Creates a Cascaded Shadow Generator object.
  138315. * A ShadowGenerator is the required tool to use the shadows.
  138316. * Each directional light casting shadows needs to use its own ShadowGenerator.
  138317. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138318. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  138319. * @param light The directional light object generating the shadows.
  138320. * @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.
  138321. */
  138322. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  138323. protected _initializeGenerator(): void;
  138324. protected _createTargetRenderTexture(): void;
  138325. protected _initializeShadowMap(): void;
  138326. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  138327. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  138328. /**
  138329. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  138330. * @param defines Defines of the material we want to update
  138331. * @param lightIndex Index of the light in the enabled light list of the material
  138332. */
  138333. prepareDefines(defines: any, lightIndex: number): void;
  138334. /**
  138335. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  138336. * defined in the generator but impacting the effect).
  138337. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  138338. * @param effect The effect we are binfing the information for
  138339. */
  138340. bindShadowLight(lightIndex: string, effect: Effect): void;
  138341. /**
  138342. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  138343. * (eq to view projection * shadow projection matrices)
  138344. * @returns The transform matrix used to create the shadow map
  138345. */
  138346. getTransformMatrix(): Matrix;
  138347. /**
  138348. * Disposes the ShadowGenerator.
  138349. * Returns nothing.
  138350. */
  138351. dispose(): void;
  138352. /**
  138353. * Serializes the shadow generator setup to a json object.
  138354. * @returns The serialized JSON object
  138355. */
  138356. serialize(): any;
  138357. /**
  138358. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  138359. * @param parsedShadowGenerator The JSON object to parse
  138360. * @param scene The scene to create the shadow map for
  138361. * @returns The parsed shadow generator
  138362. */
  138363. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  138364. }
  138365. }
  138366. declare module BABYLON {
  138367. /**
  138368. * Defines the shadow generator component responsible to manage any shadow generators
  138369. * in a given scene.
  138370. */
  138371. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  138372. /**
  138373. * The component name helpfull to identify the component in the list of scene components.
  138374. */
  138375. readonly name: string;
  138376. /**
  138377. * The scene the component belongs to.
  138378. */
  138379. scene: Scene;
  138380. /**
  138381. * Creates a new instance of the component for the given scene
  138382. * @param scene Defines the scene to register the component in
  138383. */
  138384. constructor(scene: Scene);
  138385. /**
  138386. * Registers the component in a given scene
  138387. */
  138388. register(): void;
  138389. /**
  138390. * Rebuilds the elements related to this component in case of
  138391. * context lost for instance.
  138392. */
  138393. rebuild(): void;
  138394. /**
  138395. * Serializes the component data to the specified json object
  138396. * @param serializationObject The object to serialize to
  138397. */
  138398. serialize(serializationObject: any): void;
  138399. /**
  138400. * Adds all the elements from the container to the scene
  138401. * @param container the container holding the elements
  138402. */
  138403. addFromContainer(container: AbstractScene): void;
  138404. /**
  138405. * Removes all the elements in the container from the scene
  138406. * @param container contains the elements to remove
  138407. * @param dispose if the removed element should be disposed (default: false)
  138408. */
  138409. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138410. /**
  138411. * Rebuilds the elements related to this component in case of
  138412. * context lost for instance.
  138413. */
  138414. dispose(): void;
  138415. private _gatherRenderTargets;
  138416. }
  138417. }
  138418. declare module BABYLON {
  138419. /**
  138420. * A point light is a light defined by an unique point in world space.
  138421. * The light is emitted in every direction from this point.
  138422. * A good example of a point light is a standard light bulb.
  138423. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138424. */
  138425. export class PointLight extends ShadowLight {
  138426. private _shadowAngle;
  138427. /**
  138428. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138429. * This specifies what angle the shadow will use to be created.
  138430. *
  138431. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138432. */
  138433. get shadowAngle(): number;
  138434. /**
  138435. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138436. * This specifies what angle the shadow will use to be created.
  138437. *
  138438. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138439. */
  138440. set shadowAngle(value: number);
  138441. /**
  138442. * Gets the direction if it has been set.
  138443. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138444. */
  138445. get direction(): Vector3;
  138446. /**
  138447. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138448. */
  138449. set direction(value: Vector3);
  138450. /**
  138451. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  138452. * A PointLight emits the light in every direction.
  138453. * It can cast shadows.
  138454. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  138455. * ```javascript
  138456. * var pointLight = new PointLight("pl", camera.position, scene);
  138457. * ```
  138458. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138459. * @param name The light friendly name
  138460. * @param position The position of the point light in the scene
  138461. * @param scene The scene the lights belongs to
  138462. */
  138463. constructor(name: string, position: Vector3, scene: Scene);
  138464. /**
  138465. * Returns the string "PointLight"
  138466. * @returns the class name
  138467. */
  138468. getClassName(): string;
  138469. /**
  138470. * Returns the integer 0.
  138471. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138472. */
  138473. getTypeID(): number;
  138474. /**
  138475. * Specifies wether or not the shadowmap should be a cube texture.
  138476. * @returns true if the shadowmap needs to be a cube texture.
  138477. */
  138478. needCube(): boolean;
  138479. /**
  138480. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  138481. * @param faceIndex The index of the face we are computed the direction to generate shadow
  138482. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  138483. */
  138484. getShadowDirection(faceIndex?: number): Vector3;
  138485. /**
  138486. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  138487. * - fov = PI / 2
  138488. * - aspect ratio : 1.0
  138489. * - z-near and far equal to the active camera minZ and maxZ.
  138490. * Returns the PointLight.
  138491. */
  138492. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138493. protected _buildUniformLayout(): void;
  138494. /**
  138495. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  138496. * @param effect The effect to update
  138497. * @param lightIndex The index of the light in the effect to update
  138498. * @returns The point light
  138499. */
  138500. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  138501. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138502. /**
  138503. * Prepares the list of defines specific to the light type.
  138504. * @param defines the list of defines
  138505. * @param lightIndex defines the index of the light for the effect
  138506. */
  138507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138508. }
  138509. }
  138510. declare module BABYLON {
  138511. /**
  138512. * Header information of HDR texture files.
  138513. */
  138514. export interface HDRInfo {
  138515. /**
  138516. * The height of the texture in pixels.
  138517. */
  138518. height: number;
  138519. /**
  138520. * The width of the texture in pixels.
  138521. */
  138522. width: number;
  138523. /**
  138524. * The index of the beginning of the data in the binary file.
  138525. */
  138526. dataPosition: number;
  138527. }
  138528. /**
  138529. * This groups tools to convert HDR texture to native colors array.
  138530. */
  138531. export class HDRTools {
  138532. private static Ldexp;
  138533. private static Rgbe2float;
  138534. private static readStringLine;
  138535. /**
  138536. * Reads header information from an RGBE texture stored in a native array.
  138537. * More information on this format are available here:
  138538. * https://en.wikipedia.org/wiki/RGBE_image_format
  138539. *
  138540. * @param uint8array The binary file stored in native array.
  138541. * @return The header information.
  138542. */
  138543. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  138544. /**
  138545. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  138546. * This RGBE texture needs to store the information as a panorama.
  138547. *
  138548. * More information on this format are available here:
  138549. * https://en.wikipedia.org/wiki/RGBE_image_format
  138550. *
  138551. * @param buffer The binary file stored in an array buffer.
  138552. * @param size The expected size of the extracted cubemap.
  138553. * @return The Cube Map information.
  138554. */
  138555. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  138556. /**
  138557. * Returns the pixels data extracted from an RGBE texture.
  138558. * This pixels will be stored left to right up to down in the R G B order in one array.
  138559. *
  138560. * More information on this format are available here:
  138561. * https://en.wikipedia.org/wiki/RGBE_image_format
  138562. *
  138563. * @param uint8array The binary file stored in an array buffer.
  138564. * @param hdrInfo The header information of the file.
  138565. * @return The pixels data in RGB right to left up to down order.
  138566. */
  138567. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  138568. private static RGBE_ReadPixels_RLE;
  138569. private static RGBE_ReadPixels_NOT_RLE;
  138570. }
  138571. }
  138572. declare module BABYLON {
  138573. /**
  138574. * Effect Render Options
  138575. */
  138576. export interface IEffectRendererOptions {
  138577. /**
  138578. * Defines the vertices positions.
  138579. */
  138580. positions?: number[];
  138581. /**
  138582. * Defines the indices.
  138583. */
  138584. indices?: number[];
  138585. }
  138586. /**
  138587. * Helper class to render one or more effects.
  138588. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138589. */
  138590. export class EffectRenderer {
  138591. private engine;
  138592. private static _DefaultOptions;
  138593. private _vertexBuffers;
  138594. private _indexBuffer;
  138595. private _fullscreenViewport;
  138596. /**
  138597. * Creates an effect renderer
  138598. * @param engine the engine to use for rendering
  138599. * @param options defines the options of the effect renderer
  138600. */
  138601. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138602. /**
  138603. * Sets the current viewport in normalized coordinates 0-1
  138604. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138605. */
  138606. setViewport(viewport?: Viewport): void;
  138607. /**
  138608. * Binds the embedded attributes buffer to the effect.
  138609. * @param effect Defines the effect to bind the attributes for
  138610. */
  138611. bindBuffers(effect: Effect): void;
  138612. /**
  138613. * Sets the current effect wrapper to use during draw.
  138614. * The effect needs to be ready before calling this api.
  138615. * This also sets the default full screen position attribute.
  138616. * @param effectWrapper Defines the effect to draw with
  138617. */
  138618. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138619. /**
  138620. * Restores engine states
  138621. */
  138622. restoreStates(): void;
  138623. /**
  138624. * Draws a full screen quad.
  138625. */
  138626. draw(): void;
  138627. private isRenderTargetTexture;
  138628. /**
  138629. * renders one or more effects to a specified texture
  138630. * @param effectWrapper the effect to renderer
  138631. * @param outputTexture texture to draw to, if null it will render to the screen.
  138632. */
  138633. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138634. /**
  138635. * Disposes of the effect renderer
  138636. */
  138637. dispose(): void;
  138638. }
  138639. /**
  138640. * Options to create an EffectWrapper
  138641. */
  138642. interface EffectWrapperCreationOptions {
  138643. /**
  138644. * Engine to use to create the effect
  138645. */
  138646. engine: ThinEngine;
  138647. /**
  138648. * Fragment shader for the effect
  138649. */
  138650. fragmentShader: string;
  138651. /**
  138652. * Use the shader store instead of direct source code
  138653. */
  138654. useShaderStore?: boolean;
  138655. /**
  138656. * Vertex shader for the effect
  138657. */
  138658. vertexShader?: string;
  138659. /**
  138660. * Attributes to use in the shader
  138661. */
  138662. attributeNames?: Array<string>;
  138663. /**
  138664. * Uniforms to use in the shader
  138665. */
  138666. uniformNames?: Array<string>;
  138667. /**
  138668. * Texture sampler names to use in the shader
  138669. */
  138670. samplerNames?: Array<string>;
  138671. /**
  138672. * Defines to use in the shader
  138673. */
  138674. defines?: Array<string>;
  138675. /**
  138676. * Callback when effect is compiled
  138677. */
  138678. onCompiled?: Nullable<(effect: Effect) => void>;
  138679. /**
  138680. * The friendly name of the effect displayed in Spector.
  138681. */
  138682. name?: string;
  138683. }
  138684. /**
  138685. * Wraps an effect to be used for rendering
  138686. */
  138687. export class EffectWrapper {
  138688. /**
  138689. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138690. */
  138691. onApplyObservable: Observable<{}>;
  138692. /**
  138693. * The underlying effect
  138694. */
  138695. effect: Effect;
  138696. /**
  138697. * Creates an effect to be renderer
  138698. * @param creationOptions options to create the effect
  138699. */
  138700. constructor(creationOptions: EffectWrapperCreationOptions);
  138701. /**
  138702. * Disposes of the effect wrapper
  138703. */
  138704. dispose(): void;
  138705. }
  138706. }
  138707. declare module BABYLON {
  138708. /** @hidden */
  138709. export var hdrFilteringVertexShader: {
  138710. name: string;
  138711. shader: string;
  138712. };
  138713. }
  138714. declare module BABYLON {
  138715. /** @hidden */
  138716. export var hdrFilteringPixelShader: {
  138717. name: string;
  138718. shader: string;
  138719. };
  138720. }
  138721. declare module BABYLON {
  138722. /**
  138723. * Options for texture filtering
  138724. */
  138725. interface IHDRFilteringOptions {
  138726. /**
  138727. * Scales pixel intensity for the input HDR map.
  138728. */
  138729. hdrScale?: number;
  138730. /**
  138731. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  138732. */
  138733. quality?: number;
  138734. }
  138735. /**
  138736. * Filters HDR maps to get correct renderings of PBR reflections
  138737. */
  138738. export class HDRFiltering {
  138739. private _engine;
  138740. private _effectRenderer;
  138741. private _effectWrapper;
  138742. private _lodGenerationOffset;
  138743. private _lodGenerationScale;
  138744. /**
  138745. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  138746. * you care about baking speed.
  138747. */
  138748. quality: number;
  138749. /**
  138750. * Scales pixel intensity for the input HDR map.
  138751. */
  138752. hdrScale: number;
  138753. /**
  138754. * Instantiates HDR filter for reflection maps
  138755. *
  138756. * @param engine Thin engine
  138757. * @param options Options
  138758. */
  138759. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  138760. private _createRenderTarget;
  138761. private _prefilterInternal;
  138762. private _createEffect;
  138763. /**
  138764. * Get a value indicating if the filter is ready to be used
  138765. * @param texture Texture to filter
  138766. * @returns true if the filter is ready
  138767. */
  138768. isReady(texture: BaseTexture): boolean;
  138769. /**
  138770. * Prefilters a cube texture to have mipmap levels representing roughness values.
  138771. * Prefiltering will be invoked at the end of next rendering pass.
  138772. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  138773. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  138774. * @param texture Texture to filter
  138775. * @param onFinished Callback when filtering is done
  138776. * @return Promise called when prefiltering is done
  138777. */
  138778. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  138779. }
  138780. }
  138781. declare module BABYLON {
  138782. /**
  138783. * This represents a texture coming from an HDR input.
  138784. *
  138785. * The only supported format is currently panorama picture stored in RGBE format.
  138786. * Example of such files can be found on HDRLib: http://hdrlib.com/
  138787. */
  138788. export class HDRCubeTexture extends BaseTexture {
  138789. private static _facesMapping;
  138790. private _generateHarmonics;
  138791. private _noMipmap;
  138792. private _prefilterOnLoad;
  138793. private _textureMatrix;
  138794. private _size;
  138795. private _onLoad;
  138796. private _onError;
  138797. /**
  138798. * The texture URL.
  138799. */
  138800. url: string;
  138801. /**
  138802. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  138803. */
  138804. coordinatesMode: number;
  138805. protected _isBlocking: boolean;
  138806. /**
  138807. * Sets wether or not the texture is blocking during loading.
  138808. */
  138809. set isBlocking(value: boolean);
  138810. /**
  138811. * Gets wether or not the texture is blocking during loading.
  138812. */
  138813. get isBlocking(): boolean;
  138814. protected _rotationY: number;
  138815. /**
  138816. * Sets texture matrix rotation angle around Y axis in radians.
  138817. */
  138818. set rotationY(value: number);
  138819. /**
  138820. * Gets texture matrix rotation angle around Y axis radians.
  138821. */
  138822. get rotationY(): number;
  138823. /**
  138824. * Gets or sets the center of the bounding box associated with the cube texture
  138825. * It must define where the camera used to render the texture was set
  138826. */
  138827. boundingBoxPosition: Vector3;
  138828. private _boundingBoxSize;
  138829. /**
  138830. * Gets or sets the size of the bounding box associated with the cube texture
  138831. * When defined, the cubemap will switch to local mode
  138832. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  138833. * @example https://www.babylonjs-playground.com/#RNASML
  138834. */
  138835. set boundingBoxSize(value: Vector3);
  138836. get boundingBoxSize(): Vector3;
  138837. /**
  138838. * Instantiates an HDRTexture from the following parameters.
  138839. *
  138840. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  138841. * @param sceneOrEngine The scene or engine the texture will be used in
  138842. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138843. * @param noMipmap Forces to not generate the mipmap if true
  138844. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  138845. * @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)
  138846. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  138847. */
  138848. 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>);
  138849. /**
  138850. * Get the current class name of the texture useful for serialization or dynamic coding.
  138851. * @returns "HDRCubeTexture"
  138852. */
  138853. getClassName(): string;
  138854. /**
  138855. * Occurs when the file is raw .hdr file.
  138856. */
  138857. private loadTexture;
  138858. clone(): HDRCubeTexture;
  138859. delayLoad(): void;
  138860. /**
  138861. * Get the texture reflection matrix used to rotate/transform the reflection.
  138862. * @returns the reflection matrix
  138863. */
  138864. getReflectionTextureMatrix(): Matrix;
  138865. /**
  138866. * Set the texture reflection matrix used to rotate/transform the reflection.
  138867. * @param value Define the reflection matrix to set
  138868. */
  138869. setReflectionTextureMatrix(value: Matrix): void;
  138870. /**
  138871. * Parses a JSON representation of an HDR Texture in order to create the texture
  138872. * @param parsedTexture Define the JSON representation
  138873. * @param scene Define the scene the texture should be created in
  138874. * @param rootUrl Define the root url in case we need to load relative dependencies
  138875. * @returns the newly created texture after parsing
  138876. */
  138877. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  138878. serialize(): any;
  138879. }
  138880. }
  138881. declare module BABYLON {
  138882. /**
  138883. * Class used to control physics engine
  138884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138885. */
  138886. export class PhysicsEngine implements IPhysicsEngine {
  138887. private _physicsPlugin;
  138888. /**
  138889. * Global value used to control the smallest number supported by the simulation
  138890. */
  138891. static Epsilon: number;
  138892. private _impostors;
  138893. private _joints;
  138894. private _subTimeStep;
  138895. /**
  138896. * Gets the gravity vector used by the simulation
  138897. */
  138898. gravity: Vector3;
  138899. /**
  138900. * Factory used to create the default physics plugin.
  138901. * @returns The default physics plugin
  138902. */
  138903. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  138904. /**
  138905. * Creates a new Physics Engine
  138906. * @param gravity defines the gravity vector used by the simulation
  138907. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  138908. */
  138909. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  138910. /**
  138911. * Sets the gravity vector used by the simulation
  138912. * @param gravity defines the gravity vector to use
  138913. */
  138914. setGravity(gravity: Vector3): void;
  138915. /**
  138916. * Set the time step of the physics engine.
  138917. * Default is 1/60.
  138918. * To slow it down, enter 1/600 for example.
  138919. * To speed it up, 1/30
  138920. * @param newTimeStep defines the new timestep to apply to this world.
  138921. */
  138922. setTimeStep(newTimeStep?: number): void;
  138923. /**
  138924. * Get the time step of the physics engine.
  138925. * @returns the current time step
  138926. */
  138927. getTimeStep(): number;
  138928. /**
  138929. * Set the sub time step of the physics engine.
  138930. * Default is 0 meaning there is no sub steps
  138931. * To increase physics resolution precision, set a small value (like 1 ms)
  138932. * @param subTimeStep defines the new sub timestep used for physics resolution.
  138933. */
  138934. setSubTimeStep(subTimeStep?: number): void;
  138935. /**
  138936. * Get the sub time step of the physics engine.
  138937. * @returns the current sub time step
  138938. */
  138939. getSubTimeStep(): number;
  138940. /**
  138941. * Release all resources
  138942. */
  138943. dispose(): void;
  138944. /**
  138945. * Gets the name of the current physics plugin
  138946. * @returns the name of the plugin
  138947. */
  138948. getPhysicsPluginName(): string;
  138949. /**
  138950. * Adding a new impostor for the impostor tracking.
  138951. * This will be done by the impostor itself.
  138952. * @param impostor the impostor to add
  138953. */
  138954. addImpostor(impostor: PhysicsImpostor): void;
  138955. /**
  138956. * Remove an impostor from the engine.
  138957. * This impostor and its mesh will not longer be updated by the physics engine.
  138958. * @param impostor the impostor to remove
  138959. */
  138960. removeImpostor(impostor: PhysicsImpostor): void;
  138961. /**
  138962. * Add a joint to the physics engine
  138963. * @param mainImpostor defines the main impostor to which the joint is added.
  138964. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  138965. * @param joint defines the joint that will connect both impostors.
  138966. */
  138967. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138968. /**
  138969. * Removes a joint from the simulation
  138970. * @param mainImpostor defines the impostor used with the joint
  138971. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  138972. * @param joint defines the joint to remove
  138973. */
  138974. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138975. /**
  138976. * Called by the scene. No need to call it.
  138977. * @param delta defines the timespam between frames
  138978. */
  138979. _step(delta: number): void;
  138980. /**
  138981. * Gets the current plugin used to run the simulation
  138982. * @returns current plugin
  138983. */
  138984. getPhysicsPlugin(): IPhysicsEnginePlugin;
  138985. /**
  138986. * Gets the list of physic impostors
  138987. * @returns an array of PhysicsImpostor
  138988. */
  138989. getImpostors(): Array<PhysicsImpostor>;
  138990. /**
  138991. * Gets the impostor for a physics enabled object
  138992. * @param object defines the object impersonated by the impostor
  138993. * @returns the PhysicsImpostor or null if not found
  138994. */
  138995. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  138996. /**
  138997. * Gets the impostor for a physics body object
  138998. * @param body defines physics body used by the impostor
  138999. * @returns the PhysicsImpostor or null if not found
  139000. */
  139001. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  139002. /**
  139003. * Does a raycast in the physics world
  139004. * @param from when should the ray start?
  139005. * @param to when should the ray end?
  139006. * @returns PhysicsRaycastResult
  139007. */
  139008. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139009. }
  139010. }
  139011. declare module BABYLON {
  139012. /** @hidden */
  139013. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  139014. private _useDeltaForWorldStep;
  139015. world: any;
  139016. name: string;
  139017. private _physicsMaterials;
  139018. private _fixedTimeStep;
  139019. private _cannonRaycastResult;
  139020. private _raycastResult;
  139021. private _physicsBodysToRemoveAfterStep;
  139022. private _firstFrame;
  139023. BJSCANNON: any;
  139024. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  139025. setGravity(gravity: Vector3): void;
  139026. setTimeStep(timeStep: number): void;
  139027. getTimeStep(): number;
  139028. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139029. private _removeMarkedPhysicsBodiesFromWorld;
  139030. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139031. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139032. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139033. private _processChildMeshes;
  139034. removePhysicsBody(impostor: PhysicsImpostor): void;
  139035. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139036. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139037. private _addMaterial;
  139038. private _checkWithEpsilon;
  139039. private _createShape;
  139040. private _createHeightmap;
  139041. private _minus90X;
  139042. private _plus90X;
  139043. private _tmpPosition;
  139044. private _tmpDeltaPosition;
  139045. private _tmpUnityRotation;
  139046. private _updatePhysicsBodyTransformation;
  139047. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139048. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139049. isSupported(): boolean;
  139050. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139051. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139052. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139053. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139054. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139055. getBodyMass(impostor: PhysicsImpostor): number;
  139056. getBodyFriction(impostor: PhysicsImpostor): number;
  139057. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139058. getBodyRestitution(impostor: PhysicsImpostor): number;
  139059. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139060. sleepBody(impostor: PhysicsImpostor): void;
  139061. wakeUpBody(impostor: PhysicsImpostor): void;
  139062. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  139063. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139064. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139065. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139066. getRadius(impostor: PhysicsImpostor): number;
  139067. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139068. dispose(): void;
  139069. private _extendNamespace;
  139070. /**
  139071. * Does a raycast in the physics world
  139072. * @param from when should the ray start?
  139073. * @param to when should the ray end?
  139074. * @returns PhysicsRaycastResult
  139075. */
  139076. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139077. }
  139078. }
  139079. declare module BABYLON {
  139080. /** @hidden */
  139081. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  139082. private _useDeltaForWorldStep;
  139083. world: any;
  139084. name: string;
  139085. BJSOIMO: any;
  139086. private _raycastResult;
  139087. private _fixedTimeStep;
  139088. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  139089. setGravity(gravity: Vector3): void;
  139090. setTimeStep(timeStep: number): void;
  139091. getTimeStep(): number;
  139092. private _tmpImpostorsArray;
  139093. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139094. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139095. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139096. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139097. private _tmpPositionVector;
  139098. removePhysicsBody(impostor: PhysicsImpostor): void;
  139099. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139100. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139101. isSupported(): boolean;
  139102. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139103. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139104. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139105. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139106. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139107. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139108. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139109. getBodyMass(impostor: PhysicsImpostor): number;
  139110. getBodyFriction(impostor: PhysicsImpostor): number;
  139111. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139112. getBodyRestitution(impostor: PhysicsImpostor): number;
  139113. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139114. sleepBody(impostor: PhysicsImpostor): void;
  139115. wakeUpBody(impostor: PhysicsImpostor): void;
  139116. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139117. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  139118. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  139119. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139120. getRadius(impostor: PhysicsImpostor): number;
  139121. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139122. dispose(): void;
  139123. /**
  139124. * Does a raycast in the physics world
  139125. * @param from when should the ray start?
  139126. * @param to when should the ray end?
  139127. * @returns PhysicsRaycastResult
  139128. */
  139129. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139130. }
  139131. }
  139132. declare module BABYLON {
  139133. /**
  139134. * AmmoJS Physics plugin
  139135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139136. * @see https://github.com/kripken/ammo.js/
  139137. */
  139138. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  139139. private _useDeltaForWorldStep;
  139140. /**
  139141. * Reference to the Ammo library
  139142. */
  139143. bjsAMMO: any;
  139144. /**
  139145. * Created ammoJS world which physics bodies are added to
  139146. */
  139147. world: any;
  139148. /**
  139149. * Name of the plugin
  139150. */
  139151. name: string;
  139152. private _timeStep;
  139153. private _fixedTimeStep;
  139154. private _maxSteps;
  139155. private _tmpQuaternion;
  139156. private _tmpAmmoTransform;
  139157. private _tmpAmmoQuaternion;
  139158. private _tmpAmmoConcreteContactResultCallback;
  139159. private _collisionConfiguration;
  139160. private _dispatcher;
  139161. private _overlappingPairCache;
  139162. private _solver;
  139163. private _softBodySolver;
  139164. private _tmpAmmoVectorA;
  139165. private _tmpAmmoVectorB;
  139166. private _tmpAmmoVectorC;
  139167. private _tmpAmmoVectorD;
  139168. private _tmpContactCallbackResult;
  139169. private _tmpAmmoVectorRCA;
  139170. private _tmpAmmoVectorRCB;
  139171. private _raycastResult;
  139172. private static readonly DISABLE_COLLISION_FLAG;
  139173. private static readonly KINEMATIC_FLAG;
  139174. private static readonly DISABLE_DEACTIVATION_FLAG;
  139175. /**
  139176. * Initializes the ammoJS plugin
  139177. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  139178. * @param ammoInjection can be used to inject your own ammo reference
  139179. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  139180. */
  139181. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  139182. /**
  139183. * Sets the gravity of the physics world (m/(s^2))
  139184. * @param gravity Gravity to set
  139185. */
  139186. setGravity(gravity: Vector3): void;
  139187. /**
  139188. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  139189. * @param timeStep timestep to use in seconds
  139190. */
  139191. setTimeStep(timeStep: number): void;
  139192. /**
  139193. * 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)
  139194. * @param fixedTimeStep fixedTimeStep to use in seconds
  139195. */
  139196. setFixedTimeStep(fixedTimeStep: number): void;
  139197. /**
  139198. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  139199. * @param maxSteps the maximum number of steps by the physics engine per frame
  139200. */
  139201. setMaxSteps(maxSteps: number): void;
  139202. /**
  139203. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  139204. * @returns the current timestep in seconds
  139205. */
  139206. getTimeStep(): number;
  139207. /**
  139208. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  139209. */
  139210. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  139211. private _isImpostorInContact;
  139212. private _isImpostorPairInContact;
  139213. private _stepSimulation;
  139214. /**
  139215. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  139216. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  139217. * After the step the babylon meshes are set to the position of the physics imposters
  139218. * @param delta amount of time to step forward
  139219. * @param impostors array of imposters to update before/after the step
  139220. */
  139221. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139222. /**
  139223. * Update babylon mesh to match physics world object
  139224. * @param impostor imposter to match
  139225. */
  139226. private _afterSoftStep;
  139227. /**
  139228. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139229. * @param impostor imposter to match
  139230. */
  139231. private _ropeStep;
  139232. /**
  139233. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139234. * @param impostor imposter to match
  139235. */
  139236. private _softbodyOrClothStep;
  139237. private _tmpMatrix;
  139238. /**
  139239. * Applies an impulse on the imposter
  139240. * @param impostor imposter to apply impulse to
  139241. * @param force amount of force to be applied to the imposter
  139242. * @param contactPoint the location to apply the impulse on the imposter
  139243. */
  139244. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139245. /**
  139246. * Applies a force on the imposter
  139247. * @param impostor imposter to apply force
  139248. * @param force amount of force to be applied to the imposter
  139249. * @param contactPoint the location to apply the force on the imposter
  139250. */
  139251. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139252. /**
  139253. * Creates a physics body using the plugin
  139254. * @param impostor the imposter to create the physics body on
  139255. */
  139256. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139257. /**
  139258. * Removes the physics body from the imposter and disposes of the body's memory
  139259. * @param impostor imposter to remove the physics body from
  139260. */
  139261. removePhysicsBody(impostor: PhysicsImpostor): void;
  139262. /**
  139263. * Generates a joint
  139264. * @param impostorJoint the imposter joint to create the joint with
  139265. */
  139266. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139267. /**
  139268. * Removes a joint
  139269. * @param impostorJoint the imposter joint to remove the joint from
  139270. */
  139271. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139272. private _addMeshVerts;
  139273. /**
  139274. * Initialise the soft body vertices to match its object's (mesh) vertices
  139275. * Softbody vertices (nodes) are in world space and to match this
  139276. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139277. * @param impostor to create the softbody for
  139278. */
  139279. private _softVertexData;
  139280. /**
  139281. * Create an impostor's soft body
  139282. * @param impostor to create the softbody for
  139283. */
  139284. private _createSoftbody;
  139285. /**
  139286. * Create cloth for an impostor
  139287. * @param impostor to create the softbody for
  139288. */
  139289. private _createCloth;
  139290. /**
  139291. * Create rope for an impostor
  139292. * @param impostor to create the softbody for
  139293. */
  139294. private _createRope;
  139295. /**
  139296. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139297. * @param impostor to create the custom physics shape for
  139298. */
  139299. private _createCustom;
  139300. private _addHullVerts;
  139301. private _createShape;
  139302. /**
  139303. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139304. * @param impostor imposter containing the physics body and babylon object
  139305. */
  139306. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139307. /**
  139308. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139309. * @param impostor imposter containing the physics body and babylon object
  139310. * @param newPosition new position
  139311. * @param newRotation new rotation
  139312. */
  139313. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139314. /**
  139315. * If this plugin is supported
  139316. * @returns true if its supported
  139317. */
  139318. isSupported(): boolean;
  139319. /**
  139320. * Sets the linear velocity of the physics body
  139321. * @param impostor imposter to set the velocity on
  139322. * @param velocity velocity to set
  139323. */
  139324. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139325. /**
  139326. * Sets the angular velocity of the physics body
  139327. * @param impostor imposter to set the velocity on
  139328. * @param velocity velocity to set
  139329. */
  139330. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139331. /**
  139332. * gets the linear velocity
  139333. * @param impostor imposter to get linear velocity from
  139334. * @returns linear velocity
  139335. */
  139336. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139337. /**
  139338. * gets the angular velocity
  139339. * @param impostor imposter to get angular velocity from
  139340. * @returns angular velocity
  139341. */
  139342. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139343. /**
  139344. * Sets the mass of physics body
  139345. * @param impostor imposter to set the mass on
  139346. * @param mass mass to set
  139347. */
  139348. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139349. /**
  139350. * Gets the mass of the physics body
  139351. * @param impostor imposter to get the mass from
  139352. * @returns mass
  139353. */
  139354. getBodyMass(impostor: PhysicsImpostor): number;
  139355. /**
  139356. * Gets friction of the impostor
  139357. * @param impostor impostor to get friction from
  139358. * @returns friction value
  139359. */
  139360. getBodyFriction(impostor: PhysicsImpostor): number;
  139361. /**
  139362. * Sets friction of the impostor
  139363. * @param impostor impostor to set friction on
  139364. * @param friction friction value
  139365. */
  139366. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139367. /**
  139368. * Gets restitution of the impostor
  139369. * @param impostor impostor to get restitution from
  139370. * @returns restitution value
  139371. */
  139372. getBodyRestitution(impostor: PhysicsImpostor): number;
  139373. /**
  139374. * Sets resitution of the impostor
  139375. * @param impostor impostor to set resitution on
  139376. * @param restitution resitution value
  139377. */
  139378. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139379. /**
  139380. * Gets pressure inside the impostor
  139381. * @param impostor impostor to get pressure from
  139382. * @returns pressure value
  139383. */
  139384. getBodyPressure(impostor: PhysicsImpostor): number;
  139385. /**
  139386. * Sets pressure inside a soft body impostor
  139387. * Cloth and rope must remain 0 pressure
  139388. * @param impostor impostor to set pressure on
  139389. * @param pressure pressure value
  139390. */
  139391. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  139392. /**
  139393. * Gets stiffness of the impostor
  139394. * @param impostor impostor to get stiffness from
  139395. * @returns pressure value
  139396. */
  139397. getBodyStiffness(impostor: PhysicsImpostor): number;
  139398. /**
  139399. * Sets stiffness of the impostor
  139400. * @param impostor impostor to set stiffness on
  139401. * @param stiffness stiffness value from 0 to 1
  139402. */
  139403. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  139404. /**
  139405. * Gets velocityIterations of the impostor
  139406. * @param impostor impostor to get velocity iterations from
  139407. * @returns velocityIterations value
  139408. */
  139409. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  139410. /**
  139411. * Sets velocityIterations of the impostor
  139412. * @param impostor impostor to set velocity iterations on
  139413. * @param velocityIterations velocityIterations value
  139414. */
  139415. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  139416. /**
  139417. * Gets positionIterations of the impostor
  139418. * @param impostor impostor to get position iterations from
  139419. * @returns positionIterations value
  139420. */
  139421. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  139422. /**
  139423. * Sets positionIterations of the impostor
  139424. * @param impostor impostor to set position on
  139425. * @param positionIterations positionIterations value
  139426. */
  139427. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  139428. /**
  139429. * Append an anchor to a cloth object
  139430. * @param impostor is the cloth impostor to add anchor to
  139431. * @param otherImpostor is the rigid impostor to anchor to
  139432. * @param width ratio across width from 0 to 1
  139433. * @param height ratio up height from 0 to 1
  139434. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  139435. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139436. */
  139437. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139438. /**
  139439. * Append an hook to a rope object
  139440. * @param impostor is the rope impostor to add hook to
  139441. * @param otherImpostor is the rigid impostor to hook to
  139442. * @param length ratio along the rope from 0 to 1
  139443. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  139444. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139445. */
  139446. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139447. /**
  139448. * Sleeps the physics body and stops it from being active
  139449. * @param impostor impostor to sleep
  139450. */
  139451. sleepBody(impostor: PhysicsImpostor): void;
  139452. /**
  139453. * Activates the physics body
  139454. * @param impostor impostor to activate
  139455. */
  139456. wakeUpBody(impostor: PhysicsImpostor): void;
  139457. /**
  139458. * Updates the distance parameters of the joint
  139459. * @param joint joint to update
  139460. * @param maxDistance maximum distance of the joint
  139461. * @param minDistance minimum distance of the joint
  139462. */
  139463. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139464. /**
  139465. * Sets a motor on the joint
  139466. * @param joint joint to set motor on
  139467. * @param speed speed of the motor
  139468. * @param maxForce maximum force of the motor
  139469. * @param motorIndex index of the motor
  139470. */
  139471. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139472. /**
  139473. * Sets the motors limit
  139474. * @param joint joint to set limit on
  139475. * @param upperLimit upper limit
  139476. * @param lowerLimit lower limit
  139477. */
  139478. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139479. /**
  139480. * Syncs the position and rotation of a mesh with the impostor
  139481. * @param mesh mesh to sync
  139482. * @param impostor impostor to update the mesh with
  139483. */
  139484. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139485. /**
  139486. * Gets the radius of the impostor
  139487. * @param impostor impostor to get radius from
  139488. * @returns the radius
  139489. */
  139490. getRadius(impostor: PhysicsImpostor): number;
  139491. /**
  139492. * Gets the box size of the impostor
  139493. * @param impostor impostor to get box size from
  139494. * @param result the resulting box size
  139495. */
  139496. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139497. /**
  139498. * Disposes of the impostor
  139499. */
  139500. dispose(): void;
  139501. /**
  139502. * Does a raycast in the physics world
  139503. * @param from when should the ray start?
  139504. * @param to when should the ray end?
  139505. * @returns PhysicsRaycastResult
  139506. */
  139507. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139508. }
  139509. }
  139510. declare module BABYLON {
  139511. interface AbstractScene {
  139512. /**
  139513. * The list of reflection probes added to the scene
  139514. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139515. */
  139516. reflectionProbes: Array<ReflectionProbe>;
  139517. /**
  139518. * Removes the given reflection probe from this scene.
  139519. * @param toRemove The reflection probe to remove
  139520. * @returns The index of the removed reflection probe
  139521. */
  139522. removeReflectionProbe(toRemove: ReflectionProbe): number;
  139523. /**
  139524. * Adds the given reflection probe to this scene.
  139525. * @param newReflectionProbe The reflection probe to add
  139526. */
  139527. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  139528. }
  139529. /**
  139530. * Class used to generate realtime reflection / refraction cube textures
  139531. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139532. */
  139533. export class ReflectionProbe {
  139534. /** defines the name of the probe */
  139535. name: string;
  139536. private _scene;
  139537. private _renderTargetTexture;
  139538. private _projectionMatrix;
  139539. private _viewMatrix;
  139540. private _target;
  139541. private _add;
  139542. private _attachedMesh;
  139543. private _invertYAxis;
  139544. /** Gets or sets probe position (center of the cube map) */
  139545. position: Vector3;
  139546. /**
  139547. * Creates a new reflection probe
  139548. * @param name defines the name of the probe
  139549. * @param size defines the texture resolution (for each face)
  139550. * @param scene defines the hosting scene
  139551. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  139552. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  139553. */
  139554. constructor(
  139555. /** defines the name of the probe */
  139556. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  139557. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  139558. get samples(): number;
  139559. set samples(value: number);
  139560. /** Gets or sets the refresh rate to use (on every frame by default) */
  139561. get refreshRate(): number;
  139562. set refreshRate(value: number);
  139563. /**
  139564. * Gets the hosting scene
  139565. * @returns a Scene
  139566. */
  139567. getScene(): Scene;
  139568. /** Gets the internal CubeTexture used to render to */
  139569. get cubeTexture(): RenderTargetTexture;
  139570. /** Gets the list of meshes to render */
  139571. get renderList(): Nullable<AbstractMesh[]>;
  139572. /**
  139573. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  139574. * @param mesh defines the mesh to attach to
  139575. */
  139576. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  139577. /**
  139578. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  139579. * @param renderingGroupId The rendering group id corresponding to its index
  139580. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  139581. */
  139582. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  139583. /**
  139584. * Clean all associated resources
  139585. */
  139586. dispose(): void;
  139587. /**
  139588. * Converts the reflection probe information to a readable string for debug purpose.
  139589. * @param fullDetails Supports for multiple levels of logging within scene loading
  139590. * @returns the human readable reflection probe info
  139591. */
  139592. toString(fullDetails?: boolean): string;
  139593. /**
  139594. * Get the class name of the relfection probe.
  139595. * @returns "ReflectionProbe"
  139596. */
  139597. getClassName(): string;
  139598. /**
  139599. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  139600. * @returns The JSON representation of the texture
  139601. */
  139602. serialize(): any;
  139603. /**
  139604. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  139605. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  139606. * @param scene Define the scene the parsed reflection probe should be instantiated in
  139607. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  139608. * @returns The parsed reflection probe if successful
  139609. */
  139610. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  139611. }
  139612. }
  139613. declare module BABYLON {
  139614. /** @hidden */
  139615. export var _BabylonLoaderRegistered: boolean;
  139616. /**
  139617. * Helps setting up some configuration for the babylon file loader.
  139618. */
  139619. export class BabylonFileLoaderConfiguration {
  139620. /**
  139621. * The loader does not allow injecting custom physix engine into the plugins.
  139622. * Unfortunately in ES6, we need to manually inject them into the plugin.
  139623. * So you could set this variable to your engine import to make it work.
  139624. */
  139625. static LoaderInjectedPhysicsEngine: any;
  139626. }
  139627. }
  139628. declare module BABYLON {
  139629. /**
  139630. * The Physically based simple base material of BJS.
  139631. *
  139632. * This enables better naming and convention enforcements on top of the pbrMaterial.
  139633. * It is used as the base class for both the specGloss and metalRough conventions.
  139634. */
  139635. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  139636. /**
  139637. * Number of Simultaneous lights allowed on the material.
  139638. */
  139639. maxSimultaneousLights: number;
  139640. /**
  139641. * If sets to true, disables all the lights affecting the material.
  139642. */
  139643. disableLighting: boolean;
  139644. /**
  139645. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  139646. */
  139647. environmentTexture: BaseTexture;
  139648. /**
  139649. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  139650. */
  139651. invertNormalMapX: boolean;
  139652. /**
  139653. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  139654. */
  139655. invertNormalMapY: boolean;
  139656. /**
  139657. * Normal map used in the model.
  139658. */
  139659. normalTexture: BaseTexture;
  139660. /**
  139661. * Emissivie color used to self-illuminate the model.
  139662. */
  139663. emissiveColor: Color3;
  139664. /**
  139665. * Emissivie texture used to self-illuminate the model.
  139666. */
  139667. emissiveTexture: BaseTexture;
  139668. /**
  139669. * Occlusion Channel Strenght.
  139670. */
  139671. occlusionStrength: number;
  139672. /**
  139673. * Occlusion Texture of the material (adding extra occlusion effects).
  139674. */
  139675. occlusionTexture: BaseTexture;
  139676. /**
  139677. * Defines the alpha limits in alpha test mode.
  139678. */
  139679. alphaCutOff: number;
  139680. /**
  139681. * Gets the current double sided mode.
  139682. */
  139683. get doubleSided(): boolean;
  139684. /**
  139685. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  139686. */
  139687. set doubleSided(value: boolean);
  139688. /**
  139689. * Stores the pre-calculated light information of a mesh in a texture.
  139690. */
  139691. lightmapTexture: BaseTexture;
  139692. /**
  139693. * If true, the light map contains occlusion information instead of lighting info.
  139694. */
  139695. useLightmapAsShadowmap: boolean;
  139696. /**
  139697. * Instantiates a new PBRMaterial instance.
  139698. *
  139699. * @param name The material name
  139700. * @param scene The scene the material will be use in.
  139701. */
  139702. constructor(name: string, scene: Scene);
  139703. getClassName(): string;
  139704. }
  139705. }
  139706. declare module BABYLON {
  139707. /**
  139708. * The PBR material of BJS following the metal roughness convention.
  139709. *
  139710. * This fits to the PBR convention in the GLTF definition:
  139711. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  139712. */
  139713. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  139714. /**
  139715. * The base color has two different interpretations depending on the value of metalness.
  139716. * When the material is a metal, the base color is the specific measured reflectance value
  139717. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  139718. * of the material.
  139719. */
  139720. baseColor: Color3;
  139721. /**
  139722. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  139723. * well as opacity information in the alpha channel.
  139724. */
  139725. baseTexture: BaseTexture;
  139726. /**
  139727. * Specifies the metallic scalar value of the material.
  139728. * Can also be used to scale the metalness values of the metallic texture.
  139729. */
  139730. metallic: number;
  139731. /**
  139732. * Specifies the roughness scalar value of the material.
  139733. * Can also be used to scale the roughness values of the metallic texture.
  139734. */
  139735. roughness: number;
  139736. /**
  139737. * Texture containing both the metallic value in the B channel and the
  139738. * roughness value in the G channel to keep better precision.
  139739. */
  139740. metallicRoughnessTexture: BaseTexture;
  139741. /**
  139742. * Instantiates a new PBRMetalRoughnessMaterial instance.
  139743. *
  139744. * @param name The material name
  139745. * @param scene The scene the material will be use in.
  139746. */
  139747. constructor(name: string, scene: Scene);
  139748. /**
  139749. * Return the currrent class name of the material.
  139750. */
  139751. getClassName(): string;
  139752. /**
  139753. * Makes a duplicate of the current material.
  139754. * @param name - name to use for the new material.
  139755. */
  139756. clone(name: string): PBRMetallicRoughnessMaterial;
  139757. /**
  139758. * Serialize the material to a parsable JSON object.
  139759. */
  139760. serialize(): any;
  139761. /**
  139762. * Parses a JSON object correponding to the serialize function.
  139763. */
  139764. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  139765. }
  139766. }
  139767. declare module BABYLON {
  139768. /**
  139769. * The PBR material of BJS following the specular glossiness convention.
  139770. *
  139771. * This fits to the PBR convention in the GLTF definition:
  139772. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  139773. */
  139774. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  139775. /**
  139776. * Specifies the diffuse color of the material.
  139777. */
  139778. diffuseColor: Color3;
  139779. /**
  139780. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  139781. * channel.
  139782. */
  139783. diffuseTexture: BaseTexture;
  139784. /**
  139785. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  139786. */
  139787. specularColor: Color3;
  139788. /**
  139789. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  139790. */
  139791. glossiness: number;
  139792. /**
  139793. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  139794. */
  139795. specularGlossinessTexture: BaseTexture;
  139796. /**
  139797. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  139798. *
  139799. * @param name The material name
  139800. * @param scene The scene the material will be use in.
  139801. */
  139802. constructor(name: string, scene: Scene);
  139803. /**
  139804. * Return the currrent class name of the material.
  139805. */
  139806. getClassName(): string;
  139807. /**
  139808. * Makes a duplicate of the current material.
  139809. * @param name - name to use for the new material.
  139810. */
  139811. clone(name: string): PBRSpecularGlossinessMaterial;
  139812. /**
  139813. * Serialize the material to a parsable JSON object.
  139814. */
  139815. serialize(): any;
  139816. /**
  139817. * Parses a JSON object correponding to the serialize function.
  139818. */
  139819. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  139820. }
  139821. }
  139822. declare module BABYLON {
  139823. /**
  139824. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  139825. * It can help converting any input color in a desired output one. This can then be used to create effects
  139826. * from sepia, black and white to sixties or futuristic rendering...
  139827. *
  139828. * The only supported format is currently 3dl.
  139829. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  139830. */
  139831. export class ColorGradingTexture extends BaseTexture {
  139832. /**
  139833. * The texture URL.
  139834. */
  139835. url: string;
  139836. /**
  139837. * Empty line regex stored for GC.
  139838. */
  139839. private static _noneEmptyLineRegex;
  139840. private _textureMatrix;
  139841. private _onLoad;
  139842. /**
  139843. * Instantiates a ColorGradingTexture from the following parameters.
  139844. *
  139845. * @param url The location of the color gradind data (currently only supporting 3dl)
  139846. * @param sceneOrEngine The scene or engine the texture will be used in
  139847. * @param onLoad defines a callback triggered when the texture has been loaded
  139848. */
  139849. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  139850. /**
  139851. * Fires the onload event from the constructor if requested.
  139852. */
  139853. private _triggerOnLoad;
  139854. /**
  139855. * Returns the texture matrix used in most of the material.
  139856. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  139857. */
  139858. getTextureMatrix(): Matrix;
  139859. /**
  139860. * Occurs when the file being loaded is a .3dl LUT file.
  139861. */
  139862. private load3dlTexture;
  139863. /**
  139864. * Starts the loading process of the texture.
  139865. */
  139866. private loadTexture;
  139867. /**
  139868. * Clones the color gradind texture.
  139869. */
  139870. clone(): ColorGradingTexture;
  139871. /**
  139872. * Called during delayed load for textures.
  139873. */
  139874. delayLoad(): void;
  139875. /**
  139876. * Parses a color grading texture serialized by Babylon.
  139877. * @param parsedTexture The texture information being parsedTexture
  139878. * @param scene The scene to load the texture in
  139879. * @param rootUrl The root url of the data assets to load
  139880. * @return A color gradind texture
  139881. */
  139882. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  139883. /**
  139884. * Serializes the LUT texture to json format.
  139885. */
  139886. serialize(): any;
  139887. }
  139888. }
  139889. declare module BABYLON {
  139890. /**
  139891. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  139892. */
  139893. export class EquiRectangularCubeTexture extends BaseTexture {
  139894. /** The six faces of the cube. */
  139895. private static _FacesMapping;
  139896. private _noMipmap;
  139897. private _onLoad;
  139898. private _onError;
  139899. /** The size of the cubemap. */
  139900. private _size;
  139901. /** The buffer of the image. */
  139902. private _buffer;
  139903. /** The width of the input image. */
  139904. private _width;
  139905. /** The height of the input image. */
  139906. private _height;
  139907. /** The URL to the image. */
  139908. url: string;
  139909. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  139910. coordinatesMode: number;
  139911. /**
  139912. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  139913. * @param url The location of the image
  139914. * @param scene The scene the texture will be used in
  139915. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139916. * @param noMipmap Forces to not generate the mipmap if true
  139917. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  139918. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  139919. * @param onLoad — defines a callback called when texture is loaded
  139920. * @param onError — defines a callback called if there is an error
  139921. */
  139922. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  139923. /**
  139924. * Load the image data, by putting the image on a canvas and extracting its buffer.
  139925. */
  139926. private loadImage;
  139927. /**
  139928. * Convert the image buffer into a cubemap and create a CubeTexture.
  139929. */
  139930. private loadTexture;
  139931. /**
  139932. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  139933. * @param buffer The ArrayBuffer that should be converted.
  139934. * @returns The buffer as Float32Array.
  139935. */
  139936. private getFloat32ArrayFromArrayBuffer;
  139937. /**
  139938. * Get the current class name of the texture useful for serialization or dynamic coding.
  139939. * @returns "EquiRectangularCubeTexture"
  139940. */
  139941. getClassName(): string;
  139942. /**
  139943. * Create a clone of the current EquiRectangularCubeTexture and return it.
  139944. * @returns A clone of the current EquiRectangularCubeTexture.
  139945. */
  139946. clone(): EquiRectangularCubeTexture;
  139947. }
  139948. }
  139949. declare module BABYLON {
  139950. /**
  139951. * Defines the options related to the creation of an HtmlElementTexture
  139952. */
  139953. export interface IHtmlElementTextureOptions {
  139954. /**
  139955. * Defines wether mip maps should be created or not.
  139956. */
  139957. generateMipMaps?: boolean;
  139958. /**
  139959. * Defines the sampling mode of the texture.
  139960. */
  139961. samplingMode?: number;
  139962. /**
  139963. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  139964. */
  139965. engine: Nullable<ThinEngine>;
  139966. /**
  139967. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  139968. */
  139969. scene: Nullable<Scene>;
  139970. }
  139971. /**
  139972. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  139973. * To be as efficient as possible depending on your constraints nothing aside the first upload
  139974. * is automatically managed.
  139975. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  139976. * in your application.
  139977. *
  139978. * As the update is not automatic, you need to call them manually.
  139979. */
  139980. export class HtmlElementTexture extends BaseTexture {
  139981. /**
  139982. * The texture URL.
  139983. */
  139984. element: HTMLVideoElement | HTMLCanvasElement;
  139985. private static readonly DefaultOptions;
  139986. private _textureMatrix;
  139987. private _isVideo;
  139988. private _generateMipMaps;
  139989. private _samplingMode;
  139990. /**
  139991. * Instantiates a HtmlElementTexture from the following parameters.
  139992. *
  139993. * @param name Defines the name of the texture
  139994. * @param element Defines the video or canvas the texture is filled with
  139995. * @param options Defines the other none mandatory texture creation options
  139996. */
  139997. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  139998. private _createInternalTexture;
  139999. /**
  140000. * Returns the texture matrix used in most of the material.
  140001. */
  140002. getTextureMatrix(): Matrix;
  140003. /**
  140004. * Updates the content of the texture.
  140005. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  140006. */
  140007. update(invertY?: Nullable<boolean>): void;
  140008. }
  140009. }
  140010. declare module BABYLON {
  140011. /**
  140012. * Based on jsTGALoader - Javascript loader for TGA file
  140013. * By Vincent Thibault
  140014. * @see http://blog.robrowser.com/javascript-tga-loader.html
  140015. */
  140016. export class TGATools {
  140017. private static _TYPE_INDEXED;
  140018. private static _TYPE_RGB;
  140019. private static _TYPE_GREY;
  140020. private static _TYPE_RLE_INDEXED;
  140021. private static _TYPE_RLE_RGB;
  140022. private static _TYPE_RLE_GREY;
  140023. private static _ORIGIN_MASK;
  140024. private static _ORIGIN_SHIFT;
  140025. private static _ORIGIN_BL;
  140026. private static _ORIGIN_BR;
  140027. private static _ORIGIN_UL;
  140028. private static _ORIGIN_UR;
  140029. /**
  140030. * Gets the header of a TGA file
  140031. * @param data defines the TGA data
  140032. * @returns the header
  140033. */
  140034. static GetTGAHeader(data: Uint8Array): any;
  140035. /**
  140036. * Uploads TGA content to a Babylon Texture
  140037. * @hidden
  140038. */
  140039. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  140040. /** @hidden */
  140041. 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;
  140042. /** @hidden */
  140043. 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;
  140044. /** @hidden */
  140045. 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;
  140046. /** @hidden */
  140047. 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;
  140048. /** @hidden */
  140049. 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;
  140050. /** @hidden */
  140051. 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;
  140052. }
  140053. }
  140054. declare module BABYLON {
  140055. /**
  140056. * Implementation of the TGA Texture Loader.
  140057. * @hidden
  140058. */
  140059. export class _TGATextureLoader implements IInternalTextureLoader {
  140060. /**
  140061. * Defines wether the loader supports cascade loading the different faces.
  140062. */
  140063. readonly supportCascades: boolean;
  140064. /**
  140065. * This returns if the loader support the current file information.
  140066. * @param extension defines the file extension of the file being loaded
  140067. * @returns true if the loader can load the specified file
  140068. */
  140069. canLoad(extension: string): boolean;
  140070. /**
  140071. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140072. * @param data contains the texture data
  140073. * @param texture defines the BabylonJS internal texture
  140074. * @param createPolynomials will be true if polynomials have been requested
  140075. * @param onLoad defines the callback to trigger once the texture is ready
  140076. * @param onError defines the callback to trigger in case of error
  140077. */
  140078. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140079. /**
  140080. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140081. * @param data contains the texture data
  140082. * @param texture defines the BabylonJS internal texture
  140083. * @param callback defines the method to call once ready to upload
  140084. */
  140085. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140086. }
  140087. }
  140088. declare module BABYLON {
  140089. /**
  140090. * Info about the .basis files
  140091. */
  140092. class BasisFileInfo {
  140093. /**
  140094. * If the file has alpha
  140095. */
  140096. hasAlpha: boolean;
  140097. /**
  140098. * Info about each image of the basis file
  140099. */
  140100. images: Array<{
  140101. levels: Array<{
  140102. width: number;
  140103. height: number;
  140104. transcodedPixels: ArrayBufferView;
  140105. }>;
  140106. }>;
  140107. }
  140108. /**
  140109. * Result of transcoding a basis file
  140110. */
  140111. class TranscodeResult {
  140112. /**
  140113. * Info about the .basis file
  140114. */
  140115. fileInfo: BasisFileInfo;
  140116. /**
  140117. * Format to use when loading the file
  140118. */
  140119. format: number;
  140120. }
  140121. /**
  140122. * Configuration options for the Basis transcoder
  140123. */
  140124. export class BasisTranscodeConfiguration {
  140125. /**
  140126. * Supported compression formats used to determine the supported output format of the transcoder
  140127. */
  140128. supportedCompressionFormats?: {
  140129. /**
  140130. * etc1 compression format
  140131. */
  140132. etc1?: boolean;
  140133. /**
  140134. * s3tc compression format
  140135. */
  140136. s3tc?: boolean;
  140137. /**
  140138. * pvrtc compression format
  140139. */
  140140. pvrtc?: boolean;
  140141. /**
  140142. * etc2 compression format
  140143. */
  140144. etc2?: boolean;
  140145. };
  140146. /**
  140147. * If mipmap levels should be loaded for transcoded images (Default: true)
  140148. */
  140149. loadMipmapLevels?: boolean;
  140150. /**
  140151. * Index of a single image to load (Default: all images)
  140152. */
  140153. loadSingleImage?: number;
  140154. }
  140155. /**
  140156. * Used to load .Basis files
  140157. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  140158. */
  140159. export class BasisTools {
  140160. private static _IgnoreSupportedFormats;
  140161. /**
  140162. * URL to use when loading the basis transcoder
  140163. */
  140164. static JSModuleURL: string;
  140165. /**
  140166. * URL to use when loading the wasm module for the transcoder
  140167. */
  140168. static WasmModuleURL: string;
  140169. /**
  140170. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  140171. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  140172. * @returns internal format corresponding to the Basis format
  140173. */
  140174. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  140175. private static _WorkerPromise;
  140176. private static _Worker;
  140177. private static _actionId;
  140178. private static _CreateWorkerAsync;
  140179. /**
  140180. * Transcodes a loaded image file to compressed pixel data
  140181. * @param data image data to transcode
  140182. * @param config configuration options for the transcoding
  140183. * @returns a promise resulting in the transcoded image
  140184. */
  140185. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  140186. /**
  140187. * Loads a texture from the transcode result
  140188. * @param texture texture load to
  140189. * @param transcodeResult the result of transcoding the basis file to load from
  140190. */
  140191. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  140192. }
  140193. }
  140194. declare module BABYLON {
  140195. /**
  140196. * Loader for .basis file format
  140197. */
  140198. export class _BasisTextureLoader implements IInternalTextureLoader {
  140199. /**
  140200. * Defines whether the loader supports cascade loading the different faces.
  140201. */
  140202. readonly supportCascades: boolean;
  140203. /**
  140204. * This returns if the loader support the current file information.
  140205. * @param extension defines the file extension of the file being loaded
  140206. * @returns true if the loader can load the specified file
  140207. */
  140208. canLoad(extension: string): boolean;
  140209. /**
  140210. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140211. * @param data contains the texture data
  140212. * @param texture defines the BabylonJS internal texture
  140213. * @param createPolynomials will be true if polynomials have been requested
  140214. * @param onLoad defines the callback to trigger once the texture is ready
  140215. * @param onError defines the callback to trigger in case of error
  140216. */
  140217. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140218. /**
  140219. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140220. * @param data contains the texture data
  140221. * @param texture defines the BabylonJS internal texture
  140222. * @param callback defines the method to call once ready to upload
  140223. */
  140224. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140225. }
  140226. }
  140227. declare module BABYLON {
  140228. /**
  140229. * Defines the basic options interface of a TexturePacker Frame
  140230. */
  140231. export interface ITexturePackerFrame {
  140232. /**
  140233. * The frame ID
  140234. */
  140235. id: number;
  140236. /**
  140237. * The frames Scale
  140238. */
  140239. scale: Vector2;
  140240. /**
  140241. * The Frames offset
  140242. */
  140243. offset: Vector2;
  140244. }
  140245. /**
  140246. * This is a support class for frame Data on texture packer sets.
  140247. */
  140248. export class TexturePackerFrame implements ITexturePackerFrame {
  140249. /**
  140250. * The frame ID
  140251. */
  140252. id: number;
  140253. /**
  140254. * The frames Scale
  140255. */
  140256. scale: Vector2;
  140257. /**
  140258. * The Frames offset
  140259. */
  140260. offset: Vector2;
  140261. /**
  140262. * Initializes a texture package frame.
  140263. * @param id The numerical frame identifier
  140264. * @param scale Scalar Vector2 for UV frame
  140265. * @param offset Vector2 for the frame position in UV units.
  140266. * @returns TexturePackerFrame
  140267. */
  140268. constructor(id: number, scale: Vector2, offset: Vector2);
  140269. }
  140270. }
  140271. declare module BABYLON {
  140272. /**
  140273. * Defines the basic options interface of a TexturePacker
  140274. */
  140275. export interface ITexturePackerOptions {
  140276. /**
  140277. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140278. */
  140279. map?: string[];
  140280. /**
  140281. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140282. */
  140283. uvsIn?: string;
  140284. /**
  140285. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140286. */
  140287. uvsOut?: string;
  140288. /**
  140289. * number representing the layout style. Defaults to LAYOUT_STRIP
  140290. */
  140291. layout?: number;
  140292. /**
  140293. * number of columns if using custom column count layout(2). This defaults to 4.
  140294. */
  140295. colnum?: number;
  140296. /**
  140297. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140298. */
  140299. updateInputMeshes?: boolean;
  140300. /**
  140301. * boolean flag to dispose all the source textures. Defaults to true.
  140302. */
  140303. disposeSources?: boolean;
  140304. /**
  140305. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140306. */
  140307. fillBlanks?: boolean;
  140308. /**
  140309. * string value representing the context fill style color. Defaults to 'black'.
  140310. */
  140311. customFillColor?: string;
  140312. /**
  140313. * Width and Height Value of each Frame in the TexturePacker Sets
  140314. */
  140315. frameSize?: number;
  140316. /**
  140317. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140318. */
  140319. paddingRatio?: number;
  140320. /**
  140321. * Number that declares the fill method for the padding gutter.
  140322. */
  140323. paddingMode?: number;
  140324. /**
  140325. * If in SUBUV_COLOR padding mode what color to use.
  140326. */
  140327. paddingColor?: Color3 | Color4;
  140328. }
  140329. /**
  140330. * Defines the basic interface of a TexturePacker JSON File
  140331. */
  140332. export interface ITexturePackerJSON {
  140333. /**
  140334. * The frame ID
  140335. */
  140336. name: string;
  140337. /**
  140338. * The base64 channel data
  140339. */
  140340. sets: any;
  140341. /**
  140342. * The options of the Packer
  140343. */
  140344. options: ITexturePackerOptions;
  140345. /**
  140346. * The frame data of the Packer
  140347. */
  140348. frames: Array<number>;
  140349. }
  140350. /**
  140351. * This is a support class that generates a series of packed texture sets.
  140352. * @see https://doc.babylonjs.com/babylon101/materials
  140353. */
  140354. export class TexturePacker {
  140355. /** Packer Layout Constant 0 */
  140356. static readonly LAYOUT_STRIP: number;
  140357. /** Packer Layout Constant 1 */
  140358. static readonly LAYOUT_POWER2: number;
  140359. /** Packer Layout Constant 2 */
  140360. static readonly LAYOUT_COLNUM: number;
  140361. /** Packer Layout Constant 0 */
  140362. static readonly SUBUV_WRAP: number;
  140363. /** Packer Layout Constant 1 */
  140364. static readonly SUBUV_EXTEND: number;
  140365. /** Packer Layout Constant 2 */
  140366. static readonly SUBUV_COLOR: number;
  140367. /** The Name of the Texture Package */
  140368. name: string;
  140369. /** The scene scope of the TexturePacker */
  140370. scene: Scene;
  140371. /** The Meshes to target */
  140372. meshes: AbstractMesh[];
  140373. /** Arguments passed with the Constructor */
  140374. options: ITexturePackerOptions;
  140375. /** The promise that is started upon initialization */
  140376. promise: Nullable<Promise<TexturePacker | string>>;
  140377. /** The Container object for the channel sets that are generated */
  140378. sets: object;
  140379. /** The Container array for the frames that are generated */
  140380. frames: TexturePackerFrame[];
  140381. /** The expected number of textures the system is parsing. */
  140382. private _expecting;
  140383. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  140384. private _paddingValue;
  140385. /**
  140386. * Initializes a texture package series from an array of meshes or a single mesh.
  140387. * @param name The name of the package
  140388. * @param meshes The target meshes to compose the package from
  140389. * @param options The arguments that texture packer should follow while building.
  140390. * @param scene The scene which the textures are scoped to.
  140391. * @returns TexturePacker
  140392. */
  140393. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  140394. /**
  140395. * Starts the package process
  140396. * @param resolve The promises resolution function
  140397. * @returns TexturePacker
  140398. */
  140399. private _createFrames;
  140400. /**
  140401. * Calculates the Size of the Channel Sets
  140402. * @returns Vector2
  140403. */
  140404. private _calculateSize;
  140405. /**
  140406. * Calculates the UV data for the frames.
  140407. * @param baseSize the base frameSize
  140408. * @param padding the base frame padding
  140409. * @param dtSize size of the Dynamic Texture for that channel
  140410. * @param dtUnits is 1/dtSize
  140411. * @param update flag to update the input meshes
  140412. */
  140413. private _calculateMeshUVFrames;
  140414. /**
  140415. * Calculates the frames Offset.
  140416. * @param index of the frame
  140417. * @returns Vector2
  140418. */
  140419. private _getFrameOffset;
  140420. /**
  140421. * Updates a Mesh to the frame data
  140422. * @param mesh that is the target
  140423. * @param frameID or the frame index
  140424. */
  140425. private _updateMeshUV;
  140426. /**
  140427. * Updates a Meshes materials to use the texture packer channels
  140428. * @param m is the mesh to target
  140429. * @param force all channels on the packer to be set.
  140430. */
  140431. private _updateTextureReferences;
  140432. /**
  140433. * Public method to set a Mesh to a frame
  140434. * @param m that is the target
  140435. * @param frameID or the frame index
  140436. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  140437. */
  140438. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  140439. /**
  140440. * Starts the async promise to compile the texture packer.
  140441. * @returns Promise<void>
  140442. */
  140443. processAsync(): Promise<void>;
  140444. /**
  140445. * Disposes all textures associated with this packer
  140446. */
  140447. dispose(): void;
  140448. /**
  140449. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  140450. * @param imageType is the image type to use.
  140451. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  140452. */
  140453. download(imageType?: string, quality?: number): void;
  140454. /**
  140455. * Public method to load a texturePacker JSON file.
  140456. * @param data of the JSON file in string format.
  140457. */
  140458. updateFromJSON(data: string): void;
  140459. }
  140460. }
  140461. declare module BABYLON {
  140462. /**
  140463. * 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.
  140464. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140465. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140466. */
  140467. export class CustomProceduralTexture extends ProceduralTexture {
  140468. private _animate;
  140469. private _time;
  140470. private _config;
  140471. private _texturePath;
  140472. /**
  140473. * Instantiates a new Custom Procedural Texture.
  140474. * 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.
  140475. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140476. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140477. * @param name Define the name of the texture
  140478. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  140479. * @param size Define the size of the texture to create
  140480. * @param scene Define the scene the texture belongs to
  140481. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  140482. * @param generateMipMaps Define if the texture should creates mip maps or not
  140483. */
  140484. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140485. private _loadJson;
  140486. /**
  140487. * Is the texture ready to be used ? (rendered at least once)
  140488. * @returns true if ready, otherwise, false.
  140489. */
  140490. isReady(): boolean;
  140491. /**
  140492. * Render the texture to its associated render target.
  140493. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  140494. */
  140495. render(useCameraPostProcess?: boolean): void;
  140496. /**
  140497. * Update the list of dependant textures samplers in the shader.
  140498. */
  140499. updateTextures(): void;
  140500. /**
  140501. * Update the uniform values of the procedural texture in the shader.
  140502. */
  140503. updateShaderUniforms(): void;
  140504. /**
  140505. * Define if the texture animates or not.
  140506. */
  140507. get animate(): boolean;
  140508. set animate(value: boolean);
  140509. }
  140510. }
  140511. declare module BABYLON {
  140512. /** @hidden */
  140513. export var noisePixelShader: {
  140514. name: string;
  140515. shader: string;
  140516. };
  140517. }
  140518. declare module BABYLON {
  140519. /**
  140520. * Class used to generate noise procedural textures
  140521. */
  140522. export class NoiseProceduralTexture extends ProceduralTexture {
  140523. private _time;
  140524. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  140525. brightness: number;
  140526. /** Defines the number of octaves to process */
  140527. octaves: number;
  140528. /** Defines the level of persistence (0.8 by default) */
  140529. persistence: number;
  140530. /** Gets or sets animation speed factor (default is 1) */
  140531. animationSpeedFactor: number;
  140532. /**
  140533. * Creates a new NoiseProceduralTexture
  140534. * @param name defines the name fo the texture
  140535. * @param size defines the size of the texture (default is 256)
  140536. * @param scene defines the hosting scene
  140537. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  140538. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  140539. */
  140540. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140541. private _updateShaderUniforms;
  140542. protected _getDefines(): string;
  140543. /** Generate the current state of the procedural texture */
  140544. render(useCameraPostProcess?: boolean): void;
  140545. /**
  140546. * Serializes this noise procedural texture
  140547. * @returns a serialized noise procedural texture object
  140548. */
  140549. serialize(): any;
  140550. /**
  140551. * Clone the texture.
  140552. * @returns the cloned texture
  140553. */
  140554. clone(): NoiseProceduralTexture;
  140555. /**
  140556. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  140557. * @param parsedTexture defines parsed texture data
  140558. * @param scene defines the current scene
  140559. * @param rootUrl defines the root URL containing noise procedural texture information
  140560. * @returns a parsed NoiseProceduralTexture
  140561. */
  140562. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  140563. }
  140564. }
  140565. declare module BABYLON {
  140566. /**
  140567. * Raw cube texture where the raw buffers are passed in
  140568. */
  140569. export class RawCubeTexture extends CubeTexture {
  140570. /**
  140571. * Creates a cube texture where the raw buffers are passed in.
  140572. * @param scene defines the scene the texture is attached to
  140573. * @param data defines the array of data to use to create each face
  140574. * @param size defines the size of the textures
  140575. * @param format defines the format of the data
  140576. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  140577. * @param generateMipMaps defines if the engine should generate the mip levels
  140578. * @param invertY defines if data must be stored with Y axis inverted
  140579. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  140580. * @param compression defines the compression used (null by default)
  140581. */
  140582. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  140583. /**
  140584. * Updates the raw cube texture.
  140585. * @param data defines the data to store
  140586. * @param format defines the data format
  140587. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140588. * @param invertY defines if data must be stored with Y axis inverted
  140589. * @param compression defines the compression used (null by default)
  140590. * @param level defines which level of the texture to update
  140591. */
  140592. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  140593. /**
  140594. * Updates a raw cube texture with RGBD encoded data.
  140595. * @param data defines the array of data [mipmap][face] to use to create each face
  140596. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  140597. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  140598. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  140599. * @returns a promsie that resolves when the operation is complete
  140600. */
  140601. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  140602. /**
  140603. * Clones the raw cube texture.
  140604. * @return a new cube texture
  140605. */
  140606. clone(): CubeTexture;
  140607. /** @hidden */
  140608. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  140609. }
  140610. }
  140611. declare module BABYLON {
  140612. /**
  140613. * Class used to store 2D array textures containing user data
  140614. */
  140615. export class RawTexture2DArray extends Texture {
  140616. /** Gets or sets the texture format to use */
  140617. format: number;
  140618. /**
  140619. * Create a new RawTexture2DArray
  140620. * @param data defines the data of the texture
  140621. * @param width defines the width of the texture
  140622. * @param height defines the height of the texture
  140623. * @param depth defines the number of layers of the texture
  140624. * @param format defines the texture format to use
  140625. * @param scene defines the hosting scene
  140626. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140627. * @param invertY defines if texture must be stored with Y axis inverted
  140628. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140629. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140630. */
  140631. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140632. /** Gets or sets the texture format to use */
  140633. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140634. /**
  140635. * Update the texture with new data
  140636. * @param data defines the data to store in the texture
  140637. */
  140638. update(data: ArrayBufferView): void;
  140639. }
  140640. }
  140641. declare module BABYLON {
  140642. /**
  140643. * Class used to store 3D textures containing user data
  140644. */
  140645. export class RawTexture3D extends Texture {
  140646. /** Gets or sets the texture format to use */
  140647. format: number;
  140648. /**
  140649. * Create a new RawTexture3D
  140650. * @param data defines the data of the texture
  140651. * @param width defines the width of the texture
  140652. * @param height defines the height of the texture
  140653. * @param depth defines the depth of the texture
  140654. * @param format defines the texture format to use
  140655. * @param scene defines the hosting scene
  140656. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140657. * @param invertY defines if texture must be stored with Y axis inverted
  140658. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140659. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140660. */
  140661. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140662. /** Gets or sets the texture format to use */
  140663. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140664. /**
  140665. * Update the texture with new data
  140666. * @param data defines the data to store in the texture
  140667. */
  140668. update(data: ArrayBufferView): void;
  140669. }
  140670. }
  140671. declare module BABYLON {
  140672. /**
  140673. * Creates a refraction texture used by refraction channel of the standard material.
  140674. * It is like a mirror but to see through a material.
  140675. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140676. */
  140677. export class RefractionTexture extends RenderTargetTexture {
  140678. /**
  140679. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  140680. * 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.
  140681. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140682. */
  140683. refractionPlane: Plane;
  140684. /**
  140685. * Define how deep under the surface we should see.
  140686. */
  140687. depth: number;
  140688. /**
  140689. * Creates a refraction texture used by refraction channel of the standard material.
  140690. * It is like a mirror but to see through a material.
  140691. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140692. * @param name Define the texture name
  140693. * @param size Define the size of the underlying texture
  140694. * @param scene Define the scene the refraction belongs to
  140695. * @param generateMipMaps Define if we need to generate mips level for the refraction
  140696. */
  140697. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  140698. /**
  140699. * Clone the refraction texture.
  140700. * @returns the cloned texture
  140701. */
  140702. clone(): RefractionTexture;
  140703. /**
  140704. * Serialize the texture to a JSON representation you could use in Parse later on
  140705. * @returns the serialized JSON representation
  140706. */
  140707. serialize(): any;
  140708. }
  140709. }
  140710. declare module BABYLON {
  140711. /**
  140712. * Block used to add support for vertex skinning (bones)
  140713. */
  140714. export class BonesBlock extends NodeMaterialBlock {
  140715. /**
  140716. * Creates a new BonesBlock
  140717. * @param name defines the block name
  140718. */
  140719. constructor(name: string);
  140720. /**
  140721. * Initialize the block and prepare the context for build
  140722. * @param state defines the state that will be used for the build
  140723. */
  140724. initialize(state: NodeMaterialBuildState): void;
  140725. /**
  140726. * Gets the current class name
  140727. * @returns the class name
  140728. */
  140729. getClassName(): string;
  140730. /**
  140731. * Gets the matrix indices input component
  140732. */
  140733. get matricesIndices(): NodeMaterialConnectionPoint;
  140734. /**
  140735. * Gets the matrix weights input component
  140736. */
  140737. get matricesWeights(): NodeMaterialConnectionPoint;
  140738. /**
  140739. * Gets the extra matrix indices input component
  140740. */
  140741. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  140742. /**
  140743. * Gets the extra matrix weights input component
  140744. */
  140745. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  140746. /**
  140747. * Gets the world input component
  140748. */
  140749. get world(): NodeMaterialConnectionPoint;
  140750. /**
  140751. * Gets the output component
  140752. */
  140753. get output(): NodeMaterialConnectionPoint;
  140754. autoConfigure(material: NodeMaterial): void;
  140755. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  140756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140758. protected _buildBlock(state: NodeMaterialBuildState): this;
  140759. }
  140760. }
  140761. declare module BABYLON {
  140762. /**
  140763. * Block used to add support for instances
  140764. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  140765. */
  140766. export class InstancesBlock extends NodeMaterialBlock {
  140767. /**
  140768. * Creates a new InstancesBlock
  140769. * @param name defines the block name
  140770. */
  140771. constructor(name: string);
  140772. /**
  140773. * Gets the current class name
  140774. * @returns the class name
  140775. */
  140776. getClassName(): string;
  140777. /**
  140778. * Gets the first world row input component
  140779. */
  140780. get world0(): NodeMaterialConnectionPoint;
  140781. /**
  140782. * Gets the second world row input component
  140783. */
  140784. get world1(): NodeMaterialConnectionPoint;
  140785. /**
  140786. * Gets the third world row input component
  140787. */
  140788. get world2(): NodeMaterialConnectionPoint;
  140789. /**
  140790. * Gets the forth world row input component
  140791. */
  140792. get world3(): NodeMaterialConnectionPoint;
  140793. /**
  140794. * Gets the world input component
  140795. */
  140796. get world(): NodeMaterialConnectionPoint;
  140797. /**
  140798. * Gets the output component
  140799. */
  140800. get output(): NodeMaterialConnectionPoint;
  140801. /**
  140802. * Gets the isntanceID component
  140803. */
  140804. get instanceID(): NodeMaterialConnectionPoint;
  140805. autoConfigure(material: NodeMaterial): void;
  140806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  140807. protected _buildBlock(state: NodeMaterialBuildState): this;
  140808. }
  140809. }
  140810. declare module BABYLON {
  140811. /**
  140812. * Block used to add morph targets support to vertex shader
  140813. */
  140814. export class MorphTargetsBlock extends NodeMaterialBlock {
  140815. private _repeatableContentAnchor;
  140816. /**
  140817. * Create a new MorphTargetsBlock
  140818. * @param name defines the block name
  140819. */
  140820. constructor(name: string);
  140821. /**
  140822. * Gets the current class name
  140823. * @returns the class name
  140824. */
  140825. getClassName(): string;
  140826. /**
  140827. * Gets the position input component
  140828. */
  140829. get position(): NodeMaterialConnectionPoint;
  140830. /**
  140831. * Gets the normal input component
  140832. */
  140833. get normal(): NodeMaterialConnectionPoint;
  140834. /**
  140835. * Gets the tangent input component
  140836. */
  140837. get tangent(): NodeMaterialConnectionPoint;
  140838. /**
  140839. * Gets the tangent input component
  140840. */
  140841. get uv(): NodeMaterialConnectionPoint;
  140842. /**
  140843. * Gets the position output component
  140844. */
  140845. get positionOutput(): NodeMaterialConnectionPoint;
  140846. /**
  140847. * Gets the normal output component
  140848. */
  140849. get normalOutput(): NodeMaterialConnectionPoint;
  140850. /**
  140851. * Gets the tangent output component
  140852. */
  140853. get tangentOutput(): NodeMaterialConnectionPoint;
  140854. /**
  140855. * Gets the tangent output component
  140856. */
  140857. get uvOutput(): NodeMaterialConnectionPoint;
  140858. initialize(state: NodeMaterialBuildState): void;
  140859. autoConfigure(material: NodeMaterial): void;
  140860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140861. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140862. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  140863. protected _buildBlock(state: NodeMaterialBuildState): this;
  140864. }
  140865. }
  140866. declare module BABYLON {
  140867. /**
  140868. * Block used to get data information from a light
  140869. */
  140870. export class LightInformationBlock extends NodeMaterialBlock {
  140871. private _lightDataUniformName;
  140872. private _lightColorUniformName;
  140873. private _lightTypeDefineName;
  140874. /**
  140875. * Gets or sets the light associated with this block
  140876. */
  140877. light: Nullable<Light>;
  140878. /**
  140879. * Creates a new LightInformationBlock
  140880. * @param name defines the block name
  140881. */
  140882. constructor(name: string);
  140883. /**
  140884. * Gets the current class name
  140885. * @returns the class name
  140886. */
  140887. getClassName(): string;
  140888. /**
  140889. * Gets the world position input component
  140890. */
  140891. get worldPosition(): NodeMaterialConnectionPoint;
  140892. /**
  140893. * Gets the direction output component
  140894. */
  140895. get direction(): NodeMaterialConnectionPoint;
  140896. /**
  140897. * Gets the direction output component
  140898. */
  140899. get color(): NodeMaterialConnectionPoint;
  140900. /**
  140901. * Gets the direction output component
  140902. */
  140903. get intensity(): NodeMaterialConnectionPoint;
  140904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140906. protected _buildBlock(state: NodeMaterialBuildState): this;
  140907. serialize(): any;
  140908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140909. }
  140910. }
  140911. declare module BABYLON {
  140912. /**
  140913. * Block used to add image processing support to fragment shader
  140914. */
  140915. export class ImageProcessingBlock extends NodeMaterialBlock {
  140916. /**
  140917. * Create a new ImageProcessingBlock
  140918. * @param name defines the block name
  140919. */
  140920. constructor(name: string);
  140921. /**
  140922. * Gets the current class name
  140923. * @returns the class name
  140924. */
  140925. getClassName(): string;
  140926. /**
  140927. * Gets the color input component
  140928. */
  140929. get color(): NodeMaterialConnectionPoint;
  140930. /**
  140931. * Gets the output component
  140932. */
  140933. get output(): NodeMaterialConnectionPoint;
  140934. /**
  140935. * Initialize the block and prepare the context for build
  140936. * @param state defines the state that will be used for the build
  140937. */
  140938. initialize(state: NodeMaterialBuildState): void;
  140939. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  140940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140942. protected _buildBlock(state: NodeMaterialBuildState): this;
  140943. }
  140944. }
  140945. declare module BABYLON {
  140946. /**
  140947. * Block used to pertub normals based on a normal map
  140948. */
  140949. export class PerturbNormalBlock extends NodeMaterialBlock {
  140950. private _tangentSpaceParameterName;
  140951. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140952. invertX: boolean;
  140953. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  140954. invertY: boolean;
  140955. /**
  140956. * Create a new PerturbNormalBlock
  140957. * @param name defines the block name
  140958. */
  140959. constructor(name: string);
  140960. /**
  140961. * Gets the current class name
  140962. * @returns the class name
  140963. */
  140964. getClassName(): string;
  140965. /**
  140966. * Gets the world position input component
  140967. */
  140968. get worldPosition(): NodeMaterialConnectionPoint;
  140969. /**
  140970. * Gets the world normal input component
  140971. */
  140972. get worldNormal(): NodeMaterialConnectionPoint;
  140973. /**
  140974. * Gets the world tangent input component
  140975. */
  140976. get worldTangent(): NodeMaterialConnectionPoint;
  140977. /**
  140978. * Gets the uv input component
  140979. */
  140980. get uv(): NodeMaterialConnectionPoint;
  140981. /**
  140982. * Gets the normal map color input component
  140983. */
  140984. get normalMapColor(): NodeMaterialConnectionPoint;
  140985. /**
  140986. * Gets the strength input component
  140987. */
  140988. get strength(): NodeMaterialConnectionPoint;
  140989. /**
  140990. * Gets the output component
  140991. */
  140992. get output(): NodeMaterialConnectionPoint;
  140993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140994. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140995. autoConfigure(material: NodeMaterial): void;
  140996. protected _buildBlock(state: NodeMaterialBuildState): this;
  140997. protected _dumpPropertiesCode(): string;
  140998. serialize(): any;
  140999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141000. }
  141001. }
  141002. declare module BABYLON {
  141003. /**
  141004. * Block used to discard a pixel if a value is smaller than a cutoff
  141005. */
  141006. export class DiscardBlock extends NodeMaterialBlock {
  141007. /**
  141008. * Create a new DiscardBlock
  141009. * @param name defines the block name
  141010. */
  141011. constructor(name: string);
  141012. /**
  141013. * Gets the current class name
  141014. * @returns the class name
  141015. */
  141016. getClassName(): string;
  141017. /**
  141018. * Gets the color input component
  141019. */
  141020. get value(): NodeMaterialConnectionPoint;
  141021. /**
  141022. * Gets the cutoff input component
  141023. */
  141024. get cutoff(): NodeMaterialConnectionPoint;
  141025. protected _buildBlock(state: NodeMaterialBuildState): this;
  141026. }
  141027. }
  141028. declare module BABYLON {
  141029. /**
  141030. * Block used to test if the fragment shader is front facing
  141031. */
  141032. export class FrontFacingBlock extends NodeMaterialBlock {
  141033. /**
  141034. * Creates a new FrontFacingBlock
  141035. * @param name defines the block name
  141036. */
  141037. constructor(name: string);
  141038. /**
  141039. * Gets the current class name
  141040. * @returns the class name
  141041. */
  141042. getClassName(): string;
  141043. /**
  141044. * Gets the output component
  141045. */
  141046. get output(): NodeMaterialConnectionPoint;
  141047. protected _buildBlock(state: NodeMaterialBuildState): this;
  141048. }
  141049. }
  141050. declare module BABYLON {
  141051. /**
  141052. * Block used to get the derivative value on x and y of a given input
  141053. */
  141054. export class DerivativeBlock extends NodeMaterialBlock {
  141055. /**
  141056. * Create a new DerivativeBlock
  141057. * @param name defines the block name
  141058. */
  141059. constructor(name: string);
  141060. /**
  141061. * Gets the current class name
  141062. * @returns the class name
  141063. */
  141064. getClassName(): string;
  141065. /**
  141066. * Gets the input component
  141067. */
  141068. get input(): NodeMaterialConnectionPoint;
  141069. /**
  141070. * Gets the derivative output on x
  141071. */
  141072. get dx(): NodeMaterialConnectionPoint;
  141073. /**
  141074. * Gets the derivative output on y
  141075. */
  141076. get dy(): NodeMaterialConnectionPoint;
  141077. protected _buildBlock(state: NodeMaterialBuildState): this;
  141078. }
  141079. }
  141080. declare module BABYLON {
  141081. /**
  141082. * Block used to make gl_FragCoord available
  141083. */
  141084. export class FragCoordBlock extends NodeMaterialBlock {
  141085. /**
  141086. * Creates a new FragCoordBlock
  141087. * @param name defines the block name
  141088. */
  141089. constructor(name: string);
  141090. /**
  141091. * Gets the current class name
  141092. * @returns the class name
  141093. */
  141094. getClassName(): string;
  141095. /**
  141096. * Gets the xy component
  141097. */
  141098. get xy(): NodeMaterialConnectionPoint;
  141099. /**
  141100. * Gets the xyz component
  141101. */
  141102. get xyz(): NodeMaterialConnectionPoint;
  141103. /**
  141104. * Gets the xyzw component
  141105. */
  141106. get xyzw(): NodeMaterialConnectionPoint;
  141107. /**
  141108. * Gets the x component
  141109. */
  141110. get x(): NodeMaterialConnectionPoint;
  141111. /**
  141112. * Gets the y component
  141113. */
  141114. get y(): NodeMaterialConnectionPoint;
  141115. /**
  141116. * Gets the z component
  141117. */
  141118. get z(): NodeMaterialConnectionPoint;
  141119. /**
  141120. * Gets the w component
  141121. */
  141122. get output(): NodeMaterialConnectionPoint;
  141123. protected writeOutputs(state: NodeMaterialBuildState): string;
  141124. protected _buildBlock(state: NodeMaterialBuildState): this;
  141125. }
  141126. }
  141127. declare module BABYLON {
  141128. /**
  141129. * Block used to get the screen sizes
  141130. */
  141131. export class ScreenSizeBlock extends NodeMaterialBlock {
  141132. private _varName;
  141133. private _scene;
  141134. /**
  141135. * Creates a new ScreenSizeBlock
  141136. * @param name defines the block name
  141137. */
  141138. constructor(name: string);
  141139. /**
  141140. * Gets the current class name
  141141. * @returns the class name
  141142. */
  141143. getClassName(): string;
  141144. /**
  141145. * Gets the xy component
  141146. */
  141147. get xy(): NodeMaterialConnectionPoint;
  141148. /**
  141149. * Gets the x component
  141150. */
  141151. get x(): NodeMaterialConnectionPoint;
  141152. /**
  141153. * Gets the y component
  141154. */
  141155. get y(): NodeMaterialConnectionPoint;
  141156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141157. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  141158. protected _buildBlock(state: NodeMaterialBuildState): this;
  141159. }
  141160. }
  141161. declare module BABYLON {
  141162. /**
  141163. * Block used to add support for scene fog
  141164. */
  141165. export class FogBlock extends NodeMaterialBlock {
  141166. private _fogDistanceName;
  141167. private _fogParameters;
  141168. /**
  141169. * Create a new FogBlock
  141170. * @param name defines the block name
  141171. */
  141172. constructor(name: string);
  141173. /**
  141174. * Gets the current class name
  141175. * @returns the class name
  141176. */
  141177. getClassName(): string;
  141178. /**
  141179. * Gets the world position input component
  141180. */
  141181. get worldPosition(): NodeMaterialConnectionPoint;
  141182. /**
  141183. * Gets the view input component
  141184. */
  141185. get view(): NodeMaterialConnectionPoint;
  141186. /**
  141187. * Gets the color input component
  141188. */
  141189. get input(): NodeMaterialConnectionPoint;
  141190. /**
  141191. * Gets the fog color input component
  141192. */
  141193. get fogColor(): NodeMaterialConnectionPoint;
  141194. /**
  141195. * Gets the output component
  141196. */
  141197. get output(): NodeMaterialConnectionPoint;
  141198. autoConfigure(material: NodeMaterial): void;
  141199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141200. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141201. protected _buildBlock(state: NodeMaterialBuildState): this;
  141202. }
  141203. }
  141204. declare module BABYLON {
  141205. /**
  141206. * Block used to add light in the fragment shader
  141207. */
  141208. export class LightBlock extends NodeMaterialBlock {
  141209. private _lightId;
  141210. /**
  141211. * Gets or sets the light associated with this block
  141212. */
  141213. light: Nullable<Light>;
  141214. /**
  141215. * Create a new LightBlock
  141216. * @param name defines the block name
  141217. */
  141218. constructor(name: string);
  141219. /**
  141220. * Gets the current class name
  141221. * @returns the class name
  141222. */
  141223. getClassName(): string;
  141224. /**
  141225. * Gets the world position input component
  141226. */
  141227. get worldPosition(): NodeMaterialConnectionPoint;
  141228. /**
  141229. * Gets the world normal input component
  141230. */
  141231. get worldNormal(): NodeMaterialConnectionPoint;
  141232. /**
  141233. * Gets the camera (or eye) position component
  141234. */
  141235. get cameraPosition(): NodeMaterialConnectionPoint;
  141236. /**
  141237. * Gets the glossiness component
  141238. */
  141239. get glossiness(): NodeMaterialConnectionPoint;
  141240. /**
  141241. * Gets the glossinness power component
  141242. */
  141243. get glossPower(): NodeMaterialConnectionPoint;
  141244. /**
  141245. * Gets the diffuse color component
  141246. */
  141247. get diffuseColor(): NodeMaterialConnectionPoint;
  141248. /**
  141249. * Gets the specular color component
  141250. */
  141251. get specularColor(): NodeMaterialConnectionPoint;
  141252. /**
  141253. * Gets the diffuse output component
  141254. */
  141255. get diffuseOutput(): NodeMaterialConnectionPoint;
  141256. /**
  141257. * Gets the specular output component
  141258. */
  141259. get specularOutput(): NodeMaterialConnectionPoint;
  141260. /**
  141261. * Gets the shadow output component
  141262. */
  141263. get shadow(): NodeMaterialConnectionPoint;
  141264. autoConfigure(material: NodeMaterial): void;
  141265. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141266. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141267. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141268. private _injectVertexCode;
  141269. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141270. serialize(): any;
  141271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141272. }
  141273. }
  141274. declare module BABYLON {
  141275. /**
  141276. * Block used to read a reflection texture from a sampler
  141277. */
  141278. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141279. /**
  141280. * Create a new ReflectionTextureBlock
  141281. * @param name defines the block name
  141282. */
  141283. constructor(name: string);
  141284. /**
  141285. * Gets the current class name
  141286. * @returns the class name
  141287. */
  141288. getClassName(): string;
  141289. /**
  141290. * Gets the world position input component
  141291. */
  141292. get position(): NodeMaterialConnectionPoint;
  141293. /**
  141294. * Gets the world position input component
  141295. */
  141296. get worldPosition(): NodeMaterialConnectionPoint;
  141297. /**
  141298. * Gets the world normal input component
  141299. */
  141300. get worldNormal(): NodeMaterialConnectionPoint;
  141301. /**
  141302. * Gets the world input component
  141303. */
  141304. get world(): NodeMaterialConnectionPoint;
  141305. /**
  141306. * Gets the camera (or eye) position component
  141307. */
  141308. get cameraPosition(): NodeMaterialConnectionPoint;
  141309. /**
  141310. * Gets the view input component
  141311. */
  141312. get view(): NodeMaterialConnectionPoint;
  141313. /**
  141314. * Gets the rgb output component
  141315. */
  141316. get rgb(): NodeMaterialConnectionPoint;
  141317. /**
  141318. * Gets the rgba output component
  141319. */
  141320. get rgba(): NodeMaterialConnectionPoint;
  141321. /**
  141322. * Gets the r output component
  141323. */
  141324. get r(): NodeMaterialConnectionPoint;
  141325. /**
  141326. * Gets the g output component
  141327. */
  141328. get g(): NodeMaterialConnectionPoint;
  141329. /**
  141330. * Gets the b output component
  141331. */
  141332. get b(): NodeMaterialConnectionPoint;
  141333. /**
  141334. * Gets the a output component
  141335. */
  141336. get a(): NodeMaterialConnectionPoint;
  141337. autoConfigure(material: NodeMaterial): void;
  141338. protected _buildBlock(state: NodeMaterialBuildState): this;
  141339. }
  141340. }
  141341. declare module BABYLON {
  141342. /**
  141343. * Block used to add 2 vectors
  141344. */
  141345. export class AddBlock extends NodeMaterialBlock {
  141346. /**
  141347. * Creates a new AddBlock
  141348. * @param name defines the block name
  141349. */
  141350. constructor(name: string);
  141351. /**
  141352. * Gets the current class name
  141353. * @returns the class name
  141354. */
  141355. getClassName(): string;
  141356. /**
  141357. * Gets the left operand input component
  141358. */
  141359. get left(): NodeMaterialConnectionPoint;
  141360. /**
  141361. * Gets the right operand input component
  141362. */
  141363. get right(): NodeMaterialConnectionPoint;
  141364. /**
  141365. * Gets the output component
  141366. */
  141367. get output(): NodeMaterialConnectionPoint;
  141368. protected _buildBlock(state: NodeMaterialBuildState): this;
  141369. }
  141370. }
  141371. declare module BABYLON {
  141372. /**
  141373. * Block used to scale a vector by a float
  141374. */
  141375. export class ScaleBlock extends NodeMaterialBlock {
  141376. /**
  141377. * Creates a new ScaleBlock
  141378. * @param name defines the block name
  141379. */
  141380. constructor(name: string);
  141381. /**
  141382. * Gets the current class name
  141383. * @returns the class name
  141384. */
  141385. getClassName(): string;
  141386. /**
  141387. * Gets the input component
  141388. */
  141389. get input(): NodeMaterialConnectionPoint;
  141390. /**
  141391. * Gets the factor input component
  141392. */
  141393. get factor(): NodeMaterialConnectionPoint;
  141394. /**
  141395. * Gets the output component
  141396. */
  141397. get output(): NodeMaterialConnectionPoint;
  141398. protected _buildBlock(state: NodeMaterialBuildState): this;
  141399. }
  141400. }
  141401. declare module BABYLON {
  141402. /**
  141403. * Block used to clamp a float
  141404. */
  141405. export class ClampBlock extends NodeMaterialBlock {
  141406. /** Gets or sets the minimum range */
  141407. minimum: number;
  141408. /** Gets or sets the maximum range */
  141409. maximum: number;
  141410. /**
  141411. * Creates a new ClampBlock
  141412. * @param name defines the block name
  141413. */
  141414. constructor(name: string);
  141415. /**
  141416. * Gets the current class name
  141417. * @returns the class name
  141418. */
  141419. getClassName(): string;
  141420. /**
  141421. * Gets the value input component
  141422. */
  141423. get value(): NodeMaterialConnectionPoint;
  141424. /**
  141425. * Gets the output component
  141426. */
  141427. get output(): NodeMaterialConnectionPoint;
  141428. protected _buildBlock(state: NodeMaterialBuildState): this;
  141429. protected _dumpPropertiesCode(): string;
  141430. serialize(): any;
  141431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141432. }
  141433. }
  141434. declare module BABYLON {
  141435. /**
  141436. * Block used to apply a cross product between 2 vectors
  141437. */
  141438. export class CrossBlock extends NodeMaterialBlock {
  141439. /**
  141440. * Creates a new CrossBlock
  141441. * @param name defines the block name
  141442. */
  141443. constructor(name: string);
  141444. /**
  141445. * Gets the current class name
  141446. * @returns the class name
  141447. */
  141448. getClassName(): string;
  141449. /**
  141450. * Gets the left operand input component
  141451. */
  141452. get left(): NodeMaterialConnectionPoint;
  141453. /**
  141454. * Gets the right operand input component
  141455. */
  141456. get right(): NodeMaterialConnectionPoint;
  141457. /**
  141458. * Gets the output component
  141459. */
  141460. get output(): NodeMaterialConnectionPoint;
  141461. protected _buildBlock(state: NodeMaterialBuildState): this;
  141462. }
  141463. }
  141464. declare module BABYLON {
  141465. /**
  141466. * Block used to apply a dot product between 2 vectors
  141467. */
  141468. export class DotBlock extends NodeMaterialBlock {
  141469. /**
  141470. * Creates a new DotBlock
  141471. * @param name defines the block name
  141472. */
  141473. constructor(name: string);
  141474. /**
  141475. * Gets the current class name
  141476. * @returns the class name
  141477. */
  141478. getClassName(): string;
  141479. /**
  141480. * Gets the left operand input component
  141481. */
  141482. get left(): NodeMaterialConnectionPoint;
  141483. /**
  141484. * Gets the right operand input component
  141485. */
  141486. get right(): NodeMaterialConnectionPoint;
  141487. /**
  141488. * Gets the output component
  141489. */
  141490. get output(): NodeMaterialConnectionPoint;
  141491. protected _buildBlock(state: NodeMaterialBuildState): this;
  141492. }
  141493. }
  141494. declare module BABYLON {
  141495. /**
  141496. * Block used to normalize a vector
  141497. */
  141498. export class NormalizeBlock extends NodeMaterialBlock {
  141499. /**
  141500. * Creates a new NormalizeBlock
  141501. * @param name defines the block name
  141502. */
  141503. constructor(name: string);
  141504. /**
  141505. * Gets the current class name
  141506. * @returns the class name
  141507. */
  141508. getClassName(): string;
  141509. /**
  141510. * Gets the input component
  141511. */
  141512. get input(): NodeMaterialConnectionPoint;
  141513. /**
  141514. * Gets the output component
  141515. */
  141516. get output(): NodeMaterialConnectionPoint;
  141517. protected _buildBlock(state: NodeMaterialBuildState): this;
  141518. }
  141519. }
  141520. declare module BABYLON {
  141521. /**
  141522. * Operations supported by the Trigonometry block
  141523. */
  141524. export enum TrigonometryBlockOperations {
  141525. /** Cos */
  141526. Cos = 0,
  141527. /** Sin */
  141528. Sin = 1,
  141529. /** Abs */
  141530. Abs = 2,
  141531. /** Exp */
  141532. Exp = 3,
  141533. /** Exp2 */
  141534. Exp2 = 4,
  141535. /** Round */
  141536. Round = 5,
  141537. /** Floor */
  141538. Floor = 6,
  141539. /** Ceiling */
  141540. Ceiling = 7,
  141541. /** Square root */
  141542. Sqrt = 8,
  141543. /** Log */
  141544. Log = 9,
  141545. /** Tangent */
  141546. Tan = 10,
  141547. /** Arc tangent */
  141548. ArcTan = 11,
  141549. /** Arc cosinus */
  141550. ArcCos = 12,
  141551. /** Arc sinus */
  141552. ArcSin = 13,
  141553. /** Fraction */
  141554. Fract = 14,
  141555. /** Sign */
  141556. Sign = 15,
  141557. /** To radians (from degrees) */
  141558. Radians = 16,
  141559. /** To degrees (from radians) */
  141560. Degrees = 17
  141561. }
  141562. /**
  141563. * Block used to apply trigonometry operation to floats
  141564. */
  141565. export class TrigonometryBlock extends NodeMaterialBlock {
  141566. /**
  141567. * Gets or sets the operation applied by the block
  141568. */
  141569. operation: TrigonometryBlockOperations;
  141570. /**
  141571. * Creates a new TrigonometryBlock
  141572. * @param name defines the block name
  141573. */
  141574. constructor(name: string);
  141575. /**
  141576. * Gets the current class name
  141577. * @returns the class name
  141578. */
  141579. getClassName(): string;
  141580. /**
  141581. * Gets the input component
  141582. */
  141583. get input(): NodeMaterialConnectionPoint;
  141584. /**
  141585. * Gets the output component
  141586. */
  141587. get output(): NodeMaterialConnectionPoint;
  141588. protected _buildBlock(state: NodeMaterialBuildState): this;
  141589. serialize(): any;
  141590. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141591. protected _dumpPropertiesCode(): string;
  141592. }
  141593. }
  141594. declare module BABYLON {
  141595. /**
  141596. * Block used to create a Color3/4 out of individual inputs (one for each component)
  141597. */
  141598. export class ColorMergerBlock extends NodeMaterialBlock {
  141599. /**
  141600. * Create a new ColorMergerBlock
  141601. * @param name defines the block name
  141602. */
  141603. constructor(name: string);
  141604. /**
  141605. * Gets the current class name
  141606. * @returns the class name
  141607. */
  141608. getClassName(): string;
  141609. /**
  141610. * Gets the rgb component (input)
  141611. */
  141612. get rgbIn(): NodeMaterialConnectionPoint;
  141613. /**
  141614. * Gets the r component (input)
  141615. */
  141616. get r(): NodeMaterialConnectionPoint;
  141617. /**
  141618. * Gets the g component (input)
  141619. */
  141620. get g(): NodeMaterialConnectionPoint;
  141621. /**
  141622. * Gets the b component (input)
  141623. */
  141624. get b(): NodeMaterialConnectionPoint;
  141625. /**
  141626. * Gets the a component (input)
  141627. */
  141628. get a(): NodeMaterialConnectionPoint;
  141629. /**
  141630. * Gets the rgba component (output)
  141631. */
  141632. get rgba(): NodeMaterialConnectionPoint;
  141633. /**
  141634. * Gets the rgb component (output)
  141635. */
  141636. get rgbOut(): NodeMaterialConnectionPoint;
  141637. /**
  141638. * Gets the rgb component (output)
  141639. * @deprecated Please use rgbOut instead.
  141640. */
  141641. get rgb(): NodeMaterialConnectionPoint;
  141642. protected _buildBlock(state: NodeMaterialBuildState): this;
  141643. }
  141644. }
  141645. declare module BABYLON {
  141646. /**
  141647. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  141648. */
  141649. export class VectorSplitterBlock extends NodeMaterialBlock {
  141650. /**
  141651. * Create a new VectorSplitterBlock
  141652. * @param name defines the block name
  141653. */
  141654. constructor(name: string);
  141655. /**
  141656. * Gets the current class name
  141657. * @returns the class name
  141658. */
  141659. getClassName(): string;
  141660. /**
  141661. * Gets the xyzw component (input)
  141662. */
  141663. get xyzw(): NodeMaterialConnectionPoint;
  141664. /**
  141665. * Gets the xyz component (input)
  141666. */
  141667. get xyzIn(): NodeMaterialConnectionPoint;
  141668. /**
  141669. * Gets the xy component (input)
  141670. */
  141671. get xyIn(): NodeMaterialConnectionPoint;
  141672. /**
  141673. * Gets the xyz component (output)
  141674. */
  141675. get xyzOut(): NodeMaterialConnectionPoint;
  141676. /**
  141677. * Gets the xy component (output)
  141678. */
  141679. get xyOut(): NodeMaterialConnectionPoint;
  141680. /**
  141681. * Gets the x component (output)
  141682. */
  141683. get x(): NodeMaterialConnectionPoint;
  141684. /**
  141685. * Gets the y component (output)
  141686. */
  141687. get y(): NodeMaterialConnectionPoint;
  141688. /**
  141689. * Gets the z component (output)
  141690. */
  141691. get z(): NodeMaterialConnectionPoint;
  141692. /**
  141693. * Gets the w component (output)
  141694. */
  141695. get w(): NodeMaterialConnectionPoint;
  141696. protected _inputRename(name: string): string;
  141697. protected _outputRename(name: string): string;
  141698. protected _buildBlock(state: NodeMaterialBuildState): this;
  141699. }
  141700. }
  141701. declare module BABYLON {
  141702. /**
  141703. * Block used to lerp between 2 values
  141704. */
  141705. export class LerpBlock extends NodeMaterialBlock {
  141706. /**
  141707. * Creates a new LerpBlock
  141708. * @param name defines the block name
  141709. */
  141710. constructor(name: string);
  141711. /**
  141712. * Gets the current class name
  141713. * @returns the class name
  141714. */
  141715. getClassName(): string;
  141716. /**
  141717. * Gets the left operand input component
  141718. */
  141719. get left(): NodeMaterialConnectionPoint;
  141720. /**
  141721. * Gets the right operand input component
  141722. */
  141723. get right(): NodeMaterialConnectionPoint;
  141724. /**
  141725. * Gets the gradient operand input component
  141726. */
  141727. get gradient(): NodeMaterialConnectionPoint;
  141728. /**
  141729. * Gets the output component
  141730. */
  141731. get output(): NodeMaterialConnectionPoint;
  141732. protected _buildBlock(state: NodeMaterialBuildState): this;
  141733. }
  141734. }
  141735. declare module BABYLON {
  141736. /**
  141737. * Block used to divide 2 vectors
  141738. */
  141739. export class DivideBlock extends NodeMaterialBlock {
  141740. /**
  141741. * Creates a new DivideBlock
  141742. * @param name defines the block name
  141743. */
  141744. constructor(name: string);
  141745. /**
  141746. * Gets the current class name
  141747. * @returns the class name
  141748. */
  141749. getClassName(): string;
  141750. /**
  141751. * Gets the left operand input component
  141752. */
  141753. get left(): NodeMaterialConnectionPoint;
  141754. /**
  141755. * Gets the right operand input component
  141756. */
  141757. get right(): NodeMaterialConnectionPoint;
  141758. /**
  141759. * Gets the output component
  141760. */
  141761. get output(): NodeMaterialConnectionPoint;
  141762. protected _buildBlock(state: NodeMaterialBuildState): this;
  141763. }
  141764. }
  141765. declare module BABYLON {
  141766. /**
  141767. * Block used to subtract 2 vectors
  141768. */
  141769. export class SubtractBlock extends NodeMaterialBlock {
  141770. /**
  141771. * Creates a new SubtractBlock
  141772. * @param name defines the block name
  141773. */
  141774. constructor(name: string);
  141775. /**
  141776. * Gets the current class name
  141777. * @returns the class name
  141778. */
  141779. getClassName(): string;
  141780. /**
  141781. * Gets the left operand input component
  141782. */
  141783. get left(): NodeMaterialConnectionPoint;
  141784. /**
  141785. * Gets the right operand input component
  141786. */
  141787. get right(): NodeMaterialConnectionPoint;
  141788. /**
  141789. * Gets the output component
  141790. */
  141791. get output(): NodeMaterialConnectionPoint;
  141792. protected _buildBlock(state: NodeMaterialBuildState): this;
  141793. }
  141794. }
  141795. declare module BABYLON {
  141796. /**
  141797. * Block used to step a value
  141798. */
  141799. export class StepBlock extends NodeMaterialBlock {
  141800. /**
  141801. * Creates a new StepBlock
  141802. * @param name defines the block name
  141803. */
  141804. constructor(name: string);
  141805. /**
  141806. * Gets the current class name
  141807. * @returns the class name
  141808. */
  141809. getClassName(): string;
  141810. /**
  141811. * Gets the value operand input component
  141812. */
  141813. get value(): NodeMaterialConnectionPoint;
  141814. /**
  141815. * Gets the edge operand input component
  141816. */
  141817. get edge(): NodeMaterialConnectionPoint;
  141818. /**
  141819. * Gets the output component
  141820. */
  141821. get output(): NodeMaterialConnectionPoint;
  141822. protected _buildBlock(state: NodeMaterialBuildState): this;
  141823. }
  141824. }
  141825. declare module BABYLON {
  141826. /**
  141827. * Block used to get the opposite (1 - x) of a value
  141828. */
  141829. export class OneMinusBlock extends NodeMaterialBlock {
  141830. /**
  141831. * Creates a new OneMinusBlock
  141832. * @param name defines the block name
  141833. */
  141834. constructor(name: string);
  141835. /**
  141836. * Gets the current class name
  141837. * @returns the class name
  141838. */
  141839. getClassName(): string;
  141840. /**
  141841. * Gets the input component
  141842. */
  141843. get input(): NodeMaterialConnectionPoint;
  141844. /**
  141845. * Gets the output component
  141846. */
  141847. get output(): NodeMaterialConnectionPoint;
  141848. protected _buildBlock(state: NodeMaterialBuildState): this;
  141849. }
  141850. }
  141851. declare module BABYLON {
  141852. /**
  141853. * Block used to get the view direction
  141854. */
  141855. export class ViewDirectionBlock extends NodeMaterialBlock {
  141856. /**
  141857. * Creates a new ViewDirectionBlock
  141858. * @param name defines the block name
  141859. */
  141860. constructor(name: string);
  141861. /**
  141862. * Gets the current class name
  141863. * @returns the class name
  141864. */
  141865. getClassName(): string;
  141866. /**
  141867. * Gets the world position component
  141868. */
  141869. get worldPosition(): NodeMaterialConnectionPoint;
  141870. /**
  141871. * Gets the camera position component
  141872. */
  141873. get cameraPosition(): NodeMaterialConnectionPoint;
  141874. /**
  141875. * Gets the output component
  141876. */
  141877. get output(): NodeMaterialConnectionPoint;
  141878. autoConfigure(material: NodeMaterial): void;
  141879. protected _buildBlock(state: NodeMaterialBuildState): this;
  141880. }
  141881. }
  141882. declare module BABYLON {
  141883. /**
  141884. * Block used to compute fresnel value
  141885. */
  141886. export class FresnelBlock extends NodeMaterialBlock {
  141887. /**
  141888. * Create a new FresnelBlock
  141889. * @param name defines the block name
  141890. */
  141891. constructor(name: string);
  141892. /**
  141893. * Gets the current class name
  141894. * @returns the class name
  141895. */
  141896. getClassName(): string;
  141897. /**
  141898. * Gets the world normal input component
  141899. */
  141900. get worldNormal(): NodeMaterialConnectionPoint;
  141901. /**
  141902. * Gets the view direction input component
  141903. */
  141904. get viewDirection(): NodeMaterialConnectionPoint;
  141905. /**
  141906. * Gets the bias input component
  141907. */
  141908. get bias(): NodeMaterialConnectionPoint;
  141909. /**
  141910. * Gets the camera (or eye) position component
  141911. */
  141912. get power(): NodeMaterialConnectionPoint;
  141913. /**
  141914. * Gets the fresnel output component
  141915. */
  141916. get fresnel(): NodeMaterialConnectionPoint;
  141917. autoConfigure(material: NodeMaterial): void;
  141918. protected _buildBlock(state: NodeMaterialBuildState): this;
  141919. }
  141920. }
  141921. declare module BABYLON {
  141922. /**
  141923. * Block used to get the max of 2 values
  141924. */
  141925. export class MaxBlock extends NodeMaterialBlock {
  141926. /**
  141927. * Creates a new MaxBlock
  141928. * @param name defines the block name
  141929. */
  141930. constructor(name: string);
  141931. /**
  141932. * Gets the current class name
  141933. * @returns the class name
  141934. */
  141935. getClassName(): string;
  141936. /**
  141937. * Gets the left operand input component
  141938. */
  141939. get left(): NodeMaterialConnectionPoint;
  141940. /**
  141941. * Gets the right operand input component
  141942. */
  141943. get right(): NodeMaterialConnectionPoint;
  141944. /**
  141945. * Gets the output component
  141946. */
  141947. get output(): NodeMaterialConnectionPoint;
  141948. protected _buildBlock(state: NodeMaterialBuildState): this;
  141949. }
  141950. }
  141951. declare module BABYLON {
  141952. /**
  141953. * Block used to get the min of 2 values
  141954. */
  141955. export class MinBlock extends NodeMaterialBlock {
  141956. /**
  141957. * Creates a new MinBlock
  141958. * @param name defines the block name
  141959. */
  141960. constructor(name: string);
  141961. /**
  141962. * Gets the current class name
  141963. * @returns the class name
  141964. */
  141965. getClassName(): string;
  141966. /**
  141967. * Gets the left operand input component
  141968. */
  141969. get left(): NodeMaterialConnectionPoint;
  141970. /**
  141971. * Gets the right operand input component
  141972. */
  141973. get right(): NodeMaterialConnectionPoint;
  141974. /**
  141975. * Gets the output component
  141976. */
  141977. get output(): NodeMaterialConnectionPoint;
  141978. protected _buildBlock(state: NodeMaterialBuildState): this;
  141979. }
  141980. }
  141981. declare module BABYLON {
  141982. /**
  141983. * Block used to get the distance between 2 values
  141984. */
  141985. export class DistanceBlock extends NodeMaterialBlock {
  141986. /**
  141987. * Creates a new DistanceBlock
  141988. * @param name defines the block name
  141989. */
  141990. constructor(name: string);
  141991. /**
  141992. * Gets the current class name
  141993. * @returns the class name
  141994. */
  141995. getClassName(): string;
  141996. /**
  141997. * Gets the left operand input component
  141998. */
  141999. get left(): NodeMaterialConnectionPoint;
  142000. /**
  142001. * Gets the right operand input component
  142002. */
  142003. get right(): NodeMaterialConnectionPoint;
  142004. /**
  142005. * Gets the output component
  142006. */
  142007. get output(): NodeMaterialConnectionPoint;
  142008. protected _buildBlock(state: NodeMaterialBuildState): this;
  142009. }
  142010. }
  142011. declare module BABYLON {
  142012. /**
  142013. * Block used to get the length of a vector
  142014. */
  142015. export class LengthBlock extends NodeMaterialBlock {
  142016. /**
  142017. * Creates a new LengthBlock
  142018. * @param name defines the block name
  142019. */
  142020. constructor(name: string);
  142021. /**
  142022. * Gets the current class name
  142023. * @returns the class name
  142024. */
  142025. getClassName(): string;
  142026. /**
  142027. * Gets the value input component
  142028. */
  142029. get value(): NodeMaterialConnectionPoint;
  142030. /**
  142031. * Gets the output component
  142032. */
  142033. get output(): NodeMaterialConnectionPoint;
  142034. protected _buildBlock(state: NodeMaterialBuildState): this;
  142035. }
  142036. }
  142037. declare module BABYLON {
  142038. /**
  142039. * Block used to get negative version of a value (i.e. x * -1)
  142040. */
  142041. export class NegateBlock extends NodeMaterialBlock {
  142042. /**
  142043. * Creates a new NegateBlock
  142044. * @param name defines the block name
  142045. */
  142046. constructor(name: string);
  142047. /**
  142048. * Gets the current class name
  142049. * @returns the class name
  142050. */
  142051. getClassName(): string;
  142052. /**
  142053. * Gets the value input component
  142054. */
  142055. get value(): NodeMaterialConnectionPoint;
  142056. /**
  142057. * Gets the output component
  142058. */
  142059. get output(): NodeMaterialConnectionPoint;
  142060. protected _buildBlock(state: NodeMaterialBuildState): this;
  142061. }
  142062. }
  142063. declare module BABYLON {
  142064. /**
  142065. * Block used to get the value of the first parameter raised to the power of the second
  142066. */
  142067. export class PowBlock extends NodeMaterialBlock {
  142068. /**
  142069. * Creates a new PowBlock
  142070. * @param name defines the block name
  142071. */
  142072. constructor(name: string);
  142073. /**
  142074. * Gets the current class name
  142075. * @returns the class name
  142076. */
  142077. getClassName(): string;
  142078. /**
  142079. * Gets the value operand input component
  142080. */
  142081. get value(): NodeMaterialConnectionPoint;
  142082. /**
  142083. * Gets the power operand input component
  142084. */
  142085. get power(): NodeMaterialConnectionPoint;
  142086. /**
  142087. * Gets the output component
  142088. */
  142089. get output(): NodeMaterialConnectionPoint;
  142090. protected _buildBlock(state: NodeMaterialBuildState): this;
  142091. }
  142092. }
  142093. declare module BABYLON {
  142094. /**
  142095. * Block used to get a random number
  142096. */
  142097. export class RandomNumberBlock extends NodeMaterialBlock {
  142098. /**
  142099. * Creates a new RandomNumberBlock
  142100. * @param name defines the block name
  142101. */
  142102. constructor(name: string);
  142103. /**
  142104. * Gets the current class name
  142105. * @returns the class name
  142106. */
  142107. getClassName(): string;
  142108. /**
  142109. * Gets the seed input component
  142110. */
  142111. get seed(): NodeMaterialConnectionPoint;
  142112. /**
  142113. * Gets the output component
  142114. */
  142115. get output(): NodeMaterialConnectionPoint;
  142116. protected _buildBlock(state: NodeMaterialBuildState): this;
  142117. }
  142118. }
  142119. declare module BABYLON {
  142120. /**
  142121. * Block used to compute arc tangent of 2 values
  142122. */
  142123. export class ArcTan2Block extends NodeMaterialBlock {
  142124. /**
  142125. * Creates a new ArcTan2Block
  142126. * @param name defines the block name
  142127. */
  142128. constructor(name: string);
  142129. /**
  142130. * Gets the current class name
  142131. * @returns the class name
  142132. */
  142133. getClassName(): string;
  142134. /**
  142135. * Gets the x operand input component
  142136. */
  142137. get x(): NodeMaterialConnectionPoint;
  142138. /**
  142139. * Gets the y operand input component
  142140. */
  142141. get y(): NodeMaterialConnectionPoint;
  142142. /**
  142143. * Gets the output component
  142144. */
  142145. get output(): NodeMaterialConnectionPoint;
  142146. protected _buildBlock(state: NodeMaterialBuildState): this;
  142147. }
  142148. }
  142149. declare module BABYLON {
  142150. /**
  142151. * Block used to smooth step a value
  142152. */
  142153. export class SmoothStepBlock extends NodeMaterialBlock {
  142154. /**
  142155. * Creates a new SmoothStepBlock
  142156. * @param name defines the block name
  142157. */
  142158. constructor(name: string);
  142159. /**
  142160. * Gets the current class name
  142161. * @returns the class name
  142162. */
  142163. getClassName(): string;
  142164. /**
  142165. * Gets the value operand input component
  142166. */
  142167. get value(): NodeMaterialConnectionPoint;
  142168. /**
  142169. * Gets the first edge operand input component
  142170. */
  142171. get edge0(): NodeMaterialConnectionPoint;
  142172. /**
  142173. * Gets the second edge operand input component
  142174. */
  142175. get edge1(): NodeMaterialConnectionPoint;
  142176. /**
  142177. * Gets the output component
  142178. */
  142179. get output(): NodeMaterialConnectionPoint;
  142180. protected _buildBlock(state: NodeMaterialBuildState): this;
  142181. }
  142182. }
  142183. declare module BABYLON {
  142184. /**
  142185. * Block used to get the reciprocal (1 / x) of a value
  142186. */
  142187. export class ReciprocalBlock extends NodeMaterialBlock {
  142188. /**
  142189. * Creates a new ReciprocalBlock
  142190. * @param name defines the block name
  142191. */
  142192. constructor(name: string);
  142193. /**
  142194. * Gets the current class name
  142195. * @returns the class name
  142196. */
  142197. getClassName(): string;
  142198. /**
  142199. * Gets the input component
  142200. */
  142201. get input(): NodeMaterialConnectionPoint;
  142202. /**
  142203. * Gets the output component
  142204. */
  142205. get output(): NodeMaterialConnectionPoint;
  142206. protected _buildBlock(state: NodeMaterialBuildState): this;
  142207. }
  142208. }
  142209. declare module BABYLON {
  142210. /**
  142211. * Block used to replace a color by another one
  142212. */
  142213. export class ReplaceColorBlock extends NodeMaterialBlock {
  142214. /**
  142215. * Creates a new ReplaceColorBlock
  142216. * @param name defines the block name
  142217. */
  142218. constructor(name: string);
  142219. /**
  142220. * Gets the current class name
  142221. * @returns the class name
  142222. */
  142223. getClassName(): string;
  142224. /**
  142225. * Gets the value input component
  142226. */
  142227. get value(): NodeMaterialConnectionPoint;
  142228. /**
  142229. * Gets the reference input component
  142230. */
  142231. get reference(): NodeMaterialConnectionPoint;
  142232. /**
  142233. * Gets the distance input component
  142234. */
  142235. get distance(): NodeMaterialConnectionPoint;
  142236. /**
  142237. * Gets the replacement input component
  142238. */
  142239. get replacement(): NodeMaterialConnectionPoint;
  142240. /**
  142241. * Gets the output component
  142242. */
  142243. get output(): NodeMaterialConnectionPoint;
  142244. protected _buildBlock(state: NodeMaterialBuildState): this;
  142245. }
  142246. }
  142247. declare module BABYLON {
  142248. /**
  142249. * Block used to posterize a value
  142250. * @see https://en.wikipedia.org/wiki/Posterization
  142251. */
  142252. export class PosterizeBlock extends NodeMaterialBlock {
  142253. /**
  142254. * Creates a new PosterizeBlock
  142255. * @param name defines the block name
  142256. */
  142257. constructor(name: string);
  142258. /**
  142259. * Gets the current class name
  142260. * @returns the class name
  142261. */
  142262. getClassName(): string;
  142263. /**
  142264. * Gets the value input component
  142265. */
  142266. get value(): NodeMaterialConnectionPoint;
  142267. /**
  142268. * Gets the steps input component
  142269. */
  142270. get steps(): NodeMaterialConnectionPoint;
  142271. /**
  142272. * Gets the output component
  142273. */
  142274. get output(): NodeMaterialConnectionPoint;
  142275. protected _buildBlock(state: NodeMaterialBuildState): this;
  142276. }
  142277. }
  142278. declare module BABYLON {
  142279. /**
  142280. * Operations supported by the Wave block
  142281. */
  142282. export enum WaveBlockKind {
  142283. /** SawTooth */
  142284. SawTooth = 0,
  142285. /** Square */
  142286. Square = 1,
  142287. /** Triangle */
  142288. Triangle = 2
  142289. }
  142290. /**
  142291. * Block used to apply wave operation to floats
  142292. */
  142293. export class WaveBlock extends NodeMaterialBlock {
  142294. /**
  142295. * Gets or sets the kibnd of wave to be applied by the block
  142296. */
  142297. kind: WaveBlockKind;
  142298. /**
  142299. * Creates a new WaveBlock
  142300. * @param name defines the block name
  142301. */
  142302. constructor(name: string);
  142303. /**
  142304. * Gets the current class name
  142305. * @returns the class name
  142306. */
  142307. getClassName(): string;
  142308. /**
  142309. * Gets the input component
  142310. */
  142311. get input(): NodeMaterialConnectionPoint;
  142312. /**
  142313. * Gets the output component
  142314. */
  142315. get output(): NodeMaterialConnectionPoint;
  142316. protected _buildBlock(state: NodeMaterialBuildState): this;
  142317. serialize(): any;
  142318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142319. }
  142320. }
  142321. declare module BABYLON {
  142322. /**
  142323. * Class used to store a color step for the GradientBlock
  142324. */
  142325. export class GradientBlockColorStep {
  142326. /**
  142327. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142328. */
  142329. step: number;
  142330. /**
  142331. * Gets or sets the color associated with this step
  142332. */
  142333. color: Color3;
  142334. /**
  142335. * Creates a new GradientBlockColorStep
  142336. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  142337. * @param color defines the color associated with this step
  142338. */
  142339. constructor(
  142340. /**
  142341. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142342. */
  142343. step: number,
  142344. /**
  142345. * Gets or sets the color associated with this step
  142346. */
  142347. color: Color3);
  142348. }
  142349. /**
  142350. * Block used to return a color from a gradient based on an input value between 0 and 1
  142351. */
  142352. export class GradientBlock extends NodeMaterialBlock {
  142353. /**
  142354. * Gets or sets the list of color steps
  142355. */
  142356. colorSteps: GradientBlockColorStep[];
  142357. /**
  142358. * Creates a new GradientBlock
  142359. * @param name defines the block name
  142360. */
  142361. constructor(name: string);
  142362. /**
  142363. * Gets the current class name
  142364. * @returns the class name
  142365. */
  142366. getClassName(): string;
  142367. /**
  142368. * Gets the gradient input component
  142369. */
  142370. get gradient(): NodeMaterialConnectionPoint;
  142371. /**
  142372. * Gets the output component
  142373. */
  142374. get output(): NodeMaterialConnectionPoint;
  142375. private _writeColorConstant;
  142376. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142377. serialize(): any;
  142378. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142379. protected _dumpPropertiesCode(): string;
  142380. }
  142381. }
  142382. declare module BABYLON {
  142383. /**
  142384. * Block used to normalize lerp between 2 values
  142385. */
  142386. export class NLerpBlock extends NodeMaterialBlock {
  142387. /**
  142388. * Creates a new NLerpBlock
  142389. * @param name defines the block name
  142390. */
  142391. constructor(name: string);
  142392. /**
  142393. * Gets the current class name
  142394. * @returns the class name
  142395. */
  142396. getClassName(): string;
  142397. /**
  142398. * Gets the left operand input component
  142399. */
  142400. get left(): NodeMaterialConnectionPoint;
  142401. /**
  142402. * Gets the right operand input component
  142403. */
  142404. get right(): NodeMaterialConnectionPoint;
  142405. /**
  142406. * Gets the gradient operand input component
  142407. */
  142408. get gradient(): NodeMaterialConnectionPoint;
  142409. /**
  142410. * Gets the output component
  142411. */
  142412. get output(): NodeMaterialConnectionPoint;
  142413. protected _buildBlock(state: NodeMaterialBuildState): this;
  142414. }
  142415. }
  142416. declare module BABYLON {
  142417. /**
  142418. * block used to Generate a Worley Noise 3D Noise Pattern
  142419. */
  142420. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  142421. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142422. manhattanDistance: boolean;
  142423. /**
  142424. * Creates a new WorleyNoise3DBlock
  142425. * @param name defines the block name
  142426. */
  142427. constructor(name: string);
  142428. /**
  142429. * Gets the current class name
  142430. * @returns the class name
  142431. */
  142432. getClassName(): string;
  142433. /**
  142434. * Gets the seed input component
  142435. */
  142436. get seed(): NodeMaterialConnectionPoint;
  142437. /**
  142438. * Gets the jitter input component
  142439. */
  142440. get jitter(): NodeMaterialConnectionPoint;
  142441. /**
  142442. * Gets the output component
  142443. */
  142444. get output(): NodeMaterialConnectionPoint;
  142445. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142446. /**
  142447. * Exposes the properties to the UI?
  142448. */
  142449. protected _dumpPropertiesCode(): string;
  142450. /**
  142451. * Exposes the properties to the Seralize?
  142452. */
  142453. serialize(): any;
  142454. /**
  142455. * Exposes the properties to the deseralize?
  142456. */
  142457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142458. }
  142459. }
  142460. declare module BABYLON {
  142461. /**
  142462. * block used to Generate a Simplex Perlin 3d Noise Pattern
  142463. */
  142464. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  142465. /**
  142466. * Creates a new SimplexPerlin3DBlock
  142467. * @param name defines the block name
  142468. */
  142469. constructor(name: string);
  142470. /**
  142471. * Gets the current class name
  142472. * @returns the class name
  142473. */
  142474. getClassName(): string;
  142475. /**
  142476. * Gets the seed operand input component
  142477. */
  142478. get seed(): NodeMaterialConnectionPoint;
  142479. /**
  142480. * Gets the output component
  142481. */
  142482. get output(): NodeMaterialConnectionPoint;
  142483. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142484. }
  142485. }
  142486. declare module BABYLON {
  142487. /**
  142488. * Block used to blend normals
  142489. */
  142490. export class NormalBlendBlock extends NodeMaterialBlock {
  142491. /**
  142492. * Creates a new NormalBlendBlock
  142493. * @param name defines the block name
  142494. */
  142495. constructor(name: string);
  142496. /**
  142497. * Gets the current class name
  142498. * @returns the class name
  142499. */
  142500. getClassName(): string;
  142501. /**
  142502. * Gets the first input component
  142503. */
  142504. get normalMap0(): NodeMaterialConnectionPoint;
  142505. /**
  142506. * Gets the second input component
  142507. */
  142508. get normalMap1(): NodeMaterialConnectionPoint;
  142509. /**
  142510. * Gets the output component
  142511. */
  142512. get output(): NodeMaterialConnectionPoint;
  142513. protected _buildBlock(state: NodeMaterialBuildState): this;
  142514. }
  142515. }
  142516. declare module BABYLON {
  142517. /**
  142518. * Block used to rotate a 2d vector by a given angle
  142519. */
  142520. export class Rotate2dBlock extends NodeMaterialBlock {
  142521. /**
  142522. * Creates a new Rotate2dBlock
  142523. * @param name defines the block name
  142524. */
  142525. constructor(name: string);
  142526. /**
  142527. * Gets the current class name
  142528. * @returns the class name
  142529. */
  142530. getClassName(): string;
  142531. /**
  142532. * Gets the input vector
  142533. */
  142534. get input(): NodeMaterialConnectionPoint;
  142535. /**
  142536. * Gets the input angle
  142537. */
  142538. get angle(): NodeMaterialConnectionPoint;
  142539. /**
  142540. * Gets the output component
  142541. */
  142542. get output(): NodeMaterialConnectionPoint;
  142543. autoConfigure(material: NodeMaterial): void;
  142544. protected _buildBlock(state: NodeMaterialBuildState): this;
  142545. }
  142546. }
  142547. declare module BABYLON {
  142548. /**
  142549. * Block used to get the reflected vector from a direction and a normal
  142550. */
  142551. export class ReflectBlock extends NodeMaterialBlock {
  142552. /**
  142553. * Creates a new ReflectBlock
  142554. * @param name defines the block name
  142555. */
  142556. constructor(name: string);
  142557. /**
  142558. * Gets the current class name
  142559. * @returns the class name
  142560. */
  142561. getClassName(): string;
  142562. /**
  142563. * Gets the incident component
  142564. */
  142565. get incident(): NodeMaterialConnectionPoint;
  142566. /**
  142567. * Gets the normal component
  142568. */
  142569. get normal(): NodeMaterialConnectionPoint;
  142570. /**
  142571. * Gets the output component
  142572. */
  142573. get output(): NodeMaterialConnectionPoint;
  142574. protected _buildBlock(state: NodeMaterialBuildState): this;
  142575. }
  142576. }
  142577. declare module BABYLON {
  142578. /**
  142579. * Block used to get the refracted vector from a direction and a normal
  142580. */
  142581. export class RefractBlock extends NodeMaterialBlock {
  142582. /**
  142583. * Creates a new RefractBlock
  142584. * @param name defines the block name
  142585. */
  142586. constructor(name: string);
  142587. /**
  142588. * Gets the current class name
  142589. * @returns the class name
  142590. */
  142591. getClassName(): string;
  142592. /**
  142593. * Gets the incident component
  142594. */
  142595. get incident(): NodeMaterialConnectionPoint;
  142596. /**
  142597. * Gets the normal component
  142598. */
  142599. get normal(): NodeMaterialConnectionPoint;
  142600. /**
  142601. * Gets the index of refraction component
  142602. */
  142603. get ior(): NodeMaterialConnectionPoint;
  142604. /**
  142605. * Gets the output component
  142606. */
  142607. get output(): NodeMaterialConnectionPoint;
  142608. protected _buildBlock(state: NodeMaterialBuildState): this;
  142609. }
  142610. }
  142611. declare module BABYLON {
  142612. /**
  142613. * Block used to desaturate a color
  142614. */
  142615. export class DesaturateBlock extends NodeMaterialBlock {
  142616. /**
  142617. * Creates a new DesaturateBlock
  142618. * @param name defines the block name
  142619. */
  142620. constructor(name: string);
  142621. /**
  142622. * Gets the current class name
  142623. * @returns the class name
  142624. */
  142625. getClassName(): string;
  142626. /**
  142627. * Gets the color operand input component
  142628. */
  142629. get color(): NodeMaterialConnectionPoint;
  142630. /**
  142631. * Gets the level operand input component
  142632. */
  142633. get level(): NodeMaterialConnectionPoint;
  142634. /**
  142635. * Gets the output component
  142636. */
  142637. get output(): NodeMaterialConnectionPoint;
  142638. protected _buildBlock(state: NodeMaterialBuildState): this;
  142639. }
  142640. }
  142641. declare module BABYLON {
  142642. /**
  142643. * Block used to implement the ambient occlusion module of the PBR material
  142644. */
  142645. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  142646. /**
  142647. * Create a new AmbientOcclusionBlock
  142648. * @param name defines the block name
  142649. */
  142650. constructor(name: string);
  142651. /**
  142652. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  142653. */
  142654. useAmbientInGrayScale: boolean;
  142655. /**
  142656. * Initialize the block and prepare the context for build
  142657. * @param state defines the state that will be used for the build
  142658. */
  142659. initialize(state: NodeMaterialBuildState): void;
  142660. /**
  142661. * Gets the current class name
  142662. * @returns the class name
  142663. */
  142664. getClassName(): string;
  142665. /**
  142666. * Gets the texture input component
  142667. */
  142668. get texture(): NodeMaterialConnectionPoint;
  142669. /**
  142670. * Gets the texture intensity component
  142671. */
  142672. get intensity(): NodeMaterialConnectionPoint;
  142673. /**
  142674. * Gets the direct light intensity input component
  142675. */
  142676. get directLightIntensity(): NodeMaterialConnectionPoint;
  142677. /**
  142678. * Gets the ambient occlusion object output component
  142679. */
  142680. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142681. /**
  142682. * Gets the main code of the block (fragment side)
  142683. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  142684. * @returns the shader code
  142685. */
  142686. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  142687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142688. protected _buildBlock(state: NodeMaterialBuildState): this;
  142689. protected _dumpPropertiesCode(): string;
  142690. serialize(): any;
  142691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142692. }
  142693. }
  142694. declare module BABYLON {
  142695. /**
  142696. * Block used to implement the reflection module of the PBR material
  142697. */
  142698. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  142699. /** @hidden */
  142700. _defineLODReflectionAlpha: string;
  142701. /** @hidden */
  142702. _defineLinearSpecularReflection: string;
  142703. private _vEnvironmentIrradianceName;
  142704. /** @hidden */
  142705. _vReflectionMicrosurfaceInfosName: string;
  142706. /** @hidden */
  142707. _vReflectionInfosName: string;
  142708. /** @hidden */
  142709. _vReflectionFilteringInfoName: string;
  142710. private _scene;
  142711. /**
  142712. * The three properties below are set by the main PBR block prior to calling methods of this class.
  142713. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142714. * It's less burden on the user side in the editor part.
  142715. */
  142716. /** @hidden */
  142717. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142718. /** @hidden */
  142719. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142720. /** @hidden */
  142721. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  142722. /**
  142723. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  142724. * diffuse part of the IBL.
  142725. */
  142726. useSphericalHarmonics: boolean;
  142727. /**
  142728. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  142729. */
  142730. forceIrradianceInFragment: boolean;
  142731. /**
  142732. * Create a new ReflectionBlock
  142733. * @param name defines the block name
  142734. */
  142735. constructor(name: string);
  142736. /**
  142737. * Gets the current class name
  142738. * @returns the class name
  142739. */
  142740. getClassName(): string;
  142741. /**
  142742. * Gets the position input component
  142743. */
  142744. get position(): NodeMaterialConnectionPoint;
  142745. /**
  142746. * Gets the world position input component
  142747. */
  142748. get worldPosition(): NodeMaterialConnectionPoint;
  142749. /**
  142750. * Gets the world normal input component
  142751. */
  142752. get worldNormal(): NodeMaterialConnectionPoint;
  142753. /**
  142754. * Gets the world input component
  142755. */
  142756. get world(): NodeMaterialConnectionPoint;
  142757. /**
  142758. * Gets the camera (or eye) position component
  142759. */
  142760. get cameraPosition(): NodeMaterialConnectionPoint;
  142761. /**
  142762. * Gets the view input component
  142763. */
  142764. get view(): NodeMaterialConnectionPoint;
  142765. /**
  142766. * Gets the color input component
  142767. */
  142768. get color(): NodeMaterialConnectionPoint;
  142769. /**
  142770. * Gets the reflection object output component
  142771. */
  142772. get reflection(): NodeMaterialConnectionPoint;
  142773. /**
  142774. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  142775. */
  142776. get hasTexture(): boolean;
  142777. /**
  142778. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  142779. */
  142780. get reflectionColor(): string;
  142781. protected _getTexture(): Nullable<BaseTexture>;
  142782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142784. /**
  142785. * Gets the code to inject in the vertex shader
  142786. * @param state current state of the node material building
  142787. * @returns the shader code
  142788. */
  142789. handleVertexSide(state: NodeMaterialBuildState): string;
  142790. /**
  142791. * Gets the main code of the block (fragment side)
  142792. * @param state current state of the node material building
  142793. * @param normalVarName name of the existing variable corresponding to the normal
  142794. * @returns the shader code
  142795. */
  142796. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  142797. protected _buildBlock(state: NodeMaterialBuildState): this;
  142798. protected _dumpPropertiesCode(): string;
  142799. serialize(): any;
  142800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142801. }
  142802. }
  142803. declare module BABYLON {
  142804. /**
  142805. * Block used to implement the sheen module of the PBR material
  142806. */
  142807. export class SheenBlock extends NodeMaterialBlock {
  142808. /**
  142809. * Create a new SheenBlock
  142810. * @param name defines the block name
  142811. */
  142812. constructor(name: string);
  142813. /**
  142814. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  142815. * It allows the strength of the sheen effect to not depend on the base color of the material,
  142816. * making it easier to setup and tweak the effect
  142817. */
  142818. albedoScaling: boolean;
  142819. /**
  142820. * Defines if the sheen is linked to the sheen color.
  142821. */
  142822. linkSheenWithAlbedo: boolean;
  142823. /**
  142824. * Initialize the block and prepare the context for build
  142825. * @param state defines the state that will be used for the build
  142826. */
  142827. initialize(state: NodeMaterialBuildState): void;
  142828. /**
  142829. * Gets the current class name
  142830. * @returns the class name
  142831. */
  142832. getClassName(): string;
  142833. /**
  142834. * Gets the intensity input component
  142835. */
  142836. get intensity(): NodeMaterialConnectionPoint;
  142837. /**
  142838. * Gets the color input component
  142839. */
  142840. get color(): NodeMaterialConnectionPoint;
  142841. /**
  142842. * Gets the roughness input component
  142843. */
  142844. get roughness(): NodeMaterialConnectionPoint;
  142845. /**
  142846. * Gets the sheen object output component
  142847. */
  142848. get sheen(): NodeMaterialConnectionPoint;
  142849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142850. /**
  142851. * Gets the main code of the block (fragment side)
  142852. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142853. * @returns the shader code
  142854. */
  142855. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  142856. protected _buildBlock(state: NodeMaterialBuildState): this;
  142857. protected _dumpPropertiesCode(): string;
  142858. serialize(): any;
  142859. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142860. }
  142861. }
  142862. declare module BABYLON {
  142863. /**
  142864. * Block used to implement the reflectivity module of the PBR material
  142865. */
  142866. export class ReflectivityBlock extends NodeMaterialBlock {
  142867. private _metallicReflectanceColor;
  142868. private _metallicF0Factor;
  142869. /** @hidden */
  142870. _vMetallicReflectanceFactorsName: string;
  142871. /**
  142872. * The property below is set by the main PBR block prior to calling methods of this class.
  142873. */
  142874. /** @hidden */
  142875. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  142876. /**
  142877. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  142878. */
  142879. useAmbientOcclusionFromMetallicTextureRed: boolean;
  142880. /**
  142881. * Specifies if the metallic texture contains the metallness information in its blue channel.
  142882. */
  142883. useMetallnessFromMetallicTextureBlue: boolean;
  142884. /**
  142885. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  142886. */
  142887. useRoughnessFromMetallicTextureAlpha: boolean;
  142888. /**
  142889. * Specifies if the metallic texture contains the roughness information in its green channel.
  142890. */
  142891. useRoughnessFromMetallicTextureGreen: boolean;
  142892. /**
  142893. * Create a new ReflectivityBlock
  142894. * @param name defines the block name
  142895. */
  142896. constructor(name: string);
  142897. /**
  142898. * Initialize the block and prepare the context for build
  142899. * @param state defines the state that will be used for the build
  142900. */
  142901. initialize(state: NodeMaterialBuildState): void;
  142902. /**
  142903. * Gets the current class name
  142904. * @returns the class name
  142905. */
  142906. getClassName(): string;
  142907. /**
  142908. * Gets the metallic input component
  142909. */
  142910. get metallic(): NodeMaterialConnectionPoint;
  142911. /**
  142912. * Gets the roughness input component
  142913. */
  142914. get roughness(): NodeMaterialConnectionPoint;
  142915. /**
  142916. * Gets the texture input component
  142917. */
  142918. get texture(): NodeMaterialConnectionPoint;
  142919. /**
  142920. * Gets the reflectivity object output component
  142921. */
  142922. get reflectivity(): NodeMaterialConnectionPoint;
  142923. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142924. /**
  142925. * Gets the main code of the block (fragment side)
  142926. * @param state current state of the node material building
  142927. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  142928. * @returns the shader code
  142929. */
  142930. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  142931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142932. protected _buildBlock(state: NodeMaterialBuildState): this;
  142933. protected _dumpPropertiesCode(): string;
  142934. serialize(): any;
  142935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142936. }
  142937. }
  142938. declare module BABYLON {
  142939. /**
  142940. * Block used to implement the anisotropy module of the PBR material
  142941. */
  142942. export class AnisotropyBlock extends NodeMaterialBlock {
  142943. /**
  142944. * The two properties below are set by the main PBR block prior to calling methods of this class.
  142945. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142946. * It's less burden on the user side in the editor part.
  142947. */
  142948. /** @hidden */
  142949. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142950. /** @hidden */
  142951. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142952. /**
  142953. * Create a new AnisotropyBlock
  142954. * @param name defines the block name
  142955. */
  142956. constructor(name: string);
  142957. /**
  142958. * Initialize the block and prepare the context for build
  142959. * @param state defines the state that will be used for the build
  142960. */
  142961. initialize(state: NodeMaterialBuildState): void;
  142962. /**
  142963. * Gets the current class name
  142964. * @returns the class name
  142965. */
  142966. getClassName(): string;
  142967. /**
  142968. * Gets the intensity input component
  142969. */
  142970. get intensity(): NodeMaterialConnectionPoint;
  142971. /**
  142972. * Gets the direction input component
  142973. */
  142974. get direction(): NodeMaterialConnectionPoint;
  142975. /**
  142976. * Gets the texture input component
  142977. */
  142978. get texture(): NodeMaterialConnectionPoint;
  142979. /**
  142980. * Gets the uv input component
  142981. */
  142982. get uv(): NodeMaterialConnectionPoint;
  142983. /**
  142984. * Gets the worldTangent input component
  142985. */
  142986. get worldTangent(): NodeMaterialConnectionPoint;
  142987. /**
  142988. * Gets the anisotropy object output component
  142989. */
  142990. get anisotropy(): NodeMaterialConnectionPoint;
  142991. private _generateTBNSpace;
  142992. /**
  142993. * Gets the main code of the block (fragment side)
  142994. * @param state current state of the node material building
  142995. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  142996. * @returns the shader code
  142997. */
  142998. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  142999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143000. protected _buildBlock(state: NodeMaterialBuildState): this;
  143001. }
  143002. }
  143003. declare module BABYLON {
  143004. /**
  143005. * Block used to implement the clear coat module of the PBR material
  143006. */
  143007. export class ClearCoatBlock extends NodeMaterialBlock {
  143008. private _scene;
  143009. /**
  143010. * Create a new ClearCoatBlock
  143011. * @param name defines the block name
  143012. */
  143013. constructor(name: string);
  143014. /**
  143015. * Initialize the block and prepare the context for build
  143016. * @param state defines the state that will be used for the build
  143017. */
  143018. initialize(state: NodeMaterialBuildState): void;
  143019. /**
  143020. * Gets the current class name
  143021. * @returns the class name
  143022. */
  143023. getClassName(): string;
  143024. /**
  143025. * Gets the intensity input component
  143026. */
  143027. get intensity(): NodeMaterialConnectionPoint;
  143028. /**
  143029. * Gets the roughness input component
  143030. */
  143031. get roughness(): NodeMaterialConnectionPoint;
  143032. /**
  143033. * Gets the ior input component
  143034. */
  143035. get ior(): NodeMaterialConnectionPoint;
  143036. /**
  143037. * Gets the texture input component
  143038. */
  143039. get texture(): NodeMaterialConnectionPoint;
  143040. /**
  143041. * Gets the bump texture input component
  143042. */
  143043. get bumpTexture(): NodeMaterialConnectionPoint;
  143044. /**
  143045. * Gets the uv input component
  143046. */
  143047. get uv(): NodeMaterialConnectionPoint;
  143048. /**
  143049. * Gets the tint color input component
  143050. */
  143051. get tintColor(): NodeMaterialConnectionPoint;
  143052. /**
  143053. * Gets the tint "at distance" input component
  143054. */
  143055. get tintAtDistance(): NodeMaterialConnectionPoint;
  143056. /**
  143057. * Gets the tint thickness input component
  143058. */
  143059. get tintThickness(): NodeMaterialConnectionPoint;
  143060. /**
  143061. * Gets the world tangent input component
  143062. */
  143063. get worldTangent(): NodeMaterialConnectionPoint;
  143064. /**
  143065. * Gets the clear coat object output component
  143066. */
  143067. get clearcoat(): NodeMaterialConnectionPoint;
  143068. autoConfigure(material: NodeMaterial): void;
  143069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143071. private _generateTBNSpace;
  143072. /**
  143073. * Gets the main code of the block (fragment side)
  143074. * @param state current state of the node material building
  143075. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  143076. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143077. * @param worldPosVarName name of the variable holding the world position
  143078. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143079. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  143080. * @param worldNormalVarName name of the variable holding the world normal
  143081. * @returns the shader code
  143082. */
  143083. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  143084. protected _buildBlock(state: NodeMaterialBuildState): this;
  143085. }
  143086. }
  143087. declare module BABYLON {
  143088. /**
  143089. * Block used to implement the sub surface module of the PBR material
  143090. */
  143091. export class SubSurfaceBlock extends NodeMaterialBlock {
  143092. /**
  143093. * Create a new SubSurfaceBlock
  143094. * @param name defines the block name
  143095. */
  143096. constructor(name: string);
  143097. /**
  143098. * Stores the intensity of the different subsurface effects in the thickness texture.
  143099. * * the green channel is the translucency intensity.
  143100. * * the blue channel is the scattering intensity.
  143101. * * the alpha channel is the refraction intensity.
  143102. */
  143103. useMaskFromThicknessTexture: boolean;
  143104. /**
  143105. * Initialize the block and prepare the context for build
  143106. * @param state defines the state that will be used for the build
  143107. */
  143108. initialize(state: NodeMaterialBuildState): void;
  143109. /**
  143110. * Gets the current class name
  143111. * @returns the class name
  143112. */
  143113. getClassName(): string;
  143114. /**
  143115. * Gets the min thickness input component
  143116. */
  143117. get minThickness(): NodeMaterialConnectionPoint;
  143118. /**
  143119. * Gets the max thickness input component
  143120. */
  143121. get maxThickness(): NodeMaterialConnectionPoint;
  143122. /**
  143123. * Gets the thickness texture component
  143124. */
  143125. get thicknessTexture(): NodeMaterialConnectionPoint;
  143126. /**
  143127. * Gets the tint color input component
  143128. */
  143129. get tintColor(): NodeMaterialConnectionPoint;
  143130. /**
  143131. * Gets the translucency intensity input component
  143132. */
  143133. get translucencyIntensity(): NodeMaterialConnectionPoint;
  143134. /**
  143135. * Gets the translucency diffusion distance input component
  143136. */
  143137. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  143138. /**
  143139. * Gets the refraction object parameters
  143140. */
  143141. get refraction(): NodeMaterialConnectionPoint;
  143142. /**
  143143. * Gets the sub surface object output component
  143144. */
  143145. get subsurface(): NodeMaterialConnectionPoint;
  143146. autoConfigure(material: NodeMaterial): void;
  143147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143148. /**
  143149. * Gets the main code of the block (fragment side)
  143150. * @param state current state of the node material building
  143151. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  143152. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143153. * @param worldPosVarName name of the variable holding the world position
  143154. * @returns the shader code
  143155. */
  143156. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  143157. protected _buildBlock(state: NodeMaterialBuildState): this;
  143158. }
  143159. }
  143160. declare module BABYLON {
  143161. /**
  143162. * Block used to implement the PBR metallic/roughness model
  143163. */
  143164. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  143165. /**
  143166. * Gets or sets the light associated with this block
  143167. */
  143168. light: Nullable<Light>;
  143169. private _lightId;
  143170. private _scene;
  143171. private _environmentBRDFTexture;
  143172. private _environmentBrdfSamplerName;
  143173. private _vNormalWName;
  143174. private _invertNormalName;
  143175. /**
  143176. * Create a new ReflectionBlock
  143177. * @param name defines the block name
  143178. */
  143179. constructor(name: string);
  143180. /**
  143181. * Intensity of the direct lights e.g. the four lights available in your scene.
  143182. * This impacts both the direct diffuse and specular highlights.
  143183. */
  143184. directIntensity: number;
  143185. /**
  143186. * Intensity of the environment e.g. how much the environment will light the object
  143187. * either through harmonics for rough material or through the refelction for shiny ones.
  143188. */
  143189. environmentIntensity: number;
  143190. /**
  143191. * This is a special control allowing the reduction of the specular highlights coming from the
  143192. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  143193. */
  143194. specularIntensity: number;
  143195. /**
  143196. * Defines the falloff type used in this material.
  143197. * It by default is Physical.
  143198. */
  143199. lightFalloff: number;
  143200. /**
  143201. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  143202. */
  143203. useAlphaFromAlbedoTexture: boolean;
  143204. /**
  143205. * Specifies that alpha test should be used
  143206. */
  143207. useAlphaTest: boolean;
  143208. /**
  143209. * Defines the alpha limits in alpha test mode.
  143210. */
  143211. alphaTestCutoff: number;
  143212. /**
  143213. * Specifies that alpha blending should be used
  143214. */
  143215. useAlphaBlending: boolean;
  143216. /**
  143217. * Defines if the alpha value should be determined via the rgb values.
  143218. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  143219. */
  143220. opacityRGB: boolean;
  143221. /**
  143222. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  143223. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  143224. */
  143225. useRadianceOverAlpha: boolean;
  143226. /**
  143227. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  143228. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  143229. */
  143230. useSpecularOverAlpha: boolean;
  143231. /**
  143232. * Enables specular anti aliasing in the PBR shader.
  143233. * It will both interacts on the Geometry for analytical and IBL lighting.
  143234. * It also prefilter the roughness map based on the bump values.
  143235. */
  143236. enableSpecularAntiAliasing: boolean;
  143237. /**
  143238. * Enables realtime filtering on the texture.
  143239. */
  143240. realTimeFiltering: boolean;
  143241. /**
  143242. * Quality switch for realtime filtering
  143243. */
  143244. realTimeFilteringQuality: number;
  143245. /**
  143246. * Defines if the material uses energy conservation.
  143247. */
  143248. useEnergyConservation: boolean;
  143249. /**
  143250. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143251. * too much the area relying on ambient texture to define their ambient occlusion.
  143252. */
  143253. useRadianceOcclusion: boolean;
  143254. /**
  143255. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143256. * makes the reflect vector face the model (under horizon).
  143257. */
  143258. useHorizonOcclusion: boolean;
  143259. /**
  143260. * If set to true, no lighting calculations will be applied.
  143261. */
  143262. unlit: boolean;
  143263. /**
  143264. * Force normal to face away from face.
  143265. */
  143266. forceNormalForward: boolean;
  143267. /**
  143268. * Defines the material debug mode.
  143269. * It helps seeing only some components of the material while troubleshooting.
  143270. */
  143271. debugMode: number;
  143272. /**
  143273. * Specify from where on screen the debug mode should start.
  143274. * The value goes from -1 (full screen) to 1 (not visible)
  143275. * It helps with side by side comparison against the final render
  143276. * This defaults to 0
  143277. */
  143278. debugLimit: number;
  143279. /**
  143280. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143281. * You can use the factor to better multiply the final value.
  143282. */
  143283. debugFactor: number;
  143284. /**
  143285. * Initialize the block and prepare the context for build
  143286. * @param state defines the state that will be used for the build
  143287. */
  143288. initialize(state: NodeMaterialBuildState): void;
  143289. /**
  143290. * Gets the current class name
  143291. * @returns the class name
  143292. */
  143293. getClassName(): string;
  143294. /**
  143295. * Gets the world position input component
  143296. */
  143297. get worldPosition(): NodeMaterialConnectionPoint;
  143298. /**
  143299. * Gets the world normal input component
  143300. */
  143301. get worldNormal(): NodeMaterialConnectionPoint;
  143302. /**
  143303. * Gets the perturbed normal input component
  143304. */
  143305. get perturbedNormal(): NodeMaterialConnectionPoint;
  143306. /**
  143307. * Gets the camera position input component
  143308. */
  143309. get cameraPosition(): NodeMaterialConnectionPoint;
  143310. /**
  143311. * Gets the base color input component
  143312. */
  143313. get baseColor(): NodeMaterialConnectionPoint;
  143314. /**
  143315. * Gets the opacity texture input component
  143316. */
  143317. get opacityTexture(): NodeMaterialConnectionPoint;
  143318. /**
  143319. * Gets the ambient color input component
  143320. */
  143321. get ambientColor(): NodeMaterialConnectionPoint;
  143322. /**
  143323. * Gets the reflectivity object parameters
  143324. */
  143325. get reflectivity(): NodeMaterialConnectionPoint;
  143326. /**
  143327. * Gets the ambient occlusion object parameters
  143328. */
  143329. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143330. /**
  143331. * Gets the reflection object parameters
  143332. */
  143333. get reflection(): NodeMaterialConnectionPoint;
  143334. /**
  143335. * Gets the sheen object parameters
  143336. */
  143337. get sheen(): NodeMaterialConnectionPoint;
  143338. /**
  143339. * Gets the clear coat object parameters
  143340. */
  143341. get clearcoat(): NodeMaterialConnectionPoint;
  143342. /**
  143343. * Gets the sub surface object parameters
  143344. */
  143345. get subsurface(): NodeMaterialConnectionPoint;
  143346. /**
  143347. * Gets the anisotropy object parameters
  143348. */
  143349. get anisotropy(): NodeMaterialConnectionPoint;
  143350. /**
  143351. * Gets the ambient output component
  143352. */
  143353. get ambient(): NodeMaterialConnectionPoint;
  143354. /**
  143355. * Gets the diffuse output component
  143356. */
  143357. get diffuse(): NodeMaterialConnectionPoint;
  143358. /**
  143359. * Gets the specular output component
  143360. */
  143361. get specular(): NodeMaterialConnectionPoint;
  143362. /**
  143363. * Gets the sheen output component
  143364. */
  143365. get sheenDir(): NodeMaterialConnectionPoint;
  143366. /**
  143367. * Gets the clear coat output component
  143368. */
  143369. get clearcoatDir(): NodeMaterialConnectionPoint;
  143370. /**
  143371. * Gets the indirect diffuse output component
  143372. */
  143373. get diffuseIndirect(): NodeMaterialConnectionPoint;
  143374. /**
  143375. * Gets the indirect specular output component
  143376. */
  143377. get specularIndirect(): NodeMaterialConnectionPoint;
  143378. /**
  143379. * Gets the indirect sheen output component
  143380. */
  143381. get sheenIndirect(): NodeMaterialConnectionPoint;
  143382. /**
  143383. * Gets the indirect clear coat output component
  143384. */
  143385. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  143386. /**
  143387. * Gets the refraction output component
  143388. */
  143389. get refraction(): NodeMaterialConnectionPoint;
  143390. /**
  143391. * Gets the global lighting output component
  143392. */
  143393. get lighting(): NodeMaterialConnectionPoint;
  143394. /**
  143395. * Gets the shadow output component
  143396. */
  143397. get shadow(): NodeMaterialConnectionPoint;
  143398. /**
  143399. * Gets the alpha output component
  143400. */
  143401. get alpha(): NodeMaterialConnectionPoint;
  143402. autoConfigure(material: NodeMaterial): void;
  143403. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143404. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143405. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143406. private _injectVertexCode;
  143407. /**
  143408. * Gets the code corresponding to the albedo/opacity module
  143409. * @returns the shader code
  143410. */
  143411. getAlbedoOpacityCode(): string;
  143412. protected _buildBlock(state: NodeMaterialBuildState): this;
  143413. protected _dumpPropertiesCode(): string;
  143414. serialize(): any;
  143415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143416. }
  143417. }
  143418. declare module BABYLON {
  143419. /**
  143420. * Block used to compute value of one parameter modulo another
  143421. */
  143422. export class ModBlock extends NodeMaterialBlock {
  143423. /**
  143424. * Creates a new ModBlock
  143425. * @param name defines the block name
  143426. */
  143427. constructor(name: string);
  143428. /**
  143429. * Gets the current class name
  143430. * @returns the class name
  143431. */
  143432. getClassName(): string;
  143433. /**
  143434. * Gets the left operand input component
  143435. */
  143436. get left(): NodeMaterialConnectionPoint;
  143437. /**
  143438. * Gets the right operand input component
  143439. */
  143440. get right(): NodeMaterialConnectionPoint;
  143441. /**
  143442. * Gets the output component
  143443. */
  143444. get output(): NodeMaterialConnectionPoint;
  143445. protected _buildBlock(state: NodeMaterialBuildState): this;
  143446. }
  143447. }
  143448. declare module BABYLON {
  143449. /**
  143450. * Helper class to push actions to a pool of workers.
  143451. */
  143452. export class WorkerPool implements IDisposable {
  143453. private _workerInfos;
  143454. private _pendingActions;
  143455. /**
  143456. * Constructor
  143457. * @param workers Array of workers to use for actions
  143458. */
  143459. constructor(workers: Array<Worker>);
  143460. /**
  143461. * Terminates all workers and clears any pending actions.
  143462. */
  143463. dispose(): void;
  143464. /**
  143465. * Pushes an action to the worker pool. If all the workers are active, the action will be
  143466. * pended until a worker has completed its action.
  143467. * @param action The action to perform. Call onComplete when the action is complete.
  143468. */
  143469. push(action: (worker: Worker, onComplete: () => void) => void): void;
  143470. private _execute;
  143471. }
  143472. }
  143473. declare module BABYLON {
  143474. /**
  143475. * Configuration for Draco compression
  143476. */
  143477. export interface IDracoCompressionConfiguration {
  143478. /**
  143479. * Configuration for the decoder.
  143480. */
  143481. decoder: {
  143482. /**
  143483. * The url to the WebAssembly module.
  143484. */
  143485. wasmUrl?: string;
  143486. /**
  143487. * The url to the WebAssembly binary.
  143488. */
  143489. wasmBinaryUrl?: string;
  143490. /**
  143491. * The url to the fallback JavaScript module.
  143492. */
  143493. fallbackUrl?: string;
  143494. };
  143495. }
  143496. /**
  143497. * Draco compression (https://google.github.io/draco/)
  143498. *
  143499. * This class wraps the Draco module.
  143500. *
  143501. * **Encoder**
  143502. *
  143503. * The encoder is not currently implemented.
  143504. *
  143505. * **Decoder**
  143506. *
  143507. * 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.
  143508. *
  143509. * To update the configuration, use the following code:
  143510. * ```javascript
  143511. * DracoCompression.Configuration = {
  143512. * decoder: {
  143513. * wasmUrl: "<url to the WebAssembly library>",
  143514. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  143515. * fallbackUrl: "<url to the fallback JavaScript library>",
  143516. * }
  143517. * };
  143518. * ```
  143519. *
  143520. * 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.
  143521. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  143522. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  143523. *
  143524. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  143525. * ```javascript
  143526. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  143527. * ```
  143528. *
  143529. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  143530. */
  143531. export class DracoCompression implements IDisposable {
  143532. private _workerPoolPromise?;
  143533. private _decoderModulePromise?;
  143534. /**
  143535. * The configuration. Defaults to the following urls:
  143536. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  143537. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  143538. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  143539. */
  143540. static Configuration: IDracoCompressionConfiguration;
  143541. /**
  143542. * Returns true if the decoder configuration is available.
  143543. */
  143544. static get DecoderAvailable(): boolean;
  143545. /**
  143546. * Default number of workers to create when creating the draco compression object.
  143547. */
  143548. static DefaultNumWorkers: number;
  143549. private static GetDefaultNumWorkers;
  143550. private static _Default;
  143551. /**
  143552. * Default instance for the draco compression object.
  143553. */
  143554. static get Default(): DracoCompression;
  143555. /**
  143556. * Constructor
  143557. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  143558. */
  143559. constructor(numWorkers?: number);
  143560. /**
  143561. * Stop all async operations and release resources.
  143562. */
  143563. dispose(): void;
  143564. /**
  143565. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  143566. * @returns a promise that resolves when ready
  143567. */
  143568. whenReadyAsync(): Promise<void>;
  143569. /**
  143570. * Decode Draco compressed mesh data to vertex data.
  143571. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  143572. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  143573. * @returns A promise that resolves with the decoded vertex data
  143574. */
  143575. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  143576. [kind: string]: number;
  143577. }): Promise<VertexData>;
  143578. }
  143579. }
  143580. declare module BABYLON {
  143581. /**
  143582. * Class for building Constructive Solid Geometry
  143583. */
  143584. export class CSG {
  143585. private polygons;
  143586. /**
  143587. * The world matrix
  143588. */
  143589. matrix: Matrix;
  143590. /**
  143591. * Stores the position
  143592. */
  143593. position: Vector3;
  143594. /**
  143595. * Stores the rotation
  143596. */
  143597. rotation: Vector3;
  143598. /**
  143599. * Stores the rotation quaternion
  143600. */
  143601. rotationQuaternion: Nullable<Quaternion>;
  143602. /**
  143603. * Stores the scaling vector
  143604. */
  143605. scaling: Vector3;
  143606. /**
  143607. * Convert the Mesh to CSG
  143608. * @param mesh The Mesh to convert to CSG
  143609. * @returns A new CSG from the Mesh
  143610. */
  143611. static FromMesh(mesh: Mesh): CSG;
  143612. /**
  143613. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  143614. * @param polygons Polygons used to construct a CSG solid
  143615. */
  143616. private static FromPolygons;
  143617. /**
  143618. * Clones, or makes a deep copy, of the CSG
  143619. * @returns A new CSG
  143620. */
  143621. clone(): CSG;
  143622. /**
  143623. * Unions this CSG with another CSG
  143624. * @param csg The CSG to union against this CSG
  143625. * @returns The unioned CSG
  143626. */
  143627. union(csg: CSG): CSG;
  143628. /**
  143629. * Unions this CSG with another CSG in place
  143630. * @param csg The CSG to union against this CSG
  143631. */
  143632. unionInPlace(csg: CSG): void;
  143633. /**
  143634. * Subtracts this CSG with another CSG
  143635. * @param csg The CSG to subtract against this CSG
  143636. * @returns A new CSG
  143637. */
  143638. subtract(csg: CSG): CSG;
  143639. /**
  143640. * Subtracts this CSG with another CSG in place
  143641. * @param csg The CSG to subtact against this CSG
  143642. */
  143643. subtractInPlace(csg: CSG): void;
  143644. /**
  143645. * Intersect this CSG with another CSG
  143646. * @param csg The CSG to intersect against this CSG
  143647. * @returns A new CSG
  143648. */
  143649. intersect(csg: CSG): CSG;
  143650. /**
  143651. * Intersects this CSG with another CSG in place
  143652. * @param csg The CSG to intersect against this CSG
  143653. */
  143654. intersectInPlace(csg: CSG): void;
  143655. /**
  143656. * Return a new CSG solid with solid and empty space switched. This solid is
  143657. * not modified.
  143658. * @returns A new CSG solid with solid and empty space switched
  143659. */
  143660. inverse(): CSG;
  143661. /**
  143662. * Inverses the CSG in place
  143663. */
  143664. inverseInPlace(): void;
  143665. /**
  143666. * This is used to keep meshes transformations so they can be restored
  143667. * when we build back a Babylon Mesh
  143668. * NB : All CSG operations are performed in world coordinates
  143669. * @param csg The CSG to copy the transform attributes from
  143670. * @returns This CSG
  143671. */
  143672. copyTransformAttributes(csg: CSG): CSG;
  143673. /**
  143674. * Build Raw mesh from CSG
  143675. * Coordinates here are in world space
  143676. * @param name The name of the mesh geometry
  143677. * @param scene The Scene
  143678. * @param keepSubMeshes Specifies if the submeshes should be kept
  143679. * @returns A new Mesh
  143680. */
  143681. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143682. /**
  143683. * Build Mesh from CSG taking material and transforms into account
  143684. * @param name The name of the Mesh
  143685. * @param material The material of the Mesh
  143686. * @param scene The Scene
  143687. * @param keepSubMeshes Specifies if submeshes should be kept
  143688. * @returns The new Mesh
  143689. */
  143690. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143691. }
  143692. }
  143693. declare module BABYLON {
  143694. /**
  143695. * Class used to create a trail following a mesh
  143696. */
  143697. export class TrailMesh extends Mesh {
  143698. private _generator;
  143699. private _autoStart;
  143700. private _running;
  143701. private _diameter;
  143702. private _length;
  143703. private _sectionPolygonPointsCount;
  143704. private _sectionVectors;
  143705. private _sectionNormalVectors;
  143706. private _beforeRenderObserver;
  143707. /**
  143708. * @constructor
  143709. * @param name The value used by scene.getMeshByName() to do a lookup.
  143710. * @param generator The mesh or transform node to generate a trail.
  143711. * @param scene The scene to add this mesh to.
  143712. * @param diameter Diameter of trailing mesh. Default is 1.
  143713. * @param length Length of trailing mesh. Default is 60.
  143714. * @param autoStart Automatically start trailing mesh. Default true.
  143715. */
  143716. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  143717. /**
  143718. * "TrailMesh"
  143719. * @returns "TrailMesh"
  143720. */
  143721. getClassName(): string;
  143722. private _createMesh;
  143723. /**
  143724. * Start trailing mesh.
  143725. */
  143726. start(): void;
  143727. /**
  143728. * Stop trailing mesh.
  143729. */
  143730. stop(): void;
  143731. /**
  143732. * Update trailing mesh geometry.
  143733. */
  143734. update(): void;
  143735. /**
  143736. * Returns a new TrailMesh object.
  143737. * @param name is a string, the name given to the new mesh
  143738. * @param newGenerator use new generator object for cloned trail mesh
  143739. * @returns a new mesh
  143740. */
  143741. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  143742. /**
  143743. * Serializes this trail mesh
  143744. * @param serializationObject object to write serialization to
  143745. */
  143746. serialize(serializationObject: any): void;
  143747. /**
  143748. * Parses a serialized trail mesh
  143749. * @param parsedMesh the serialized mesh
  143750. * @param scene the scene to create the trail mesh in
  143751. * @returns the created trail mesh
  143752. */
  143753. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  143754. }
  143755. }
  143756. declare module BABYLON {
  143757. /**
  143758. * Class containing static functions to help procedurally build meshes
  143759. */
  143760. export class TiledBoxBuilder {
  143761. /**
  143762. * Creates a box mesh
  143763. * 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)
  143764. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143768. * @param name defines the name of the mesh
  143769. * @param options defines the options used to create the mesh
  143770. * @param scene defines the hosting scene
  143771. * @returns the box mesh
  143772. */
  143773. static CreateTiledBox(name: string, options: {
  143774. pattern?: number;
  143775. width?: number;
  143776. height?: number;
  143777. depth?: number;
  143778. tileSize?: number;
  143779. tileWidth?: number;
  143780. tileHeight?: number;
  143781. alignHorizontal?: number;
  143782. alignVertical?: number;
  143783. faceUV?: Vector4[];
  143784. faceColors?: Color4[];
  143785. sideOrientation?: number;
  143786. updatable?: boolean;
  143787. }, scene?: Nullable<Scene>): Mesh;
  143788. }
  143789. }
  143790. declare module BABYLON {
  143791. /**
  143792. * Class containing static functions to help procedurally build meshes
  143793. */
  143794. export class TorusKnotBuilder {
  143795. /**
  143796. * Creates a torus knot mesh
  143797. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143798. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143799. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143800. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143804. * @param name defines the name of the mesh
  143805. * @param options defines the options used to create the mesh
  143806. * @param scene defines the hosting scene
  143807. * @returns the torus knot mesh
  143808. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143809. */
  143810. static CreateTorusKnot(name: string, options: {
  143811. radius?: number;
  143812. tube?: number;
  143813. radialSegments?: number;
  143814. tubularSegments?: number;
  143815. p?: number;
  143816. q?: number;
  143817. updatable?: boolean;
  143818. sideOrientation?: number;
  143819. frontUVs?: Vector4;
  143820. backUVs?: Vector4;
  143821. }, scene: any): Mesh;
  143822. }
  143823. }
  143824. declare module BABYLON {
  143825. /**
  143826. * Polygon
  143827. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  143828. */
  143829. export class Polygon {
  143830. /**
  143831. * Creates a rectangle
  143832. * @param xmin bottom X coord
  143833. * @param ymin bottom Y coord
  143834. * @param xmax top X coord
  143835. * @param ymax top Y coord
  143836. * @returns points that make the resulting rectation
  143837. */
  143838. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  143839. /**
  143840. * Creates a circle
  143841. * @param radius radius of circle
  143842. * @param cx scale in x
  143843. * @param cy scale in y
  143844. * @param numberOfSides number of sides that make up the circle
  143845. * @returns points that make the resulting circle
  143846. */
  143847. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  143848. /**
  143849. * Creates a polygon from input string
  143850. * @param input Input polygon data
  143851. * @returns the parsed points
  143852. */
  143853. static Parse(input: string): Vector2[];
  143854. /**
  143855. * Starts building a polygon from x and y coordinates
  143856. * @param x x coordinate
  143857. * @param y y coordinate
  143858. * @returns the started path2
  143859. */
  143860. static StartingAt(x: number, y: number): Path2;
  143861. }
  143862. /**
  143863. * Builds a polygon
  143864. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  143865. */
  143866. export class PolygonMeshBuilder {
  143867. private _points;
  143868. private _outlinepoints;
  143869. private _holes;
  143870. private _name;
  143871. private _scene;
  143872. private _epoints;
  143873. private _eholes;
  143874. private _addToepoint;
  143875. /**
  143876. * Babylon reference to the earcut plugin.
  143877. */
  143878. bjsEarcut: any;
  143879. /**
  143880. * Creates a PolygonMeshBuilder
  143881. * @param name name of the builder
  143882. * @param contours Path of the polygon
  143883. * @param scene scene to add to when creating the mesh
  143884. * @param earcutInjection can be used to inject your own earcut reference
  143885. */
  143886. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  143887. /**
  143888. * Adds a whole within the polygon
  143889. * @param hole Array of points defining the hole
  143890. * @returns this
  143891. */
  143892. addHole(hole: Vector2[]): PolygonMeshBuilder;
  143893. /**
  143894. * Creates the polygon
  143895. * @param updatable If the mesh should be updatable
  143896. * @param depth The depth of the mesh created
  143897. * @returns the created mesh
  143898. */
  143899. build(updatable?: boolean, depth?: number): Mesh;
  143900. /**
  143901. * Creates the polygon
  143902. * @param depth The depth of the mesh created
  143903. * @returns the created VertexData
  143904. */
  143905. buildVertexData(depth?: number): VertexData;
  143906. /**
  143907. * Adds a side to the polygon
  143908. * @param positions points that make the polygon
  143909. * @param normals normals of the polygon
  143910. * @param uvs uvs of the polygon
  143911. * @param indices indices of the polygon
  143912. * @param bounds bounds of the polygon
  143913. * @param points points of the polygon
  143914. * @param depth depth of the polygon
  143915. * @param flip flip of the polygon
  143916. */
  143917. private addSide;
  143918. }
  143919. }
  143920. declare module BABYLON {
  143921. /**
  143922. * Class containing static functions to help procedurally build meshes
  143923. */
  143924. export class PolygonBuilder {
  143925. /**
  143926. * Creates a polygon mesh
  143927. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143928. * * 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
  143929. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143932. * * Remember you can only change the shape positions, not their number when updating a polygon
  143933. * @param name defines the name of the mesh
  143934. * @param options defines the options used to create the mesh
  143935. * @param scene defines the hosting scene
  143936. * @param earcutInjection can be used to inject your own earcut reference
  143937. * @returns the polygon mesh
  143938. */
  143939. static CreatePolygon(name: string, options: {
  143940. shape: Vector3[];
  143941. holes?: Vector3[][];
  143942. depth?: number;
  143943. faceUV?: Vector4[];
  143944. faceColors?: Color4[];
  143945. updatable?: boolean;
  143946. sideOrientation?: number;
  143947. frontUVs?: Vector4;
  143948. backUVs?: Vector4;
  143949. wrap?: boolean;
  143950. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143951. /**
  143952. * Creates an extruded polygon mesh, with depth in the Y direction.
  143953. * * 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)
  143954. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  143959. * @returns the polygon mesh
  143960. */
  143961. static ExtrudePolygon(name: string, options: {
  143962. shape: Vector3[];
  143963. holes?: Vector3[][];
  143964. depth?: number;
  143965. faceUV?: Vector4[];
  143966. faceColors?: Color4[];
  143967. updatable?: boolean;
  143968. sideOrientation?: number;
  143969. frontUVs?: Vector4;
  143970. backUVs?: Vector4;
  143971. wrap?: boolean;
  143972. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143973. }
  143974. }
  143975. declare module BABYLON {
  143976. /**
  143977. * Class containing static functions to help procedurally build meshes
  143978. */
  143979. export class LatheBuilder {
  143980. /**
  143981. * Creates lathe mesh.
  143982. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143983. * * 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
  143984. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143985. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143986. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143987. * * 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
  143988. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143989. * * 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
  143990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143994. * @param name defines the name of the mesh
  143995. * @param options defines the options used to create the mesh
  143996. * @param scene defines the hosting scene
  143997. * @returns the lathe mesh
  143998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143999. */
  144000. static CreateLathe(name: string, options: {
  144001. shape: Vector3[];
  144002. radius?: number;
  144003. tessellation?: number;
  144004. clip?: number;
  144005. arc?: number;
  144006. closed?: boolean;
  144007. updatable?: boolean;
  144008. sideOrientation?: number;
  144009. frontUVs?: Vector4;
  144010. backUVs?: Vector4;
  144011. cap?: number;
  144012. invertUV?: boolean;
  144013. }, scene?: Nullable<Scene>): Mesh;
  144014. }
  144015. }
  144016. declare module BABYLON {
  144017. /**
  144018. * Class containing static functions to help procedurally build meshes
  144019. */
  144020. export class TiledPlaneBuilder {
  144021. /**
  144022. * Creates a tiled plane mesh
  144023. * * The parameter `pattern` will, depending on value, do nothing or
  144024. * * * flip (reflect about central vertical) alternate tiles across and up
  144025. * * * flip every tile on alternate rows
  144026. * * * rotate (180 degs) alternate tiles across and up
  144027. * * * rotate every tile on alternate rows
  144028. * * * flip and rotate alternate tiles across and up
  144029. * * * flip and rotate every tile on alternate rows
  144030. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  144031. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  144032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144034. * * 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)
  144035. * * 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)
  144036. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  144041. */
  144042. static CreateTiledPlane(name: string, options: {
  144043. pattern?: number;
  144044. tileSize?: number;
  144045. tileWidth?: number;
  144046. tileHeight?: number;
  144047. size?: number;
  144048. width?: number;
  144049. height?: number;
  144050. alignHorizontal?: number;
  144051. alignVertical?: number;
  144052. sideOrientation?: number;
  144053. frontUVs?: Vector4;
  144054. backUVs?: Vector4;
  144055. updatable?: boolean;
  144056. }, scene?: Nullable<Scene>): Mesh;
  144057. }
  144058. }
  144059. declare module BABYLON {
  144060. /**
  144061. * Class containing static functions to help procedurally build meshes
  144062. */
  144063. export class TubeBuilder {
  144064. /**
  144065. * Creates a tube mesh.
  144066. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144067. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144068. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144069. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144070. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144071. * * 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)
  144072. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144073. * * 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
  144074. * * 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
  144075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144079. * @param name defines the name of the mesh
  144080. * @param options defines the options used to create the mesh
  144081. * @param scene defines the hosting scene
  144082. * @returns the tube mesh
  144083. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144084. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144085. */
  144086. static CreateTube(name: string, options: {
  144087. path: Vector3[];
  144088. radius?: number;
  144089. tessellation?: number;
  144090. radiusFunction?: {
  144091. (i: number, distance: number): number;
  144092. };
  144093. cap?: number;
  144094. arc?: number;
  144095. updatable?: boolean;
  144096. sideOrientation?: number;
  144097. frontUVs?: Vector4;
  144098. backUVs?: Vector4;
  144099. instance?: Mesh;
  144100. invertUV?: boolean;
  144101. }, scene?: Nullable<Scene>): Mesh;
  144102. }
  144103. }
  144104. declare module BABYLON {
  144105. /**
  144106. * Class containing static functions to help procedurally build meshes
  144107. */
  144108. export class IcoSphereBuilder {
  144109. /**
  144110. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144111. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144112. * * 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`)
  144113. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144114. * * 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
  144115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144118. * @param name defines the name of the mesh
  144119. * @param options defines the options used to create the mesh
  144120. * @param scene defines the hosting scene
  144121. * @returns the icosahedron mesh
  144122. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144123. */
  144124. static CreateIcoSphere(name: string, options: {
  144125. radius?: number;
  144126. radiusX?: number;
  144127. radiusY?: number;
  144128. radiusZ?: number;
  144129. flat?: boolean;
  144130. subdivisions?: number;
  144131. sideOrientation?: number;
  144132. frontUVs?: Vector4;
  144133. backUVs?: Vector4;
  144134. updatable?: boolean;
  144135. }, scene?: Nullable<Scene>): Mesh;
  144136. }
  144137. }
  144138. declare module BABYLON {
  144139. /**
  144140. * Class containing static functions to help procedurally build meshes
  144141. */
  144142. export class DecalBuilder {
  144143. /**
  144144. * Creates a decal mesh.
  144145. * 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
  144146. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144147. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144148. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144149. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144150. * @param name defines the name of the mesh
  144151. * @param sourceMesh defines the mesh where the decal must be applied
  144152. * @param options defines the options used to create the mesh
  144153. * @param scene defines the hosting scene
  144154. * @returns the decal mesh
  144155. * @see https://doc.babylonjs.com/how_to/decals
  144156. */
  144157. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144158. position?: Vector3;
  144159. normal?: Vector3;
  144160. size?: Vector3;
  144161. angle?: number;
  144162. }): Mesh;
  144163. }
  144164. }
  144165. declare module BABYLON {
  144166. /**
  144167. * Class containing static functions to help procedurally build meshes
  144168. */
  144169. export class MeshBuilder {
  144170. /**
  144171. * Creates a box mesh
  144172. * * The parameter `size` sets the size (float) of each box side (default 1)
  144173. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  144174. * * 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)
  144175. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144179. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144180. * @param name defines the name of the mesh
  144181. * @param options defines the options used to create the mesh
  144182. * @param scene defines the hosting scene
  144183. * @returns the box mesh
  144184. */
  144185. static CreateBox(name: string, options: {
  144186. size?: number;
  144187. width?: number;
  144188. height?: number;
  144189. depth?: number;
  144190. faceUV?: Vector4[];
  144191. faceColors?: Color4[];
  144192. sideOrientation?: number;
  144193. frontUVs?: Vector4;
  144194. backUVs?: Vector4;
  144195. wrap?: boolean;
  144196. topBaseAt?: number;
  144197. bottomBaseAt?: number;
  144198. updatable?: boolean;
  144199. }, scene?: Nullable<Scene>): Mesh;
  144200. /**
  144201. * Creates a tiled box mesh
  144202. * * faceTiles sets the pattern, tile size and number of tiles for a face
  144203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144204. * @param name defines the name of the mesh
  144205. * @param options defines the options used to create the mesh
  144206. * @param scene defines the hosting scene
  144207. * @returns the tiled box mesh
  144208. */
  144209. static CreateTiledBox(name: string, options: {
  144210. pattern?: number;
  144211. size?: number;
  144212. width?: number;
  144213. height?: number;
  144214. depth: number;
  144215. tileSize?: number;
  144216. tileWidth?: number;
  144217. tileHeight?: number;
  144218. faceUV?: Vector4[];
  144219. faceColors?: Color4[];
  144220. alignHorizontal?: number;
  144221. alignVertical?: number;
  144222. sideOrientation?: number;
  144223. updatable?: boolean;
  144224. }, scene?: Nullable<Scene>): Mesh;
  144225. /**
  144226. * Creates a sphere mesh
  144227. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  144228. * * 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`)
  144229. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  144230. * * 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
  144231. * * 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)
  144232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144235. * @param name defines the name of the mesh
  144236. * @param options defines the options used to create the mesh
  144237. * @param scene defines the hosting scene
  144238. * @returns the sphere mesh
  144239. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  144240. */
  144241. static CreateSphere(name: string, options: {
  144242. segments?: number;
  144243. diameter?: number;
  144244. diameterX?: number;
  144245. diameterY?: number;
  144246. diameterZ?: number;
  144247. arc?: number;
  144248. slice?: number;
  144249. sideOrientation?: number;
  144250. frontUVs?: Vector4;
  144251. backUVs?: Vector4;
  144252. updatable?: boolean;
  144253. }, scene?: Nullable<Scene>): Mesh;
  144254. /**
  144255. * Creates a plane polygonal mesh. By default, this is a disc
  144256. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144257. * * 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
  144258. * * 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
  144259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144262. * @param name defines the name of the mesh
  144263. * @param options defines the options used to create the mesh
  144264. * @param scene defines the hosting scene
  144265. * @returns the plane polygonal mesh
  144266. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144267. */
  144268. static CreateDisc(name: string, options: {
  144269. radius?: number;
  144270. tessellation?: number;
  144271. arc?: number;
  144272. updatable?: boolean;
  144273. sideOrientation?: number;
  144274. frontUVs?: Vector4;
  144275. backUVs?: Vector4;
  144276. }, scene?: Nullable<Scene>): Mesh;
  144277. /**
  144278. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144279. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144280. * * 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`)
  144281. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144282. * * 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
  144283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144286. * @param name defines the name of the mesh
  144287. * @param options defines the options used to create the mesh
  144288. * @param scene defines the hosting scene
  144289. * @returns the icosahedron mesh
  144290. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144291. */
  144292. static CreateIcoSphere(name: string, options: {
  144293. radius?: number;
  144294. radiusX?: number;
  144295. radiusY?: number;
  144296. radiusZ?: number;
  144297. flat?: boolean;
  144298. subdivisions?: number;
  144299. sideOrientation?: number;
  144300. frontUVs?: Vector4;
  144301. backUVs?: Vector4;
  144302. updatable?: boolean;
  144303. }, scene?: Nullable<Scene>): Mesh;
  144304. /**
  144305. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144306. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144307. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144308. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144309. * * 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
  144310. * * 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
  144311. * * 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
  144312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144315. * * 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
  144316. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144317. * * 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
  144318. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144320. * @param name defines the name of the mesh
  144321. * @param options defines the options used to create the mesh
  144322. * @param scene defines the hosting scene
  144323. * @returns the ribbon mesh
  144324. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144326. */
  144327. static CreateRibbon(name: string, options: {
  144328. pathArray: Vector3[][];
  144329. closeArray?: boolean;
  144330. closePath?: boolean;
  144331. offset?: number;
  144332. updatable?: boolean;
  144333. sideOrientation?: number;
  144334. frontUVs?: Vector4;
  144335. backUVs?: Vector4;
  144336. instance?: Mesh;
  144337. invertUV?: boolean;
  144338. uvs?: Vector2[];
  144339. colors?: Color4[];
  144340. }, scene?: Nullable<Scene>): Mesh;
  144341. /**
  144342. * Creates a cylinder or a cone mesh
  144343. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  144344. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  144345. * * 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.
  144346. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  144347. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  144348. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  144349. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  144350. * * 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).
  144351. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  144352. * * 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).
  144353. * * 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
  144354. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  144355. * * 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
  144356. * * 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.
  144357. * * If `enclose` is false, a ring surface is one element.
  144358. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  144359. * * 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
  144360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144363. * @param name defines the name of the mesh
  144364. * @param options defines the options used to create the mesh
  144365. * @param scene defines the hosting scene
  144366. * @returns the cylinder mesh
  144367. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  144368. */
  144369. static CreateCylinder(name: string, options: {
  144370. height?: number;
  144371. diameterTop?: number;
  144372. diameterBottom?: number;
  144373. diameter?: number;
  144374. tessellation?: number;
  144375. subdivisions?: number;
  144376. arc?: number;
  144377. faceColors?: Color4[];
  144378. faceUV?: Vector4[];
  144379. updatable?: boolean;
  144380. hasRings?: boolean;
  144381. enclose?: boolean;
  144382. cap?: number;
  144383. sideOrientation?: number;
  144384. frontUVs?: Vector4;
  144385. backUVs?: Vector4;
  144386. }, scene?: Nullable<Scene>): Mesh;
  144387. /**
  144388. * Creates a torus mesh
  144389. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  144390. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  144391. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  144392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144395. * @param name defines the name of the mesh
  144396. * @param options defines the options used to create the mesh
  144397. * @param scene defines the hosting scene
  144398. * @returns the torus mesh
  144399. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  144400. */
  144401. static CreateTorus(name: string, options: {
  144402. diameter?: number;
  144403. thickness?: number;
  144404. tessellation?: number;
  144405. updatable?: boolean;
  144406. sideOrientation?: number;
  144407. frontUVs?: Vector4;
  144408. backUVs?: Vector4;
  144409. }, scene?: Nullable<Scene>): Mesh;
  144410. /**
  144411. * Creates a torus knot mesh
  144412. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144413. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144414. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144415. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144419. * @param name defines the name of the mesh
  144420. * @param options defines the options used to create the mesh
  144421. * @param scene defines the hosting scene
  144422. * @returns the torus knot mesh
  144423. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144424. */
  144425. static CreateTorusKnot(name: string, options: {
  144426. radius?: number;
  144427. tube?: number;
  144428. radialSegments?: number;
  144429. tubularSegments?: number;
  144430. p?: number;
  144431. q?: number;
  144432. updatable?: boolean;
  144433. sideOrientation?: number;
  144434. frontUVs?: Vector4;
  144435. backUVs?: Vector4;
  144436. }, scene?: Nullable<Scene>): Mesh;
  144437. /**
  144438. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  144439. * * 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
  144440. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  144441. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  144442. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  144443. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  144444. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  144445. * * 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
  144446. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  144447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  144449. * @param name defines the name of the new line system
  144450. * @param options defines the options used to create the line system
  144451. * @param scene defines the hosting scene
  144452. * @returns a new line system mesh
  144453. */
  144454. static CreateLineSystem(name: string, options: {
  144455. lines: Vector3[][];
  144456. updatable?: boolean;
  144457. instance?: Nullable<LinesMesh>;
  144458. colors?: Nullable<Color4[][]>;
  144459. useVertexAlpha?: boolean;
  144460. }, scene: Nullable<Scene>): LinesMesh;
  144461. /**
  144462. * Creates a line mesh
  144463. * 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
  144464. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144465. * * The parameter `points` is an array successive Vector3
  144466. * * 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
  144467. * * The optional parameter `colors` is an array of successive Color4, one per line point
  144468. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  144469. * * When updating an instance, remember that only point positions can change, not the number of points
  144470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  144472. * @param name defines the name of the new line system
  144473. * @param options defines the options used to create the line system
  144474. * @param scene defines the hosting scene
  144475. * @returns a new line mesh
  144476. */
  144477. static CreateLines(name: string, options: {
  144478. points: Vector3[];
  144479. updatable?: boolean;
  144480. instance?: Nullable<LinesMesh>;
  144481. colors?: Color4[];
  144482. useVertexAlpha?: boolean;
  144483. }, scene?: Nullable<Scene>): LinesMesh;
  144484. /**
  144485. * Creates a dashed line mesh
  144486. * * 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
  144487. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144488. * * The parameter `points` is an array successive Vector3
  144489. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  144490. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  144491. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  144492. * * 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
  144493. * * When updating an instance, remember that only point positions can change, not the number of points
  144494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144495. * @param name defines the name of the mesh
  144496. * @param options defines the options used to create the mesh
  144497. * @param scene defines the hosting scene
  144498. * @returns the dashed line mesh
  144499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  144500. */
  144501. static CreateDashedLines(name: string, options: {
  144502. points: Vector3[];
  144503. dashSize?: number;
  144504. gapSize?: number;
  144505. dashNb?: number;
  144506. updatable?: boolean;
  144507. instance?: LinesMesh;
  144508. }, scene?: Nullable<Scene>): LinesMesh;
  144509. /**
  144510. * 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.
  144511. * * 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.
  144512. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144513. * * 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.
  144514. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144515. * * 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
  144516. * * 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
  144517. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144520. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144522. * @param name defines the name of the mesh
  144523. * @param options defines the options used to create the mesh
  144524. * @param scene defines the hosting scene
  144525. * @returns the extruded shape mesh
  144526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144528. */
  144529. static ExtrudeShape(name: string, options: {
  144530. shape: Vector3[];
  144531. path: Vector3[];
  144532. scale?: number;
  144533. rotation?: number;
  144534. cap?: number;
  144535. updatable?: boolean;
  144536. sideOrientation?: number;
  144537. frontUVs?: Vector4;
  144538. backUVs?: Vector4;
  144539. instance?: Mesh;
  144540. invertUV?: boolean;
  144541. }, scene?: Nullable<Scene>): Mesh;
  144542. /**
  144543. * Creates an custom extruded shape mesh.
  144544. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144545. * * 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.
  144546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144547. * * 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
  144548. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144549. * * 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
  144550. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144551. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144552. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144553. * * 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
  144554. * * 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
  144555. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144558. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144560. * @param name defines the name of the mesh
  144561. * @param options defines the options used to create the mesh
  144562. * @param scene defines the hosting scene
  144563. * @returns the custom extruded shape mesh
  144564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144565. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144567. */
  144568. static ExtrudeShapeCustom(name: string, options: {
  144569. shape: Vector3[];
  144570. path: Vector3[];
  144571. scaleFunction?: any;
  144572. rotationFunction?: any;
  144573. ribbonCloseArray?: boolean;
  144574. ribbonClosePath?: boolean;
  144575. cap?: number;
  144576. updatable?: boolean;
  144577. sideOrientation?: number;
  144578. frontUVs?: Vector4;
  144579. backUVs?: Vector4;
  144580. instance?: Mesh;
  144581. invertUV?: boolean;
  144582. }, scene?: Nullable<Scene>): Mesh;
  144583. /**
  144584. * Creates lathe mesh.
  144585. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144586. * * 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
  144587. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144588. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144589. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144590. * * 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
  144591. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144592. * * 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
  144593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144595. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144597. * @param name defines the name of the mesh
  144598. * @param options defines the options used to create the mesh
  144599. * @param scene defines the hosting scene
  144600. * @returns the lathe mesh
  144601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144602. */
  144603. static CreateLathe(name: string, options: {
  144604. shape: Vector3[];
  144605. radius?: number;
  144606. tessellation?: number;
  144607. clip?: number;
  144608. arc?: number;
  144609. closed?: boolean;
  144610. updatable?: boolean;
  144611. sideOrientation?: number;
  144612. frontUVs?: Vector4;
  144613. backUVs?: Vector4;
  144614. cap?: number;
  144615. invertUV?: boolean;
  144616. }, scene?: Nullable<Scene>): Mesh;
  144617. /**
  144618. * Creates a tiled plane mesh
  144619. * * You can set a limited pattern arrangement with the tiles
  144620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144623. * @param name defines the name of the mesh
  144624. * @param options defines the options used to create the mesh
  144625. * @param scene defines the hosting scene
  144626. * @returns the plane mesh
  144627. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144628. */
  144629. static CreateTiledPlane(name: string, options: {
  144630. pattern?: number;
  144631. tileSize?: number;
  144632. tileWidth?: number;
  144633. tileHeight?: number;
  144634. size?: number;
  144635. width?: number;
  144636. height?: number;
  144637. alignHorizontal?: number;
  144638. alignVertical?: number;
  144639. sideOrientation?: number;
  144640. frontUVs?: Vector4;
  144641. backUVs?: Vector4;
  144642. updatable?: boolean;
  144643. }, scene?: Nullable<Scene>): Mesh;
  144644. /**
  144645. * Creates a plane mesh
  144646. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  144647. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  144648. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  144649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144652. * @param name defines the name of the mesh
  144653. * @param options defines the options used to create the mesh
  144654. * @param scene defines the hosting scene
  144655. * @returns the plane mesh
  144656. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144657. */
  144658. static CreatePlane(name: string, options: {
  144659. size?: number;
  144660. width?: number;
  144661. height?: number;
  144662. sideOrientation?: number;
  144663. frontUVs?: Vector4;
  144664. backUVs?: Vector4;
  144665. updatable?: boolean;
  144666. sourcePlane?: Plane;
  144667. }, scene?: Nullable<Scene>): Mesh;
  144668. /**
  144669. * Creates a ground mesh
  144670. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  144671. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  144672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144673. * @param name defines the name of the mesh
  144674. * @param options defines the options used to create the mesh
  144675. * @param scene defines the hosting scene
  144676. * @returns the ground mesh
  144677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  144678. */
  144679. static CreateGround(name: string, options: {
  144680. width?: number;
  144681. height?: number;
  144682. subdivisions?: number;
  144683. subdivisionsX?: number;
  144684. subdivisionsY?: number;
  144685. updatable?: boolean;
  144686. }, scene?: Nullable<Scene>): Mesh;
  144687. /**
  144688. * Creates a tiled ground mesh
  144689. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  144690. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  144691. * * 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
  144692. * * 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
  144693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144694. * @param name defines the name of the mesh
  144695. * @param options defines the options used to create the mesh
  144696. * @param scene defines the hosting scene
  144697. * @returns the tiled ground mesh
  144698. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  144699. */
  144700. static CreateTiledGround(name: string, options: {
  144701. xmin: number;
  144702. zmin: number;
  144703. xmax: number;
  144704. zmax: number;
  144705. subdivisions?: {
  144706. w: number;
  144707. h: number;
  144708. };
  144709. precision?: {
  144710. w: number;
  144711. h: number;
  144712. };
  144713. updatable?: boolean;
  144714. }, scene?: Nullable<Scene>): Mesh;
  144715. /**
  144716. * Creates a ground mesh from a height map
  144717. * * The parameter `url` sets the URL of the height map image resource.
  144718. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  144719. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  144720. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  144721. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  144722. * * 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.
  144723. * * 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).
  144724. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  144725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144726. * @param name defines the name of the mesh
  144727. * @param url defines the url to the height map
  144728. * @param options defines the options used to create the mesh
  144729. * @param scene defines the hosting scene
  144730. * @returns the ground mesh
  144731. * @see https://doc.babylonjs.com/babylon101/height_map
  144732. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  144733. */
  144734. static CreateGroundFromHeightMap(name: string, url: string, options: {
  144735. width?: number;
  144736. height?: number;
  144737. subdivisions?: number;
  144738. minHeight?: number;
  144739. maxHeight?: number;
  144740. colorFilter?: Color3;
  144741. alphaFilter?: number;
  144742. updatable?: boolean;
  144743. onReady?: (mesh: GroundMesh) => void;
  144744. }, scene?: Nullable<Scene>): GroundMesh;
  144745. /**
  144746. * Creates a polygon mesh
  144747. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144748. * * 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
  144749. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144752. * * Remember you can only change the shape positions, not their number when updating a polygon
  144753. * @param name defines the name of the mesh
  144754. * @param options defines the options used to create the mesh
  144755. * @param scene defines the hosting scene
  144756. * @param earcutInjection can be used to inject your own earcut reference
  144757. * @returns the polygon mesh
  144758. */
  144759. static CreatePolygon(name: string, options: {
  144760. shape: Vector3[];
  144761. holes?: Vector3[][];
  144762. depth?: number;
  144763. faceUV?: Vector4[];
  144764. faceColors?: Color4[];
  144765. updatable?: boolean;
  144766. sideOrientation?: number;
  144767. frontUVs?: Vector4;
  144768. backUVs?: Vector4;
  144769. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144770. /**
  144771. * Creates an extruded polygon mesh, with depth in the Y direction.
  144772. * * 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)
  144773. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144774. * @param name defines the name of the mesh
  144775. * @param options defines the options used to create the mesh
  144776. * @param scene defines the hosting scene
  144777. * @param earcutInjection can be used to inject your own earcut reference
  144778. * @returns the polygon mesh
  144779. */
  144780. static ExtrudePolygon(name: string, options: {
  144781. shape: Vector3[];
  144782. holes?: Vector3[][];
  144783. depth?: number;
  144784. faceUV?: Vector4[];
  144785. faceColors?: Color4[];
  144786. updatable?: boolean;
  144787. sideOrientation?: number;
  144788. frontUVs?: Vector4;
  144789. backUVs?: Vector4;
  144790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144791. /**
  144792. * Creates a tube mesh.
  144793. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144794. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144795. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144796. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144797. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144798. * * 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)
  144799. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144800. * * 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
  144801. * * 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
  144802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144804. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144806. * @param name defines the name of the mesh
  144807. * @param options defines the options used to create the mesh
  144808. * @param scene defines the hosting scene
  144809. * @returns the tube mesh
  144810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144811. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144812. */
  144813. static CreateTube(name: string, options: {
  144814. path: Vector3[];
  144815. radius?: number;
  144816. tessellation?: number;
  144817. radiusFunction?: {
  144818. (i: number, distance: number): number;
  144819. };
  144820. cap?: number;
  144821. arc?: number;
  144822. updatable?: boolean;
  144823. sideOrientation?: number;
  144824. frontUVs?: Vector4;
  144825. backUVs?: Vector4;
  144826. instance?: Mesh;
  144827. invertUV?: boolean;
  144828. }, scene?: Nullable<Scene>): Mesh;
  144829. /**
  144830. * Creates a polyhedron mesh
  144831. * * 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
  144832. * * The parameter `size` (positive float, default 1) sets the polygon size
  144833. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  144834. * * 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`
  144835. * * 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
  144836. * * 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)`)
  144837. * * 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
  144838. * * 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
  144839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144842. * @param name defines the name of the mesh
  144843. * @param options defines the options used to create the mesh
  144844. * @param scene defines the hosting scene
  144845. * @returns the polyhedron mesh
  144846. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  144847. */
  144848. static CreatePolyhedron(name: string, options: {
  144849. type?: number;
  144850. size?: number;
  144851. sizeX?: number;
  144852. sizeY?: number;
  144853. sizeZ?: number;
  144854. custom?: any;
  144855. faceUV?: Vector4[];
  144856. faceColors?: Color4[];
  144857. flat?: boolean;
  144858. updatable?: boolean;
  144859. sideOrientation?: number;
  144860. frontUVs?: Vector4;
  144861. backUVs?: Vector4;
  144862. }, scene?: Nullable<Scene>): Mesh;
  144863. /**
  144864. * Creates a decal mesh.
  144865. * 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
  144866. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144867. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144868. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144869. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144870. * @param name defines the name of the mesh
  144871. * @param sourceMesh defines the mesh where the decal must be applied
  144872. * @param options defines the options used to create the mesh
  144873. * @param scene defines the hosting scene
  144874. * @returns the decal mesh
  144875. * @see https://doc.babylonjs.com/how_to/decals
  144876. */
  144877. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144878. position?: Vector3;
  144879. normal?: Vector3;
  144880. size?: Vector3;
  144881. angle?: number;
  144882. }): Mesh;
  144883. }
  144884. }
  144885. declare module BABYLON {
  144886. /**
  144887. * A simplifier interface for future simplification implementations
  144888. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144889. */
  144890. export interface ISimplifier {
  144891. /**
  144892. * Simplification of a given mesh according to the given settings.
  144893. * Since this requires computation, it is assumed that the function runs async.
  144894. * @param settings The settings of the simplification, including quality and distance
  144895. * @param successCallback A callback that will be called after the mesh was simplified.
  144896. * @param errorCallback in case of an error, this callback will be called. optional.
  144897. */
  144898. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  144899. }
  144900. /**
  144901. * Expected simplification settings.
  144902. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  144903. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144904. */
  144905. export interface ISimplificationSettings {
  144906. /**
  144907. * Gets or sets the expected quality
  144908. */
  144909. quality: number;
  144910. /**
  144911. * Gets or sets the distance when this optimized version should be used
  144912. */
  144913. distance: number;
  144914. /**
  144915. * Gets an already optimized mesh
  144916. */
  144917. optimizeMesh?: boolean;
  144918. }
  144919. /**
  144920. * Class used to specify simplification options
  144921. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144922. */
  144923. export class SimplificationSettings implements ISimplificationSettings {
  144924. /** expected quality */
  144925. quality: number;
  144926. /** distance when this optimized version should be used */
  144927. distance: number;
  144928. /** already optimized mesh */
  144929. optimizeMesh?: boolean | undefined;
  144930. /**
  144931. * Creates a SimplificationSettings
  144932. * @param quality expected quality
  144933. * @param distance distance when this optimized version should be used
  144934. * @param optimizeMesh already optimized mesh
  144935. */
  144936. constructor(
  144937. /** expected quality */
  144938. quality: number,
  144939. /** distance when this optimized version should be used */
  144940. distance: number,
  144941. /** already optimized mesh */
  144942. optimizeMesh?: boolean | undefined);
  144943. }
  144944. /**
  144945. * Interface used to define a simplification task
  144946. */
  144947. export interface ISimplificationTask {
  144948. /**
  144949. * Array of settings
  144950. */
  144951. settings: Array<ISimplificationSettings>;
  144952. /**
  144953. * Simplification type
  144954. */
  144955. simplificationType: SimplificationType;
  144956. /**
  144957. * Mesh to simplify
  144958. */
  144959. mesh: Mesh;
  144960. /**
  144961. * Callback called on success
  144962. */
  144963. successCallback?: () => void;
  144964. /**
  144965. * Defines if parallel processing can be used
  144966. */
  144967. parallelProcessing: boolean;
  144968. }
  144969. /**
  144970. * Queue used to order the simplification tasks
  144971. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144972. */
  144973. export class SimplificationQueue {
  144974. private _simplificationArray;
  144975. /**
  144976. * Gets a boolean indicating that the process is still running
  144977. */
  144978. running: boolean;
  144979. /**
  144980. * Creates a new queue
  144981. */
  144982. constructor();
  144983. /**
  144984. * Adds a new simplification task
  144985. * @param task defines a task to add
  144986. */
  144987. addTask(task: ISimplificationTask): void;
  144988. /**
  144989. * Execute next task
  144990. */
  144991. executeNext(): void;
  144992. /**
  144993. * Execute a simplification task
  144994. * @param task defines the task to run
  144995. */
  144996. runSimplification(task: ISimplificationTask): void;
  144997. private getSimplifier;
  144998. }
  144999. /**
  145000. * The implemented types of simplification
  145001. * At the moment only Quadratic Error Decimation is implemented
  145002. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145003. */
  145004. export enum SimplificationType {
  145005. /** Quadratic error decimation */
  145006. QUADRATIC = 0
  145007. }
  145008. /**
  145009. * An implementation of the Quadratic Error simplification algorithm.
  145010. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  145011. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  145012. * @author RaananW
  145013. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145014. */
  145015. export class QuadraticErrorSimplification implements ISimplifier {
  145016. private _mesh;
  145017. private triangles;
  145018. private vertices;
  145019. private references;
  145020. private _reconstructedMesh;
  145021. /** Gets or sets the number pf sync interations */
  145022. syncIterations: number;
  145023. /** Gets or sets the aggressiveness of the simplifier */
  145024. aggressiveness: number;
  145025. /** Gets or sets the number of allowed iterations for decimation */
  145026. decimationIterations: number;
  145027. /** Gets or sets the espilon to use for bounding box computation */
  145028. boundingBoxEpsilon: number;
  145029. /**
  145030. * Creates a new QuadraticErrorSimplification
  145031. * @param _mesh defines the target mesh
  145032. */
  145033. constructor(_mesh: Mesh);
  145034. /**
  145035. * Simplification of a given mesh according to the given settings.
  145036. * Since this requires computation, it is assumed that the function runs async.
  145037. * @param settings The settings of the simplification, including quality and distance
  145038. * @param successCallback A callback that will be called after the mesh was simplified.
  145039. */
  145040. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  145041. private runDecimation;
  145042. private initWithMesh;
  145043. private init;
  145044. private reconstructMesh;
  145045. private initDecimatedMesh;
  145046. private isFlipped;
  145047. private updateTriangles;
  145048. private identifyBorder;
  145049. private updateMesh;
  145050. private vertexError;
  145051. private calculateError;
  145052. }
  145053. }
  145054. declare module BABYLON {
  145055. interface Scene {
  145056. /** @hidden (Backing field) */
  145057. _simplificationQueue: SimplificationQueue;
  145058. /**
  145059. * Gets or sets the simplification queue attached to the scene
  145060. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145061. */
  145062. simplificationQueue: SimplificationQueue;
  145063. }
  145064. interface Mesh {
  145065. /**
  145066. * Simplify the mesh according to the given array of settings.
  145067. * Function will return immediately and will simplify async
  145068. * @param settings a collection of simplification settings
  145069. * @param parallelProcessing should all levels calculate parallel or one after the other
  145070. * @param simplificationType the type of simplification to run
  145071. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  145072. * @returns the current mesh
  145073. */
  145074. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  145075. }
  145076. /**
  145077. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  145078. * created in a scene
  145079. */
  145080. export class SimplicationQueueSceneComponent implements ISceneComponent {
  145081. /**
  145082. * The component name helpfull to identify the component in the list of scene components.
  145083. */
  145084. readonly name: string;
  145085. /**
  145086. * The scene the component belongs to.
  145087. */
  145088. scene: Scene;
  145089. /**
  145090. * Creates a new instance of the component for the given scene
  145091. * @param scene Defines the scene to register the component in
  145092. */
  145093. constructor(scene: Scene);
  145094. /**
  145095. * Registers the component in a given scene
  145096. */
  145097. register(): void;
  145098. /**
  145099. * Rebuilds the elements related to this component in case of
  145100. * context lost for instance.
  145101. */
  145102. rebuild(): void;
  145103. /**
  145104. * Disposes the component and the associated ressources
  145105. */
  145106. dispose(): void;
  145107. private _beforeCameraUpdate;
  145108. }
  145109. }
  145110. declare module BABYLON {
  145111. interface Mesh {
  145112. /**
  145113. * Creates a new thin instance
  145114. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  145115. * @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
  145116. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  145117. */
  145118. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  145119. /**
  145120. * Adds the transformation (matrix) of the current mesh as a thin instance
  145121. * @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
  145122. * @returns the thin instance index number
  145123. */
  145124. thinInstanceAddSelf(refresh: boolean): number;
  145125. /**
  145126. * Registers a custom attribute to be used with thin instances
  145127. * @param kind name of the attribute
  145128. * @param stride size in floats of the attribute
  145129. */
  145130. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  145131. /**
  145132. * Sets the matrix of a thin instance
  145133. * @param index index of the thin instance
  145134. * @param matrix matrix to set
  145135. * @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
  145136. */
  145137. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  145138. /**
  145139. * Sets the value of a custom attribute for a thin instance
  145140. * @param kind name of the attribute
  145141. * @param index index of the thin instance
  145142. * @param value value to set
  145143. * @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
  145144. */
  145145. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  145146. /**
  145147. * 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.
  145148. */
  145149. thinInstanceCount: number;
  145150. /**
  145151. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  145152. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  145153. * @param buffer buffer to set
  145154. * @param stride size in floats of each value of the buffer
  145155. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  145156. */
  145157. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  145158. /**
  145159. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  145160. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  145161. */
  145162. thinInstanceBufferUpdated(kind: string): void;
  145163. /**
  145164. * Refreshes the bounding info, taking into account all the thin instances defined
  145165. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  145166. */
  145167. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  145168. /** @hidden */
  145169. _thinInstanceInitializeUserStorage(): void;
  145170. /** @hidden */
  145171. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  145172. /** @hidden */
  145173. _userThinInstanceBuffersStorage: {
  145174. data: {
  145175. [key: string]: Float32Array;
  145176. };
  145177. sizes: {
  145178. [key: string]: number;
  145179. };
  145180. vertexBuffers: {
  145181. [key: string]: Nullable<VertexBuffer>;
  145182. };
  145183. strides: {
  145184. [key: string]: number;
  145185. };
  145186. };
  145187. }
  145188. }
  145189. declare module BABYLON {
  145190. /**
  145191. * Navigation plugin interface to add navigation constrained by a navigation mesh
  145192. */
  145193. export interface INavigationEnginePlugin {
  145194. /**
  145195. * plugin name
  145196. */
  145197. name: string;
  145198. /**
  145199. * Creates a navigation mesh
  145200. * @param meshes array of all the geometry used to compute the navigatio mesh
  145201. * @param parameters bunch of parameters used to filter geometry
  145202. */
  145203. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145204. /**
  145205. * Create a navigation mesh debug mesh
  145206. * @param scene is where the mesh will be added
  145207. * @returns debug display mesh
  145208. */
  145209. createDebugNavMesh(scene: Scene): Mesh;
  145210. /**
  145211. * Get a navigation mesh constrained position, closest to the parameter position
  145212. * @param position world position
  145213. * @returns the closest point to position constrained by the navigation mesh
  145214. */
  145215. getClosestPoint(position: Vector3): Vector3;
  145216. /**
  145217. * Get a navigation mesh constrained position, closest to the parameter position
  145218. * @param position world position
  145219. * @param result output the closest point to position constrained by the navigation mesh
  145220. */
  145221. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145222. /**
  145223. * Get a navigation mesh constrained position, within a particular radius
  145224. * @param position world position
  145225. * @param maxRadius the maximum distance to the constrained world position
  145226. * @returns the closest point to position constrained by the navigation mesh
  145227. */
  145228. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145229. /**
  145230. * Get a navigation mesh constrained position, within a particular radius
  145231. * @param position world position
  145232. * @param maxRadius the maximum distance to the constrained world position
  145233. * @param result output the closest point to position constrained by the navigation mesh
  145234. */
  145235. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145236. /**
  145237. * Compute the final position from a segment made of destination-position
  145238. * @param position world position
  145239. * @param destination world position
  145240. * @returns the resulting point along the navmesh
  145241. */
  145242. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145243. /**
  145244. * Compute the final position from a segment made of destination-position
  145245. * @param position world position
  145246. * @param destination world position
  145247. * @param result output the resulting point along the navmesh
  145248. */
  145249. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145250. /**
  145251. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145252. * @param start world position
  145253. * @param end world position
  145254. * @returns array containing world position composing the path
  145255. */
  145256. computePath(start: Vector3, end: Vector3): Vector3[];
  145257. /**
  145258. * If this plugin is supported
  145259. * @returns true if plugin is supported
  145260. */
  145261. isSupported(): boolean;
  145262. /**
  145263. * Create a new Crowd so you can add agents
  145264. * @param maxAgents the maximum agent count in the crowd
  145265. * @param maxAgentRadius the maximum radius an agent can have
  145266. * @param scene to attach the crowd to
  145267. * @returns the crowd you can add agents to
  145268. */
  145269. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145270. /**
  145271. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145272. * The queries will try to find a solution within those bounds
  145273. * default is (1,1,1)
  145274. * @param extent x,y,z value that define the extent around the queries point of reference
  145275. */
  145276. setDefaultQueryExtent(extent: Vector3): void;
  145277. /**
  145278. * Get the Bounding box extent specified by setDefaultQueryExtent
  145279. * @returns the box extent values
  145280. */
  145281. getDefaultQueryExtent(): Vector3;
  145282. /**
  145283. * build the navmesh from a previously saved state using getNavmeshData
  145284. * @param data the Uint8Array returned by getNavmeshData
  145285. */
  145286. buildFromNavmeshData(data: Uint8Array): void;
  145287. /**
  145288. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145289. * @returns data the Uint8Array that can be saved and reused
  145290. */
  145291. getNavmeshData(): Uint8Array;
  145292. /**
  145293. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145294. * @param result output the box extent values
  145295. */
  145296. getDefaultQueryExtentToRef(result: Vector3): void;
  145297. /**
  145298. * Release all resources
  145299. */
  145300. dispose(): void;
  145301. }
  145302. /**
  145303. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145304. */
  145305. export interface ICrowd {
  145306. /**
  145307. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145308. * You can attach anything to that node. The node position is updated in the scene update tick.
  145309. * @param pos world position that will be constrained by the navigation mesh
  145310. * @param parameters agent parameters
  145311. * @param transform hooked to the agent that will be update by the scene
  145312. * @returns agent index
  145313. */
  145314. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145315. /**
  145316. * Returns the agent position in world space
  145317. * @param index agent index returned by addAgent
  145318. * @returns world space position
  145319. */
  145320. getAgentPosition(index: number): Vector3;
  145321. /**
  145322. * Gets the agent position result in world space
  145323. * @param index agent index returned by addAgent
  145324. * @param result output world space position
  145325. */
  145326. getAgentPositionToRef(index: number, result: Vector3): void;
  145327. /**
  145328. * Gets the agent velocity in world space
  145329. * @param index agent index returned by addAgent
  145330. * @returns world space velocity
  145331. */
  145332. getAgentVelocity(index: number): Vector3;
  145333. /**
  145334. * Gets the agent velocity result in world space
  145335. * @param index agent index returned by addAgent
  145336. * @param result output world space velocity
  145337. */
  145338. getAgentVelocityToRef(index: number, result: Vector3): void;
  145339. /**
  145340. * remove a particular agent previously created
  145341. * @param index agent index returned by addAgent
  145342. */
  145343. removeAgent(index: number): void;
  145344. /**
  145345. * get the list of all agents attached to this crowd
  145346. * @returns list of agent indices
  145347. */
  145348. getAgents(): number[];
  145349. /**
  145350. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145351. * @param deltaTime in seconds
  145352. */
  145353. update(deltaTime: number): void;
  145354. /**
  145355. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145356. * @param index agent index returned by addAgent
  145357. * @param destination targeted world position
  145358. */
  145359. agentGoto(index: number, destination: Vector3): void;
  145360. /**
  145361. * Teleport the agent to a new position
  145362. * @param index agent index returned by addAgent
  145363. * @param destination targeted world position
  145364. */
  145365. agentTeleport(index: number, destination: Vector3): void;
  145366. /**
  145367. * Update agent parameters
  145368. * @param index agent index returned by addAgent
  145369. * @param parameters agent parameters
  145370. */
  145371. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145372. /**
  145373. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145374. * The queries will try to find a solution within those bounds
  145375. * default is (1,1,1)
  145376. * @param extent x,y,z value that define the extent around the queries point of reference
  145377. */
  145378. setDefaultQueryExtent(extent: Vector3): void;
  145379. /**
  145380. * Get the Bounding box extent specified by setDefaultQueryExtent
  145381. * @returns the box extent values
  145382. */
  145383. getDefaultQueryExtent(): Vector3;
  145384. /**
  145385. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145386. * @param result output the box extent values
  145387. */
  145388. getDefaultQueryExtentToRef(result: Vector3): void;
  145389. /**
  145390. * Release all resources
  145391. */
  145392. dispose(): void;
  145393. }
  145394. /**
  145395. * Configures an agent
  145396. */
  145397. export interface IAgentParameters {
  145398. /**
  145399. * Agent radius. [Limit: >= 0]
  145400. */
  145401. radius: number;
  145402. /**
  145403. * Agent height. [Limit: > 0]
  145404. */
  145405. height: number;
  145406. /**
  145407. * Maximum allowed acceleration. [Limit: >= 0]
  145408. */
  145409. maxAcceleration: number;
  145410. /**
  145411. * Maximum allowed speed. [Limit: >= 0]
  145412. */
  145413. maxSpeed: number;
  145414. /**
  145415. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  145416. */
  145417. collisionQueryRange: number;
  145418. /**
  145419. * The path visibility optimization range. [Limit: > 0]
  145420. */
  145421. pathOptimizationRange: number;
  145422. /**
  145423. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  145424. */
  145425. separationWeight: number;
  145426. }
  145427. /**
  145428. * Configures the navigation mesh creation
  145429. */
  145430. export interface INavMeshParameters {
  145431. /**
  145432. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  145433. */
  145434. cs: number;
  145435. /**
  145436. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  145437. */
  145438. ch: number;
  145439. /**
  145440. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  145441. */
  145442. walkableSlopeAngle: number;
  145443. /**
  145444. * Minimum floor to 'ceiling' height that will still allow the floor area to
  145445. * be considered walkable. [Limit: >= 3] [Units: vx]
  145446. */
  145447. walkableHeight: number;
  145448. /**
  145449. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  145450. */
  145451. walkableClimb: number;
  145452. /**
  145453. * The distance to erode/shrink the walkable area of the heightfield away from
  145454. * obstructions. [Limit: >=0] [Units: vx]
  145455. */
  145456. walkableRadius: number;
  145457. /**
  145458. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  145459. */
  145460. maxEdgeLen: number;
  145461. /**
  145462. * The maximum distance a simplfied contour's border edges should deviate
  145463. * the original raw contour. [Limit: >=0] [Units: vx]
  145464. */
  145465. maxSimplificationError: number;
  145466. /**
  145467. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  145468. */
  145469. minRegionArea: number;
  145470. /**
  145471. * Any regions with a span count smaller than this value will, if possible,
  145472. * be merged with larger regions. [Limit: >=0] [Units: vx]
  145473. */
  145474. mergeRegionArea: number;
  145475. /**
  145476. * The maximum number of vertices allowed for polygons generated during the
  145477. * contour to polygon conversion process. [Limit: >= 3]
  145478. */
  145479. maxVertsPerPoly: number;
  145480. /**
  145481. * Sets the sampling distance to use when generating the detail mesh.
  145482. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  145483. */
  145484. detailSampleDist: number;
  145485. /**
  145486. * The maximum distance the detail mesh surface should deviate from heightfield
  145487. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  145488. */
  145489. detailSampleMaxError: number;
  145490. }
  145491. }
  145492. declare module BABYLON {
  145493. /**
  145494. * RecastJS navigation plugin
  145495. */
  145496. export class RecastJSPlugin implements INavigationEnginePlugin {
  145497. /**
  145498. * Reference to the Recast library
  145499. */
  145500. bjsRECAST: any;
  145501. /**
  145502. * plugin name
  145503. */
  145504. name: string;
  145505. /**
  145506. * the first navmesh created. We might extend this to support multiple navmeshes
  145507. */
  145508. navMesh: any;
  145509. /**
  145510. * Initializes the recastJS plugin
  145511. * @param recastInjection can be used to inject your own recast reference
  145512. */
  145513. constructor(recastInjection?: any);
  145514. /**
  145515. * Creates a navigation mesh
  145516. * @param meshes array of all the geometry used to compute the navigatio mesh
  145517. * @param parameters bunch of parameters used to filter geometry
  145518. */
  145519. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145520. /**
  145521. * Create a navigation mesh debug mesh
  145522. * @param scene is where the mesh will be added
  145523. * @returns debug display mesh
  145524. */
  145525. createDebugNavMesh(scene: Scene): Mesh;
  145526. /**
  145527. * Get a navigation mesh constrained position, closest to the parameter position
  145528. * @param position world position
  145529. * @returns the closest point to position constrained by the navigation mesh
  145530. */
  145531. getClosestPoint(position: Vector3): Vector3;
  145532. /**
  145533. * Get a navigation mesh constrained position, closest to the parameter position
  145534. * @param position world position
  145535. * @param result output the closest point to position constrained by the navigation mesh
  145536. */
  145537. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145538. /**
  145539. * Get a navigation mesh constrained position, within a particular radius
  145540. * @param position world position
  145541. * @param maxRadius the maximum distance to the constrained world position
  145542. * @returns the closest point to position constrained by the navigation mesh
  145543. */
  145544. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145545. /**
  145546. * Get a navigation mesh constrained position, within a particular radius
  145547. * @param position world position
  145548. * @param maxRadius the maximum distance to the constrained world position
  145549. * @param result output the closest point to position constrained by the navigation mesh
  145550. */
  145551. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145552. /**
  145553. * Compute the final position from a segment made of destination-position
  145554. * @param position world position
  145555. * @param destination world position
  145556. * @returns the resulting point along the navmesh
  145557. */
  145558. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145559. /**
  145560. * Compute the final position from a segment made of destination-position
  145561. * @param position world position
  145562. * @param destination world position
  145563. * @param result output the resulting point along the navmesh
  145564. */
  145565. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145566. /**
  145567. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145568. * @param start world position
  145569. * @param end world position
  145570. * @returns array containing world position composing the path
  145571. */
  145572. computePath(start: Vector3, end: Vector3): Vector3[];
  145573. /**
  145574. * Create a new Crowd so you can add agents
  145575. * @param maxAgents the maximum agent count in the crowd
  145576. * @param maxAgentRadius the maximum radius an agent can have
  145577. * @param scene to attach the crowd to
  145578. * @returns the crowd you can add agents to
  145579. */
  145580. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145581. /**
  145582. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145583. * The queries will try to find a solution within those bounds
  145584. * default is (1,1,1)
  145585. * @param extent x,y,z value that define the extent around the queries point of reference
  145586. */
  145587. setDefaultQueryExtent(extent: Vector3): void;
  145588. /**
  145589. * Get the Bounding box extent specified by setDefaultQueryExtent
  145590. * @returns the box extent values
  145591. */
  145592. getDefaultQueryExtent(): Vector3;
  145593. /**
  145594. * build the navmesh from a previously saved state using getNavmeshData
  145595. * @param data the Uint8Array returned by getNavmeshData
  145596. */
  145597. buildFromNavmeshData(data: Uint8Array): void;
  145598. /**
  145599. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145600. * @returns data the Uint8Array that can be saved and reused
  145601. */
  145602. getNavmeshData(): Uint8Array;
  145603. /**
  145604. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145605. * @param result output the box extent values
  145606. */
  145607. getDefaultQueryExtentToRef(result: Vector3): void;
  145608. /**
  145609. * Disposes
  145610. */
  145611. dispose(): void;
  145612. /**
  145613. * If this plugin is supported
  145614. * @returns true if plugin is supported
  145615. */
  145616. isSupported(): boolean;
  145617. }
  145618. /**
  145619. * Recast detour crowd implementation
  145620. */
  145621. export class RecastJSCrowd implements ICrowd {
  145622. /**
  145623. * Recast/detour plugin
  145624. */
  145625. bjsRECASTPlugin: RecastJSPlugin;
  145626. /**
  145627. * Link to the detour crowd
  145628. */
  145629. recastCrowd: any;
  145630. /**
  145631. * One transform per agent
  145632. */
  145633. transforms: TransformNode[];
  145634. /**
  145635. * All agents created
  145636. */
  145637. agents: number[];
  145638. /**
  145639. * Link to the scene is kept to unregister the crowd from the scene
  145640. */
  145641. private _scene;
  145642. /**
  145643. * Observer for crowd updates
  145644. */
  145645. private _onBeforeAnimationsObserver;
  145646. /**
  145647. * Constructor
  145648. * @param plugin recastJS plugin
  145649. * @param maxAgents the maximum agent count in the crowd
  145650. * @param maxAgentRadius the maximum radius an agent can have
  145651. * @param scene to attach the crowd to
  145652. * @returns the crowd you can add agents to
  145653. */
  145654. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  145655. /**
  145656. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145657. * You can attach anything to that node. The node position is updated in the scene update tick.
  145658. * @param pos world position that will be constrained by the navigation mesh
  145659. * @param parameters agent parameters
  145660. * @param transform hooked to the agent that will be update by the scene
  145661. * @returns agent index
  145662. */
  145663. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145664. /**
  145665. * Returns the agent position in world space
  145666. * @param index agent index returned by addAgent
  145667. * @returns world space position
  145668. */
  145669. getAgentPosition(index: number): Vector3;
  145670. /**
  145671. * Returns the agent position result in world space
  145672. * @param index agent index returned by addAgent
  145673. * @param result output world space position
  145674. */
  145675. getAgentPositionToRef(index: number, result: Vector3): void;
  145676. /**
  145677. * Returns the agent velocity in world space
  145678. * @param index agent index returned by addAgent
  145679. * @returns world space velocity
  145680. */
  145681. getAgentVelocity(index: number): Vector3;
  145682. /**
  145683. * Returns the agent velocity result in world space
  145684. * @param index agent index returned by addAgent
  145685. * @param result output world space velocity
  145686. */
  145687. getAgentVelocityToRef(index: number, result: Vector3): void;
  145688. /**
  145689. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145690. * @param index agent index returned by addAgent
  145691. * @param destination targeted world position
  145692. */
  145693. agentGoto(index: number, destination: Vector3): void;
  145694. /**
  145695. * Teleport the agent to a new position
  145696. * @param index agent index returned by addAgent
  145697. * @param destination targeted world position
  145698. */
  145699. agentTeleport(index: number, destination: Vector3): void;
  145700. /**
  145701. * Update agent parameters
  145702. * @param index agent index returned by addAgent
  145703. * @param parameters agent parameters
  145704. */
  145705. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145706. /**
  145707. * remove a particular agent previously created
  145708. * @param index agent index returned by addAgent
  145709. */
  145710. removeAgent(index: number): void;
  145711. /**
  145712. * get the list of all agents attached to this crowd
  145713. * @returns list of agent indices
  145714. */
  145715. getAgents(): number[];
  145716. /**
  145717. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145718. * @param deltaTime in seconds
  145719. */
  145720. update(deltaTime: number): void;
  145721. /**
  145722. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145723. * The queries will try to find a solution within those bounds
  145724. * default is (1,1,1)
  145725. * @param extent x,y,z value that define the extent around the queries point of reference
  145726. */
  145727. setDefaultQueryExtent(extent: Vector3): void;
  145728. /**
  145729. * Get the Bounding box extent specified by setDefaultQueryExtent
  145730. * @returns the box extent values
  145731. */
  145732. getDefaultQueryExtent(): Vector3;
  145733. /**
  145734. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145735. * @param result output the box extent values
  145736. */
  145737. getDefaultQueryExtentToRef(result: Vector3): void;
  145738. /**
  145739. * Release all resources
  145740. */
  145741. dispose(): void;
  145742. }
  145743. }
  145744. declare module BABYLON {
  145745. /**
  145746. * Class used to enable access to IndexedDB
  145747. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  145748. */
  145749. export class Database implements IOfflineProvider {
  145750. private _callbackManifestChecked;
  145751. private _currentSceneUrl;
  145752. private _db;
  145753. private _enableSceneOffline;
  145754. private _enableTexturesOffline;
  145755. private _manifestVersionFound;
  145756. private _mustUpdateRessources;
  145757. private _hasReachedQuota;
  145758. private _isSupported;
  145759. private _idbFactory;
  145760. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  145761. private static IsUASupportingBlobStorage;
  145762. /**
  145763. * Gets a boolean indicating if Database storate is enabled (off by default)
  145764. */
  145765. static IDBStorageEnabled: boolean;
  145766. /**
  145767. * Gets a boolean indicating if scene must be saved in the database
  145768. */
  145769. get enableSceneOffline(): boolean;
  145770. /**
  145771. * Gets a boolean indicating if textures must be saved in the database
  145772. */
  145773. get enableTexturesOffline(): boolean;
  145774. /**
  145775. * Creates a new Database
  145776. * @param urlToScene defines the url to load the scene
  145777. * @param callbackManifestChecked defines the callback to use when manifest is checked
  145778. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  145779. */
  145780. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  145781. private static _ParseURL;
  145782. private static _ReturnFullUrlLocation;
  145783. private _checkManifestFile;
  145784. /**
  145785. * Open the database and make it available
  145786. * @param successCallback defines the callback to call on success
  145787. * @param errorCallback defines the callback to call on error
  145788. */
  145789. open(successCallback: () => void, errorCallback: () => void): void;
  145790. /**
  145791. * Loads an image from the database
  145792. * @param url defines the url to load from
  145793. * @param image defines the target DOM image
  145794. */
  145795. loadImage(url: string, image: HTMLImageElement): void;
  145796. private _loadImageFromDBAsync;
  145797. private _saveImageIntoDBAsync;
  145798. private _checkVersionFromDB;
  145799. private _loadVersionFromDBAsync;
  145800. private _saveVersionIntoDBAsync;
  145801. /**
  145802. * Loads a file from database
  145803. * @param url defines the URL to load from
  145804. * @param sceneLoaded defines a callback to call on success
  145805. * @param progressCallBack defines a callback to call when progress changed
  145806. * @param errorCallback defines a callback to call on error
  145807. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  145808. */
  145809. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  145810. private _loadFileAsync;
  145811. private _saveFileAsync;
  145812. /**
  145813. * Validates if xhr data is correct
  145814. * @param xhr defines the request to validate
  145815. * @param dataType defines the expected data type
  145816. * @returns true if data is correct
  145817. */
  145818. private static _ValidateXHRData;
  145819. }
  145820. }
  145821. declare module BABYLON {
  145822. /** @hidden */
  145823. export var gpuUpdateParticlesPixelShader: {
  145824. name: string;
  145825. shader: string;
  145826. };
  145827. }
  145828. declare module BABYLON {
  145829. /** @hidden */
  145830. export var gpuUpdateParticlesVertexShader: {
  145831. name: string;
  145832. shader: string;
  145833. };
  145834. }
  145835. declare module BABYLON {
  145836. /** @hidden */
  145837. export var clipPlaneFragmentDeclaration2: {
  145838. name: string;
  145839. shader: string;
  145840. };
  145841. }
  145842. declare module BABYLON {
  145843. /** @hidden */
  145844. export var gpuRenderParticlesPixelShader: {
  145845. name: string;
  145846. shader: string;
  145847. };
  145848. }
  145849. declare module BABYLON {
  145850. /** @hidden */
  145851. export var clipPlaneVertexDeclaration2: {
  145852. name: string;
  145853. shader: string;
  145854. };
  145855. }
  145856. declare module BABYLON {
  145857. /** @hidden */
  145858. export var gpuRenderParticlesVertexShader: {
  145859. name: string;
  145860. shader: string;
  145861. };
  145862. }
  145863. declare module BABYLON {
  145864. /**
  145865. * This represents a GPU particle system in Babylon
  145866. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  145867. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  145868. */
  145869. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  145870. /**
  145871. * The layer mask we are rendering the particles through.
  145872. */
  145873. layerMask: number;
  145874. private _capacity;
  145875. private _activeCount;
  145876. private _currentActiveCount;
  145877. private _accumulatedCount;
  145878. private _renderEffect;
  145879. private _updateEffect;
  145880. private _buffer0;
  145881. private _buffer1;
  145882. private _spriteBuffer;
  145883. private _updateVAO;
  145884. private _renderVAO;
  145885. private _targetIndex;
  145886. private _sourceBuffer;
  145887. private _targetBuffer;
  145888. private _engine;
  145889. private _currentRenderId;
  145890. private _started;
  145891. private _stopped;
  145892. private _timeDelta;
  145893. private _randomTexture;
  145894. private _randomTexture2;
  145895. private _attributesStrideSize;
  145896. private _updateEffectOptions;
  145897. private _randomTextureSize;
  145898. private _actualFrame;
  145899. private _customEffect;
  145900. private readonly _rawTextureWidth;
  145901. /**
  145902. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  145903. */
  145904. static get IsSupported(): boolean;
  145905. /**
  145906. * An event triggered when the system is disposed.
  145907. */
  145908. onDisposeObservable: Observable<IParticleSystem>;
  145909. /**
  145910. * Gets the maximum number of particles active at the same time.
  145911. * @returns The max number of active particles.
  145912. */
  145913. getCapacity(): number;
  145914. /**
  145915. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  145916. * to override the particles.
  145917. */
  145918. forceDepthWrite: boolean;
  145919. /**
  145920. * Gets or set the number of active particles
  145921. */
  145922. get activeParticleCount(): number;
  145923. set activeParticleCount(value: number);
  145924. private _preWarmDone;
  145925. /**
  145926. * Specifies if the particles are updated in emitter local space or world space.
  145927. */
  145928. isLocal: boolean;
  145929. /**
  145930. * Is this system ready to be used/rendered
  145931. * @return true if the system is ready
  145932. */
  145933. isReady(): boolean;
  145934. /**
  145935. * Gets if the system has been started. (Note: this will still be true after stop is called)
  145936. * @returns True if it has been started, otherwise false.
  145937. */
  145938. isStarted(): boolean;
  145939. /**
  145940. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  145941. * @returns True if it has been stopped, otherwise false.
  145942. */
  145943. isStopped(): boolean;
  145944. /**
  145945. * Gets a boolean indicating that the system is stopping
  145946. * @returns true if the system is currently stopping
  145947. */
  145948. isStopping(): boolean;
  145949. /**
  145950. * Gets the number of particles active at the same time.
  145951. * @returns The number of active particles.
  145952. */
  145953. getActiveCount(): number;
  145954. /**
  145955. * Starts the particle system and begins to emit
  145956. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  145957. */
  145958. start(delay?: number): void;
  145959. /**
  145960. * Stops the particle system.
  145961. */
  145962. stop(): void;
  145963. /**
  145964. * Remove all active particles
  145965. */
  145966. reset(): void;
  145967. /**
  145968. * Returns the string "GPUParticleSystem"
  145969. * @returns a string containing the class name
  145970. */
  145971. getClassName(): string;
  145972. /**
  145973. * Gets the custom effect used to render the particles
  145974. * @param blendMode Blend mode for which the effect should be retrieved
  145975. * @returns The effect
  145976. */
  145977. getCustomEffect(blendMode?: number): Nullable<Effect>;
  145978. /**
  145979. * Sets the custom effect used to render the particles
  145980. * @param effect The effect to set
  145981. * @param blendMode Blend mode for which the effect should be set
  145982. */
  145983. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  145984. /** @hidden */
  145985. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  145986. /**
  145987. * Observable that will be called just before the particles are drawn
  145988. */
  145989. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  145990. /**
  145991. * Gets the name of the particle vertex shader
  145992. */
  145993. get vertexShaderName(): string;
  145994. private _colorGradientsTexture;
  145995. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  145996. /**
  145997. * Adds a new color gradient
  145998. * @param gradient defines the gradient to use (between 0 and 1)
  145999. * @param color1 defines the color to affect to the specified gradient
  146000. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  146001. * @returns the current particle system
  146002. */
  146003. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  146004. private _refreshColorGradient;
  146005. /** Force the system to rebuild all gradients that need to be resync */
  146006. forceRefreshGradients(): void;
  146007. /**
  146008. * Remove a specific color gradient
  146009. * @param gradient defines the gradient to remove
  146010. * @returns the current particle system
  146011. */
  146012. removeColorGradient(gradient: number): GPUParticleSystem;
  146013. private _angularSpeedGradientsTexture;
  146014. private _sizeGradientsTexture;
  146015. private _velocityGradientsTexture;
  146016. private _limitVelocityGradientsTexture;
  146017. private _dragGradientsTexture;
  146018. private _addFactorGradient;
  146019. /**
  146020. * Adds a new size gradient
  146021. * @param gradient defines the gradient to use (between 0 and 1)
  146022. * @param factor defines the size factor to affect to the specified gradient
  146023. * @returns the current particle system
  146024. */
  146025. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  146026. /**
  146027. * Remove a specific size gradient
  146028. * @param gradient defines the gradient to remove
  146029. * @returns the current particle system
  146030. */
  146031. removeSizeGradient(gradient: number): GPUParticleSystem;
  146032. private _refreshFactorGradient;
  146033. /**
  146034. * Adds a new angular speed gradient
  146035. * @param gradient defines the gradient to use (between 0 and 1)
  146036. * @param factor defines the angular speed to affect to the specified gradient
  146037. * @returns the current particle system
  146038. */
  146039. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  146040. /**
  146041. * Remove a specific angular speed gradient
  146042. * @param gradient defines the gradient to remove
  146043. * @returns the current particle system
  146044. */
  146045. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  146046. /**
  146047. * Adds a new velocity gradient
  146048. * @param gradient defines the gradient to use (between 0 and 1)
  146049. * @param factor defines the velocity to affect to the specified gradient
  146050. * @returns the current particle system
  146051. */
  146052. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146053. /**
  146054. * Remove a specific velocity gradient
  146055. * @param gradient defines the gradient to remove
  146056. * @returns the current particle system
  146057. */
  146058. removeVelocityGradient(gradient: number): GPUParticleSystem;
  146059. /**
  146060. * Adds a new limit velocity gradient
  146061. * @param gradient defines the gradient to use (between 0 and 1)
  146062. * @param factor defines the limit velocity value to affect to the specified gradient
  146063. * @returns the current particle system
  146064. */
  146065. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146066. /**
  146067. * Remove a specific limit velocity gradient
  146068. * @param gradient defines the gradient to remove
  146069. * @returns the current particle system
  146070. */
  146071. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  146072. /**
  146073. * Adds a new drag gradient
  146074. * @param gradient defines the gradient to use (between 0 and 1)
  146075. * @param factor defines the drag value to affect to the specified gradient
  146076. * @returns the current particle system
  146077. */
  146078. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  146079. /**
  146080. * Remove a specific drag gradient
  146081. * @param gradient defines the gradient to remove
  146082. * @returns the current particle system
  146083. */
  146084. removeDragGradient(gradient: number): GPUParticleSystem;
  146085. /**
  146086. * Not supported by GPUParticleSystem
  146087. * @param gradient defines the gradient to use (between 0 and 1)
  146088. * @param factor defines the emit rate value to affect to the specified gradient
  146089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146090. * @returns the current particle system
  146091. */
  146092. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146093. /**
  146094. * Not supported by GPUParticleSystem
  146095. * @param gradient defines the gradient to remove
  146096. * @returns the current particle system
  146097. */
  146098. removeEmitRateGradient(gradient: number): IParticleSystem;
  146099. /**
  146100. * Not supported by GPUParticleSystem
  146101. * @param gradient defines the gradient to use (between 0 and 1)
  146102. * @param factor defines the start size value to affect to the specified gradient
  146103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146104. * @returns the current particle system
  146105. */
  146106. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146107. /**
  146108. * Not supported by GPUParticleSystem
  146109. * @param gradient defines the gradient to remove
  146110. * @returns the current particle system
  146111. */
  146112. removeStartSizeGradient(gradient: number): IParticleSystem;
  146113. /**
  146114. * Not supported by GPUParticleSystem
  146115. * @param gradient defines the gradient to use (between 0 and 1)
  146116. * @param min defines the color remap minimal range
  146117. * @param max defines the color remap maximal range
  146118. * @returns the current particle system
  146119. */
  146120. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146121. /**
  146122. * Not supported by GPUParticleSystem
  146123. * @param gradient defines the gradient to remove
  146124. * @returns the current particle system
  146125. */
  146126. removeColorRemapGradient(): IParticleSystem;
  146127. /**
  146128. * Not supported by GPUParticleSystem
  146129. * @param gradient defines the gradient to use (between 0 and 1)
  146130. * @param min defines the alpha remap minimal range
  146131. * @param max defines the alpha remap maximal range
  146132. * @returns the current particle system
  146133. */
  146134. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146135. /**
  146136. * Not supported by GPUParticleSystem
  146137. * @param gradient defines the gradient to remove
  146138. * @returns the current particle system
  146139. */
  146140. removeAlphaRemapGradient(): IParticleSystem;
  146141. /**
  146142. * Not supported by GPUParticleSystem
  146143. * @param gradient defines the gradient to use (between 0 and 1)
  146144. * @param color defines the color to affect to the specified gradient
  146145. * @returns the current particle system
  146146. */
  146147. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  146148. /**
  146149. * Not supported by GPUParticleSystem
  146150. * @param gradient defines the gradient to remove
  146151. * @returns the current particle system
  146152. */
  146153. removeRampGradient(): IParticleSystem;
  146154. /**
  146155. * Not supported by GPUParticleSystem
  146156. * @returns the list of ramp gradients
  146157. */
  146158. getRampGradients(): Nullable<Array<Color3Gradient>>;
  146159. /**
  146160. * Not supported by GPUParticleSystem
  146161. * Gets or sets a boolean indicating that ramp gradients must be used
  146162. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  146163. */
  146164. get useRampGradients(): boolean;
  146165. set useRampGradients(value: boolean);
  146166. /**
  146167. * Not supported by GPUParticleSystem
  146168. * @param gradient defines the gradient to use (between 0 and 1)
  146169. * @param factor defines the life time factor to affect to the specified gradient
  146170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146171. * @returns the current particle system
  146172. */
  146173. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146174. /**
  146175. * Not supported by GPUParticleSystem
  146176. * @param gradient defines the gradient to remove
  146177. * @returns the current particle system
  146178. */
  146179. removeLifeTimeGradient(gradient: number): IParticleSystem;
  146180. /**
  146181. * Instantiates a GPU particle system.
  146182. * 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.
  146183. * @param name The name of the particle system
  146184. * @param options The options used to create the system
  146185. * @param scene The scene the particle system belongs to
  146186. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  146187. * @param customEffect a custom effect used to change the way particles are rendered by default
  146188. */
  146189. constructor(name: string, options: Partial<{
  146190. capacity: number;
  146191. randomTextureSize: number;
  146192. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  146193. protected _reset(): void;
  146194. private _createUpdateVAO;
  146195. private _createRenderVAO;
  146196. private _initialize;
  146197. /** @hidden */
  146198. _recreateUpdateEffect(): void;
  146199. private _getEffect;
  146200. /**
  146201. * Fill the defines array according to the current settings of the particle system
  146202. * @param defines Array to be updated
  146203. * @param blendMode blend mode to take into account when updating the array
  146204. */
  146205. fillDefines(defines: Array<string>, blendMode?: number): void;
  146206. /**
  146207. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  146208. * @param uniforms Uniforms array to fill
  146209. * @param attributes Attributes array to fill
  146210. * @param samplers Samplers array to fill
  146211. */
  146212. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  146213. /** @hidden */
  146214. _recreateRenderEffect(): Effect;
  146215. /**
  146216. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  146217. * @param preWarm defines if we are in the pre-warmimg phase
  146218. */
  146219. animate(preWarm?: boolean): void;
  146220. private _createFactorGradientTexture;
  146221. private _createSizeGradientTexture;
  146222. private _createAngularSpeedGradientTexture;
  146223. private _createVelocityGradientTexture;
  146224. private _createLimitVelocityGradientTexture;
  146225. private _createDragGradientTexture;
  146226. private _createColorGradientTexture;
  146227. /**
  146228. * Renders the particle system in its current state
  146229. * @param preWarm defines if the system should only update the particles but not render them
  146230. * @returns the current number of particles
  146231. */
  146232. render(preWarm?: boolean): number;
  146233. /**
  146234. * Rebuilds the particle system
  146235. */
  146236. rebuild(): void;
  146237. private _releaseBuffers;
  146238. private _releaseVAOs;
  146239. /**
  146240. * Disposes the particle system and free the associated resources
  146241. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  146242. */
  146243. dispose(disposeTexture?: boolean): void;
  146244. /**
  146245. * Clones the particle system.
  146246. * @param name The name of the cloned object
  146247. * @param newEmitter The new emitter to use
  146248. * @returns the cloned particle system
  146249. */
  146250. clone(name: string, newEmitter: any): GPUParticleSystem;
  146251. /**
  146252. * Serializes the particle system to a JSON object
  146253. * @param serializeTexture defines if the texture must be serialized as well
  146254. * @returns the JSON object
  146255. */
  146256. serialize(serializeTexture?: boolean): any;
  146257. /**
  146258. * Parses a JSON object to create a GPU particle system.
  146259. * @param parsedParticleSystem The JSON object to parse
  146260. * @param scene The scene to create the particle system in
  146261. * @param rootUrl The root url to use to load external dependencies like texture
  146262. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146263. * @returns the parsed GPU particle system
  146264. */
  146265. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146266. }
  146267. }
  146268. declare module BABYLON {
  146269. /**
  146270. * Represents a set of particle systems working together to create a specific effect
  146271. */
  146272. export class ParticleSystemSet implements IDisposable {
  146273. /**
  146274. * Gets or sets base Assets URL
  146275. */
  146276. static BaseAssetsUrl: string;
  146277. private _emitterCreationOptions;
  146278. private _emitterNode;
  146279. /**
  146280. * Gets the particle system list
  146281. */
  146282. systems: IParticleSystem[];
  146283. /**
  146284. * Gets the emitter node used with this set
  146285. */
  146286. get emitterNode(): Nullable<TransformNode>;
  146287. /**
  146288. * Creates a new emitter mesh as a sphere
  146289. * @param options defines the options used to create the sphere
  146290. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146291. * @param scene defines the hosting scene
  146292. */
  146293. setEmitterAsSphere(options: {
  146294. diameter: number;
  146295. segments: number;
  146296. color: Color3;
  146297. }, renderingGroupId: number, scene: Scene): void;
  146298. /**
  146299. * Starts all particle systems of the set
  146300. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146301. */
  146302. start(emitter?: AbstractMesh): void;
  146303. /**
  146304. * Release all associated resources
  146305. */
  146306. dispose(): void;
  146307. /**
  146308. * Serialize the set into a JSON compatible object
  146309. * @param serializeTexture defines if the texture must be serialized as well
  146310. * @returns a JSON compatible representation of the set
  146311. */
  146312. serialize(serializeTexture?: boolean): any;
  146313. /**
  146314. * Parse a new ParticleSystemSet from a serialized source
  146315. * @param data defines a JSON compatible representation of the set
  146316. * @param scene defines the hosting scene
  146317. * @param gpu defines if we want GPU particles or CPU particles
  146318. * @returns a new ParticleSystemSet
  146319. */
  146320. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  146321. }
  146322. }
  146323. declare module BABYLON {
  146324. /**
  146325. * This class is made for on one-liner static method to help creating particle system set.
  146326. */
  146327. export class ParticleHelper {
  146328. /**
  146329. * Gets or sets base Assets URL
  146330. */
  146331. static BaseAssetsUrl: string;
  146332. /** Define the Url to load snippets */
  146333. static SnippetUrl: string;
  146334. /**
  146335. * Create a default particle system that you can tweak
  146336. * @param emitter defines the emitter to use
  146337. * @param capacity defines the system capacity (default is 500 particles)
  146338. * @param scene defines the hosting scene
  146339. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  146340. * @returns the new Particle system
  146341. */
  146342. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  146343. /**
  146344. * This is the main static method (one-liner) of this helper to create different particle systems
  146345. * @param type This string represents the type to the particle system to create
  146346. * @param scene The scene where the particle system should live
  146347. * @param gpu If the system will use gpu
  146348. * @returns the ParticleSystemSet created
  146349. */
  146350. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  146351. /**
  146352. * Static function used to export a particle system to a ParticleSystemSet variable.
  146353. * Please note that the emitter shape is not exported
  146354. * @param systems defines the particle systems to export
  146355. * @returns the created particle system set
  146356. */
  146357. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  146358. /**
  146359. * Creates a particle system from a snippet saved in a remote file
  146360. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  146361. * @param url defines the url to load from
  146362. * @param scene defines the hosting scene
  146363. * @param gpu If the system will use gpu
  146364. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146365. * @returns a promise that will resolve to the new particle system
  146366. */
  146367. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146368. /**
  146369. * Creates a particle system from a snippet saved by the particle system editor
  146370. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  146371. * @param scene defines the hosting scene
  146372. * @param gpu If the system will use gpu
  146373. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146374. * @returns a promise that will resolve to the new particle system
  146375. */
  146376. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146377. }
  146378. }
  146379. declare module BABYLON {
  146380. interface Engine {
  146381. /**
  146382. * Create an effect to use with particle systems.
  146383. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  146384. * the particle system for which you want to create a custom effect in the last parameter
  146385. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  146386. * @param uniformsNames defines a list of attribute names
  146387. * @param samplers defines an array of string used to represent textures
  146388. * @param defines defines the string containing the defines to use to compile the shaders
  146389. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  146390. * @param onCompiled defines a function to call when the effect creation is successful
  146391. * @param onError defines a function to call when the effect creation has failed
  146392. * @param particleSystem the particle system you want to create the effect for
  146393. * @returns the new Effect
  146394. */
  146395. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  146396. }
  146397. interface Mesh {
  146398. /**
  146399. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  146400. * @returns an array of IParticleSystem
  146401. */
  146402. getEmittedParticleSystems(): IParticleSystem[];
  146403. /**
  146404. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  146405. * @returns an array of IParticleSystem
  146406. */
  146407. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  146408. }
  146409. }
  146410. declare module BABYLON {
  146411. /** Defines the 4 color options */
  146412. export enum PointColor {
  146413. /** color value */
  146414. Color = 2,
  146415. /** uv value */
  146416. UV = 1,
  146417. /** random value */
  146418. Random = 0,
  146419. /** stated value */
  146420. Stated = 3
  146421. }
  146422. /**
  146423. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  146424. * 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.
  146425. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  146426. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  146427. *
  146428. * Full documentation here : TO BE ENTERED
  146429. */
  146430. export class PointsCloudSystem implements IDisposable {
  146431. /**
  146432. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  146433. * Example : var p = SPS.particles[i];
  146434. */
  146435. particles: CloudPoint[];
  146436. /**
  146437. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  146438. */
  146439. nbParticles: number;
  146440. /**
  146441. * This a counter for your own usage. It's not set by any SPS functions.
  146442. */
  146443. counter: number;
  146444. /**
  146445. * The PCS name. This name is also given to the underlying mesh.
  146446. */
  146447. name: string;
  146448. /**
  146449. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  146450. */
  146451. mesh: Mesh;
  146452. /**
  146453. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  146454. * Please read :
  146455. */
  146456. vars: any;
  146457. /**
  146458. * @hidden
  146459. */
  146460. _size: number;
  146461. private _scene;
  146462. private _promises;
  146463. private _positions;
  146464. private _indices;
  146465. private _normals;
  146466. private _colors;
  146467. private _uvs;
  146468. private _indices32;
  146469. private _positions32;
  146470. private _colors32;
  146471. private _uvs32;
  146472. private _updatable;
  146473. private _isVisibilityBoxLocked;
  146474. private _alwaysVisible;
  146475. private _groups;
  146476. private _groupCounter;
  146477. private _computeParticleColor;
  146478. private _computeParticleTexture;
  146479. private _computeParticleRotation;
  146480. private _computeBoundingBox;
  146481. private _isReady;
  146482. /**
  146483. * Creates a PCS (Points Cloud System) object
  146484. * @param name (String) is the PCS name, this will be the underlying mesh name
  146485. * @param pointSize (number) is the size for each point
  146486. * @param scene (Scene) is the scene in which the PCS is added
  146487. * @param options defines the options of the PCS e.g.
  146488. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  146489. */
  146490. constructor(name: string, pointSize: number, scene: Scene, options?: {
  146491. updatable?: boolean;
  146492. });
  146493. /**
  146494. * Builds the PCS underlying mesh. Returns a standard Mesh.
  146495. * If no points were added to the PCS, the returned mesh is just a single point.
  146496. * @returns a promise for the created mesh
  146497. */
  146498. buildMeshAsync(): Promise<Mesh>;
  146499. /**
  146500. * @hidden
  146501. */
  146502. private _buildMesh;
  146503. private _addParticle;
  146504. private _randomUnitVector;
  146505. private _getColorIndicesForCoord;
  146506. private _setPointsColorOrUV;
  146507. private _colorFromTexture;
  146508. private _calculateDensity;
  146509. /**
  146510. * Adds points to the PCS in random positions within a unit sphere
  146511. * @param nb (positive integer) the number of particles to be created from this model
  146512. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  146513. * @returns the number of groups in the system
  146514. */
  146515. addPoints(nb: number, pointFunction?: any): number;
  146516. /**
  146517. * Adds points to the PCS from the surface of the model shape
  146518. * @param mesh is any Mesh object that will be used as a surface model for the points
  146519. * @param nb (positive integer) the number of particles to be created from this model
  146520. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146521. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146522. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146523. * @returns the number of groups in the system
  146524. */
  146525. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146526. /**
  146527. * Adds points to the PCS inside the model shape
  146528. * @param mesh is any Mesh object that will be used as a surface model for the points
  146529. * @param nb (positive integer) the number of particles to be created from this model
  146530. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146531. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146532. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146533. * @returns the number of groups in the system
  146534. */
  146535. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146536. /**
  146537. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  146538. * This method calls `updateParticle()` for each particle of the SPS.
  146539. * For an animated SPS, it is usually called within the render loop.
  146540. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  146541. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  146542. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  146543. * @returns the PCS.
  146544. */
  146545. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  146546. /**
  146547. * Disposes the PCS.
  146548. */
  146549. dispose(): void;
  146550. /**
  146551. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  146552. * doc :
  146553. * @returns the PCS.
  146554. */
  146555. refreshVisibleSize(): PointsCloudSystem;
  146556. /**
  146557. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  146558. * @param size the size (float) of the visibility box
  146559. * note : this doesn't lock the PCS mesh bounding box.
  146560. * doc :
  146561. */
  146562. setVisibilityBox(size: number): void;
  146563. /**
  146564. * Gets whether the PCS is always visible or not
  146565. * doc :
  146566. */
  146567. get isAlwaysVisible(): boolean;
  146568. /**
  146569. * Sets the PCS as always visible or not
  146570. * doc :
  146571. */
  146572. set isAlwaysVisible(val: boolean);
  146573. /**
  146574. * Tells to `setParticles()` to compute the particle rotations or not
  146575. * Default value : false. The PCS is faster when it's set to false
  146576. * Note : particle rotations are only applied to parent particles
  146577. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  146578. */
  146579. set computeParticleRotation(val: boolean);
  146580. /**
  146581. * Tells to `setParticles()` to compute the particle colors or not.
  146582. * Default value : true. The PCS is faster when it's set to false.
  146583. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146584. */
  146585. set computeParticleColor(val: boolean);
  146586. set computeParticleTexture(val: boolean);
  146587. /**
  146588. * Gets if `setParticles()` computes the particle colors or not.
  146589. * Default value : false. The PCS is faster when it's set to false.
  146590. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146591. */
  146592. get computeParticleColor(): boolean;
  146593. /**
  146594. * Gets if `setParticles()` computes the particle textures or not.
  146595. * Default value : false. The PCS is faster when it's set to false.
  146596. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  146597. */
  146598. get computeParticleTexture(): boolean;
  146599. /**
  146600. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  146601. */
  146602. set computeBoundingBox(val: boolean);
  146603. /**
  146604. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  146605. */
  146606. get computeBoundingBox(): boolean;
  146607. /**
  146608. * This function does nothing. It may be overwritten to set all the particle first values.
  146609. * The PCS doesn't call this function, you may have to call it by your own.
  146610. * doc :
  146611. */
  146612. initParticles(): void;
  146613. /**
  146614. * This function does nothing. It may be overwritten to recycle a particle
  146615. * The PCS doesn't call this function, you can to call it
  146616. * doc :
  146617. * @param particle The particle to recycle
  146618. * @returns the recycled particle
  146619. */
  146620. recycleParticle(particle: CloudPoint): CloudPoint;
  146621. /**
  146622. * Updates a particle : this function should be overwritten by the user.
  146623. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  146624. * doc :
  146625. * @example : just set a particle position or velocity and recycle conditions
  146626. * @param particle The particle to update
  146627. * @returns the updated particle
  146628. */
  146629. updateParticle(particle: CloudPoint): CloudPoint;
  146630. /**
  146631. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  146632. * This does nothing and may be overwritten by the user.
  146633. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146634. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146635. * @param update the boolean update value actually passed to setParticles()
  146636. */
  146637. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146638. /**
  146639. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  146640. * This will be passed three parameters.
  146641. * This does nothing and may be overwritten by the user.
  146642. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146643. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146644. * @param update the boolean update value actually passed to setParticles()
  146645. */
  146646. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146647. }
  146648. }
  146649. declare module BABYLON {
  146650. /**
  146651. * Represents one particle of a points cloud system.
  146652. */
  146653. export class CloudPoint {
  146654. /**
  146655. * particle global index
  146656. */
  146657. idx: number;
  146658. /**
  146659. * The color of the particle
  146660. */
  146661. color: Nullable<Color4>;
  146662. /**
  146663. * The world space position of the particle.
  146664. */
  146665. position: Vector3;
  146666. /**
  146667. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  146668. */
  146669. rotation: Vector3;
  146670. /**
  146671. * The world space rotation quaternion of the particle.
  146672. */
  146673. rotationQuaternion: Nullable<Quaternion>;
  146674. /**
  146675. * The uv of the particle.
  146676. */
  146677. uv: Nullable<Vector2>;
  146678. /**
  146679. * The current speed of the particle.
  146680. */
  146681. velocity: Vector3;
  146682. /**
  146683. * The pivot point in the particle local space.
  146684. */
  146685. pivot: Vector3;
  146686. /**
  146687. * Must the particle be translated from its pivot point in its local space ?
  146688. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  146689. * Default : false
  146690. */
  146691. translateFromPivot: boolean;
  146692. /**
  146693. * Index of this particle in the global "positions" array (Internal use)
  146694. * @hidden
  146695. */
  146696. _pos: number;
  146697. /**
  146698. * @hidden Index of this particle in the global "indices" array (Internal use)
  146699. */
  146700. _ind: number;
  146701. /**
  146702. * Group this particle belongs to
  146703. */
  146704. _group: PointsGroup;
  146705. /**
  146706. * Group id of this particle
  146707. */
  146708. groupId: number;
  146709. /**
  146710. * Index of the particle in its group id (Internal use)
  146711. */
  146712. idxInGroup: number;
  146713. /**
  146714. * @hidden Particle BoundingInfo object (Internal use)
  146715. */
  146716. _boundingInfo: BoundingInfo;
  146717. /**
  146718. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  146719. */
  146720. _pcs: PointsCloudSystem;
  146721. /**
  146722. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  146723. */
  146724. _stillInvisible: boolean;
  146725. /**
  146726. * @hidden Last computed particle rotation matrix
  146727. */
  146728. _rotationMatrix: number[];
  146729. /**
  146730. * Parent particle Id, if any.
  146731. * Default null.
  146732. */
  146733. parentId: Nullable<number>;
  146734. /**
  146735. * @hidden Internal global position in the PCS.
  146736. */
  146737. _globalPosition: Vector3;
  146738. /**
  146739. * Creates a Point Cloud object.
  146740. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  146741. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  146742. * @param group (PointsGroup) is the group the particle belongs to
  146743. * @param groupId (integer) is the group identifier in the PCS.
  146744. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  146745. * @param pcs defines the PCS it is associated to
  146746. */
  146747. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  146748. /**
  146749. * get point size
  146750. */
  146751. get size(): Vector3;
  146752. /**
  146753. * Set point size
  146754. */
  146755. set size(scale: Vector3);
  146756. /**
  146757. * Legacy support, changed quaternion to rotationQuaternion
  146758. */
  146759. get quaternion(): Nullable<Quaternion>;
  146760. /**
  146761. * Legacy support, changed quaternion to rotationQuaternion
  146762. */
  146763. set quaternion(q: Nullable<Quaternion>);
  146764. /**
  146765. * Returns a boolean. True if the particle intersects a mesh, else false
  146766. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  146767. * @param target is the object (point or mesh) what the intersection is computed against
  146768. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  146769. * @returns true if it intersects
  146770. */
  146771. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  146772. /**
  146773. * get the rotation matrix of the particle
  146774. * @hidden
  146775. */
  146776. getRotationMatrix(m: Matrix): void;
  146777. }
  146778. /**
  146779. * Represents a group of points in a points cloud system
  146780. * * PCS internal tool, don't use it manually.
  146781. */
  146782. export class PointsGroup {
  146783. /**
  146784. * The group id
  146785. * @hidden
  146786. */
  146787. groupID: number;
  146788. /**
  146789. * image data for group (internal use)
  146790. * @hidden
  146791. */
  146792. _groupImageData: Nullable<ArrayBufferView>;
  146793. /**
  146794. * Image Width (internal use)
  146795. * @hidden
  146796. */
  146797. _groupImgWidth: number;
  146798. /**
  146799. * Image Height (internal use)
  146800. * @hidden
  146801. */
  146802. _groupImgHeight: number;
  146803. /**
  146804. * Custom position function (internal use)
  146805. * @hidden
  146806. */
  146807. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  146808. /**
  146809. * density per facet for surface points
  146810. * @hidden
  146811. */
  146812. _groupDensity: number[];
  146813. /**
  146814. * Only when points are colored by texture carries pointer to texture list array
  146815. * @hidden
  146816. */
  146817. _textureNb: number;
  146818. /**
  146819. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  146820. * PCS internal tool, don't use it manually.
  146821. * @hidden
  146822. */
  146823. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  146824. }
  146825. }
  146826. declare module BABYLON {
  146827. interface Scene {
  146828. /** @hidden (Backing field) */
  146829. _physicsEngine: Nullable<IPhysicsEngine>;
  146830. /** @hidden */
  146831. _physicsTimeAccumulator: number;
  146832. /**
  146833. * Gets the current physics engine
  146834. * @returns a IPhysicsEngine or null if none attached
  146835. */
  146836. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  146837. /**
  146838. * Enables physics to the current scene
  146839. * @param gravity defines the scene's gravity for the physics engine
  146840. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  146841. * @return a boolean indicating if the physics engine was initialized
  146842. */
  146843. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  146844. /**
  146845. * Disables and disposes the physics engine associated with the scene
  146846. */
  146847. disablePhysicsEngine(): void;
  146848. /**
  146849. * Gets a boolean indicating if there is an active physics engine
  146850. * @returns a boolean indicating if there is an active physics engine
  146851. */
  146852. isPhysicsEnabled(): boolean;
  146853. /**
  146854. * Deletes a physics compound impostor
  146855. * @param compound defines the compound to delete
  146856. */
  146857. deleteCompoundImpostor(compound: any): void;
  146858. /**
  146859. * An event triggered when physic simulation is about to be run
  146860. */
  146861. onBeforePhysicsObservable: Observable<Scene>;
  146862. /**
  146863. * An event triggered when physic simulation has been done
  146864. */
  146865. onAfterPhysicsObservable: Observable<Scene>;
  146866. }
  146867. interface AbstractMesh {
  146868. /** @hidden */
  146869. _physicsImpostor: Nullable<PhysicsImpostor>;
  146870. /**
  146871. * Gets or sets impostor used for physic simulation
  146872. * @see https://doc.babylonjs.com/features/physics_engine
  146873. */
  146874. physicsImpostor: Nullable<PhysicsImpostor>;
  146875. /**
  146876. * Gets the current physics impostor
  146877. * @see https://doc.babylonjs.com/features/physics_engine
  146878. * @returns a physics impostor or null
  146879. */
  146880. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  146881. /** Apply a physic impulse to the mesh
  146882. * @param force defines the force to apply
  146883. * @param contactPoint defines where to apply the force
  146884. * @returns the current mesh
  146885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  146886. */
  146887. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  146888. /**
  146889. * Creates a physic joint between two meshes
  146890. * @param otherMesh defines the other mesh to use
  146891. * @param pivot1 defines the pivot to use on this mesh
  146892. * @param pivot2 defines the pivot to use on the other mesh
  146893. * @param options defines additional options (can be plugin dependent)
  146894. * @returns the current mesh
  146895. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  146896. */
  146897. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  146898. /** @hidden */
  146899. _disposePhysicsObserver: Nullable<Observer<Node>>;
  146900. }
  146901. /**
  146902. * Defines the physics engine scene component responsible to manage a physics engine
  146903. */
  146904. export class PhysicsEngineSceneComponent implements ISceneComponent {
  146905. /**
  146906. * The component name helpful to identify the component in the list of scene components.
  146907. */
  146908. readonly name: string;
  146909. /**
  146910. * The scene the component belongs to.
  146911. */
  146912. scene: Scene;
  146913. /**
  146914. * Creates a new instance of the component for the given scene
  146915. * @param scene Defines the scene to register the component in
  146916. */
  146917. constructor(scene: Scene);
  146918. /**
  146919. * Registers the component in a given scene
  146920. */
  146921. register(): void;
  146922. /**
  146923. * Rebuilds the elements related to this component in case of
  146924. * context lost for instance.
  146925. */
  146926. rebuild(): void;
  146927. /**
  146928. * Disposes the component and the associated ressources
  146929. */
  146930. dispose(): void;
  146931. }
  146932. }
  146933. declare module BABYLON {
  146934. /**
  146935. * A helper for physics simulations
  146936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146937. */
  146938. export class PhysicsHelper {
  146939. private _scene;
  146940. private _physicsEngine;
  146941. /**
  146942. * Initializes the Physics helper
  146943. * @param scene Babylon.js scene
  146944. */
  146945. constructor(scene: Scene);
  146946. /**
  146947. * Applies a radial explosion impulse
  146948. * @param origin the origin of the explosion
  146949. * @param radiusOrEventOptions the radius or the options of radial explosion
  146950. * @param strength the explosion strength
  146951. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146952. * @returns A physics radial explosion event, or null
  146953. */
  146954. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146955. /**
  146956. * Applies a radial explosion force
  146957. * @param origin the origin of the explosion
  146958. * @param radiusOrEventOptions the radius or the options of radial explosion
  146959. * @param strength the explosion strength
  146960. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146961. * @returns A physics radial explosion event, or null
  146962. */
  146963. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146964. /**
  146965. * Creates a gravitational field
  146966. * @param origin the origin of the explosion
  146967. * @param radiusOrEventOptions the radius or the options of radial explosion
  146968. * @param strength the explosion strength
  146969. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146970. * @returns A physics gravitational field event, or null
  146971. */
  146972. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  146973. /**
  146974. * Creates a physics updraft event
  146975. * @param origin the origin of the updraft
  146976. * @param radiusOrEventOptions the radius or the options of the updraft
  146977. * @param strength the strength of the updraft
  146978. * @param height the height of the updraft
  146979. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  146980. * @returns A physics updraft event, or null
  146981. */
  146982. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  146983. /**
  146984. * Creates a physics vortex event
  146985. * @param origin the of the vortex
  146986. * @param radiusOrEventOptions the radius or the options of the vortex
  146987. * @param strength the strength of the vortex
  146988. * @param height the height of the vortex
  146989. * @returns a Physics vortex event, or null
  146990. * A physics vortex event or null
  146991. */
  146992. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  146993. }
  146994. /**
  146995. * Represents a physics radial explosion event
  146996. */
  146997. class PhysicsRadialExplosionEvent {
  146998. private _scene;
  146999. private _options;
  147000. private _sphere;
  147001. private _dataFetched;
  147002. /**
  147003. * Initializes a radial explosioin event
  147004. * @param _scene BabylonJS scene
  147005. * @param _options The options for the vortex event
  147006. */
  147007. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  147008. /**
  147009. * Returns the data related to the radial explosion event (sphere).
  147010. * @returns The radial explosion event data
  147011. */
  147012. getData(): PhysicsRadialExplosionEventData;
  147013. /**
  147014. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  147015. * @param impostor A physics imposter
  147016. * @param origin the origin of the explosion
  147017. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  147018. */
  147019. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  147020. /**
  147021. * Triggers affecterd impostors callbacks
  147022. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  147023. */
  147024. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  147025. /**
  147026. * Disposes the sphere.
  147027. * @param force Specifies if the sphere should be disposed by force
  147028. */
  147029. dispose(force?: boolean): void;
  147030. /*** Helpers ***/
  147031. private _prepareSphere;
  147032. private _intersectsWithSphere;
  147033. }
  147034. /**
  147035. * Represents a gravitational field event
  147036. */
  147037. class PhysicsGravitationalFieldEvent {
  147038. private _physicsHelper;
  147039. private _scene;
  147040. private _origin;
  147041. private _options;
  147042. private _tickCallback;
  147043. private _sphere;
  147044. private _dataFetched;
  147045. /**
  147046. * Initializes the physics gravitational field event
  147047. * @param _physicsHelper A physics helper
  147048. * @param _scene BabylonJS scene
  147049. * @param _origin The origin position of the gravitational field event
  147050. * @param _options The options for the vortex event
  147051. */
  147052. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  147053. /**
  147054. * Returns the data related to the gravitational field event (sphere).
  147055. * @returns A gravitational field event
  147056. */
  147057. getData(): PhysicsGravitationalFieldEventData;
  147058. /**
  147059. * Enables the gravitational field.
  147060. */
  147061. enable(): void;
  147062. /**
  147063. * Disables the gravitational field.
  147064. */
  147065. disable(): void;
  147066. /**
  147067. * Disposes the sphere.
  147068. * @param force The force to dispose from the gravitational field event
  147069. */
  147070. dispose(force?: boolean): void;
  147071. private _tick;
  147072. }
  147073. /**
  147074. * Represents a physics updraft event
  147075. */
  147076. class PhysicsUpdraftEvent {
  147077. private _scene;
  147078. private _origin;
  147079. private _options;
  147080. private _physicsEngine;
  147081. private _originTop;
  147082. private _originDirection;
  147083. private _tickCallback;
  147084. private _cylinder;
  147085. private _cylinderPosition;
  147086. private _dataFetched;
  147087. /**
  147088. * Initializes the physics updraft event
  147089. * @param _scene BabylonJS scene
  147090. * @param _origin The origin position of the updraft
  147091. * @param _options The options for the updraft event
  147092. */
  147093. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  147094. /**
  147095. * Returns the data related to the updraft event (cylinder).
  147096. * @returns A physics updraft event
  147097. */
  147098. getData(): PhysicsUpdraftEventData;
  147099. /**
  147100. * Enables the updraft.
  147101. */
  147102. enable(): void;
  147103. /**
  147104. * Disables the updraft.
  147105. */
  147106. disable(): void;
  147107. /**
  147108. * Disposes the cylinder.
  147109. * @param force Specifies if the updraft should be disposed by force
  147110. */
  147111. dispose(force?: boolean): void;
  147112. private getImpostorHitData;
  147113. private _tick;
  147114. /*** Helpers ***/
  147115. private _prepareCylinder;
  147116. private _intersectsWithCylinder;
  147117. }
  147118. /**
  147119. * Represents a physics vortex event
  147120. */
  147121. class PhysicsVortexEvent {
  147122. private _scene;
  147123. private _origin;
  147124. private _options;
  147125. private _physicsEngine;
  147126. private _originTop;
  147127. private _tickCallback;
  147128. private _cylinder;
  147129. private _cylinderPosition;
  147130. private _dataFetched;
  147131. /**
  147132. * Initializes the physics vortex event
  147133. * @param _scene The BabylonJS scene
  147134. * @param _origin The origin position of the vortex
  147135. * @param _options The options for the vortex event
  147136. */
  147137. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  147138. /**
  147139. * Returns the data related to the vortex event (cylinder).
  147140. * @returns The physics vortex event data
  147141. */
  147142. getData(): PhysicsVortexEventData;
  147143. /**
  147144. * Enables the vortex.
  147145. */
  147146. enable(): void;
  147147. /**
  147148. * Disables the cortex.
  147149. */
  147150. disable(): void;
  147151. /**
  147152. * Disposes the sphere.
  147153. * @param force
  147154. */
  147155. dispose(force?: boolean): void;
  147156. private getImpostorHitData;
  147157. private _tick;
  147158. /*** Helpers ***/
  147159. private _prepareCylinder;
  147160. private _intersectsWithCylinder;
  147161. }
  147162. /**
  147163. * Options fot the radial explosion event
  147164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147165. */
  147166. export class PhysicsRadialExplosionEventOptions {
  147167. /**
  147168. * The radius of the sphere for the radial explosion.
  147169. */
  147170. radius: number;
  147171. /**
  147172. * The strenth of the explosion.
  147173. */
  147174. strength: number;
  147175. /**
  147176. * The strenght of the force in correspondence to the distance of the affected object
  147177. */
  147178. falloff: PhysicsRadialImpulseFalloff;
  147179. /**
  147180. * Sphere options for the radial explosion.
  147181. */
  147182. sphere: {
  147183. segments: number;
  147184. diameter: number;
  147185. };
  147186. /**
  147187. * Sphere options for the radial explosion.
  147188. */
  147189. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  147190. }
  147191. /**
  147192. * Options fot the updraft event
  147193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147194. */
  147195. export class PhysicsUpdraftEventOptions {
  147196. /**
  147197. * The radius of the cylinder for the vortex
  147198. */
  147199. radius: number;
  147200. /**
  147201. * The strenth of the updraft.
  147202. */
  147203. strength: number;
  147204. /**
  147205. * The height of the cylinder for the updraft.
  147206. */
  147207. height: number;
  147208. /**
  147209. * The mode for the the updraft.
  147210. */
  147211. updraftMode: PhysicsUpdraftMode;
  147212. }
  147213. /**
  147214. * Options fot the vortex event
  147215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147216. */
  147217. export class PhysicsVortexEventOptions {
  147218. /**
  147219. * The radius of the cylinder for the vortex
  147220. */
  147221. radius: number;
  147222. /**
  147223. * The strenth of the vortex.
  147224. */
  147225. strength: number;
  147226. /**
  147227. * The height of the cylinder for the vortex.
  147228. */
  147229. height: number;
  147230. /**
  147231. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  147232. */
  147233. centripetalForceThreshold: number;
  147234. /**
  147235. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  147236. */
  147237. centripetalForceMultiplier: number;
  147238. /**
  147239. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  147240. */
  147241. centrifugalForceMultiplier: number;
  147242. /**
  147243. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  147244. */
  147245. updraftForceMultiplier: number;
  147246. }
  147247. /**
  147248. * The strenght of the force in correspondence to the distance of the affected object
  147249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147250. */
  147251. export enum PhysicsRadialImpulseFalloff {
  147252. /** Defines that impulse is constant in strength across it's whole radius */
  147253. Constant = 0,
  147254. /** Defines that impulse gets weaker if it's further from the origin */
  147255. Linear = 1
  147256. }
  147257. /**
  147258. * The strength of the force in correspondence to the distance of the affected object
  147259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147260. */
  147261. export enum PhysicsUpdraftMode {
  147262. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147263. Center = 0,
  147264. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147265. Perpendicular = 1
  147266. }
  147267. /**
  147268. * Interface for a physics hit data
  147269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147270. */
  147271. export interface PhysicsHitData {
  147272. /**
  147273. * The force applied at the contact point
  147274. */
  147275. force: Vector3;
  147276. /**
  147277. * The contact point
  147278. */
  147279. contactPoint: Vector3;
  147280. /**
  147281. * The distance from the origin to the contact point
  147282. */
  147283. distanceFromOrigin: number;
  147284. }
  147285. /**
  147286. * Interface for radial explosion event data
  147287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147288. */
  147289. export interface PhysicsRadialExplosionEventData {
  147290. /**
  147291. * A sphere used for the radial explosion event
  147292. */
  147293. sphere: Mesh;
  147294. }
  147295. /**
  147296. * Interface for gravitational field event data
  147297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147298. */
  147299. export interface PhysicsGravitationalFieldEventData {
  147300. /**
  147301. * A sphere mesh used for the gravitational field event
  147302. */
  147303. sphere: Mesh;
  147304. }
  147305. /**
  147306. * Interface for updraft event data
  147307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147308. */
  147309. export interface PhysicsUpdraftEventData {
  147310. /**
  147311. * A cylinder used for the updraft event
  147312. */
  147313. cylinder: Mesh;
  147314. }
  147315. /**
  147316. * Interface for vortex event data
  147317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147318. */
  147319. export interface PhysicsVortexEventData {
  147320. /**
  147321. * A cylinder used for the vortex event
  147322. */
  147323. cylinder: Mesh;
  147324. }
  147325. /**
  147326. * Interface for an affected physics impostor
  147327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147328. */
  147329. export interface PhysicsAffectedImpostorWithData {
  147330. /**
  147331. * The impostor affected by the effect
  147332. */
  147333. impostor: PhysicsImpostor;
  147334. /**
  147335. * The data about the hit/horce from the explosion
  147336. */
  147337. hitData: PhysicsHitData;
  147338. }
  147339. }
  147340. declare module BABYLON {
  147341. /** @hidden */
  147342. export var blackAndWhitePixelShader: {
  147343. name: string;
  147344. shader: string;
  147345. };
  147346. }
  147347. declare module BABYLON {
  147348. /**
  147349. * Post process used to render in black and white
  147350. */
  147351. export class BlackAndWhitePostProcess extends PostProcess {
  147352. /**
  147353. * Linear about to convert he result to black and white (default: 1)
  147354. */
  147355. degree: number;
  147356. /**
  147357. * Creates a black and white post process
  147358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  147359. * @param name The name of the effect.
  147360. * @param options The required width/height ratio to downsize to before computing the render pass.
  147361. * @param camera The camera to apply the render pass to.
  147362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147363. * @param engine The engine which the post process will be applied. (default: current engine)
  147364. * @param reusable If the post process can be reused on the same frame. (default: false)
  147365. */
  147366. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147367. }
  147368. }
  147369. declare module BABYLON {
  147370. /**
  147371. * This represents a set of one or more post processes in Babylon.
  147372. * A post process can be used to apply a shader to a texture after it is rendered.
  147373. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147374. */
  147375. export class PostProcessRenderEffect {
  147376. private _postProcesses;
  147377. private _getPostProcesses;
  147378. private _singleInstance;
  147379. private _cameras;
  147380. private _indicesForCamera;
  147381. /**
  147382. * Name of the effect
  147383. * @hidden
  147384. */
  147385. _name: string;
  147386. /**
  147387. * Instantiates a post process render effect.
  147388. * A post process can be used to apply a shader to a texture after it is rendered.
  147389. * @param engine The engine the effect is tied to
  147390. * @param name The name of the effect
  147391. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  147392. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  147393. */
  147394. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  147395. /**
  147396. * Checks if all the post processes in the effect are supported.
  147397. */
  147398. get isSupported(): boolean;
  147399. /**
  147400. * Updates the current state of the effect
  147401. * @hidden
  147402. */
  147403. _update(): void;
  147404. /**
  147405. * Attaches the effect on cameras
  147406. * @param cameras The camera to attach to.
  147407. * @hidden
  147408. */
  147409. _attachCameras(cameras: Camera): void;
  147410. /**
  147411. * Attaches the effect on cameras
  147412. * @param cameras The camera to attach to.
  147413. * @hidden
  147414. */
  147415. _attachCameras(cameras: Camera[]): void;
  147416. /**
  147417. * Detaches the effect on cameras
  147418. * @param cameras The camera to detatch from.
  147419. * @hidden
  147420. */
  147421. _detachCameras(cameras: Camera): void;
  147422. /**
  147423. * Detatches the effect on cameras
  147424. * @param cameras The camera to detatch from.
  147425. * @hidden
  147426. */
  147427. _detachCameras(cameras: Camera[]): void;
  147428. /**
  147429. * Enables the effect on given cameras
  147430. * @param cameras The camera to enable.
  147431. * @hidden
  147432. */
  147433. _enable(cameras: Camera): void;
  147434. /**
  147435. * Enables the effect on given cameras
  147436. * @param cameras The camera to enable.
  147437. * @hidden
  147438. */
  147439. _enable(cameras: Nullable<Camera[]>): void;
  147440. /**
  147441. * Disables the effect on the given cameras
  147442. * @param cameras The camera to disable.
  147443. * @hidden
  147444. */
  147445. _disable(cameras: Camera): void;
  147446. /**
  147447. * Disables the effect on the given cameras
  147448. * @param cameras The camera to disable.
  147449. * @hidden
  147450. */
  147451. _disable(cameras: Nullable<Camera[]>): void;
  147452. /**
  147453. * Gets a list of the post processes contained in the effect.
  147454. * @param camera The camera to get the post processes on.
  147455. * @returns The list of the post processes in the effect.
  147456. */
  147457. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  147458. }
  147459. }
  147460. declare module BABYLON {
  147461. /** @hidden */
  147462. export var extractHighlightsPixelShader: {
  147463. name: string;
  147464. shader: string;
  147465. };
  147466. }
  147467. declare module BABYLON {
  147468. /**
  147469. * 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.
  147470. */
  147471. export class ExtractHighlightsPostProcess extends PostProcess {
  147472. /**
  147473. * The luminance threshold, pixels below this value will be set to black.
  147474. */
  147475. threshold: number;
  147476. /** @hidden */
  147477. _exposure: number;
  147478. /**
  147479. * Post process which has the input texture to be used when performing highlight extraction
  147480. * @hidden
  147481. */
  147482. _inputPostProcess: Nullable<PostProcess>;
  147483. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147484. }
  147485. }
  147486. declare module BABYLON {
  147487. /** @hidden */
  147488. export var bloomMergePixelShader: {
  147489. name: string;
  147490. shader: string;
  147491. };
  147492. }
  147493. declare module BABYLON {
  147494. /**
  147495. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147496. */
  147497. export class BloomMergePostProcess extends PostProcess {
  147498. /** Weight of the bloom to be added to the original input. */
  147499. weight: number;
  147500. /**
  147501. * Creates a new instance of @see BloomMergePostProcess
  147502. * @param name The name of the effect.
  147503. * @param originalFromInput Post process which's input will be used for the merge.
  147504. * @param blurred Blurred highlights post process which's output will be used.
  147505. * @param weight Weight of the bloom to be added to the original input.
  147506. * @param options The required width/height ratio to downsize to before computing the render pass.
  147507. * @param camera The camera to apply the render pass to.
  147508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147509. * @param engine The engine which the post process will be applied. (default: current engine)
  147510. * @param reusable If the post process can be reused on the same frame. (default: false)
  147511. * @param textureType Type of textures used when performing the post process. (default: 0)
  147512. * @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)
  147513. */
  147514. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  147515. /** Weight of the bloom to be added to the original input. */
  147516. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147517. }
  147518. }
  147519. declare module BABYLON {
  147520. /**
  147521. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  147522. */
  147523. export class BloomEffect extends PostProcessRenderEffect {
  147524. private bloomScale;
  147525. /**
  147526. * @hidden Internal
  147527. */
  147528. _effects: Array<PostProcess>;
  147529. /**
  147530. * @hidden Internal
  147531. */
  147532. _downscale: ExtractHighlightsPostProcess;
  147533. private _blurX;
  147534. private _blurY;
  147535. private _merge;
  147536. /**
  147537. * The luminance threshold to find bright areas of the image to bloom.
  147538. */
  147539. get threshold(): number;
  147540. set threshold(value: number);
  147541. /**
  147542. * The strength of the bloom.
  147543. */
  147544. get weight(): number;
  147545. set weight(value: number);
  147546. /**
  147547. * Specifies the size of the bloom blur kernel, relative to the final output size
  147548. */
  147549. get kernel(): number;
  147550. set kernel(value: number);
  147551. /**
  147552. * Creates a new instance of @see BloomEffect
  147553. * @param scene The scene the effect belongs to.
  147554. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  147555. * @param bloomKernel The size of the kernel to be used when applying the blur.
  147556. * @param bloomWeight The the strength of bloom.
  147557. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147558. * @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)
  147559. */
  147560. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  147561. /**
  147562. * Disposes each of the internal effects for a given camera.
  147563. * @param camera The camera to dispose the effect on.
  147564. */
  147565. disposeEffects(camera: Camera): void;
  147566. /**
  147567. * @hidden Internal
  147568. */
  147569. _updateEffects(): void;
  147570. /**
  147571. * Internal
  147572. * @returns if all the contained post processes are ready.
  147573. * @hidden
  147574. */
  147575. _isReady(): boolean;
  147576. }
  147577. }
  147578. declare module BABYLON {
  147579. /** @hidden */
  147580. export var chromaticAberrationPixelShader: {
  147581. name: string;
  147582. shader: string;
  147583. };
  147584. }
  147585. declare module BABYLON {
  147586. /**
  147587. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  147588. */
  147589. export class ChromaticAberrationPostProcess extends PostProcess {
  147590. /**
  147591. * The amount of seperation of rgb channels (default: 30)
  147592. */
  147593. aberrationAmount: number;
  147594. /**
  147595. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  147596. */
  147597. radialIntensity: number;
  147598. /**
  147599. * 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))
  147600. */
  147601. direction: Vector2;
  147602. /**
  147603. * 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))
  147604. */
  147605. centerPosition: Vector2;
  147606. /**
  147607. * Creates a new instance ChromaticAberrationPostProcess
  147608. * @param name The name of the effect.
  147609. * @param screenWidth The width of the screen to apply the effect on.
  147610. * @param screenHeight The height of the screen to apply the effect on.
  147611. * @param options The required width/height ratio to downsize to before computing the render pass.
  147612. * @param camera The camera to apply the render pass to.
  147613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147614. * @param engine The engine which the post process will be applied. (default: current engine)
  147615. * @param reusable If the post process can be reused on the same frame. (default: false)
  147616. * @param textureType Type of textures used when performing the post process. (default: 0)
  147617. * @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)
  147618. */
  147619. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147620. }
  147621. }
  147622. declare module BABYLON {
  147623. /** @hidden */
  147624. export var circleOfConfusionPixelShader: {
  147625. name: string;
  147626. shader: string;
  147627. };
  147628. }
  147629. declare module BABYLON {
  147630. /**
  147631. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  147632. */
  147633. export class CircleOfConfusionPostProcess extends PostProcess {
  147634. /**
  147635. * 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.
  147636. */
  147637. lensSize: number;
  147638. /**
  147639. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147640. */
  147641. fStop: number;
  147642. /**
  147643. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147644. */
  147645. focusDistance: number;
  147646. /**
  147647. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  147648. */
  147649. focalLength: number;
  147650. private _depthTexture;
  147651. /**
  147652. * Creates a new instance CircleOfConfusionPostProcess
  147653. * @param name The name of the effect.
  147654. * @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.
  147655. * @param options The required width/height ratio to downsize to before computing the render pass.
  147656. * @param camera The camera to apply the render pass to.
  147657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147658. * @param engine The engine which the post process will be applied. (default: current engine)
  147659. * @param reusable If the post process can be reused on the same frame. (default: false)
  147660. * @param textureType Type of textures used when performing the post process. (default: 0)
  147661. * @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)
  147662. */
  147663. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147664. /**
  147665. * 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.
  147666. */
  147667. set depthTexture(value: RenderTargetTexture);
  147668. }
  147669. }
  147670. declare module BABYLON {
  147671. /** @hidden */
  147672. export var colorCorrectionPixelShader: {
  147673. name: string;
  147674. shader: string;
  147675. };
  147676. }
  147677. declare module BABYLON {
  147678. /**
  147679. *
  147680. * This post-process allows the modification of rendered colors by using
  147681. * a 'look-up table' (LUT). This effect is also called Color Grading.
  147682. *
  147683. * The object needs to be provided an url to a texture containing the color
  147684. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  147685. * Use an image editing software to tweak the LUT to match your needs.
  147686. *
  147687. * For an example of a color LUT, see here:
  147688. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  147689. * For explanations on color grading, see here:
  147690. * @see http://udn.epicgames.com/Three/ColorGrading.html
  147691. *
  147692. */
  147693. export class ColorCorrectionPostProcess extends PostProcess {
  147694. private _colorTableTexture;
  147695. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147696. }
  147697. }
  147698. declare module BABYLON {
  147699. /** @hidden */
  147700. export var convolutionPixelShader: {
  147701. name: string;
  147702. shader: string;
  147703. };
  147704. }
  147705. declare module BABYLON {
  147706. /**
  147707. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  147708. * input texture to perform effects such as edge detection or sharpening
  147709. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147710. */
  147711. export class ConvolutionPostProcess extends PostProcess {
  147712. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147713. kernel: number[];
  147714. /**
  147715. * Creates a new instance ConvolutionPostProcess
  147716. * @param name The name of the effect.
  147717. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  147718. * @param options The required width/height ratio to downsize to before computing the render pass.
  147719. * @param camera The camera to apply the render pass to.
  147720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147721. * @param engine The engine which the post process will be applied. (default: current engine)
  147722. * @param reusable If the post process can be reused on the same frame. (default: false)
  147723. * @param textureType Type of textures used when performing the post process. (default: 0)
  147724. */
  147725. constructor(name: string,
  147726. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147727. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147728. /**
  147729. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147730. */
  147731. static EdgeDetect0Kernel: number[];
  147732. /**
  147733. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147734. */
  147735. static EdgeDetect1Kernel: number[];
  147736. /**
  147737. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147738. */
  147739. static EdgeDetect2Kernel: number[];
  147740. /**
  147741. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147742. */
  147743. static SharpenKernel: number[];
  147744. /**
  147745. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147746. */
  147747. static EmbossKernel: number[];
  147748. /**
  147749. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147750. */
  147751. static GaussianKernel: number[];
  147752. }
  147753. }
  147754. declare module BABYLON {
  147755. /**
  147756. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  147757. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  147758. * based on samples that have a large difference in distance than the center pixel.
  147759. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  147760. */
  147761. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  147762. direction: Vector2;
  147763. /**
  147764. * Creates a new instance CircleOfConfusionPostProcess
  147765. * @param name The name of the effect.
  147766. * @param scene The scene the effect belongs to.
  147767. * @param direction The direction the blur should be applied.
  147768. * @param kernel The size of the kernel used to blur.
  147769. * @param options The required width/height ratio to downsize to before computing the render pass.
  147770. * @param camera The camera to apply the render pass to.
  147771. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  147772. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  147773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147774. * @param engine The engine which the post process will be applied. (default: current engine)
  147775. * @param reusable If the post process can be reused on the same frame. (default: false)
  147776. * @param textureType Type of textures used when performing the post process. (default: 0)
  147777. * @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)
  147778. */
  147779. 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);
  147780. }
  147781. }
  147782. declare module BABYLON {
  147783. /** @hidden */
  147784. export var depthOfFieldMergePixelShader: {
  147785. name: string;
  147786. shader: string;
  147787. };
  147788. }
  147789. declare module BABYLON {
  147790. /**
  147791. * Options to be set when merging outputs from the default pipeline.
  147792. */
  147793. export class DepthOfFieldMergePostProcessOptions {
  147794. /**
  147795. * The original image to merge on top of
  147796. */
  147797. originalFromInput: PostProcess;
  147798. /**
  147799. * Parameters to perform the merge of the depth of field effect
  147800. */
  147801. depthOfField?: {
  147802. circleOfConfusion: PostProcess;
  147803. blurSteps: Array<PostProcess>;
  147804. };
  147805. /**
  147806. * Parameters to perform the merge of bloom effect
  147807. */
  147808. bloom?: {
  147809. blurred: PostProcess;
  147810. weight: number;
  147811. };
  147812. }
  147813. /**
  147814. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147815. */
  147816. export class DepthOfFieldMergePostProcess extends PostProcess {
  147817. private blurSteps;
  147818. /**
  147819. * Creates a new instance of DepthOfFieldMergePostProcess
  147820. * @param name The name of the effect.
  147821. * @param originalFromInput Post process which's input will be used for the merge.
  147822. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  147823. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  147824. * @param options The required width/height ratio to downsize to before computing the render pass.
  147825. * @param camera The camera to apply the render pass to.
  147826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147827. * @param engine The engine which the post process will be applied. (default: current engine)
  147828. * @param reusable If the post process can be reused on the same frame. (default: false)
  147829. * @param textureType Type of textures used when performing the post process. (default: 0)
  147830. * @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)
  147831. */
  147832. 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);
  147833. /**
  147834. * Updates the effect with the current post process compile time values and recompiles the shader.
  147835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  147836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  147837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  147838. * @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
  147839. * @param onCompiled Called when the shader has been compiled.
  147840. * @param onError Called if there is an error when compiling a shader.
  147841. */
  147842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  147843. }
  147844. }
  147845. declare module BABYLON {
  147846. /**
  147847. * Specifies the level of max blur that should be applied when using the depth of field effect
  147848. */
  147849. export enum DepthOfFieldEffectBlurLevel {
  147850. /**
  147851. * Subtle blur
  147852. */
  147853. Low = 0,
  147854. /**
  147855. * Medium blur
  147856. */
  147857. Medium = 1,
  147858. /**
  147859. * Large blur
  147860. */
  147861. High = 2
  147862. }
  147863. /**
  147864. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  147865. */
  147866. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  147867. private _circleOfConfusion;
  147868. /**
  147869. * @hidden Internal, blurs from high to low
  147870. */
  147871. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  147872. private _depthOfFieldBlurY;
  147873. private _dofMerge;
  147874. /**
  147875. * @hidden Internal post processes in depth of field effect
  147876. */
  147877. _effects: Array<PostProcess>;
  147878. /**
  147879. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  147880. */
  147881. set focalLength(value: number);
  147882. get focalLength(): number;
  147883. /**
  147884. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147885. */
  147886. set fStop(value: number);
  147887. get fStop(): number;
  147888. /**
  147889. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147890. */
  147891. set focusDistance(value: number);
  147892. get focusDistance(): number;
  147893. /**
  147894. * 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.
  147895. */
  147896. set lensSize(value: number);
  147897. get lensSize(): number;
  147898. /**
  147899. * Creates a new instance DepthOfFieldEffect
  147900. * @param scene The scene the effect belongs to.
  147901. * @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.
  147902. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147903. * @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)
  147904. */
  147905. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  147906. /**
  147907. * Get the current class name of the current effet
  147908. * @returns "DepthOfFieldEffect"
  147909. */
  147910. getClassName(): string;
  147911. /**
  147912. * 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.
  147913. */
  147914. set depthTexture(value: RenderTargetTexture);
  147915. /**
  147916. * Disposes each of the internal effects for a given camera.
  147917. * @param camera The camera to dispose the effect on.
  147918. */
  147919. disposeEffects(camera: Camera): void;
  147920. /**
  147921. * @hidden Internal
  147922. */
  147923. _updateEffects(): void;
  147924. /**
  147925. * Internal
  147926. * @returns if all the contained post processes are ready.
  147927. * @hidden
  147928. */
  147929. _isReady(): boolean;
  147930. }
  147931. }
  147932. declare module BABYLON {
  147933. /** @hidden */
  147934. export var displayPassPixelShader: {
  147935. name: string;
  147936. shader: string;
  147937. };
  147938. }
  147939. declare module BABYLON {
  147940. /**
  147941. * DisplayPassPostProcess which produces an output the same as it's input
  147942. */
  147943. export class DisplayPassPostProcess extends PostProcess {
  147944. /**
  147945. * Creates the DisplayPassPostProcess
  147946. * @param name The name of the effect.
  147947. * @param options The required width/height ratio to downsize to before computing the render pass.
  147948. * @param camera The camera to apply the render pass to.
  147949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147950. * @param engine The engine which the post process will be applied. (default: current engine)
  147951. * @param reusable If the post process can be reused on the same frame. (default: false)
  147952. */
  147953. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147954. }
  147955. }
  147956. declare module BABYLON {
  147957. /** @hidden */
  147958. export var filterPixelShader: {
  147959. name: string;
  147960. shader: string;
  147961. };
  147962. }
  147963. declare module BABYLON {
  147964. /**
  147965. * Applies a kernel filter to the image
  147966. */
  147967. export class FilterPostProcess extends PostProcess {
  147968. /** The matrix to be applied to the image */
  147969. kernelMatrix: Matrix;
  147970. /**
  147971. *
  147972. * @param name The name of the effect.
  147973. * @param kernelMatrix The matrix to be applied to the image
  147974. * @param options The required width/height ratio to downsize to before computing the render pass.
  147975. * @param camera The camera to apply the render pass to.
  147976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147977. * @param engine The engine which the post process will be applied. (default: current engine)
  147978. * @param reusable If the post process can be reused on the same frame. (default: false)
  147979. */
  147980. constructor(name: string,
  147981. /** The matrix to be applied to the image */
  147982. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147983. }
  147984. }
  147985. declare module BABYLON {
  147986. /** @hidden */
  147987. export var fxaaPixelShader: {
  147988. name: string;
  147989. shader: string;
  147990. };
  147991. }
  147992. declare module BABYLON {
  147993. /** @hidden */
  147994. export var fxaaVertexShader: {
  147995. name: string;
  147996. shader: string;
  147997. };
  147998. }
  147999. declare module BABYLON {
  148000. /**
  148001. * Fxaa post process
  148002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  148003. */
  148004. export class FxaaPostProcess extends PostProcess {
  148005. /** @hidden */
  148006. texelWidth: number;
  148007. /** @hidden */
  148008. texelHeight: number;
  148009. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148010. private _getDefines;
  148011. }
  148012. }
  148013. declare module BABYLON {
  148014. /** @hidden */
  148015. export var grainPixelShader: {
  148016. name: string;
  148017. shader: string;
  148018. };
  148019. }
  148020. declare module BABYLON {
  148021. /**
  148022. * The GrainPostProcess adds noise to the image at mid luminance levels
  148023. */
  148024. export class GrainPostProcess extends PostProcess {
  148025. /**
  148026. * The intensity of the grain added (default: 30)
  148027. */
  148028. intensity: number;
  148029. /**
  148030. * If the grain should be randomized on every frame
  148031. */
  148032. animated: boolean;
  148033. /**
  148034. * Creates a new instance of @see GrainPostProcess
  148035. * @param name The name of the effect.
  148036. * @param options The required width/height ratio to downsize to before computing the render pass.
  148037. * @param camera The camera to apply the render pass to.
  148038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148039. * @param engine The engine which the post process will be applied. (default: current engine)
  148040. * @param reusable If the post process can be reused on the same frame. (default: false)
  148041. * @param textureType Type of textures used when performing the post process. (default: 0)
  148042. * @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)
  148043. */
  148044. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148045. }
  148046. }
  148047. declare module BABYLON {
  148048. /** @hidden */
  148049. export var highlightsPixelShader: {
  148050. name: string;
  148051. shader: string;
  148052. };
  148053. }
  148054. declare module BABYLON {
  148055. /**
  148056. * Extracts highlights from the image
  148057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148058. */
  148059. export class HighlightsPostProcess extends PostProcess {
  148060. /**
  148061. * Extracts highlights from the image
  148062. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148063. * @param name The name of the effect.
  148064. * @param options The required width/height ratio to downsize to before computing the render pass.
  148065. * @param camera The camera to apply the render pass to.
  148066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148067. * @param engine The engine which the post process will be applied. (default: current engine)
  148068. * @param reusable If the post process can be reused on the same frame. (default: false)
  148069. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  148070. */
  148071. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148072. }
  148073. }
  148074. declare module BABYLON {
  148075. /** @hidden */
  148076. export var mrtFragmentDeclaration: {
  148077. name: string;
  148078. shader: string;
  148079. };
  148080. }
  148081. declare module BABYLON {
  148082. /** @hidden */
  148083. export var geometryPixelShader: {
  148084. name: string;
  148085. shader: string;
  148086. };
  148087. }
  148088. declare module BABYLON {
  148089. /** @hidden */
  148090. export var geometryVertexShader: {
  148091. name: string;
  148092. shader: string;
  148093. };
  148094. }
  148095. declare module BABYLON {
  148096. /** @hidden */
  148097. interface ISavedTransformationMatrix {
  148098. world: Matrix;
  148099. viewProjection: Matrix;
  148100. }
  148101. /**
  148102. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  148103. */
  148104. export class GeometryBufferRenderer {
  148105. /**
  148106. * Constant used to retrieve the position texture index in the G-Buffer textures array
  148107. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  148108. */
  148109. static readonly POSITION_TEXTURE_TYPE: number;
  148110. /**
  148111. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  148112. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  148113. */
  148114. static readonly VELOCITY_TEXTURE_TYPE: number;
  148115. /**
  148116. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  148117. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  148118. */
  148119. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  148120. /**
  148121. * Dictionary used to store the previous transformation matrices of each rendered mesh
  148122. * in order to compute objects velocities when enableVelocity is set to "true"
  148123. * @hidden
  148124. */
  148125. _previousTransformationMatrices: {
  148126. [index: number]: ISavedTransformationMatrix;
  148127. };
  148128. /**
  148129. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  148130. * in order to compute objects velocities when enableVelocity is set to "true"
  148131. * @hidden
  148132. */
  148133. _previousBonesTransformationMatrices: {
  148134. [index: number]: Float32Array;
  148135. };
  148136. /**
  148137. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  148138. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  148139. */
  148140. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  148141. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  148142. renderTransparentMeshes: boolean;
  148143. private _scene;
  148144. private _resizeObserver;
  148145. private _multiRenderTarget;
  148146. private _ratio;
  148147. private _enablePosition;
  148148. private _enableVelocity;
  148149. private _enableReflectivity;
  148150. private _positionIndex;
  148151. private _velocityIndex;
  148152. private _reflectivityIndex;
  148153. protected _effect: Effect;
  148154. protected _cachedDefines: string;
  148155. /**
  148156. * Set the render list (meshes to be rendered) used in the G buffer.
  148157. */
  148158. set renderList(meshes: Mesh[]);
  148159. /**
  148160. * Gets wether or not G buffer are supported by the running hardware.
  148161. * This requires draw buffer supports
  148162. */
  148163. get isSupported(): boolean;
  148164. /**
  148165. * Returns the index of the given texture type in the G-Buffer textures array
  148166. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  148167. * @returns the index of the given texture type in the G-Buffer textures array
  148168. */
  148169. getTextureIndex(textureType: number): number;
  148170. /**
  148171. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  148172. */
  148173. get enablePosition(): boolean;
  148174. /**
  148175. * Sets whether or not objects positions are enabled for the G buffer.
  148176. */
  148177. set enablePosition(enable: boolean);
  148178. /**
  148179. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  148180. */
  148181. get enableVelocity(): boolean;
  148182. /**
  148183. * Sets wether or not objects velocities are enabled for the G buffer.
  148184. */
  148185. set enableVelocity(enable: boolean);
  148186. /**
  148187. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  148188. */
  148189. get enableReflectivity(): boolean;
  148190. /**
  148191. * Sets wether or not objects roughness are enabled for the G buffer.
  148192. */
  148193. set enableReflectivity(enable: boolean);
  148194. /**
  148195. * Gets the scene associated with the buffer.
  148196. */
  148197. get scene(): Scene;
  148198. /**
  148199. * Gets the ratio used by the buffer during its creation.
  148200. * How big is the buffer related to the main canvas.
  148201. */
  148202. get ratio(): number;
  148203. /** @hidden */
  148204. static _SceneComponentInitialization: (scene: Scene) => void;
  148205. /**
  148206. * Creates a new G Buffer for the scene
  148207. * @param scene The scene the buffer belongs to
  148208. * @param ratio How big is the buffer related to the main canvas.
  148209. */
  148210. constructor(scene: Scene, ratio?: number);
  148211. /**
  148212. * Checks wether everything is ready to render a submesh to the G buffer.
  148213. * @param subMesh the submesh to check readiness for
  148214. * @param useInstances is the mesh drawn using instance or not
  148215. * @returns true if ready otherwise false
  148216. */
  148217. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148218. /**
  148219. * Gets the current underlying G Buffer.
  148220. * @returns the buffer
  148221. */
  148222. getGBuffer(): MultiRenderTarget;
  148223. /**
  148224. * Gets the number of samples used to render the buffer (anti aliasing).
  148225. */
  148226. get samples(): number;
  148227. /**
  148228. * Sets the number of samples used to render the buffer (anti aliasing).
  148229. */
  148230. set samples(value: number);
  148231. /**
  148232. * Disposes the renderer and frees up associated resources.
  148233. */
  148234. dispose(): void;
  148235. protected _createRenderTargets(): void;
  148236. private _copyBonesTransformationMatrices;
  148237. }
  148238. }
  148239. declare module BABYLON {
  148240. interface Scene {
  148241. /** @hidden (Backing field) */
  148242. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148243. /**
  148244. * Gets or Sets the current geometry buffer associated to the scene.
  148245. */
  148246. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148247. /**
  148248. * Enables a GeometryBufferRender and associates it with the scene
  148249. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  148250. * @returns the GeometryBufferRenderer
  148251. */
  148252. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  148253. /**
  148254. * Disables the GeometryBufferRender associated with the scene
  148255. */
  148256. disableGeometryBufferRenderer(): void;
  148257. }
  148258. /**
  148259. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  148260. * in several rendering techniques.
  148261. */
  148262. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  148263. /**
  148264. * The component name helpful to identify the component in the list of scene components.
  148265. */
  148266. readonly name: string;
  148267. /**
  148268. * The scene the component belongs to.
  148269. */
  148270. scene: Scene;
  148271. /**
  148272. * Creates a new instance of the component for the given scene
  148273. * @param scene Defines the scene to register the component in
  148274. */
  148275. constructor(scene: Scene);
  148276. /**
  148277. * Registers the component in a given scene
  148278. */
  148279. register(): void;
  148280. /**
  148281. * Rebuilds the elements related to this component in case of
  148282. * context lost for instance.
  148283. */
  148284. rebuild(): void;
  148285. /**
  148286. * Disposes the component and the associated ressources
  148287. */
  148288. dispose(): void;
  148289. private _gatherRenderTargets;
  148290. }
  148291. }
  148292. declare module BABYLON {
  148293. /** @hidden */
  148294. export var motionBlurPixelShader: {
  148295. name: string;
  148296. shader: string;
  148297. };
  148298. }
  148299. declare module BABYLON {
  148300. /**
  148301. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  148302. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  148303. * As an example, all you have to do is to create the post-process:
  148304. * var mb = new BABYLON.MotionBlurPostProcess(
  148305. * 'mb', // The name of the effect.
  148306. * scene, // The scene containing the objects to blur according to their velocity.
  148307. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  148308. * camera // The camera to apply the render pass to.
  148309. * );
  148310. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  148311. */
  148312. export class MotionBlurPostProcess extends PostProcess {
  148313. /**
  148314. * Defines how much the image is blurred by the movement. Default value is equal to 1
  148315. */
  148316. motionStrength: number;
  148317. /**
  148318. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  148319. */
  148320. get motionBlurSamples(): number;
  148321. /**
  148322. * Sets the number of iterations to be used for motion blur quality
  148323. */
  148324. set motionBlurSamples(samples: number);
  148325. private _motionBlurSamples;
  148326. private _geometryBufferRenderer;
  148327. /**
  148328. * Creates a new instance MotionBlurPostProcess
  148329. * @param name The name of the effect.
  148330. * @param scene The scene containing the objects to blur according to their velocity.
  148331. * @param options The required width/height ratio to downsize to before computing the render pass.
  148332. * @param camera The camera to apply the render pass to.
  148333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148334. * @param engine The engine which the post process will be applied. (default: current engine)
  148335. * @param reusable If the post process can be reused on the same frame. (default: false)
  148336. * @param textureType Type of textures used when performing the post process. (default: 0)
  148337. * @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)
  148338. */
  148339. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148340. /**
  148341. * Excludes the given skinned mesh from computing bones velocities.
  148342. * 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.
  148343. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  148344. */
  148345. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148346. /**
  148347. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  148348. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  148349. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  148350. */
  148351. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148352. /**
  148353. * Disposes the post process.
  148354. * @param camera The camera to dispose the post process on.
  148355. */
  148356. dispose(camera?: Camera): void;
  148357. }
  148358. }
  148359. declare module BABYLON {
  148360. /** @hidden */
  148361. export var refractionPixelShader: {
  148362. name: string;
  148363. shader: string;
  148364. };
  148365. }
  148366. declare module BABYLON {
  148367. /**
  148368. * Post process which applies a refractin texture
  148369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148370. */
  148371. export class RefractionPostProcess extends PostProcess {
  148372. /** the base color of the refraction (used to taint the rendering) */
  148373. color: Color3;
  148374. /** simulated refraction depth */
  148375. depth: number;
  148376. /** the coefficient of the base color (0 to remove base color tainting) */
  148377. colorLevel: number;
  148378. private _refTexture;
  148379. private _ownRefractionTexture;
  148380. /**
  148381. * Gets or sets the refraction texture
  148382. * Please note that you are responsible for disposing the texture if you set it manually
  148383. */
  148384. get refractionTexture(): Texture;
  148385. set refractionTexture(value: Texture);
  148386. /**
  148387. * Initializes the RefractionPostProcess
  148388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148389. * @param name The name of the effect.
  148390. * @param refractionTextureUrl Url of the refraction texture to use
  148391. * @param color the base color of the refraction (used to taint the rendering)
  148392. * @param depth simulated refraction depth
  148393. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  148394. * @param camera The camera to apply the render pass to.
  148395. * @param options The required width/height ratio to downsize to before computing the render pass.
  148396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148397. * @param engine The engine which the post process will be applied. (default: current engine)
  148398. * @param reusable If the post process can be reused on the same frame. (default: false)
  148399. */
  148400. constructor(name: string, refractionTextureUrl: string,
  148401. /** the base color of the refraction (used to taint the rendering) */
  148402. color: Color3,
  148403. /** simulated refraction depth */
  148404. depth: number,
  148405. /** the coefficient of the base color (0 to remove base color tainting) */
  148406. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148407. /**
  148408. * Disposes of the post process
  148409. * @param camera Camera to dispose post process on
  148410. */
  148411. dispose(camera: Camera): void;
  148412. }
  148413. }
  148414. declare module BABYLON {
  148415. /** @hidden */
  148416. export var sharpenPixelShader: {
  148417. name: string;
  148418. shader: string;
  148419. };
  148420. }
  148421. declare module BABYLON {
  148422. /**
  148423. * The SharpenPostProcess applies a sharpen kernel to every pixel
  148424. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148425. */
  148426. export class SharpenPostProcess extends PostProcess {
  148427. /**
  148428. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  148429. */
  148430. colorAmount: number;
  148431. /**
  148432. * How much sharpness should be applied (default: 0.3)
  148433. */
  148434. edgeAmount: number;
  148435. /**
  148436. * Creates a new instance ConvolutionPostProcess
  148437. * @param name The name of the effect.
  148438. * @param options The required width/height ratio to downsize to before computing the render pass.
  148439. * @param camera The camera to apply the render pass to.
  148440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148441. * @param engine The engine which the post process will be applied. (default: current engine)
  148442. * @param reusable If the post process can be reused on the same frame. (default: false)
  148443. * @param textureType Type of textures used when performing the post process. (default: 0)
  148444. * @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)
  148445. */
  148446. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148447. }
  148448. }
  148449. declare module BABYLON {
  148450. /**
  148451. * PostProcessRenderPipeline
  148452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148453. */
  148454. export class PostProcessRenderPipeline {
  148455. private engine;
  148456. private _renderEffects;
  148457. private _renderEffectsForIsolatedPass;
  148458. /**
  148459. * List of inspectable custom properties (used by the Inspector)
  148460. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  148461. */
  148462. inspectableCustomProperties: IInspectable[];
  148463. /**
  148464. * @hidden
  148465. */
  148466. protected _cameras: Camera[];
  148467. /** @hidden */
  148468. _name: string;
  148469. /**
  148470. * Gets pipeline name
  148471. */
  148472. get name(): string;
  148473. /** Gets the list of attached cameras */
  148474. get cameras(): Camera[];
  148475. /**
  148476. * Initializes a PostProcessRenderPipeline
  148477. * @param engine engine to add the pipeline to
  148478. * @param name name of the pipeline
  148479. */
  148480. constructor(engine: Engine, name: string);
  148481. /**
  148482. * Gets the class name
  148483. * @returns "PostProcessRenderPipeline"
  148484. */
  148485. getClassName(): string;
  148486. /**
  148487. * If all the render effects in the pipeline are supported
  148488. */
  148489. get isSupported(): boolean;
  148490. /**
  148491. * Adds an effect to the pipeline
  148492. * @param renderEffect the effect to add
  148493. */
  148494. addEffect(renderEffect: PostProcessRenderEffect): void;
  148495. /** @hidden */
  148496. _rebuild(): void;
  148497. /** @hidden */
  148498. _enableEffect(renderEffectName: string, cameras: Camera): void;
  148499. /** @hidden */
  148500. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  148501. /** @hidden */
  148502. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148503. /** @hidden */
  148504. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148505. /** @hidden */
  148506. _attachCameras(cameras: Camera, unique: boolean): void;
  148507. /** @hidden */
  148508. _attachCameras(cameras: Camera[], unique: boolean): void;
  148509. /** @hidden */
  148510. _detachCameras(cameras: Camera): void;
  148511. /** @hidden */
  148512. _detachCameras(cameras: Nullable<Camera[]>): void;
  148513. /** @hidden */
  148514. _update(): void;
  148515. /** @hidden */
  148516. _reset(): void;
  148517. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  148518. /**
  148519. * Sets the required values to the prepass renderer.
  148520. * @param prePassRenderer defines the prepass renderer to setup.
  148521. * @returns true if the pre pass is needed.
  148522. */
  148523. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148524. /**
  148525. * Disposes of the pipeline
  148526. */
  148527. dispose(): void;
  148528. }
  148529. }
  148530. declare module BABYLON {
  148531. /**
  148532. * PostProcessRenderPipelineManager class
  148533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148534. */
  148535. export class PostProcessRenderPipelineManager {
  148536. private _renderPipelines;
  148537. /**
  148538. * Initializes a PostProcessRenderPipelineManager
  148539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148540. */
  148541. constructor();
  148542. /**
  148543. * Gets the list of supported render pipelines
  148544. */
  148545. get supportedPipelines(): PostProcessRenderPipeline[];
  148546. /**
  148547. * Adds a pipeline to the manager
  148548. * @param renderPipeline The pipeline to add
  148549. */
  148550. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  148551. /**
  148552. * Attaches a camera to the pipeline
  148553. * @param renderPipelineName The name of the pipeline to attach to
  148554. * @param cameras the camera to attach
  148555. * @param unique if the camera can be attached multiple times to the pipeline
  148556. */
  148557. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  148558. /**
  148559. * Detaches a camera from the pipeline
  148560. * @param renderPipelineName The name of the pipeline to detach from
  148561. * @param cameras the camera to detach
  148562. */
  148563. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  148564. /**
  148565. * Enables an effect by name on a pipeline
  148566. * @param renderPipelineName the name of the pipeline to enable the effect in
  148567. * @param renderEffectName the name of the effect to enable
  148568. * @param cameras the cameras that the effect should be enabled on
  148569. */
  148570. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148571. /**
  148572. * Disables an effect by name on a pipeline
  148573. * @param renderPipelineName the name of the pipeline to disable the effect in
  148574. * @param renderEffectName the name of the effect to disable
  148575. * @param cameras the cameras that the effect should be disabled on
  148576. */
  148577. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148578. /**
  148579. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  148580. */
  148581. update(): void;
  148582. /** @hidden */
  148583. _rebuild(): void;
  148584. /**
  148585. * Disposes of the manager and pipelines
  148586. */
  148587. dispose(): void;
  148588. }
  148589. }
  148590. declare module BABYLON {
  148591. interface Scene {
  148592. /** @hidden (Backing field) */
  148593. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148594. /**
  148595. * Gets the postprocess render pipeline manager
  148596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148597. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148598. */
  148599. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148600. }
  148601. /**
  148602. * Defines the Render Pipeline scene component responsible to rendering pipelines
  148603. */
  148604. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  148605. /**
  148606. * The component name helpfull to identify the component in the list of scene components.
  148607. */
  148608. readonly name: string;
  148609. /**
  148610. * The scene the component belongs to.
  148611. */
  148612. scene: Scene;
  148613. /**
  148614. * Creates a new instance of the component for the given scene
  148615. * @param scene Defines the scene to register the component in
  148616. */
  148617. constructor(scene: Scene);
  148618. /**
  148619. * Registers the component in a given scene
  148620. */
  148621. register(): void;
  148622. /**
  148623. * Rebuilds the elements related to this component in case of
  148624. * context lost for instance.
  148625. */
  148626. rebuild(): void;
  148627. /**
  148628. * Disposes the component and the associated ressources
  148629. */
  148630. dispose(): void;
  148631. private _gatherRenderTargets;
  148632. }
  148633. }
  148634. declare module BABYLON {
  148635. /**
  148636. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  148637. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148638. */
  148639. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148640. private _scene;
  148641. private _camerasToBeAttached;
  148642. /**
  148643. * ID of the sharpen post process,
  148644. */
  148645. private readonly SharpenPostProcessId;
  148646. /**
  148647. * @ignore
  148648. * ID of the image processing post process;
  148649. */
  148650. readonly ImageProcessingPostProcessId: string;
  148651. /**
  148652. * @ignore
  148653. * ID of the Fast Approximate Anti-Aliasing post process;
  148654. */
  148655. readonly FxaaPostProcessId: string;
  148656. /**
  148657. * ID of the chromatic aberration post process,
  148658. */
  148659. private readonly ChromaticAberrationPostProcessId;
  148660. /**
  148661. * ID of the grain post process
  148662. */
  148663. private readonly GrainPostProcessId;
  148664. /**
  148665. * Sharpen post process which will apply a sharpen convolution to enhance edges
  148666. */
  148667. sharpen: SharpenPostProcess;
  148668. private _sharpenEffect;
  148669. private bloom;
  148670. /**
  148671. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  148672. */
  148673. depthOfField: DepthOfFieldEffect;
  148674. /**
  148675. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148676. */
  148677. fxaa: FxaaPostProcess;
  148678. /**
  148679. * Image post processing pass used to perform operations such as tone mapping or color grading.
  148680. */
  148681. imageProcessing: ImageProcessingPostProcess;
  148682. /**
  148683. * Chromatic aberration post process which will shift rgb colors in the image
  148684. */
  148685. chromaticAberration: ChromaticAberrationPostProcess;
  148686. private _chromaticAberrationEffect;
  148687. /**
  148688. * Grain post process which add noise to the image
  148689. */
  148690. grain: GrainPostProcess;
  148691. private _grainEffect;
  148692. /**
  148693. * Glow post process which adds a glow to emissive areas of the image
  148694. */
  148695. private _glowLayer;
  148696. /**
  148697. * Animations which can be used to tweak settings over a period of time
  148698. */
  148699. animations: Animation[];
  148700. private _imageProcessingConfigurationObserver;
  148701. private _sharpenEnabled;
  148702. private _bloomEnabled;
  148703. private _depthOfFieldEnabled;
  148704. private _depthOfFieldBlurLevel;
  148705. private _fxaaEnabled;
  148706. private _imageProcessingEnabled;
  148707. private _defaultPipelineTextureType;
  148708. private _bloomScale;
  148709. private _chromaticAberrationEnabled;
  148710. private _grainEnabled;
  148711. private _buildAllowed;
  148712. /**
  148713. * Gets active scene
  148714. */
  148715. get scene(): Scene;
  148716. /**
  148717. * Enable or disable the sharpen process from the pipeline
  148718. */
  148719. set sharpenEnabled(enabled: boolean);
  148720. get sharpenEnabled(): boolean;
  148721. private _resizeObserver;
  148722. private _hardwareScaleLevel;
  148723. private _bloomKernel;
  148724. /**
  148725. * Specifies the size of the bloom blur kernel, relative to the final output size
  148726. */
  148727. get bloomKernel(): number;
  148728. set bloomKernel(value: number);
  148729. /**
  148730. * Specifies the weight of the bloom in the final rendering
  148731. */
  148732. private _bloomWeight;
  148733. /**
  148734. * Specifies the luma threshold for the area that will be blurred by the bloom
  148735. */
  148736. private _bloomThreshold;
  148737. private _hdr;
  148738. /**
  148739. * The strength of the bloom.
  148740. */
  148741. set bloomWeight(value: number);
  148742. get bloomWeight(): number;
  148743. /**
  148744. * The strength of the bloom.
  148745. */
  148746. set bloomThreshold(value: number);
  148747. get bloomThreshold(): number;
  148748. /**
  148749. * The scale of the bloom, lower value will provide better performance.
  148750. */
  148751. set bloomScale(value: number);
  148752. get bloomScale(): number;
  148753. /**
  148754. * Enable or disable the bloom from the pipeline
  148755. */
  148756. set bloomEnabled(enabled: boolean);
  148757. get bloomEnabled(): boolean;
  148758. private _rebuildBloom;
  148759. /**
  148760. * If the depth of field is enabled.
  148761. */
  148762. get depthOfFieldEnabled(): boolean;
  148763. set depthOfFieldEnabled(enabled: boolean);
  148764. /**
  148765. * Blur level of the depth of field effect. (Higher blur will effect performance)
  148766. */
  148767. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  148768. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  148769. /**
  148770. * If the anti aliasing is enabled.
  148771. */
  148772. set fxaaEnabled(enabled: boolean);
  148773. get fxaaEnabled(): boolean;
  148774. private _samples;
  148775. /**
  148776. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148777. */
  148778. set samples(sampleCount: number);
  148779. get samples(): number;
  148780. /**
  148781. * If image processing is enabled.
  148782. */
  148783. set imageProcessingEnabled(enabled: boolean);
  148784. get imageProcessingEnabled(): boolean;
  148785. /**
  148786. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  148787. */
  148788. set glowLayerEnabled(enabled: boolean);
  148789. get glowLayerEnabled(): boolean;
  148790. /**
  148791. * Gets the glow layer (or null if not defined)
  148792. */
  148793. get glowLayer(): Nullable<GlowLayer>;
  148794. /**
  148795. * Enable or disable the chromaticAberration process from the pipeline
  148796. */
  148797. set chromaticAberrationEnabled(enabled: boolean);
  148798. get chromaticAberrationEnabled(): boolean;
  148799. /**
  148800. * Enable or disable the grain process from the pipeline
  148801. */
  148802. set grainEnabled(enabled: boolean);
  148803. get grainEnabled(): boolean;
  148804. /**
  148805. * @constructor
  148806. * @param name - The rendering pipeline name (default: "")
  148807. * @param hdr - If high dynamic range textures should be used (default: true)
  148808. * @param scene - The scene linked to this pipeline (default: the last created scene)
  148809. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  148810. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  148811. */
  148812. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  148813. /**
  148814. * Get the class name
  148815. * @returns "DefaultRenderingPipeline"
  148816. */
  148817. getClassName(): string;
  148818. /**
  148819. * Force the compilation of the entire pipeline.
  148820. */
  148821. prepare(): void;
  148822. private _hasCleared;
  148823. private _prevPostProcess;
  148824. private _prevPrevPostProcess;
  148825. private _setAutoClearAndTextureSharing;
  148826. private _depthOfFieldSceneObserver;
  148827. private _buildPipeline;
  148828. private _disposePostProcesses;
  148829. /**
  148830. * Adds a camera to the pipeline
  148831. * @param camera the camera to be added
  148832. */
  148833. addCamera(camera: Camera): void;
  148834. /**
  148835. * Removes a camera from the pipeline
  148836. * @param camera the camera to remove
  148837. */
  148838. removeCamera(camera: Camera): void;
  148839. /**
  148840. * Dispose of the pipeline and stop all post processes
  148841. */
  148842. dispose(): void;
  148843. /**
  148844. * Serialize the rendering pipeline (Used when exporting)
  148845. * @returns the serialized object
  148846. */
  148847. serialize(): any;
  148848. /**
  148849. * Parse the serialized pipeline
  148850. * @param source Source pipeline.
  148851. * @param scene The scene to load the pipeline to.
  148852. * @param rootUrl The URL of the serialized pipeline.
  148853. * @returns An instantiated pipeline from the serialized object.
  148854. */
  148855. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  148856. }
  148857. }
  148858. declare module BABYLON {
  148859. /** @hidden */
  148860. export var lensHighlightsPixelShader: {
  148861. name: string;
  148862. shader: string;
  148863. };
  148864. }
  148865. declare module BABYLON {
  148866. /** @hidden */
  148867. export var depthOfFieldPixelShader: {
  148868. name: string;
  148869. shader: string;
  148870. };
  148871. }
  148872. declare module BABYLON {
  148873. /**
  148874. * BABYLON.JS Chromatic Aberration GLSL Shader
  148875. * Author: Olivier Guyot
  148876. * Separates very slightly R, G and B colors on the edges of the screen
  148877. * Inspired by Francois Tarlier & Martins Upitis
  148878. */
  148879. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  148880. /**
  148881. * @ignore
  148882. * The chromatic aberration PostProcess id in the pipeline
  148883. */
  148884. LensChromaticAberrationEffect: string;
  148885. /**
  148886. * @ignore
  148887. * The highlights enhancing PostProcess id in the pipeline
  148888. */
  148889. HighlightsEnhancingEffect: string;
  148890. /**
  148891. * @ignore
  148892. * The depth-of-field PostProcess id in the pipeline
  148893. */
  148894. LensDepthOfFieldEffect: string;
  148895. private _scene;
  148896. private _depthTexture;
  148897. private _grainTexture;
  148898. private _chromaticAberrationPostProcess;
  148899. private _highlightsPostProcess;
  148900. private _depthOfFieldPostProcess;
  148901. private _edgeBlur;
  148902. private _grainAmount;
  148903. private _chromaticAberration;
  148904. private _distortion;
  148905. private _highlightsGain;
  148906. private _highlightsThreshold;
  148907. private _dofDistance;
  148908. private _dofAperture;
  148909. private _dofDarken;
  148910. private _dofPentagon;
  148911. private _blurNoise;
  148912. /**
  148913. * @constructor
  148914. *
  148915. * Effect parameters are as follow:
  148916. * {
  148917. * chromatic_aberration: number; // from 0 to x (1 for realism)
  148918. * edge_blur: number; // from 0 to x (1 for realism)
  148919. * distortion: number; // from 0 to x (1 for realism)
  148920. * grain_amount: number; // from 0 to 1
  148921. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  148922. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  148923. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  148924. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  148925. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  148926. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  148927. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  148928. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  148929. * }
  148930. * Note: if an effect parameter is unset, effect is disabled
  148931. *
  148932. * @param name The rendering pipeline name
  148933. * @param parameters - An object containing all parameters (see above)
  148934. * @param scene The scene linked to this pipeline
  148935. * @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)
  148936. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148937. */
  148938. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  148939. /**
  148940. * Get the class name
  148941. * @returns "LensRenderingPipeline"
  148942. */
  148943. getClassName(): string;
  148944. /**
  148945. * Gets associated scene
  148946. */
  148947. get scene(): Scene;
  148948. /**
  148949. * Gets or sets the edge blur
  148950. */
  148951. get edgeBlur(): number;
  148952. set edgeBlur(value: number);
  148953. /**
  148954. * Gets or sets the grain amount
  148955. */
  148956. get grainAmount(): number;
  148957. set grainAmount(value: number);
  148958. /**
  148959. * Gets or sets the chromatic aberration amount
  148960. */
  148961. get chromaticAberration(): number;
  148962. set chromaticAberration(value: number);
  148963. /**
  148964. * Gets or sets the depth of field aperture
  148965. */
  148966. get dofAperture(): number;
  148967. set dofAperture(value: number);
  148968. /**
  148969. * Gets or sets the edge distortion
  148970. */
  148971. get edgeDistortion(): number;
  148972. set edgeDistortion(value: number);
  148973. /**
  148974. * Gets or sets the depth of field distortion
  148975. */
  148976. get dofDistortion(): number;
  148977. set dofDistortion(value: number);
  148978. /**
  148979. * Gets or sets the darken out of focus amount
  148980. */
  148981. get darkenOutOfFocus(): number;
  148982. set darkenOutOfFocus(value: number);
  148983. /**
  148984. * Gets or sets a boolean indicating if blur noise is enabled
  148985. */
  148986. get blurNoise(): boolean;
  148987. set blurNoise(value: boolean);
  148988. /**
  148989. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  148990. */
  148991. get pentagonBokeh(): boolean;
  148992. set pentagonBokeh(value: boolean);
  148993. /**
  148994. * Gets or sets the highlight grain amount
  148995. */
  148996. get highlightsGain(): number;
  148997. set highlightsGain(value: number);
  148998. /**
  148999. * Gets or sets the highlight threshold
  149000. */
  149001. get highlightsThreshold(): number;
  149002. set highlightsThreshold(value: number);
  149003. /**
  149004. * Sets the amount of blur at the edges
  149005. * @param amount blur amount
  149006. */
  149007. setEdgeBlur(amount: number): void;
  149008. /**
  149009. * Sets edge blur to 0
  149010. */
  149011. disableEdgeBlur(): void;
  149012. /**
  149013. * Sets the amout of grain
  149014. * @param amount Amount of grain
  149015. */
  149016. setGrainAmount(amount: number): void;
  149017. /**
  149018. * Set grain amount to 0
  149019. */
  149020. disableGrain(): void;
  149021. /**
  149022. * Sets the chromatic aberration amount
  149023. * @param amount amount of chromatic aberration
  149024. */
  149025. setChromaticAberration(amount: number): void;
  149026. /**
  149027. * Sets chromatic aberration amount to 0
  149028. */
  149029. disableChromaticAberration(): void;
  149030. /**
  149031. * Sets the EdgeDistortion amount
  149032. * @param amount amount of EdgeDistortion
  149033. */
  149034. setEdgeDistortion(amount: number): void;
  149035. /**
  149036. * Sets edge distortion to 0
  149037. */
  149038. disableEdgeDistortion(): void;
  149039. /**
  149040. * Sets the FocusDistance amount
  149041. * @param amount amount of FocusDistance
  149042. */
  149043. setFocusDistance(amount: number): void;
  149044. /**
  149045. * Disables depth of field
  149046. */
  149047. disableDepthOfField(): void;
  149048. /**
  149049. * Sets the Aperture amount
  149050. * @param amount amount of Aperture
  149051. */
  149052. setAperture(amount: number): void;
  149053. /**
  149054. * Sets the DarkenOutOfFocus amount
  149055. * @param amount amount of DarkenOutOfFocus
  149056. */
  149057. setDarkenOutOfFocus(amount: number): void;
  149058. private _pentagonBokehIsEnabled;
  149059. /**
  149060. * Creates a pentagon bokeh effect
  149061. */
  149062. enablePentagonBokeh(): void;
  149063. /**
  149064. * Disables the pentagon bokeh effect
  149065. */
  149066. disablePentagonBokeh(): void;
  149067. /**
  149068. * Enables noise blur
  149069. */
  149070. enableNoiseBlur(): void;
  149071. /**
  149072. * Disables noise blur
  149073. */
  149074. disableNoiseBlur(): void;
  149075. /**
  149076. * Sets the HighlightsGain amount
  149077. * @param amount amount of HighlightsGain
  149078. */
  149079. setHighlightsGain(amount: number): void;
  149080. /**
  149081. * Sets the HighlightsThreshold amount
  149082. * @param amount amount of HighlightsThreshold
  149083. */
  149084. setHighlightsThreshold(amount: number): void;
  149085. /**
  149086. * Disables highlights
  149087. */
  149088. disableHighlights(): void;
  149089. /**
  149090. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  149091. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  149092. */
  149093. dispose(disableDepthRender?: boolean): void;
  149094. private _createChromaticAberrationPostProcess;
  149095. private _createHighlightsPostProcess;
  149096. private _createDepthOfFieldPostProcess;
  149097. private _createGrainTexture;
  149098. }
  149099. }
  149100. declare module BABYLON {
  149101. /** @hidden */
  149102. export var ssao2PixelShader: {
  149103. name: string;
  149104. shader: string;
  149105. };
  149106. }
  149107. declare module BABYLON {
  149108. /** @hidden */
  149109. export var ssaoCombinePixelShader: {
  149110. name: string;
  149111. shader: string;
  149112. };
  149113. }
  149114. declare module BABYLON {
  149115. /**
  149116. * Render pipeline to produce ssao effect
  149117. */
  149118. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  149119. /**
  149120. * @ignore
  149121. * The PassPostProcess id in the pipeline that contains the original scene color
  149122. */
  149123. SSAOOriginalSceneColorEffect: string;
  149124. /**
  149125. * @ignore
  149126. * The SSAO PostProcess id in the pipeline
  149127. */
  149128. SSAORenderEffect: string;
  149129. /**
  149130. * @ignore
  149131. * The horizontal blur PostProcess id in the pipeline
  149132. */
  149133. SSAOBlurHRenderEffect: string;
  149134. /**
  149135. * @ignore
  149136. * The vertical blur PostProcess id in the pipeline
  149137. */
  149138. SSAOBlurVRenderEffect: string;
  149139. /**
  149140. * @ignore
  149141. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149142. */
  149143. SSAOCombineRenderEffect: string;
  149144. /**
  149145. * The output strength of the SSAO post-process. Default value is 1.0.
  149146. */
  149147. totalStrength: number;
  149148. /**
  149149. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  149150. */
  149151. maxZ: number;
  149152. /**
  149153. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  149154. */
  149155. minZAspect: number;
  149156. private _samples;
  149157. /**
  149158. * Number of samples used for the SSAO calculations. Default value is 8
  149159. */
  149160. set samples(n: number);
  149161. get samples(): number;
  149162. private _textureSamples;
  149163. /**
  149164. * Number of samples to use for antialiasing
  149165. */
  149166. set textureSamples(n: number);
  149167. get textureSamples(): number;
  149168. /**
  149169. * Force rendering the geometry through geometry buffer
  149170. */
  149171. private _forceGeometryBuffer;
  149172. /**
  149173. * Ratio object used for SSAO ratio and blur ratio
  149174. */
  149175. private _ratio;
  149176. /**
  149177. * Dynamically generated sphere sampler.
  149178. */
  149179. private _sampleSphere;
  149180. /**
  149181. * Blur filter offsets
  149182. */
  149183. private _samplerOffsets;
  149184. private _expensiveBlur;
  149185. /**
  149186. * If bilateral blur should be used
  149187. */
  149188. set expensiveBlur(b: boolean);
  149189. get expensiveBlur(): boolean;
  149190. /**
  149191. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  149192. */
  149193. radius: number;
  149194. /**
  149195. * The base color of the SSAO post-process
  149196. * The final result is "base + ssao" between [0, 1]
  149197. */
  149198. base: number;
  149199. /**
  149200. * Support test.
  149201. */
  149202. static get IsSupported(): boolean;
  149203. private _scene;
  149204. private _randomTexture;
  149205. private _originalColorPostProcess;
  149206. private _ssaoPostProcess;
  149207. private _blurHPostProcess;
  149208. private _blurVPostProcess;
  149209. private _ssaoCombinePostProcess;
  149210. private _prePassRenderer;
  149211. /**
  149212. * Gets active scene
  149213. */
  149214. get scene(): Scene;
  149215. /**
  149216. * @constructor
  149217. * @param name The rendering pipeline name
  149218. * @param scene The scene linked to this pipeline
  149219. * @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 }
  149220. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149221. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  149222. */
  149223. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  149224. /**
  149225. * Get the class name
  149226. * @returns "SSAO2RenderingPipeline"
  149227. */
  149228. getClassName(): string;
  149229. /**
  149230. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149231. */
  149232. dispose(disableGeometryBufferRenderer?: boolean): void;
  149233. private _createBlurPostProcess;
  149234. /** @hidden */
  149235. _rebuild(): void;
  149236. private _bits;
  149237. private _radicalInverse_VdC;
  149238. private _hammersley;
  149239. private _hemisphereSample_uniform;
  149240. private _generateHemisphere;
  149241. private _getDefinesForSSAO;
  149242. private _createSSAOPostProcess;
  149243. private _createSSAOCombinePostProcess;
  149244. private _createRandomTexture;
  149245. /**
  149246. * Serialize the rendering pipeline (Used when exporting)
  149247. * @returns the serialized object
  149248. */
  149249. serialize(): any;
  149250. /**
  149251. * Parse the serialized pipeline
  149252. * @param source Source pipeline.
  149253. * @param scene The scene to load the pipeline to.
  149254. * @param rootUrl The URL of the serialized pipeline.
  149255. * @returns An instantiated pipeline from the serialized object.
  149256. */
  149257. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  149258. /**
  149259. * Sets the required values to the prepass renderer.
  149260. * @param prePassRenderer defines the prepass renderer to setup
  149261. * @returns true if the pre pass is needed.
  149262. */
  149263. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149264. }
  149265. }
  149266. declare module BABYLON {
  149267. /** @hidden */
  149268. export var ssaoPixelShader: {
  149269. name: string;
  149270. shader: string;
  149271. };
  149272. }
  149273. declare module BABYLON {
  149274. /**
  149275. * Render pipeline to produce ssao effect
  149276. */
  149277. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  149278. /**
  149279. * @ignore
  149280. * The PassPostProcess id in the pipeline that contains the original scene color
  149281. */
  149282. SSAOOriginalSceneColorEffect: string;
  149283. /**
  149284. * @ignore
  149285. * The SSAO PostProcess id in the pipeline
  149286. */
  149287. SSAORenderEffect: string;
  149288. /**
  149289. * @ignore
  149290. * The horizontal blur PostProcess id in the pipeline
  149291. */
  149292. SSAOBlurHRenderEffect: string;
  149293. /**
  149294. * @ignore
  149295. * The vertical blur PostProcess id in the pipeline
  149296. */
  149297. SSAOBlurVRenderEffect: string;
  149298. /**
  149299. * @ignore
  149300. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149301. */
  149302. SSAOCombineRenderEffect: string;
  149303. /**
  149304. * The output strength of the SSAO post-process. Default value is 1.0.
  149305. */
  149306. totalStrength: number;
  149307. /**
  149308. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  149309. */
  149310. radius: number;
  149311. /**
  149312. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  149313. * Must not be equal to fallOff and superior to fallOff.
  149314. * Default value is 0.0075
  149315. */
  149316. area: number;
  149317. /**
  149318. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  149319. * Must not be equal to area and inferior to area.
  149320. * Default value is 0.000001
  149321. */
  149322. fallOff: number;
  149323. /**
  149324. * The base color of the SSAO post-process
  149325. * The final result is "base + ssao" between [0, 1]
  149326. */
  149327. base: number;
  149328. private _scene;
  149329. private _depthTexture;
  149330. private _randomTexture;
  149331. private _originalColorPostProcess;
  149332. private _ssaoPostProcess;
  149333. private _blurHPostProcess;
  149334. private _blurVPostProcess;
  149335. private _ssaoCombinePostProcess;
  149336. private _firstUpdate;
  149337. /**
  149338. * Gets active scene
  149339. */
  149340. get scene(): Scene;
  149341. /**
  149342. * @constructor
  149343. * @param name - The rendering pipeline name
  149344. * @param scene - The scene linked to this pipeline
  149345. * @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 }
  149346. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  149347. */
  149348. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  149349. /**
  149350. * Get the class name
  149351. * @returns "SSAORenderingPipeline"
  149352. */
  149353. getClassName(): string;
  149354. /**
  149355. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149356. */
  149357. dispose(disableDepthRender?: boolean): void;
  149358. private _createBlurPostProcess;
  149359. /** @hidden */
  149360. _rebuild(): void;
  149361. private _createSSAOPostProcess;
  149362. private _createSSAOCombinePostProcess;
  149363. private _createRandomTexture;
  149364. }
  149365. }
  149366. declare module BABYLON {
  149367. /** @hidden */
  149368. export var screenSpaceReflectionPixelShader: {
  149369. name: string;
  149370. shader: string;
  149371. };
  149372. }
  149373. declare module BABYLON {
  149374. /**
  149375. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  149376. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  149377. */
  149378. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  149379. /**
  149380. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  149381. */
  149382. threshold: number;
  149383. /**
  149384. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  149385. */
  149386. strength: number;
  149387. /**
  149388. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  149389. */
  149390. reflectionSpecularFalloffExponent: number;
  149391. /**
  149392. * 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]
  149393. */
  149394. step: number;
  149395. /**
  149396. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  149397. */
  149398. roughnessFactor: number;
  149399. private _geometryBufferRenderer;
  149400. private _enableSmoothReflections;
  149401. private _reflectionSamples;
  149402. private _smoothSteps;
  149403. /**
  149404. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  149405. * @param name The name of the effect.
  149406. * @param scene The scene containing the objects to calculate reflections.
  149407. * @param options The required width/height ratio to downsize to before computing the render pass.
  149408. * @param camera The camera to apply the render pass to.
  149409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149410. * @param engine The engine which the post process will be applied. (default: current engine)
  149411. * @param reusable If the post process can be reused on the same frame. (default: false)
  149412. * @param textureType Type of textures used when performing the post process. (default: 0)
  149413. * @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)
  149414. */
  149415. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149416. /**
  149417. * Gets wether or not smoothing reflections is enabled.
  149418. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149419. */
  149420. get enableSmoothReflections(): boolean;
  149421. /**
  149422. * Sets wether or not smoothing reflections is enabled.
  149423. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149424. */
  149425. set enableSmoothReflections(enabled: boolean);
  149426. /**
  149427. * Gets the number of samples taken while computing reflections. More samples count is high,
  149428. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149429. */
  149430. get reflectionSamples(): number;
  149431. /**
  149432. * Sets the number of samples taken while computing reflections. More samples count is high,
  149433. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149434. */
  149435. set reflectionSamples(samples: number);
  149436. /**
  149437. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  149438. * more the post-process will require GPU power and can generate a drop in FPS.
  149439. * Default value (5.0) work pretty well in all cases but can be adjusted.
  149440. */
  149441. get smoothSteps(): number;
  149442. set smoothSteps(steps: number);
  149443. private _updateEffectDefines;
  149444. }
  149445. }
  149446. declare module BABYLON {
  149447. /** @hidden */
  149448. export var standardPixelShader: {
  149449. name: string;
  149450. shader: string;
  149451. };
  149452. }
  149453. declare module BABYLON {
  149454. /**
  149455. * Standard rendering pipeline
  149456. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149457. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  149458. */
  149459. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149460. /**
  149461. * Public members
  149462. */
  149463. /**
  149464. * Post-process which contains the original scene color before the pipeline applies all the effects
  149465. */
  149466. originalPostProcess: Nullable<PostProcess>;
  149467. /**
  149468. * Post-process used to down scale an image x4
  149469. */
  149470. downSampleX4PostProcess: Nullable<PostProcess>;
  149471. /**
  149472. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  149473. */
  149474. brightPassPostProcess: Nullable<PostProcess>;
  149475. /**
  149476. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  149477. */
  149478. blurHPostProcesses: PostProcess[];
  149479. /**
  149480. * Post-process array storing all the vertical blur post-processes used by the pipeline
  149481. */
  149482. blurVPostProcesses: PostProcess[];
  149483. /**
  149484. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  149485. */
  149486. textureAdderPostProcess: Nullable<PostProcess>;
  149487. /**
  149488. * Post-process used to create volumetric lighting effect
  149489. */
  149490. volumetricLightPostProcess: Nullable<PostProcess>;
  149491. /**
  149492. * Post-process used to smooth the previous volumetric light post-process on the X axis
  149493. */
  149494. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  149495. /**
  149496. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  149497. */
  149498. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  149499. /**
  149500. * Post-process used to merge the volumetric light effect and the real scene color
  149501. */
  149502. volumetricLightMergePostProces: Nullable<PostProcess>;
  149503. /**
  149504. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  149505. */
  149506. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  149507. /**
  149508. * Base post-process used to calculate the average luminance of the final image for HDR
  149509. */
  149510. luminancePostProcess: Nullable<PostProcess>;
  149511. /**
  149512. * Post-processes used to create down sample post-processes in order to get
  149513. * the average luminance of the final image for HDR
  149514. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  149515. */
  149516. luminanceDownSamplePostProcesses: PostProcess[];
  149517. /**
  149518. * Post-process used to create a HDR effect (light adaptation)
  149519. */
  149520. hdrPostProcess: Nullable<PostProcess>;
  149521. /**
  149522. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  149523. */
  149524. textureAdderFinalPostProcess: Nullable<PostProcess>;
  149525. /**
  149526. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  149527. */
  149528. lensFlareFinalPostProcess: Nullable<PostProcess>;
  149529. /**
  149530. * Post-process used to merge the final HDR post-process and the real scene color
  149531. */
  149532. hdrFinalPostProcess: Nullable<PostProcess>;
  149533. /**
  149534. * Post-process used to create a lens flare effect
  149535. */
  149536. lensFlarePostProcess: Nullable<PostProcess>;
  149537. /**
  149538. * Post-process that merges the result of the lens flare post-process and the real scene color
  149539. */
  149540. lensFlareComposePostProcess: Nullable<PostProcess>;
  149541. /**
  149542. * Post-process used to create a motion blur effect
  149543. */
  149544. motionBlurPostProcess: Nullable<PostProcess>;
  149545. /**
  149546. * Post-process used to create a depth of field effect
  149547. */
  149548. depthOfFieldPostProcess: Nullable<PostProcess>;
  149549. /**
  149550. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149551. */
  149552. fxaaPostProcess: Nullable<FxaaPostProcess>;
  149553. /**
  149554. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  149555. */
  149556. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  149557. /**
  149558. * Represents the brightness threshold in order to configure the illuminated surfaces
  149559. */
  149560. brightThreshold: number;
  149561. /**
  149562. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  149563. */
  149564. blurWidth: number;
  149565. /**
  149566. * Sets if the blur for highlighted surfaces must be only horizontal
  149567. */
  149568. horizontalBlur: boolean;
  149569. /**
  149570. * Gets the overall exposure used by the pipeline
  149571. */
  149572. get exposure(): number;
  149573. /**
  149574. * Sets the overall exposure used by the pipeline
  149575. */
  149576. set exposure(value: number);
  149577. /**
  149578. * Texture used typically to simulate "dirty" on camera lens
  149579. */
  149580. lensTexture: Nullable<Texture>;
  149581. /**
  149582. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  149583. */
  149584. volumetricLightCoefficient: number;
  149585. /**
  149586. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  149587. */
  149588. volumetricLightPower: number;
  149589. /**
  149590. * Used the set the blur intensity to smooth the volumetric lights
  149591. */
  149592. volumetricLightBlurScale: number;
  149593. /**
  149594. * Light (spot or directional) used to generate the volumetric lights rays
  149595. * The source light must have a shadow generate so the pipeline can get its
  149596. * depth map
  149597. */
  149598. sourceLight: Nullable<SpotLight | DirectionalLight>;
  149599. /**
  149600. * For eye adaptation, represents the minimum luminance the eye can see
  149601. */
  149602. hdrMinimumLuminance: number;
  149603. /**
  149604. * For eye adaptation, represents the decrease luminance speed
  149605. */
  149606. hdrDecreaseRate: number;
  149607. /**
  149608. * For eye adaptation, represents the increase luminance speed
  149609. */
  149610. hdrIncreaseRate: number;
  149611. /**
  149612. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149613. */
  149614. get hdrAutoExposure(): boolean;
  149615. /**
  149616. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149617. */
  149618. set hdrAutoExposure(value: boolean);
  149619. /**
  149620. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  149621. */
  149622. lensColorTexture: Nullable<Texture>;
  149623. /**
  149624. * The overall strengh for the lens flare effect
  149625. */
  149626. lensFlareStrength: number;
  149627. /**
  149628. * Dispersion coefficient for lens flare ghosts
  149629. */
  149630. lensFlareGhostDispersal: number;
  149631. /**
  149632. * Main lens flare halo width
  149633. */
  149634. lensFlareHaloWidth: number;
  149635. /**
  149636. * Based on the lens distortion effect, defines how much the lens flare result
  149637. * is distorted
  149638. */
  149639. lensFlareDistortionStrength: number;
  149640. /**
  149641. * Configures the blur intensity used for for lens flare (halo)
  149642. */
  149643. lensFlareBlurWidth: number;
  149644. /**
  149645. * Lens star texture must be used to simulate rays on the flares and is available
  149646. * in the documentation
  149647. */
  149648. lensStarTexture: Nullable<Texture>;
  149649. /**
  149650. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  149651. * flare effect by taking account of the dirt texture
  149652. */
  149653. lensFlareDirtTexture: Nullable<Texture>;
  149654. /**
  149655. * Represents the focal length for the depth of field effect
  149656. */
  149657. depthOfFieldDistance: number;
  149658. /**
  149659. * Represents the blur intensity for the blurred part of the depth of field effect
  149660. */
  149661. depthOfFieldBlurWidth: number;
  149662. /**
  149663. * Gets how much the image is blurred by the movement while using the motion blur post-process
  149664. */
  149665. get motionStrength(): number;
  149666. /**
  149667. * Sets how much the image is blurred by the movement while using the motion blur post-process
  149668. */
  149669. set motionStrength(strength: number);
  149670. /**
  149671. * Gets wether or not the motion blur post-process is object based or screen based.
  149672. */
  149673. get objectBasedMotionBlur(): boolean;
  149674. /**
  149675. * Sets wether or not the motion blur post-process should be object based or screen based
  149676. */
  149677. set objectBasedMotionBlur(value: boolean);
  149678. /**
  149679. * List of animations for the pipeline (IAnimatable implementation)
  149680. */
  149681. animations: Animation[];
  149682. /**
  149683. * Private members
  149684. */
  149685. private _scene;
  149686. private _currentDepthOfFieldSource;
  149687. private _basePostProcess;
  149688. private _fixedExposure;
  149689. private _currentExposure;
  149690. private _hdrAutoExposure;
  149691. private _hdrCurrentLuminance;
  149692. private _motionStrength;
  149693. private _isObjectBasedMotionBlur;
  149694. private _floatTextureType;
  149695. private _camerasToBeAttached;
  149696. private _ratio;
  149697. private _bloomEnabled;
  149698. private _depthOfFieldEnabled;
  149699. private _vlsEnabled;
  149700. private _lensFlareEnabled;
  149701. private _hdrEnabled;
  149702. private _motionBlurEnabled;
  149703. private _fxaaEnabled;
  149704. private _screenSpaceReflectionsEnabled;
  149705. private _motionBlurSamples;
  149706. private _volumetricLightStepsCount;
  149707. private _samples;
  149708. /**
  149709. * @ignore
  149710. * Specifies if the bloom pipeline is enabled
  149711. */
  149712. get BloomEnabled(): boolean;
  149713. set BloomEnabled(enabled: boolean);
  149714. /**
  149715. * @ignore
  149716. * Specifies if the depth of field pipeline is enabed
  149717. */
  149718. get DepthOfFieldEnabled(): boolean;
  149719. set DepthOfFieldEnabled(enabled: boolean);
  149720. /**
  149721. * @ignore
  149722. * Specifies if the lens flare pipeline is enabed
  149723. */
  149724. get LensFlareEnabled(): boolean;
  149725. set LensFlareEnabled(enabled: boolean);
  149726. /**
  149727. * @ignore
  149728. * Specifies if the HDR pipeline is enabled
  149729. */
  149730. get HDREnabled(): boolean;
  149731. set HDREnabled(enabled: boolean);
  149732. /**
  149733. * @ignore
  149734. * Specifies if the volumetric lights scattering effect is enabled
  149735. */
  149736. get VLSEnabled(): boolean;
  149737. set VLSEnabled(enabled: boolean);
  149738. /**
  149739. * @ignore
  149740. * Specifies if the motion blur effect is enabled
  149741. */
  149742. get MotionBlurEnabled(): boolean;
  149743. set MotionBlurEnabled(enabled: boolean);
  149744. /**
  149745. * Specifies if anti-aliasing is enabled
  149746. */
  149747. get fxaaEnabled(): boolean;
  149748. set fxaaEnabled(enabled: boolean);
  149749. /**
  149750. * Specifies if screen space reflections are enabled.
  149751. */
  149752. get screenSpaceReflectionsEnabled(): boolean;
  149753. set screenSpaceReflectionsEnabled(enabled: boolean);
  149754. /**
  149755. * Specifies the number of steps used to calculate the volumetric lights
  149756. * Typically in interval [50, 200]
  149757. */
  149758. get volumetricLightStepsCount(): number;
  149759. set volumetricLightStepsCount(count: number);
  149760. /**
  149761. * Specifies the number of samples used for the motion blur effect
  149762. * Typically in interval [16, 64]
  149763. */
  149764. get motionBlurSamples(): number;
  149765. set motionBlurSamples(samples: number);
  149766. /**
  149767. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149768. */
  149769. get samples(): number;
  149770. set samples(sampleCount: number);
  149771. /**
  149772. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149773. * @constructor
  149774. * @param name The rendering pipeline name
  149775. * @param scene The scene linked to this pipeline
  149776. * @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)
  149777. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  149778. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149779. */
  149780. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  149781. private _buildPipeline;
  149782. private _createDownSampleX4PostProcess;
  149783. private _createBrightPassPostProcess;
  149784. private _createBlurPostProcesses;
  149785. private _createTextureAdderPostProcess;
  149786. private _createVolumetricLightPostProcess;
  149787. private _createLuminancePostProcesses;
  149788. private _createHdrPostProcess;
  149789. private _createLensFlarePostProcess;
  149790. private _createDepthOfFieldPostProcess;
  149791. private _createMotionBlurPostProcess;
  149792. private _getDepthTexture;
  149793. private _disposePostProcesses;
  149794. /**
  149795. * Dispose of the pipeline and stop all post processes
  149796. */
  149797. dispose(): void;
  149798. /**
  149799. * Serialize the rendering pipeline (Used when exporting)
  149800. * @returns the serialized object
  149801. */
  149802. serialize(): any;
  149803. /**
  149804. * Parse the serialized pipeline
  149805. * @param source Source pipeline.
  149806. * @param scene The scene to load the pipeline to.
  149807. * @param rootUrl The URL of the serialized pipeline.
  149808. * @returns An instantiated pipeline from the serialized object.
  149809. */
  149810. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  149811. /**
  149812. * Luminance steps
  149813. */
  149814. static LuminanceSteps: number;
  149815. }
  149816. }
  149817. declare module BABYLON {
  149818. /** @hidden */
  149819. export var stereoscopicInterlacePixelShader: {
  149820. name: string;
  149821. shader: string;
  149822. };
  149823. }
  149824. declare module BABYLON {
  149825. /**
  149826. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  149827. */
  149828. export class StereoscopicInterlacePostProcessI extends PostProcess {
  149829. private _stepSize;
  149830. private _passedProcess;
  149831. /**
  149832. * Initializes a StereoscopicInterlacePostProcessI
  149833. * @param name The name of the effect.
  149834. * @param rigCameras The rig cameras to be appled to the post process
  149835. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  149836. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  149837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149838. * @param engine The engine which the post process will be applied. (default: current engine)
  149839. * @param reusable If the post process can be reused on the same frame. (default: false)
  149840. */
  149841. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149842. }
  149843. /**
  149844. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  149845. */
  149846. export class StereoscopicInterlacePostProcess extends PostProcess {
  149847. private _stepSize;
  149848. private _passedProcess;
  149849. /**
  149850. * Initializes a StereoscopicInterlacePostProcess
  149851. * @param name The name of the effect.
  149852. * @param rigCameras The rig cameras to be appled to the post process
  149853. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  149854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149855. * @param engine The engine which the post process will be applied. (default: current engine)
  149856. * @param reusable If the post process can be reused on the same frame. (default: false)
  149857. */
  149858. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149859. }
  149860. }
  149861. declare module BABYLON {
  149862. /** @hidden */
  149863. export var tonemapPixelShader: {
  149864. name: string;
  149865. shader: string;
  149866. };
  149867. }
  149868. declare module BABYLON {
  149869. /** Defines operator used for tonemapping */
  149870. export enum TonemappingOperator {
  149871. /** Hable */
  149872. Hable = 0,
  149873. /** Reinhard */
  149874. Reinhard = 1,
  149875. /** HejiDawson */
  149876. HejiDawson = 2,
  149877. /** Photographic */
  149878. Photographic = 3
  149879. }
  149880. /**
  149881. * Defines a post process to apply tone mapping
  149882. */
  149883. export class TonemapPostProcess extends PostProcess {
  149884. private _operator;
  149885. /** Defines the required exposure adjustement */
  149886. exposureAdjustment: number;
  149887. /**
  149888. * Creates a new TonemapPostProcess
  149889. * @param name defines the name of the postprocess
  149890. * @param _operator defines the operator to use
  149891. * @param exposureAdjustment defines the required exposure adjustement
  149892. * @param camera defines the camera to use (can be null)
  149893. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  149894. * @param engine defines the hosting engine (can be ignore if camera is set)
  149895. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  149896. */
  149897. constructor(name: string, _operator: TonemappingOperator,
  149898. /** Defines the required exposure adjustement */
  149899. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  149900. }
  149901. }
  149902. declare module BABYLON {
  149903. /** @hidden */
  149904. export var volumetricLightScatteringPixelShader: {
  149905. name: string;
  149906. shader: string;
  149907. };
  149908. }
  149909. declare module BABYLON {
  149910. /** @hidden */
  149911. export var volumetricLightScatteringPassVertexShader: {
  149912. name: string;
  149913. shader: string;
  149914. };
  149915. }
  149916. declare module BABYLON {
  149917. /** @hidden */
  149918. export var volumetricLightScatteringPassPixelShader: {
  149919. name: string;
  149920. shader: string;
  149921. };
  149922. }
  149923. declare module BABYLON {
  149924. /**
  149925. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  149926. */
  149927. export class VolumetricLightScatteringPostProcess extends PostProcess {
  149928. private _volumetricLightScatteringPass;
  149929. private _volumetricLightScatteringRTT;
  149930. private _viewPort;
  149931. private _screenCoordinates;
  149932. private _cachedDefines;
  149933. /**
  149934. * If not undefined, the mesh position is computed from the attached node position
  149935. */
  149936. attachedNode: {
  149937. position: Vector3;
  149938. };
  149939. /**
  149940. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  149941. */
  149942. customMeshPosition: Vector3;
  149943. /**
  149944. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  149945. */
  149946. useCustomMeshPosition: boolean;
  149947. /**
  149948. * If the post-process should inverse the light scattering direction
  149949. */
  149950. invert: boolean;
  149951. /**
  149952. * The internal mesh used by the post-process
  149953. */
  149954. mesh: Mesh;
  149955. /**
  149956. * @hidden
  149957. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  149958. */
  149959. get useDiffuseColor(): boolean;
  149960. set useDiffuseColor(useDiffuseColor: boolean);
  149961. /**
  149962. * Array containing the excluded meshes not rendered in the internal pass
  149963. */
  149964. excludedMeshes: AbstractMesh[];
  149965. /**
  149966. * Controls the overall intensity of the post-process
  149967. */
  149968. exposure: number;
  149969. /**
  149970. * Dissipates each sample's contribution in range [0, 1]
  149971. */
  149972. decay: number;
  149973. /**
  149974. * Controls the overall intensity of each sample
  149975. */
  149976. weight: number;
  149977. /**
  149978. * Controls the density of each sample
  149979. */
  149980. density: number;
  149981. /**
  149982. * @constructor
  149983. * @param name The post-process name
  149984. * @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)
  149985. * @param camera The camera that the post-process will be attached to
  149986. * @param mesh The mesh used to create the light scattering
  149987. * @param samples The post-process quality, default 100
  149988. * @param samplingModeThe post-process filtering mode
  149989. * @param engine The babylon engine
  149990. * @param reusable If the post-process is reusable
  149991. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  149992. */
  149993. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  149994. /**
  149995. * Returns the string "VolumetricLightScatteringPostProcess"
  149996. * @returns "VolumetricLightScatteringPostProcess"
  149997. */
  149998. getClassName(): string;
  149999. private _isReady;
  150000. /**
  150001. * Sets the new light position for light scattering effect
  150002. * @param position The new custom light position
  150003. */
  150004. setCustomMeshPosition(position: Vector3): void;
  150005. /**
  150006. * Returns the light position for light scattering effect
  150007. * @return Vector3 The custom light position
  150008. */
  150009. getCustomMeshPosition(): Vector3;
  150010. /**
  150011. * Disposes the internal assets and detaches the post-process from the camera
  150012. */
  150013. dispose(camera: Camera): void;
  150014. /**
  150015. * Returns the render target texture used by the post-process
  150016. * @return the render target texture used by the post-process
  150017. */
  150018. getPass(): RenderTargetTexture;
  150019. private _meshExcluded;
  150020. private _createPass;
  150021. private _updateMeshScreenCoordinates;
  150022. /**
  150023. * Creates a default mesh for the Volumeric Light Scattering post-process
  150024. * @param name The mesh name
  150025. * @param scene The scene where to create the mesh
  150026. * @return the default mesh
  150027. */
  150028. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  150029. }
  150030. }
  150031. declare module BABYLON {
  150032. /** @hidden */
  150033. export var screenSpaceCurvaturePixelShader: {
  150034. name: string;
  150035. shader: string;
  150036. };
  150037. }
  150038. declare module BABYLON {
  150039. /**
  150040. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  150041. */
  150042. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  150043. /**
  150044. * Defines how much ridge the curvature effect displays.
  150045. */
  150046. ridge: number;
  150047. /**
  150048. * Defines how much valley the curvature effect displays.
  150049. */
  150050. valley: number;
  150051. private _geometryBufferRenderer;
  150052. /**
  150053. * Creates a new instance ScreenSpaceCurvaturePostProcess
  150054. * @param name The name of the effect.
  150055. * @param scene The scene containing the objects to blur according to their velocity.
  150056. * @param options The required width/height ratio to downsize to before computing the render pass.
  150057. * @param camera The camera to apply the render pass to.
  150058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150059. * @param engine The engine which the post process will be applied. (default: current engine)
  150060. * @param reusable If the post process can be reused on the same frame. (default: false)
  150061. * @param textureType Type of textures used when performing the post process. (default: 0)
  150062. * @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)
  150063. */
  150064. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150065. /**
  150066. * Support test.
  150067. */
  150068. static get IsSupported(): boolean;
  150069. }
  150070. }
  150071. declare module BABYLON {
  150072. interface Scene {
  150073. /** @hidden (Backing field) */
  150074. _boundingBoxRenderer: BoundingBoxRenderer;
  150075. /** @hidden (Backing field) */
  150076. _forceShowBoundingBoxes: boolean;
  150077. /**
  150078. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  150079. */
  150080. forceShowBoundingBoxes: boolean;
  150081. /**
  150082. * Gets the bounding box renderer associated with the scene
  150083. * @returns a BoundingBoxRenderer
  150084. */
  150085. getBoundingBoxRenderer(): BoundingBoxRenderer;
  150086. }
  150087. interface AbstractMesh {
  150088. /** @hidden (Backing field) */
  150089. _showBoundingBox: boolean;
  150090. /**
  150091. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  150092. */
  150093. showBoundingBox: boolean;
  150094. }
  150095. /**
  150096. * Component responsible of rendering the bounding box of the meshes in a scene.
  150097. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  150098. */
  150099. export class BoundingBoxRenderer implements ISceneComponent {
  150100. /**
  150101. * The component name helpfull to identify the component in the list of scene components.
  150102. */
  150103. readonly name: string;
  150104. /**
  150105. * The scene the component belongs to.
  150106. */
  150107. scene: Scene;
  150108. /**
  150109. * Color of the bounding box lines placed in front of an object
  150110. */
  150111. frontColor: Color3;
  150112. /**
  150113. * Color of the bounding box lines placed behind an object
  150114. */
  150115. backColor: Color3;
  150116. /**
  150117. * Defines if the renderer should show the back lines or not
  150118. */
  150119. showBackLines: boolean;
  150120. /**
  150121. * Observable raised before rendering a bounding box
  150122. */
  150123. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  150124. /**
  150125. * Observable raised after rendering a bounding box
  150126. */
  150127. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  150128. /**
  150129. * @hidden
  150130. */
  150131. renderList: SmartArray<BoundingBox>;
  150132. private _colorShader;
  150133. private _vertexBuffers;
  150134. private _indexBuffer;
  150135. private _fillIndexBuffer;
  150136. private _fillIndexData;
  150137. /**
  150138. * Instantiates a new bounding box renderer in a scene.
  150139. * @param scene the scene the renderer renders in
  150140. */
  150141. constructor(scene: Scene);
  150142. /**
  150143. * Registers the component in a given scene
  150144. */
  150145. register(): void;
  150146. private _evaluateSubMesh;
  150147. private _activeMesh;
  150148. private _prepareRessources;
  150149. private _createIndexBuffer;
  150150. /**
  150151. * Rebuilds the elements related to this component in case of
  150152. * context lost for instance.
  150153. */
  150154. rebuild(): void;
  150155. /**
  150156. * @hidden
  150157. */
  150158. reset(): void;
  150159. /**
  150160. * Render the bounding boxes of a specific rendering group
  150161. * @param renderingGroupId defines the rendering group to render
  150162. */
  150163. render(renderingGroupId: number): void;
  150164. /**
  150165. * In case of occlusion queries, we can render the occlusion bounding box through this method
  150166. * @param mesh Define the mesh to render the occlusion bounding box for
  150167. */
  150168. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  150169. /**
  150170. * Dispose and release the resources attached to this renderer.
  150171. */
  150172. dispose(): void;
  150173. }
  150174. }
  150175. declare module BABYLON {
  150176. interface Scene {
  150177. /** @hidden (Backing field) */
  150178. _depthRenderer: {
  150179. [id: string]: DepthRenderer;
  150180. };
  150181. /**
  150182. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  150183. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  150184. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  150185. * @returns the created depth renderer
  150186. */
  150187. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  150188. /**
  150189. * Disables a depth renderer for a given camera
  150190. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  150191. */
  150192. disableDepthRenderer(camera?: Nullable<Camera>): void;
  150193. }
  150194. /**
  150195. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  150196. * in several rendering techniques.
  150197. */
  150198. export class DepthRendererSceneComponent implements ISceneComponent {
  150199. /**
  150200. * The component name helpfull to identify the component in the list of scene components.
  150201. */
  150202. readonly name: string;
  150203. /**
  150204. * The scene the component belongs to.
  150205. */
  150206. scene: Scene;
  150207. /**
  150208. * Creates a new instance of the component for the given scene
  150209. * @param scene Defines the scene to register the component in
  150210. */
  150211. constructor(scene: Scene);
  150212. /**
  150213. * Registers the component in a given scene
  150214. */
  150215. register(): void;
  150216. /**
  150217. * Rebuilds the elements related to this component in case of
  150218. * context lost for instance.
  150219. */
  150220. rebuild(): void;
  150221. /**
  150222. * Disposes the component and the associated ressources
  150223. */
  150224. dispose(): void;
  150225. private _gatherRenderTargets;
  150226. private _gatherActiveCameraRenderTargets;
  150227. }
  150228. }
  150229. declare module BABYLON {
  150230. interface AbstractScene {
  150231. /** @hidden (Backing field) */
  150232. _prePassRenderer: Nullable<PrePassRenderer>;
  150233. /**
  150234. * Gets or Sets the current prepass renderer associated to the scene.
  150235. */
  150236. prePassRenderer: Nullable<PrePassRenderer>;
  150237. /**
  150238. * Enables the prepass and associates it with the scene
  150239. * @returns the PrePassRenderer
  150240. */
  150241. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  150242. /**
  150243. * Disables the prepass associated with the scene
  150244. */
  150245. disablePrePassRenderer(): void;
  150246. }
  150247. /**
  150248. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150249. * in several rendering techniques.
  150250. */
  150251. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  150252. /**
  150253. * The component name helpful to identify the component in the list of scene components.
  150254. */
  150255. readonly name: string;
  150256. /**
  150257. * The scene the component belongs to.
  150258. */
  150259. scene: Scene;
  150260. /**
  150261. * Creates a new instance of the component for the given scene
  150262. * @param scene Defines the scene to register the component in
  150263. */
  150264. constructor(scene: Scene);
  150265. /**
  150266. * Registers the component in a given scene
  150267. */
  150268. register(): void;
  150269. private _beforeCameraDraw;
  150270. private _afterCameraDraw;
  150271. private _beforeClearStage;
  150272. /**
  150273. * Serializes the component data to the specified json object
  150274. * @param serializationObject The object to serialize to
  150275. */
  150276. serialize(serializationObject: any): void;
  150277. /**
  150278. * Adds all the elements from the container to the scene
  150279. * @param container the container holding the elements
  150280. */
  150281. addFromContainer(container: AbstractScene): void;
  150282. /**
  150283. * Removes all the elements in the container from the scene
  150284. * @param container contains the elements to remove
  150285. * @param dispose if the removed element should be disposed (default: false)
  150286. */
  150287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  150288. /**
  150289. * Rebuilds the elements related to this component in case of
  150290. * context lost for instance.
  150291. */
  150292. rebuild(): void;
  150293. /**
  150294. * Disposes the component and the associated ressources
  150295. */
  150296. dispose(): void;
  150297. }
  150298. }
  150299. declare module BABYLON {
  150300. /** @hidden */
  150301. export var outlinePixelShader: {
  150302. name: string;
  150303. shader: string;
  150304. };
  150305. }
  150306. declare module BABYLON {
  150307. /** @hidden */
  150308. export var outlineVertexShader: {
  150309. name: string;
  150310. shader: string;
  150311. };
  150312. }
  150313. declare module BABYLON {
  150314. interface Scene {
  150315. /** @hidden */
  150316. _outlineRenderer: OutlineRenderer;
  150317. /**
  150318. * Gets the outline renderer associated with the scene
  150319. * @returns a OutlineRenderer
  150320. */
  150321. getOutlineRenderer(): OutlineRenderer;
  150322. }
  150323. interface AbstractMesh {
  150324. /** @hidden (Backing field) */
  150325. _renderOutline: boolean;
  150326. /**
  150327. * Gets or sets a boolean indicating if the outline must be rendered as well
  150328. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  150329. */
  150330. renderOutline: boolean;
  150331. /** @hidden (Backing field) */
  150332. _renderOverlay: boolean;
  150333. /**
  150334. * Gets or sets a boolean indicating if the overlay must be rendered as well
  150335. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  150336. */
  150337. renderOverlay: boolean;
  150338. }
  150339. /**
  150340. * This class is responsible to draw bothe outline/overlay of meshes.
  150341. * It should not be used directly but through the available method on mesh.
  150342. */
  150343. export class OutlineRenderer implements ISceneComponent {
  150344. /**
  150345. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  150346. */
  150347. private static _StencilReference;
  150348. /**
  150349. * The name of the component. Each component must have a unique name.
  150350. */
  150351. name: string;
  150352. /**
  150353. * The scene the component belongs to.
  150354. */
  150355. scene: Scene;
  150356. /**
  150357. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  150358. */
  150359. zOffset: number;
  150360. private _engine;
  150361. private _effect;
  150362. private _cachedDefines;
  150363. private _savedDepthWrite;
  150364. /**
  150365. * Instantiates a new outline renderer. (There could be only one per scene).
  150366. * @param scene Defines the scene it belongs to
  150367. */
  150368. constructor(scene: Scene);
  150369. /**
  150370. * Register the component to one instance of a scene.
  150371. */
  150372. register(): void;
  150373. /**
  150374. * Rebuilds the elements related to this component in case of
  150375. * context lost for instance.
  150376. */
  150377. rebuild(): void;
  150378. /**
  150379. * Disposes the component and the associated ressources.
  150380. */
  150381. dispose(): void;
  150382. /**
  150383. * Renders the outline in the canvas.
  150384. * @param subMesh Defines the sumesh to render
  150385. * @param batch Defines the batch of meshes in case of instances
  150386. * @param useOverlay Defines if the rendering is for the overlay or the outline
  150387. */
  150388. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  150389. /**
  150390. * Returns whether or not the outline renderer is ready for a given submesh.
  150391. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  150392. * @param subMesh Defines the submesh to check readyness for
  150393. * @param useInstances Defines wheter wee are trying to render instances or not
  150394. * @returns true if ready otherwise false
  150395. */
  150396. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150397. private _beforeRenderingMesh;
  150398. private _afterRenderingMesh;
  150399. }
  150400. }
  150401. declare module BABYLON {
  150402. /**
  150403. * Defines the basic options interface of a Sprite Frame Source Size.
  150404. */
  150405. export interface ISpriteJSONSpriteSourceSize {
  150406. /**
  150407. * number of the original width of the Frame
  150408. */
  150409. w: number;
  150410. /**
  150411. * number of the original height of the Frame
  150412. */
  150413. h: number;
  150414. }
  150415. /**
  150416. * Defines the basic options interface of a Sprite Frame Data.
  150417. */
  150418. export interface ISpriteJSONSpriteFrameData {
  150419. /**
  150420. * number of the x offset of the Frame
  150421. */
  150422. x: number;
  150423. /**
  150424. * number of the y offset of the Frame
  150425. */
  150426. y: number;
  150427. /**
  150428. * number of the width of the Frame
  150429. */
  150430. w: number;
  150431. /**
  150432. * number of the height of the Frame
  150433. */
  150434. h: number;
  150435. }
  150436. /**
  150437. * Defines the basic options interface of a JSON Sprite.
  150438. */
  150439. export interface ISpriteJSONSprite {
  150440. /**
  150441. * string name of the Frame
  150442. */
  150443. filename: string;
  150444. /**
  150445. * ISpriteJSONSpriteFrame basic object of the frame data
  150446. */
  150447. frame: ISpriteJSONSpriteFrameData;
  150448. /**
  150449. * boolean to flag is the frame was rotated.
  150450. */
  150451. rotated: boolean;
  150452. /**
  150453. * boolean to flag is the frame was trimmed.
  150454. */
  150455. trimmed: boolean;
  150456. /**
  150457. * ISpriteJSONSpriteFrame basic object of the source data
  150458. */
  150459. spriteSourceSize: ISpriteJSONSpriteFrameData;
  150460. /**
  150461. * ISpriteJSONSpriteFrame basic object of the source data
  150462. */
  150463. sourceSize: ISpriteJSONSpriteSourceSize;
  150464. }
  150465. /**
  150466. * Defines the basic options interface of a JSON atlas.
  150467. */
  150468. export interface ISpriteJSONAtlas {
  150469. /**
  150470. * Array of objects that contain the frame data.
  150471. */
  150472. frames: Array<ISpriteJSONSprite>;
  150473. /**
  150474. * object basic object containing the sprite meta data.
  150475. */
  150476. meta?: object;
  150477. }
  150478. }
  150479. declare module BABYLON {
  150480. /** @hidden */
  150481. export var spriteMapPixelShader: {
  150482. name: string;
  150483. shader: string;
  150484. };
  150485. }
  150486. declare module BABYLON {
  150487. /** @hidden */
  150488. export var spriteMapVertexShader: {
  150489. name: string;
  150490. shader: string;
  150491. };
  150492. }
  150493. declare module BABYLON {
  150494. /**
  150495. * Defines the basic options interface of a SpriteMap
  150496. */
  150497. export interface ISpriteMapOptions {
  150498. /**
  150499. * Vector2 of the number of cells in the grid.
  150500. */
  150501. stageSize?: Vector2;
  150502. /**
  150503. * Vector2 of the size of the output plane in World Units.
  150504. */
  150505. outputSize?: Vector2;
  150506. /**
  150507. * Vector3 of the position of the output plane in World Units.
  150508. */
  150509. outputPosition?: Vector3;
  150510. /**
  150511. * Vector3 of the rotation of the output plane.
  150512. */
  150513. outputRotation?: Vector3;
  150514. /**
  150515. * number of layers that the system will reserve in resources.
  150516. */
  150517. layerCount?: number;
  150518. /**
  150519. * number of max animation frames a single cell will reserve in resources.
  150520. */
  150521. maxAnimationFrames?: number;
  150522. /**
  150523. * number cell index of the base tile when the system compiles.
  150524. */
  150525. baseTile?: number;
  150526. /**
  150527. * boolean flip the sprite after its been repositioned by the framing data.
  150528. */
  150529. flipU?: boolean;
  150530. /**
  150531. * Vector3 scalar of the global RGB values of the SpriteMap.
  150532. */
  150533. colorMultiply?: Vector3;
  150534. }
  150535. /**
  150536. * Defines the IDisposable interface in order to be cleanable from resources.
  150537. */
  150538. export interface ISpriteMap extends IDisposable {
  150539. /**
  150540. * String name of the SpriteMap.
  150541. */
  150542. name: string;
  150543. /**
  150544. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  150545. */
  150546. atlasJSON: ISpriteJSONAtlas;
  150547. /**
  150548. * Texture of the SpriteMap.
  150549. */
  150550. spriteSheet: Texture;
  150551. /**
  150552. * The parameters to initialize the SpriteMap with.
  150553. */
  150554. options: ISpriteMapOptions;
  150555. }
  150556. /**
  150557. * Class used to manage a grid restricted sprite deployment on an Output plane.
  150558. */
  150559. export class SpriteMap implements ISpriteMap {
  150560. /** The Name of the spriteMap */
  150561. name: string;
  150562. /** The JSON file with the frame and meta data */
  150563. atlasJSON: ISpriteJSONAtlas;
  150564. /** The systems Sprite Sheet Texture */
  150565. spriteSheet: Texture;
  150566. /** Arguments passed with the Constructor */
  150567. options: ISpriteMapOptions;
  150568. /** Public Sprite Storage array, parsed from atlasJSON */
  150569. sprites: Array<ISpriteJSONSprite>;
  150570. /** Returns the Number of Sprites in the System */
  150571. get spriteCount(): number;
  150572. /** Returns the Position of Output Plane*/
  150573. get position(): Vector3;
  150574. /** Returns the Position of Output Plane*/
  150575. set position(v: Vector3);
  150576. /** Returns the Rotation of Output Plane*/
  150577. get rotation(): Vector3;
  150578. /** Returns the Rotation of Output Plane*/
  150579. set rotation(v: Vector3);
  150580. /** Sets the AnimationMap*/
  150581. get animationMap(): RawTexture;
  150582. /** Sets the AnimationMap*/
  150583. set animationMap(v: RawTexture);
  150584. /** Scene that the SpriteMap was created in */
  150585. private _scene;
  150586. /** Texture Buffer of Float32 that holds tile frame data*/
  150587. private _frameMap;
  150588. /** Texture Buffers of Float32 that holds tileMap data*/
  150589. private _tileMaps;
  150590. /** Texture Buffer of Float32 that holds Animation Data*/
  150591. private _animationMap;
  150592. /** Custom ShaderMaterial Central to the System*/
  150593. private _material;
  150594. /** Custom ShaderMaterial Central to the System*/
  150595. private _output;
  150596. /** Systems Time Ticker*/
  150597. private _time;
  150598. /**
  150599. * Creates a new SpriteMap
  150600. * @param name defines the SpriteMaps Name
  150601. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  150602. * @param spriteSheet is the Texture that the Sprites are on.
  150603. * @param options a basic deployment configuration
  150604. * @param scene The Scene that the map is deployed on
  150605. */
  150606. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  150607. /**
  150608. * Returns tileID location
  150609. * @returns Vector2 the cell position ID
  150610. */
  150611. getTileID(): Vector2;
  150612. /**
  150613. * Gets the UV location of the mouse over the SpriteMap.
  150614. * @returns Vector2 the UV position of the mouse interaction
  150615. */
  150616. getMousePosition(): Vector2;
  150617. /**
  150618. * Creates the "frame" texture Buffer
  150619. * -------------------------------------
  150620. * Structure of frames
  150621. * "filename": "Falling-Water-2.png",
  150622. * "frame": {"x":69,"y":103,"w":24,"h":32},
  150623. * "rotated": true,
  150624. * "trimmed": true,
  150625. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  150626. * "sourceSize": {"w":32,"h":32}
  150627. * @returns RawTexture of the frameMap
  150628. */
  150629. private _createFrameBuffer;
  150630. /**
  150631. * Creates the tileMap texture Buffer
  150632. * @param buffer normally and array of numbers, or a false to generate from scratch
  150633. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  150634. * @returns RawTexture of the tileMap
  150635. */
  150636. private _createTileBuffer;
  150637. /**
  150638. * Modifies the data of the tileMaps
  150639. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  150640. * @param pos is the iVector2 Coordinates of the Tile
  150641. * @param tile The SpriteIndex of the new Tile
  150642. */
  150643. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  150644. /**
  150645. * Creates the animationMap texture Buffer
  150646. * @param buffer normally and array of numbers, or a false to generate from scratch
  150647. * @returns RawTexture of the animationMap
  150648. */
  150649. private _createTileAnimationBuffer;
  150650. /**
  150651. * Modifies the data of the animationMap
  150652. * @param cellID is the Index of the Sprite
  150653. * @param _frame is the target Animation frame
  150654. * @param toCell is the Target Index of the next frame of the animation
  150655. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  150656. * @param speed is a global scalar of the time variable on the map.
  150657. */
  150658. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  150659. /**
  150660. * Exports the .tilemaps file
  150661. */
  150662. saveTileMaps(): void;
  150663. /**
  150664. * Imports the .tilemaps file
  150665. * @param url of the .tilemaps file
  150666. */
  150667. loadTileMaps(url: string): void;
  150668. /**
  150669. * Release associated resources
  150670. */
  150671. dispose(): void;
  150672. }
  150673. }
  150674. declare module BABYLON {
  150675. /**
  150676. * Class used to manage multiple sprites of different sizes on the same spritesheet
  150677. * @see https://doc.babylonjs.com/babylon101/sprites
  150678. */
  150679. export class SpritePackedManager extends SpriteManager {
  150680. /** defines the packed manager's name */
  150681. name: string;
  150682. /**
  150683. * Creates a new sprite manager from a packed sprite sheet
  150684. * @param name defines the manager's name
  150685. * @param imgUrl defines the sprite sheet url
  150686. * @param capacity defines the maximum allowed number of sprites
  150687. * @param scene defines the hosting scene
  150688. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  150689. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  150690. * @param samplingMode defines the smapling mode to use with spritesheet
  150691. * @param fromPacked set to true; do not alter
  150692. */
  150693. constructor(
  150694. /** defines the packed manager's name */
  150695. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  150696. }
  150697. }
  150698. declare module BABYLON {
  150699. /**
  150700. * Defines the list of states available for a task inside a AssetsManager
  150701. */
  150702. export enum AssetTaskState {
  150703. /**
  150704. * Initialization
  150705. */
  150706. INIT = 0,
  150707. /**
  150708. * Running
  150709. */
  150710. RUNNING = 1,
  150711. /**
  150712. * Done
  150713. */
  150714. DONE = 2,
  150715. /**
  150716. * Error
  150717. */
  150718. ERROR = 3
  150719. }
  150720. /**
  150721. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  150722. */
  150723. export abstract class AbstractAssetTask {
  150724. /**
  150725. * Task name
  150726. */ name: string;
  150727. /**
  150728. * Callback called when the task is successful
  150729. */
  150730. onSuccess: (task: any) => void;
  150731. /**
  150732. * Callback called when the task is not successful
  150733. */
  150734. onError: (task: any, message?: string, exception?: any) => void;
  150735. /**
  150736. * Creates a new AssetsManager
  150737. * @param name defines the name of the task
  150738. */
  150739. constructor(
  150740. /**
  150741. * Task name
  150742. */ name: string);
  150743. private _isCompleted;
  150744. private _taskState;
  150745. private _errorObject;
  150746. /**
  150747. * Get if the task is completed
  150748. */
  150749. get isCompleted(): boolean;
  150750. /**
  150751. * Gets the current state of the task
  150752. */
  150753. get taskState(): AssetTaskState;
  150754. /**
  150755. * Gets the current error object (if task is in error)
  150756. */
  150757. get errorObject(): {
  150758. message?: string;
  150759. exception?: any;
  150760. };
  150761. /**
  150762. * Internal only
  150763. * @hidden
  150764. */
  150765. _setErrorObject(message?: string, exception?: any): void;
  150766. /**
  150767. * Execute the current task
  150768. * @param scene defines the scene where you want your assets to be loaded
  150769. * @param onSuccess is a callback called when the task is successfully executed
  150770. * @param onError is a callback called if an error occurs
  150771. */
  150772. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150773. /**
  150774. * Execute the current task
  150775. * @param scene defines the scene where you want your assets to be loaded
  150776. * @param onSuccess is a callback called when the task is successfully executed
  150777. * @param onError is a callback called if an error occurs
  150778. */
  150779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150780. /**
  150781. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  150782. * This can be used with failed tasks that have the reason for failure fixed.
  150783. */
  150784. reset(): void;
  150785. private onErrorCallback;
  150786. private onDoneCallback;
  150787. }
  150788. /**
  150789. * Define the interface used by progress events raised during assets loading
  150790. */
  150791. export interface IAssetsProgressEvent {
  150792. /**
  150793. * Defines the number of remaining tasks to process
  150794. */
  150795. remainingCount: number;
  150796. /**
  150797. * Defines the total number of tasks
  150798. */
  150799. totalCount: number;
  150800. /**
  150801. * Defines the task that was just processed
  150802. */
  150803. task: AbstractAssetTask;
  150804. }
  150805. /**
  150806. * Class used to share progress information about assets loading
  150807. */
  150808. export class AssetsProgressEvent implements IAssetsProgressEvent {
  150809. /**
  150810. * Defines the number of remaining tasks to process
  150811. */
  150812. remainingCount: number;
  150813. /**
  150814. * Defines the total number of tasks
  150815. */
  150816. totalCount: number;
  150817. /**
  150818. * Defines the task that was just processed
  150819. */
  150820. task: AbstractAssetTask;
  150821. /**
  150822. * Creates a AssetsProgressEvent
  150823. * @param remainingCount defines the number of remaining tasks to process
  150824. * @param totalCount defines the total number of tasks
  150825. * @param task defines the task that was just processed
  150826. */
  150827. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  150828. }
  150829. /**
  150830. * Define a task used by AssetsManager to load assets into a container
  150831. */
  150832. export class ContainerAssetTask extends AbstractAssetTask {
  150833. /**
  150834. * Defines the name of the task
  150835. */
  150836. name: string;
  150837. /**
  150838. * Defines the list of mesh's names you want to load
  150839. */
  150840. meshesNames: any;
  150841. /**
  150842. * Defines the root url to use as a base to load your meshes and associated resources
  150843. */
  150844. rootUrl: string;
  150845. /**
  150846. * Defines the filename or File of the scene to load from
  150847. */
  150848. sceneFilename: string | File;
  150849. /**
  150850. * Get the loaded asset container
  150851. */
  150852. loadedContainer: AssetContainer;
  150853. /**
  150854. * Gets the list of loaded meshes
  150855. */
  150856. loadedMeshes: Array<AbstractMesh>;
  150857. /**
  150858. * Gets the list of loaded particle systems
  150859. */
  150860. loadedParticleSystems: Array<IParticleSystem>;
  150861. /**
  150862. * Gets the list of loaded skeletons
  150863. */
  150864. loadedSkeletons: Array<Skeleton>;
  150865. /**
  150866. * Gets the list of loaded animation groups
  150867. */
  150868. loadedAnimationGroups: Array<AnimationGroup>;
  150869. /**
  150870. * Callback called when the task is successful
  150871. */
  150872. onSuccess: (task: ContainerAssetTask) => void;
  150873. /**
  150874. * Callback called when the task is successful
  150875. */
  150876. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  150877. /**
  150878. * Creates a new ContainerAssetTask
  150879. * @param name defines the name of the task
  150880. * @param meshesNames defines the list of mesh's names you want to load
  150881. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150882. * @param sceneFilename defines the filename or File of the scene to load from
  150883. */
  150884. constructor(
  150885. /**
  150886. * Defines the name of the task
  150887. */
  150888. name: string,
  150889. /**
  150890. * Defines the list of mesh's names you want to load
  150891. */
  150892. meshesNames: any,
  150893. /**
  150894. * Defines the root url to use as a base to load your meshes and associated resources
  150895. */
  150896. rootUrl: string,
  150897. /**
  150898. * Defines the filename or File of the scene to load from
  150899. */
  150900. sceneFilename: string | File);
  150901. /**
  150902. * Execute the current task
  150903. * @param scene defines the scene where you want your assets to be loaded
  150904. * @param onSuccess is a callback called when the task is successfully executed
  150905. * @param onError is a callback called if an error occurs
  150906. */
  150907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150908. }
  150909. /**
  150910. * Define a task used by AssetsManager to load meshes
  150911. */
  150912. export class MeshAssetTask extends AbstractAssetTask {
  150913. /**
  150914. * Defines the name of the task
  150915. */
  150916. name: string;
  150917. /**
  150918. * Defines the list of mesh's names you want to load
  150919. */
  150920. meshesNames: any;
  150921. /**
  150922. * Defines the root url to use as a base to load your meshes and associated resources
  150923. */
  150924. rootUrl: string;
  150925. /**
  150926. * Defines the filename or File of the scene to load from
  150927. */
  150928. sceneFilename: string | File;
  150929. /**
  150930. * Gets the list of loaded meshes
  150931. */
  150932. loadedMeshes: Array<AbstractMesh>;
  150933. /**
  150934. * Gets the list of loaded particle systems
  150935. */
  150936. loadedParticleSystems: Array<IParticleSystem>;
  150937. /**
  150938. * Gets the list of loaded skeletons
  150939. */
  150940. loadedSkeletons: Array<Skeleton>;
  150941. /**
  150942. * Gets the list of loaded animation groups
  150943. */
  150944. loadedAnimationGroups: Array<AnimationGroup>;
  150945. /**
  150946. * Callback called when the task is successful
  150947. */
  150948. onSuccess: (task: MeshAssetTask) => void;
  150949. /**
  150950. * Callback called when the task is successful
  150951. */
  150952. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  150953. /**
  150954. * Creates a new MeshAssetTask
  150955. * @param name defines the name of the task
  150956. * @param meshesNames defines the list of mesh's names you want to load
  150957. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150958. * @param sceneFilename defines the filename or File of the scene to load from
  150959. */
  150960. constructor(
  150961. /**
  150962. * Defines the name of the task
  150963. */
  150964. name: string,
  150965. /**
  150966. * Defines the list of mesh's names you want to load
  150967. */
  150968. meshesNames: any,
  150969. /**
  150970. * Defines the root url to use as a base to load your meshes and associated resources
  150971. */
  150972. rootUrl: string,
  150973. /**
  150974. * Defines the filename or File of the scene to load from
  150975. */
  150976. sceneFilename: string | File);
  150977. /**
  150978. * Execute the current task
  150979. * @param scene defines the scene where you want your assets to be loaded
  150980. * @param onSuccess is a callback called when the task is successfully executed
  150981. * @param onError is a callback called if an error occurs
  150982. */
  150983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150984. }
  150985. /**
  150986. * Define a task used by AssetsManager to load text content
  150987. */
  150988. export class TextFileAssetTask extends AbstractAssetTask {
  150989. /**
  150990. * Defines the name of the task
  150991. */
  150992. name: string;
  150993. /**
  150994. * Defines the location of the file to load
  150995. */
  150996. url: string;
  150997. /**
  150998. * Gets the loaded text string
  150999. */
  151000. text: string;
  151001. /**
  151002. * Callback called when the task is successful
  151003. */
  151004. onSuccess: (task: TextFileAssetTask) => void;
  151005. /**
  151006. * Callback called when the task is successful
  151007. */
  151008. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  151009. /**
  151010. * Creates a new TextFileAssetTask object
  151011. * @param name defines the name of the task
  151012. * @param url defines the location of the file to load
  151013. */
  151014. constructor(
  151015. /**
  151016. * Defines the name of the task
  151017. */
  151018. name: string,
  151019. /**
  151020. * Defines the location of the file to load
  151021. */
  151022. url: string);
  151023. /**
  151024. * Execute the current task
  151025. * @param scene defines the scene where you want your assets to be loaded
  151026. * @param onSuccess is a callback called when the task is successfully executed
  151027. * @param onError is a callback called if an error occurs
  151028. */
  151029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151030. }
  151031. /**
  151032. * Define a task used by AssetsManager to load binary data
  151033. */
  151034. export class BinaryFileAssetTask extends AbstractAssetTask {
  151035. /**
  151036. * Defines the name of the task
  151037. */
  151038. name: string;
  151039. /**
  151040. * Defines the location of the file to load
  151041. */
  151042. url: string;
  151043. /**
  151044. * Gets the lodaded data (as an array buffer)
  151045. */
  151046. data: ArrayBuffer;
  151047. /**
  151048. * Callback called when the task is successful
  151049. */
  151050. onSuccess: (task: BinaryFileAssetTask) => void;
  151051. /**
  151052. * Callback called when the task is successful
  151053. */
  151054. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  151055. /**
  151056. * Creates a new BinaryFileAssetTask object
  151057. * @param name defines the name of the new task
  151058. * @param url defines the location of the file to load
  151059. */
  151060. constructor(
  151061. /**
  151062. * Defines the name of the task
  151063. */
  151064. name: string,
  151065. /**
  151066. * Defines the location of the file to load
  151067. */
  151068. url: string);
  151069. /**
  151070. * Execute the current task
  151071. * @param scene defines the scene where you want your assets to be loaded
  151072. * @param onSuccess is a callback called when the task is successfully executed
  151073. * @param onError is a callback called if an error occurs
  151074. */
  151075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151076. }
  151077. /**
  151078. * Define a task used by AssetsManager to load images
  151079. */
  151080. export class ImageAssetTask extends AbstractAssetTask {
  151081. /**
  151082. * Defines the name of the task
  151083. */
  151084. name: string;
  151085. /**
  151086. * Defines the location of the image to load
  151087. */
  151088. url: string;
  151089. /**
  151090. * Gets the loaded images
  151091. */
  151092. image: HTMLImageElement;
  151093. /**
  151094. * Callback called when the task is successful
  151095. */
  151096. onSuccess: (task: ImageAssetTask) => void;
  151097. /**
  151098. * Callback called when the task is successful
  151099. */
  151100. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  151101. /**
  151102. * Creates a new ImageAssetTask
  151103. * @param name defines the name of the task
  151104. * @param url defines the location of the image to load
  151105. */
  151106. constructor(
  151107. /**
  151108. * Defines the name of the task
  151109. */
  151110. name: string,
  151111. /**
  151112. * Defines the location of the image to load
  151113. */
  151114. url: string);
  151115. /**
  151116. * Execute the current task
  151117. * @param scene defines the scene where you want your assets to be loaded
  151118. * @param onSuccess is a callback called when the task is successfully executed
  151119. * @param onError is a callback called if an error occurs
  151120. */
  151121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151122. }
  151123. /**
  151124. * Defines the interface used by texture loading tasks
  151125. */
  151126. export interface ITextureAssetTask<TEX extends BaseTexture> {
  151127. /**
  151128. * Gets the loaded texture
  151129. */
  151130. texture: TEX;
  151131. }
  151132. /**
  151133. * Define a task used by AssetsManager to load 2D textures
  151134. */
  151135. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  151136. /**
  151137. * Defines the name of the task
  151138. */
  151139. name: string;
  151140. /**
  151141. * Defines the location of the file to load
  151142. */
  151143. url: string;
  151144. /**
  151145. * Defines if mipmap should not be generated (default is false)
  151146. */
  151147. noMipmap?: boolean | undefined;
  151148. /**
  151149. * Defines if texture must be inverted on Y axis (default is true)
  151150. */
  151151. invertY: boolean;
  151152. /**
  151153. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151154. */
  151155. samplingMode: number;
  151156. /**
  151157. * Gets the loaded texture
  151158. */
  151159. texture: Texture;
  151160. /**
  151161. * Callback called when the task is successful
  151162. */
  151163. onSuccess: (task: TextureAssetTask) => void;
  151164. /**
  151165. * Callback called when the task is successful
  151166. */
  151167. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  151168. /**
  151169. * Creates a new TextureAssetTask object
  151170. * @param name defines the name of the task
  151171. * @param url defines the location of the file to load
  151172. * @param noMipmap defines if mipmap should not be generated (default is false)
  151173. * @param invertY defines if texture must be inverted on Y axis (default is true)
  151174. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151175. */
  151176. constructor(
  151177. /**
  151178. * Defines the name of the task
  151179. */
  151180. name: string,
  151181. /**
  151182. * Defines the location of the file to load
  151183. */
  151184. url: string,
  151185. /**
  151186. * Defines if mipmap should not be generated (default is false)
  151187. */
  151188. noMipmap?: boolean | undefined,
  151189. /**
  151190. * Defines if texture must be inverted on Y axis (default is true)
  151191. */
  151192. invertY?: boolean,
  151193. /**
  151194. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151195. */
  151196. samplingMode?: number);
  151197. /**
  151198. * Execute the current task
  151199. * @param scene defines the scene where you want your assets to be loaded
  151200. * @param onSuccess is a callback called when the task is successfully executed
  151201. * @param onError is a callback called if an error occurs
  151202. */
  151203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151204. }
  151205. /**
  151206. * Define a task used by AssetsManager to load cube textures
  151207. */
  151208. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  151209. /**
  151210. * Defines the name of the task
  151211. */
  151212. name: string;
  151213. /**
  151214. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151215. */
  151216. url: string;
  151217. /**
  151218. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151219. */
  151220. extensions?: string[] | undefined;
  151221. /**
  151222. * Defines if mipmaps should not be generated (default is false)
  151223. */
  151224. noMipmap?: boolean | undefined;
  151225. /**
  151226. * Defines the explicit list of files (undefined by default)
  151227. */
  151228. files?: string[] | undefined;
  151229. /**
  151230. * Gets the loaded texture
  151231. */
  151232. texture: CubeTexture;
  151233. /**
  151234. * Callback called when the task is successful
  151235. */
  151236. onSuccess: (task: CubeTextureAssetTask) => void;
  151237. /**
  151238. * Callback called when the task is successful
  151239. */
  151240. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  151241. /**
  151242. * Creates a new CubeTextureAssetTask
  151243. * @param name defines the name of the task
  151244. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151245. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151246. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151247. * @param files defines the explicit list of files (undefined by default)
  151248. */
  151249. constructor(
  151250. /**
  151251. * Defines the name of the task
  151252. */
  151253. name: string,
  151254. /**
  151255. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151256. */
  151257. url: string,
  151258. /**
  151259. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151260. */
  151261. extensions?: string[] | undefined,
  151262. /**
  151263. * Defines if mipmaps should not be generated (default is false)
  151264. */
  151265. noMipmap?: boolean | undefined,
  151266. /**
  151267. * Defines the explicit list of files (undefined by default)
  151268. */
  151269. files?: string[] | undefined);
  151270. /**
  151271. * Execute the current task
  151272. * @param scene defines the scene where you want your assets to be loaded
  151273. * @param onSuccess is a callback called when the task is successfully executed
  151274. * @param onError is a callback called if an error occurs
  151275. */
  151276. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151277. }
  151278. /**
  151279. * Define a task used by AssetsManager to load HDR cube textures
  151280. */
  151281. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  151282. /**
  151283. * Defines the name of the task
  151284. */
  151285. name: string;
  151286. /**
  151287. * Defines the location of the file to load
  151288. */
  151289. url: string;
  151290. /**
  151291. * Defines the desired size (the more it increases the longer the generation will be)
  151292. */
  151293. size: number;
  151294. /**
  151295. * Defines if mipmaps should not be generated (default is false)
  151296. */
  151297. noMipmap: boolean;
  151298. /**
  151299. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151300. */
  151301. generateHarmonics: boolean;
  151302. /**
  151303. * 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)
  151304. */
  151305. gammaSpace: boolean;
  151306. /**
  151307. * Internal Use Only
  151308. */
  151309. reserved: boolean;
  151310. /**
  151311. * Gets the loaded texture
  151312. */
  151313. texture: HDRCubeTexture;
  151314. /**
  151315. * Callback called when the task is successful
  151316. */
  151317. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  151318. /**
  151319. * Callback called when the task is successful
  151320. */
  151321. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  151322. /**
  151323. * Creates a new HDRCubeTextureAssetTask object
  151324. * @param name defines the name of the task
  151325. * @param url defines the location of the file to load
  151326. * @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.
  151327. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151328. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151329. * @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)
  151330. * @param reserved Internal use only
  151331. */
  151332. constructor(
  151333. /**
  151334. * Defines the name of the task
  151335. */
  151336. name: string,
  151337. /**
  151338. * Defines the location of the file to load
  151339. */
  151340. url: string,
  151341. /**
  151342. * Defines the desired size (the more it increases the longer the generation will be)
  151343. */
  151344. size: number,
  151345. /**
  151346. * Defines if mipmaps should not be generated (default is false)
  151347. */
  151348. noMipmap?: boolean,
  151349. /**
  151350. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151351. */
  151352. generateHarmonics?: boolean,
  151353. /**
  151354. * 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)
  151355. */
  151356. gammaSpace?: boolean,
  151357. /**
  151358. * Internal Use Only
  151359. */
  151360. reserved?: boolean);
  151361. /**
  151362. * Execute the current task
  151363. * @param scene defines the scene where you want your assets to be loaded
  151364. * @param onSuccess is a callback called when the task is successfully executed
  151365. * @param onError is a callback called if an error occurs
  151366. */
  151367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151368. }
  151369. /**
  151370. * Define a task used by AssetsManager to load Equirectangular cube textures
  151371. */
  151372. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  151373. /**
  151374. * Defines the name of the task
  151375. */
  151376. name: string;
  151377. /**
  151378. * Defines the location of the file to load
  151379. */
  151380. url: string;
  151381. /**
  151382. * Defines the desired size (the more it increases the longer the generation will be)
  151383. */
  151384. size: number;
  151385. /**
  151386. * Defines if mipmaps should not be generated (default is false)
  151387. */
  151388. noMipmap: boolean;
  151389. /**
  151390. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151391. * but the standard material would require them in Gamma space) (default is true)
  151392. */
  151393. gammaSpace: boolean;
  151394. /**
  151395. * Gets the loaded texture
  151396. */
  151397. texture: EquiRectangularCubeTexture;
  151398. /**
  151399. * Callback called when the task is successful
  151400. */
  151401. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  151402. /**
  151403. * Callback called when the task is successful
  151404. */
  151405. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  151406. /**
  151407. * Creates a new EquiRectangularCubeTextureAssetTask object
  151408. * @param name defines the name of the task
  151409. * @param url defines the location of the file to load
  151410. * @param size defines the desired size (the more it increases the longer the generation will be)
  151411. * If the size is omitted this implies you are using a preprocessed cubemap.
  151412. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151413. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  151414. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  151415. * (default is true)
  151416. */
  151417. constructor(
  151418. /**
  151419. * Defines the name of the task
  151420. */
  151421. name: string,
  151422. /**
  151423. * Defines the location of the file to load
  151424. */
  151425. url: string,
  151426. /**
  151427. * Defines the desired size (the more it increases the longer the generation will be)
  151428. */
  151429. size: number,
  151430. /**
  151431. * Defines if mipmaps should not be generated (default is false)
  151432. */
  151433. noMipmap?: boolean,
  151434. /**
  151435. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151436. * but the standard material would require them in Gamma space) (default is true)
  151437. */
  151438. gammaSpace?: boolean);
  151439. /**
  151440. * Execute the current task
  151441. * @param scene defines the scene where you want your assets to be loaded
  151442. * @param onSuccess is a callback called when the task is successfully executed
  151443. * @param onError is a callback called if an error occurs
  151444. */
  151445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151446. }
  151447. /**
  151448. * This class can be used to easily import assets into a scene
  151449. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  151450. */
  151451. export class AssetsManager {
  151452. private _scene;
  151453. private _isLoading;
  151454. protected _tasks: AbstractAssetTask[];
  151455. protected _waitingTasksCount: number;
  151456. protected _totalTasksCount: number;
  151457. /**
  151458. * Callback called when all tasks are processed
  151459. */
  151460. onFinish: (tasks: AbstractAssetTask[]) => void;
  151461. /**
  151462. * Callback called when a task is successful
  151463. */
  151464. onTaskSuccess: (task: AbstractAssetTask) => void;
  151465. /**
  151466. * Callback called when a task had an error
  151467. */
  151468. onTaskError: (task: AbstractAssetTask) => void;
  151469. /**
  151470. * Callback called when a task is done (whatever the result is)
  151471. */
  151472. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  151473. /**
  151474. * Observable called when all tasks are processed
  151475. */
  151476. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  151477. /**
  151478. * Observable called when a task had an error
  151479. */
  151480. onTaskErrorObservable: Observable<AbstractAssetTask>;
  151481. /**
  151482. * Observable called when all tasks were executed
  151483. */
  151484. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  151485. /**
  151486. * Observable called when a task is done (whatever the result is)
  151487. */
  151488. onProgressObservable: Observable<IAssetsProgressEvent>;
  151489. /**
  151490. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  151491. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  151492. */
  151493. useDefaultLoadingScreen: boolean;
  151494. /**
  151495. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  151496. * when all assets have been downloaded.
  151497. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  151498. */
  151499. autoHideLoadingUI: boolean;
  151500. /**
  151501. * Creates a new AssetsManager
  151502. * @param scene defines the scene to work on
  151503. */
  151504. constructor(scene: Scene);
  151505. /**
  151506. * Add a ContainerAssetTask to the list of active tasks
  151507. * @param taskName defines the name of the new task
  151508. * @param meshesNames defines the name of meshes to load
  151509. * @param rootUrl defines the root url to use to locate files
  151510. * @param sceneFilename defines the filename of the scene file
  151511. * @returns a new ContainerAssetTask object
  151512. */
  151513. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  151514. /**
  151515. * Add a MeshAssetTask to the list of active tasks
  151516. * @param taskName defines the name of the new task
  151517. * @param meshesNames defines the name of meshes to load
  151518. * @param rootUrl defines the root url to use to locate files
  151519. * @param sceneFilename defines the filename of the scene file
  151520. * @returns a new MeshAssetTask object
  151521. */
  151522. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  151523. /**
  151524. * Add a TextFileAssetTask to the list of active tasks
  151525. * @param taskName defines the name of the new task
  151526. * @param url defines the url of the file to load
  151527. * @returns a new TextFileAssetTask object
  151528. */
  151529. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  151530. /**
  151531. * Add a BinaryFileAssetTask to the list of active tasks
  151532. * @param taskName defines the name of the new task
  151533. * @param url defines the url of the file to load
  151534. * @returns a new BinaryFileAssetTask object
  151535. */
  151536. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  151537. /**
  151538. * Add a ImageAssetTask to the list of active tasks
  151539. * @param taskName defines the name of the new task
  151540. * @param url defines the url of the file to load
  151541. * @returns a new ImageAssetTask object
  151542. */
  151543. addImageTask(taskName: string, url: string): ImageAssetTask;
  151544. /**
  151545. * Add a TextureAssetTask to the list of active tasks
  151546. * @param taskName defines the name of the new task
  151547. * @param url defines the url of the file to load
  151548. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151549. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  151550. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151551. * @returns a new TextureAssetTask object
  151552. */
  151553. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  151554. /**
  151555. * Add a CubeTextureAssetTask to the list of active tasks
  151556. * @param taskName defines the name of the new task
  151557. * @param url defines the url of the file to load
  151558. * @param extensions defines the extension to use to load the cube map (can be null)
  151559. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151560. * @param files defines the list of files to load (can be null)
  151561. * @returns a new CubeTextureAssetTask object
  151562. */
  151563. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  151564. /**
  151565. *
  151566. * Add a HDRCubeTextureAssetTask to the list of active tasks
  151567. * @param taskName defines the name of the new task
  151568. * @param url defines the url of the file to load
  151569. * @param size defines the size you want for the cubemap (can be null)
  151570. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151571. * @param generateHarmonics defines if you want to automatically generate (true by default)
  151572. * @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)
  151573. * @param reserved Internal use only
  151574. * @returns a new HDRCubeTextureAssetTask object
  151575. */
  151576. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  151577. /**
  151578. *
  151579. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  151580. * @param taskName defines the name of the new task
  151581. * @param url defines the url of the file to load
  151582. * @param size defines the size you want for the cubemap (can be null)
  151583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151584. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151585. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151586. * @returns a new EquiRectangularCubeTextureAssetTask object
  151587. */
  151588. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  151589. /**
  151590. * Remove a task from the assets manager.
  151591. * @param task the task to remove
  151592. */
  151593. removeTask(task: AbstractAssetTask): void;
  151594. private _decreaseWaitingTasksCount;
  151595. private _runTask;
  151596. /**
  151597. * Reset the AssetsManager and remove all tasks
  151598. * @return the current instance of the AssetsManager
  151599. */
  151600. reset(): AssetsManager;
  151601. /**
  151602. * Start the loading process
  151603. * @return the current instance of the AssetsManager
  151604. */
  151605. load(): AssetsManager;
  151606. /**
  151607. * Start the loading process as an async operation
  151608. * @return a promise returning the list of failed tasks
  151609. */
  151610. loadAsync(): Promise<void>;
  151611. }
  151612. }
  151613. declare module BABYLON {
  151614. /**
  151615. * Wrapper class for promise with external resolve and reject.
  151616. */
  151617. export class Deferred<T> {
  151618. /**
  151619. * The promise associated with this deferred object.
  151620. */
  151621. readonly promise: Promise<T>;
  151622. private _resolve;
  151623. private _reject;
  151624. /**
  151625. * The resolve method of the promise associated with this deferred object.
  151626. */
  151627. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  151628. /**
  151629. * The reject method of the promise associated with this deferred object.
  151630. */
  151631. get reject(): (reason?: any) => void;
  151632. /**
  151633. * Constructor for this deferred object.
  151634. */
  151635. constructor();
  151636. }
  151637. }
  151638. declare module BABYLON {
  151639. /**
  151640. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  151641. */
  151642. export class MeshExploder {
  151643. private _centerMesh;
  151644. private _meshes;
  151645. private _meshesOrigins;
  151646. private _toCenterVectors;
  151647. private _scaledDirection;
  151648. private _newPosition;
  151649. private _centerPosition;
  151650. /**
  151651. * Explodes meshes from a center mesh.
  151652. * @param meshes The meshes to explode.
  151653. * @param centerMesh The mesh to be center of explosion.
  151654. */
  151655. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  151656. private _setCenterMesh;
  151657. /**
  151658. * Get class name
  151659. * @returns "MeshExploder"
  151660. */
  151661. getClassName(): string;
  151662. /**
  151663. * "Exploded meshes"
  151664. * @returns Array of meshes with the centerMesh at index 0.
  151665. */
  151666. getMeshes(): Array<Mesh>;
  151667. /**
  151668. * Explodes meshes giving a specific direction
  151669. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  151670. */
  151671. explode(direction?: number): void;
  151672. }
  151673. }
  151674. declare module BABYLON {
  151675. /**
  151676. * Class used to help managing file picking and drag'n'drop
  151677. */
  151678. export class FilesInput {
  151679. /**
  151680. * List of files ready to be loaded
  151681. */
  151682. static get FilesToLoad(): {
  151683. [key: string]: File;
  151684. };
  151685. /**
  151686. * Callback called when a file is processed
  151687. */
  151688. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  151689. private _engine;
  151690. private _currentScene;
  151691. private _sceneLoadedCallback;
  151692. private _progressCallback;
  151693. private _additionalRenderLoopLogicCallback;
  151694. private _textureLoadingCallback;
  151695. private _startingProcessingFilesCallback;
  151696. private _onReloadCallback;
  151697. private _errorCallback;
  151698. private _elementToMonitor;
  151699. private _sceneFileToLoad;
  151700. private _filesToLoad;
  151701. /**
  151702. * Creates a new FilesInput
  151703. * @param engine defines the rendering engine
  151704. * @param scene defines the hosting scene
  151705. * @param sceneLoadedCallback callback called when scene is loaded
  151706. * @param progressCallback callback called to track progress
  151707. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  151708. * @param textureLoadingCallback callback called when a texture is loading
  151709. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  151710. * @param onReloadCallback callback called when a reload is requested
  151711. * @param errorCallback callback call if an error occurs
  151712. */
  151713. 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>);
  151714. private _dragEnterHandler;
  151715. private _dragOverHandler;
  151716. private _dropHandler;
  151717. /**
  151718. * Calls this function to listen to drag'n'drop events on a specific DOM element
  151719. * @param elementToMonitor defines the DOM element to track
  151720. */
  151721. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  151722. /** Gets the current list of files to load */
  151723. get filesToLoad(): File[];
  151724. /**
  151725. * Release all associated resources
  151726. */
  151727. dispose(): void;
  151728. private renderFunction;
  151729. private drag;
  151730. private drop;
  151731. private _traverseFolder;
  151732. private _processFiles;
  151733. /**
  151734. * Load files from a drop event
  151735. * @param event defines the drop event to use as source
  151736. */
  151737. loadFiles(event: any): void;
  151738. private _processReload;
  151739. /**
  151740. * Reload the current scene from the loaded files
  151741. */
  151742. reload(): void;
  151743. }
  151744. }
  151745. declare module BABYLON {
  151746. /**
  151747. * Defines the root class used to create scene optimization to use with SceneOptimizer
  151748. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151749. */
  151750. export class SceneOptimization {
  151751. /**
  151752. * Defines the priority of this optimization (0 by default which means first in the list)
  151753. */
  151754. priority: number;
  151755. /**
  151756. * Gets a string describing the action executed by the current optimization
  151757. * @returns description string
  151758. */
  151759. getDescription(): string;
  151760. /**
  151761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151762. * @param scene defines the current scene where to apply this optimization
  151763. * @param optimizer defines the current optimizer
  151764. * @returns true if everything that can be done was applied
  151765. */
  151766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151767. /**
  151768. * Creates the SceneOptimization object
  151769. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151770. * @param desc defines the description associated with the optimization
  151771. */
  151772. constructor(
  151773. /**
  151774. * Defines the priority of this optimization (0 by default which means first in the list)
  151775. */
  151776. priority?: number);
  151777. }
  151778. /**
  151779. * Defines an optimization used to reduce the size of render target textures
  151780. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151781. */
  151782. export class TextureOptimization extends SceneOptimization {
  151783. /**
  151784. * Defines the priority of this optimization (0 by default which means first in the list)
  151785. */
  151786. priority: number;
  151787. /**
  151788. * 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
  151789. */
  151790. maximumSize: number;
  151791. /**
  151792. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151793. */
  151794. step: number;
  151795. /**
  151796. * Gets a string describing the action executed by the current optimization
  151797. * @returns description string
  151798. */
  151799. getDescription(): string;
  151800. /**
  151801. * Creates the TextureOptimization object
  151802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151803. * @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
  151804. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151805. */
  151806. constructor(
  151807. /**
  151808. * Defines the priority of this optimization (0 by default which means first in the list)
  151809. */
  151810. priority?: number,
  151811. /**
  151812. * 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
  151813. */
  151814. maximumSize?: number,
  151815. /**
  151816. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151817. */
  151818. step?: number);
  151819. /**
  151820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151821. * @param scene defines the current scene where to apply this optimization
  151822. * @param optimizer defines the current optimizer
  151823. * @returns true if everything that can be done was applied
  151824. */
  151825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151826. }
  151827. /**
  151828. * Defines an optimization used to increase or decrease the rendering resolution
  151829. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151830. */
  151831. export class HardwareScalingOptimization extends SceneOptimization {
  151832. /**
  151833. * Defines the priority of this optimization (0 by default which means first in the list)
  151834. */
  151835. priority: number;
  151836. /**
  151837. * Defines the maximum scale to use (2 by default)
  151838. */
  151839. maximumScale: number;
  151840. /**
  151841. * Defines the step to use between two passes (0.5 by default)
  151842. */
  151843. step: number;
  151844. private _currentScale;
  151845. private _directionOffset;
  151846. /**
  151847. * Gets a string describing the action executed by the current optimization
  151848. * @return description string
  151849. */
  151850. getDescription(): string;
  151851. /**
  151852. * Creates the HardwareScalingOptimization object
  151853. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151854. * @param maximumScale defines the maximum scale to use (2 by default)
  151855. * @param step defines the step to use between two passes (0.5 by default)
  151856. */
  151857. constructor(
  151858. /**
  151859. * Defines the priority of this optimization (0 by default which means first in the list)
  151860. */
  151861. priority?: number,
  151862. /**
  151863. * Defines the maximum scale to use (2 by default)
  151864. */
  151865. maximumScale?: number,
  151866. /**
  151867. * Defines the step to use between two passes (0.5 by default)
  151868. */
  151869. step?: number);
  151870. /**
  151871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151872. * @param scene defines the current scene where to apply this optimization
  151873. * @param optimizer defines the current optimizer
  151874. * @returns true if everything that can be done was applied
  151875. */
  151876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151877. }
  151878. /**
  151879. * Defines an optimization used to remove shadows
  151880. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151881. */
  151882. export class ShadowsOptimization extends SceneOptimization {
  151883. /**
  151884. * Gets a string describing the action executed by the current optimization
  151885. * @return description string
  151886. */
  151887. getDescription(): string;
  151888. /**
  151889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151890. * @param scene defines the current scene where to apply this optimization
  151891. * @param optimizer defines the current optimizer
  151892. * @returns true if everything that can be done was applied
  151893. */
  151894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151895. }
  151896. /**
  151897. * Defines an optimization used to turn post-processes off
  151898. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151899. */
  151900. export class PostProcessesOptimization extends SceneOptimization {
  151901. /**
  151902. * Gets a string describing the action executed by the current optimization
  151903. * @return description string
  151904. */
  151905. getDescription(): string;
  151906. /**
  151907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151908. * @param scene defines the current scene where to apply this optimization
  151909. * @param optimizer defines the current optimizer
  151910. * @returns true if everything that can be done was applied
  151911. */
  151912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151913. }
  151914. /**
  151915. * Defines an optimization used to turn lens flares off
  151916. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151917. */
  151918. export class LensFlaresOptimization extends SceneOptimization {
  151919. /**
  151920. * Gets a string describing the action executed by the current optimization
  151921. * @return description string
  151922. */
  151923. getDescription(): string;
  151924. /**
  151925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151926. * @param scene defines the current scene where to apply this optimization
  151927. * @param optimizer defines the current optimizer
  151928. * @returns true if everything that can be done was applied
  151929. */
  151930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151931. }
  151932. /**
  151933. * Defines an optimization based on user defined callback.
  151934. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151935. */
  151936. export class CustomOptimization extends SceneOptimization {
  151937. /**
  151938. * Callback called to apply the custom optimization.
  151939. */
  151940. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  151941. /**
  151942. * Callback called to get custom description
  151943. */
  151944. onGetDescription: () => string;
  151945. /**
  151946. * Gets a string describing the action executed by the current optimization
  151947. * @returns description string
  151948. */
  151949. getDescription(): string;
  151950. /**
  151951. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151952. * @param scene defines the current scene where to apply this optimization
  151953. * @param optimizer defines the current optimizer
  151954. * @returns true if everything that can be done was applied
  151955. */
  151956. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151957. }
  151958. /**
  151959. * Defines an optimization used to turn particles off
  151960. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151961. */
  151962. export class ParticlesOptimization extends SceneOptimization {
  151963. /**
  151964. * Gets a string describing the action executed by the current optimization
  151965. * @return description string
  151966. */
  151967. getDescription(): string;
  151968. /**
  151969. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151970. * @param scene defines the current scene where to apply this optimization
  151971. * @param optimizer defines the current optimizer
  151972. * @returns true if everything that can be done was applied
  151973. */
  151974. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151975. }
  151976. /**
  151977. * Defines an optimization used to turn render targets off
  151978. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151979. */
  151980. export class RenderTargetsOptimization extends SceneOptimization {
  151981. /**
  151982. * Gets a string describing the action executed by the current optimization
  151983. * @return description string
  151984. */
  151985. getDescription(): string;
  151986. /**
  151987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151988. * @param scene defines the current scene where to apply this optimization
  151989. * @param optimizer defines the current optimizer
  151990. * @returns true if everything that can be done was applied
  151991. */
  151992. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151993. }
  151994. /**
  151995. * Defines an optimization used to merge meshes with compatible materials
  151996. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151997. */
  151998. export class MergeMeshesOptimization extends SceneOptimization {
  151999. private static _UpdateSelectionTree;
  152000. /**
  152001. * Gets or sets a boolean which defines if optimization octree has to be updated
  152002. */
  152003. static get UpdateSelectionTree(): boolean;
  152004. /**
  152005. * Gets or sets a boolean which defines if optimization octree has to be updated
  152006. */
  152007. static set UpdateSelectionTree(value: boolean);
  152008. /**
  152009. * Gets a string describing the action executed by the current optimization
  152010. * @return description string
  152011. */
  152012. getDescription(): string;
  152013. private _canBeMerged;
  152014. /**
  152015. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152016. * @param scene defines the current scene where to apply this optimization
  152017. * @param optimizer defines the current optimizer
  152018. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  152019. * @returns true if everything that can be done was applied
  152020. */
  152021. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  152022. }
  152023. /**
  152024. * Defines a list of options used by SceneOptimizer
  152025. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152026. */
  152027. export class SceneOptimizerOptions {
  152028. /**
  152029. * Defines the target frame rate to reach (60 by default)
  152030. */
  152031. targetFrameRate: number;
  152032. /**
  152033. * Defines the interval between two checkes (2000ms by default)
  152034. */
  152035. trackerDuration: number;
  152036. /**
  152037. * Gets the list of optimizations to apply
  152038. */
  152039. optimizations: SceneOptimization[];
  152040. /**
  152041. * Creates a new list of options used by SceneOptimizer
  152042. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  152043. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  152044. */
  152045. constructor(
  152046. /**
  152047. * Defines the target frame rate to reach (60 by default)
  152048. */
  152049. targetFrameRate?: number,
  152050. /**
  152051. * Defines the interval between two checkes (2000ms by default)
  152052. */
  152053. trackerDuration?: number);
  152054. /**
  152055. * Add a new optimization
  152056. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  152057. * @returns the current SceneOptimizerOptions
  152058. */
  152059. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  152060. /**
  152061. * Add a new custom optimization
  152062. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  152063. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  152064. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152065. * @returns the current SceneOptimizerOptions
  152066. */
  152067. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  152068. /**
  152069. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  152070. * @param targetFrameRate defines the target frame rate (60 by default)
  152071. * @returns a SceneOptimizerOptions object
  152072. */
  152073. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152074. /**
  152075. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  152076. * @param targetFrameRate defines the target frame rate (60 by default)
  152077. * @returns a SceneOptimizerOptions object
  152078. */
  152079. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152080. /**
  152081. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  152082. * @param targetFrameRate defines the target frame rate (60 by default)
  152083. * @returns a SceneOptimizerOptions object
  152084. */
  152085. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152086. }
  152087. /**
  152088. * Class used to run optimizations in order to reach a target frame rate
  152089. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152090. */
  152091. export class SceneOptimizer implements IDisposable {
  152092. private _isRunning;
  152093. private _options;
  152094. private _scene;
  152095. private _currentPriorityLevel;
  152096. private _targetFrameRate;
  152097. private _trackerDuration;
  152098. private _currentFrameRate;
  152099. private _sceneDisposeObserver;
  152100. private _improvementMode;
  152101. /**
  152102. * Defines an observable called when the optimizer reaches the target frame rate
  152103. */
  152104. onSuccessObservable: Observable<SceneOptimizer>;
  152105. /**
  152106. * Defines an observable called when the optimizer enables an optimization
  152107. */
  152108. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  152109. /**
  152110. * Defines an observable called when the optimizer is not able to reach the target frame rate
  152111. */
  152112. onFailureObservable: Observable<SceneOptimizer>;
  152113. /**
  152114. * Gets a boolean indicating if the optimizer is in improvement mode
  152115. */
  152116. get isInImprovementMode(): boolean;
  152117. /**
  152118. * Gets the current priority level (0 at start)
  152119. */
  152120. get currentPriorityLevel(): number;
  152121. /**
  152122. * Gets the current frame rate checked by the SceneOptimizer
  152123. */
  152124. get currentFrameRate(): number;
  152125. /**
  152126. * Gets or sets the current target frame rate (60 by default)
  152127. */
  152128. get targetFrameRate(): number;
  152129. /**
  152130. * Gets or sets the current target frame rate (60 by default)
  152131. */
  152132. set targetFrameRate(value: number);
  152133. /**
  152134. * Gets or sets the current interval between two checks (every 2000ms by default)
  152135. */
  152136. get trackerDuration(): number;
  152137. /**
  152138. * Gets or sets the current interval between two checks (every 2000ms by default)
  152139. */
  152140. set trackerDuration(value: number);
  152141. /**
  152142. * Gets the list of active optimizations
  152143. */
  152144. get optimizations(): SceneOptimization[];
  152145. /**
  152146. * Creates a new SceneOptimizer
  152147. * @param scene defines the scene to work on
  152148. * @param options defines the options to use with the SceneOptimizer
  152149. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  152150. * @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)
  152151. */
  152152. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  152153. /**
  152154. * Stops the current optimizer
  152155. */
  152156. stop(): void;
  152157. /**
  152158. * Reset the optimizer to initial step (current priority level = 0)
  152159. */
  152160. reset(): void;
  152161. /**
  152162. * Start the optimizer. By default it will try to reach a specific framerate
  152163. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  152164. */
  152165. start(): void;
  152166. private _checkCurrentState;
  152167. /**
  152168. * Release all resources
  152169. */
  152170. dispose(): void;
  152171. /**
  152172. * Helper function to create a SceneOptimizer with one single line of code
  152173. * @param scene defines the scene to work on
  152174. * @param options defines the options to use with the SceneOptimizer
  152175. * @param onSuccess defines a callback to call on success
  152176. * @param onFailure defines a callback to call on failure
  152177. * @returns the new SceneOptimizer object
  152178. */
  152179. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  152180. }
  152181. }
  152182. declare module BABYLON {
  152183. /**
  152184. * Class used to serialize a scene into a string
  152185. */
  152186. export class SceneSerializer {
  152187. /**
  152188. * Clear cache used by a previous serialization
  152189. */
  152190. static ClearCache(): void;
  152191. /**
  152192. * Serialize a scene into a JSON compatible object
  152193. * @param scene defines the scene to serialize
  152194. * @returns a JSON compatible object
  152195. */
  152196. static Serialize(scene: Scene): any;
  152197. /**
  152198. * Serialize a mesh into a JSON compatible object
  152199. * @param toSerialize defines the mesh to serialize
  152200. * @param withParents defines if parents must be serialized as well
  152201. * @param withChildren defines if children must be serialized as well
  152202. * @returns a JSON compatible object
  152203. */
  152204. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  152205. }
  152206. }
  152207. declare module BABYLON {
  152208. /**
  152209. * Class used to host texture specific utilities
  152210. */
  152211. export class TextureTools {
  152212. /**
  152213. * Uses the GPU to create a copy texture rescaled at a given size
  152214. * @param texture Texture to copy from
  152215. * @param width defines the desired width
  152216. * @param height defines the desired height
  152217. * @param useBilinearMode defines if bilinear mode has to be used
  152218. * @return the generated texture
  152219. */
  152220. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  152221. }
  152222. }
  152223. declare module BABYLON {
  152224. /**
  152225. * This represents the different options available for the video capture.
  152226. */
  152227. export interface VideoRecorderOptions {
  152228. /** Defines the mime type of the video. */
  152229. mimeType: string;
  152230. /** Defines the FPS the video should be recorded at. */
  152231. fps: number;
  152232. /** Defines the chunk size for the recording data. */
  152233. recordChunckSize: number;
  152234. /** The audio tracks to attach to the recording. */
  152235. audioTracks?: MediaStreamTrack[];
  152236. }
  152237. /**
  152238. * This can help with recording videos from BabylonJS.
  152239. * This is based on the available WebRTC functionalities of the browser.
  152240. *
  152241. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  152242. */
  152243. export class VideoRecorder {
  152244. private static readonly _defaultOptions;
  152245. /**
  152246. * Returns whether or not the VideoRecorder is available in your browser.
  152247. * @param engine Defines the Babylon Engine.
  152248. * @returns true if supported otherwise false.
  152249. */
  152250. static IsSupported(engine: Engine): boolean;
  152251. private readonly _options;
  152252. private _canvas;
  152253. private _mediaRecorder;
  152254. private _recordedChunks;
  152255. private _fileName;
  152256. private _resolve;
  152257. private _reject;
  152258. /**
  152259. * True when a recording is already in progress.
  152260. */
  152261. get isRecording(): boolean;
  152262. /**
  152263. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  152264. * @param engine Defines the BabylonJS Engine you wish to record.
  152265. * @param options Defines options that can be used to customize the capture.
  152266. */
  152267. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  152268. /**
  152269. * Stops the current recording before the default capture timeout passed in the startRecording function.
  152270. */
  152271. stopRecording(): void;
  152272. /**
  152273. * Starts recording the canvas for a max duration specified in parameters.
  152274. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  152275. * If null no automatic download will start and you can rely on the promise to get the data back.
  152276. * @param maxDuration Defines the maximum recording time in seconds.
  152277. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  152278. * @return A promise callback at the end of the recording with the video data in Blob.
  152279. */
  152280. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  152281. /**
  152282. * Releases internal resources used during the recording.
  152283. */
  152284. dispose(): void;
  152285. private _handleDataAvailable;
  152286. private _handleError;
  152287. private _handleStop;
  152288. }
  152289. }
  152290. declare module BABYLON {
  152291. /**
  152292. * Class containing a set of static utilities functions for screenshots
  152293. */
  152294. export class ScreenshotTools {
  152295. /**
  152296. * Captures a screenshot of the current rendering
  152297. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152298. * @param engine defines the rendering engine
  152299. * @param camera defines the source camera
  152300. * @param size This parameter can be set to a single number or to an object with the
  152301. * following (optional) properties: precision, width, height. If a single number is passed,
  152302. * it will be used for both width and height. If an object is passed, the screenshot size
  152303. * will be derived from the parameters. The precision property is a multiplier allowing
  152304. * rendering at a higher or lower resolution
  152305. * @param successCallback defines the callback receives a single parameter which contains the
  152306. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152307. * src parameter of an <img> to display it
  152308. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152309. * Check your browser for supported MIME types
  152310. */
  152311. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  152312. /**
  152313. * Captures a screenshot of the current rendering
  152314. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152315. * @param engine defines the rendering engine
  152316. * @param camera defines the source camera
  152317. * @param size This parameter can be set to a single number or to an object with the
  152318. * following (optional) properties: precision, width, height. If a single number is passed,
  152319. * it will be used for both width and height. If an object is passed, the screenshot size
  152320. * will be derived from the parameters. The precision property is a multiplier allowing
  152321. * rendering at a higher or lower resolution
  152322. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152323. * Check your browser for supported MIME types
  152324. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152325. * to the src parameter of an <img> to display it
  152326. */
  152327. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  152328. /**
  152329. * Generates an image screenshot from the specified camera.
  152330. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152331. * @param engine The engine to use for rendering
  152332. * @param camera The camera to use for rendering
  152333. * @param size This parameter can be set to a single number or to an object with the
  152334. * following (optional) properties: precision, width, height. If a single number is passed,
  152335. * it will be used for both width and height. If an object is passed, the screenshot size
  152336. * will be derived from the parameters. The precision property is a multiplier allowing
  152337. * rendering at a higher or lower resolution
  152338. * @param successCallback The callback receives a single parameter which contains the
  152339. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152340. * src parameter of an <img> to display it
  152341. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152342. * Check your browser for supported MIME types
  152343. * @param samples Texture samples (default: 1)
  152344. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152345. * @param fileName A name for for the downloaded file.
  152346. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152347. */
  152348. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  152349. /**
  152350. * Generates an image screenshot from the specified camera.
  152351. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152352. * @param engine The engine to use for rendering
  152353. * @param camera The camera to use for rendering
  152354. * @param size This parameter can be set to a single number or to an object with the
  152355. * following (optional) properties: precision, width, height. If a single number is passed,
  152356. * it will be used for both width and height. If an object is passed, the screenshot size
  152357. * will be derived from the parameters. The precision property is a multiplier allowing
  152358. * rendering at a higher or lower resolution
  152359. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152360. * Check your browser for supported MIME types
  152361. * @param samples Texture samples (default: 1)
  152362. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152363. * @param fileName A name for for the downloaded file.
  152364. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152365. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152366. * to the src parameter of an <img> to display it
  152367. */
  152368. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  152369. /**
  152370. * Gets height and width for screenshot size
  152371. * @private
  152372. */
  152373. private static _getScreenshotSize;
  152374. }
  152375. }
  152376. declare module BABYLON {
  152377. /**
  152378. * Interface for a data buffer
  152379. */
  152380. export interface IDataBuffer {
  152381. /**
  152382. * Reads bytes from the data buffer.
  152383. * @param byteOffset The byte offset to read
  152384. * @param byteLength The byte length to read
  152385. * @returns A promise that resolves when the bytes are read
  152386. */
  152387. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  152388. /**
  152389. * The byte length of the buffer.
  152390. */
  152391. readonly byteLength: number;
  152392. }
  152393. /**
  152394. * Utility class for reading from a data buffer
  152395. */
  152396. export class DataReader {
  152397. /**
  152398. * The data buffer associated with this data reader.
  152399. */
  152400. readonly buffer: IDataBuffer;
  152401. /**
  152402. * The current byte offset from the beginning of the data buffer.
  152403. */
  152404. byteOffset: number;
  152405. private _dataView;
  152406. private _dataByteOffset;
  152407. /**
  152408. * Constructor
  152409. * @param buffer The buffer to read
  152410. */
  152411. constructor(buffer: IDataBuffer);
  152412. /**
  152413. * Loads the given byte length.
  152414. * @param byteLength The byte length to load
  152415. * @returns A promise that resolves when the load is complete
  152416. */
  152417. loadAsync(byteLength: number): Promise<void>;
  152418. /**
  152419. * Read a unsigned 32-bit integer from the currently loaded data range.
  152420. * @returns The 32-bit integer read
  152421. */
  152422. readUint32(): number;
  152423. /**
  152424. * Read a byte array from the currently loaded data range.
  152425. * @param byteLength The byte length to read
  152426. * @returns The byte array read
  152427. */
  152428. readUint8Array(byteLength: number): Uint8Array;
  152429. /**
  152430. * Read a string from the currently loaded data range.
  152431. * @param byteLength The byte length to read
  152432. * @returns The string read
  152433. */
  152434. readString(byteLength: number): string;
  152435. /**
  152436. * Skips the given byte length the currently loaded data range.
  152437. * @param byteLength The byte length to skip
  152438. */
  152439. skipBytes(byteLength: number): void;
  152440. }
  152441. }
  152442. declare module BABYLON {
  152443. /**
  152444. * Class for storing data to local storage if available or in-memory storage otherwise
  152445. */
  152446. export class DataStorage {
  152447. private static _Storage;
  152448. private static _GetStorage;
  152449. /**
  152450. * Reads a string from the data storage
  152451. * @param key The key to read
  152452. * @param defaultValue The value if the key doesn't exist
  152453. * @returns The string value
  152454. */
  152455. static ReadString(key: string, defaultValue: string): string;
  152456. /**
  152457. * Writes a string to the data storage
  152458. * @param key The key to write
  152459. * @param value The value to write
  152460. */
  152461. static WriteString(key: string, value: string): void;
  152462. /**
  152463. * Reads a boolean from the data storage
  152464. * @param key The key to read
  152465. * @param defaultValue The value if the key doesn't exist
  152466. * @returns The boolean value
  152467. */
  152468. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  152469. /**
  152470. * Writes a boolean to the data storage
  152471. * @param key The key to write
  152472. * @param value The value to write
  152473. */
  152474. static WriteBoolean(key: string, value: boolean): void;
  152475. /**
  152476. * Reads a number from the data storage
  152477. * @param key The key to read
  152478. * @param defaultValue The value if the key doesn't exist
  152479. * @returns The number value
  152480. */
  152481. static ReadNumber(key: string, defaultValue: number): number;
  152482. /**
  152483. * Writes a number to the data storage
  152484. * @param key The key to write
  152485. * @param value The value to write
  152486. */
  152487. static WriteNumber(key: string, value: number): void;
  152488. }
  152489. }
  152490. declare module BABYLON {
  152491. /**
  152492. * Class used to record delta files between 2 scene states
  152493. */
  152494. export class SceneRecorder {
  152495. private _trackedScene;
  152496. private _savedJSON;
  152497. /**
  152498. * Track a given scene. This means the current scene state will be considered the original state
  152499. * @param scene defines the scene to track
  152500. */
  152501. track(scene: Scene): void;
  152502. /**
  152503. * Get the delta between current state and original state
  152504. * @returns a string containing the delta
  152505. */
  152506. getDelta(): any;
  152507. private _compareArray;
  152508. private _compareObjects;
  152509. private _compareCollections;
  152510. private static GetShadowGeneratorById;
  152511. /**
  152512. * Apply a given delta to a given scene
  152513. * @param deltaJSON defines the JSON containing the delta
  152514. * @param scene defines the scene to apply the delta to
  152515. */
  152516. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  152517. private static _ApplyPropertiesToEntity;
  152518. private static _ApplyDeltaForEntity;
  152519. }
  152520. }
  152521. declare module BABYLON {
  152522. /**
  152523. * An interface for all Hit test features
  152524. */
  152525. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  152526. /**
  152527. * Triggered when new babylon (transformed) hit test results are available
  152528. */
  152529. onHitTestResultObservable: Observable<T[]>;
  152530. }
  152531. /**
  152532. * Options used for hit testing
  152533. */
  152534. export interface IWebXRLegacyHitTestOptions {
  152535. /**
  152536. * Only test when user interacted with the scene. Default - hit test every frame
  152537. */
  152538. testOnPointerDownOnly?: boolean;
  152539. /**
  152540. * The node to use to transform the local results to world coordinates
  152541. */
  152542. worldParentNode?: TransformNode;
  152543. }
  152544. /**
  152545. * Interface defining the babylon result of raycasting/hit-test
  152546. */
  152547. export interface IWebXRLegacyHitResult {
  152548. /**
  152549. * Transformation matrix that can be applied to a node that will put it in the hit point location
  152550. */
  152551. transformationMatrix: Matrix;
  152552. /**
  152553. * The native hit test result
  152554. */
  152555. xrHitResult: XRHitResult | XRHitTestResult;
  152556. }
  152557. /**
  152558. * The currently-working hit-test module.
  152559. * Hit test (or Ray-casting) is used to interact with the real world.
  152560. * For further information read here - https://github.com/immersive-web/hit-test
  152561. */
  152562. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  152563. /**
  152564. * options to use when constructing this feature
  152565. */
  152566. readonly options: IWebXRLegacyHitTestOptions;
  152567. private _direction;
  152568. private _mat;
  152569. private _onSelectEnabled;
  152570. private _origin;
  152571. /**
  152572. * The module's name
  152573. */
  152574. static readonly Name: string;
  152575. /**
  152576. * The (Babylon) version of this module.
  152577. * This is an integer representing the implementation version.
  152578. * This number does not correspond to the WebXR specs version
  152579. */
  152580. static readonly Version: number;
  152581. /**
  152582. * Populated with the last native XR Hit Results
  152583. */
  152584. lastNativeXRHitResults: XRHitResult[];
  152585. /**
  152586. * Triggered when new babylon (transformed) hit test results are available
  152587. */
  152588. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  152589. /**
  152590. * Creates a new instance of the (legacy version) hit test feature
  152591. * @param _xrSessionManager an instance of WebXRSessionManager
  152592. * @param options options to use when constructing this feature
  152593. */
  152594. constructor(_xrSessionManager: WebXRSessionManager,
  152595. /**
  152596. * options to use when constructing this feature
  152597. */
  152598. options?: IWebXRLegacyHitTestOptions);
  152599. /**
  152600. * execute a hit test with an XR Ray
  152601. *
  152602. * @param xrSession a native xrSession that will execute this hit test
  152603. * @param xrRay the ray (position and direction) to use for ray-casting
  152604. * @param referenceSpace native XR reference space to use for the hit-test
  152605. * @param filter filter function that will filter the results
  152606. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152607. */
  152608. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  152609. /**
  152610. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  152611. * @param event the (select) event to use to select with
  152612. * @param referenceSpace the reference space to use for this hit test
  152613. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152614. */
  152615. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152616. /**
  152617. * attach this feature
  152618. * Will usually be called by the features manager
  152619. *
  152620. * @returns true if successful.
  152621. */
  152622. attach(): boolean;
  152623. /**
  152624. * detach this feature.
  152625. * Will usually be called by the features manager
  152626. *
  152627. * @returns true if successful.
  152628. */
  152629. detach(): boolean;
  152630. /**
  152631. * Dispose this feature and all of the resources attached
  152632. */
  152633. dispose(): void;
  152634. protected _onXRFrame(frame: XRFrame): void;
  152635. private _onHitTestResults;
  152636. private _onSelect;
  152637. }
  152638. }
  152639. declare module BABYLON {
  152640. /**
  152641. * Options used for hit testing (version 2)
  152642. */
  152643. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  152644. /**
  152645. * Do not create a permanent hit test. Will usually be used when only
  152646. * transient inputs are needed.
  152647. */
  152648. disablePermanentHitTest?: boolean;
  152649. /**
  152650. * Enable transient (for example touch-based) hit test inspections
  152651. */
  152652. enableTransientHitTest?: boolean;
  152653. /**
  152654. * Offset ray for the permanent hit test
  152655. */
  152656. offsetRay?: Vector3;
  152657. /**
  152658. * Offset ray for the transient hit test
  152659. */
  152660. transientOffsetRay?: Vector3;
  152661. /**
  152662. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  152663. */
  152664. useReferenceSpace?: boolean;
  152665. }
  152666. /**
  152667. * Interface defining the babylon result of hit-test
  152668. */
  152669. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  152670. /**
  152671. * The input source that generated this hit test (if transient)
  152672. */
  152673. inputSource?: XRInputSource;
  152674. /**
  152675. * Is this a transient hit test
  152676. */
  152677. isTransient?: boolean;
  152678. /**
  152679. * Position of the hit test result
  152680. */
  152681. position: Vector3;
  152682. /**
  152683. * Rotation of the hit test result
  152684. */
  152685. rotationQuaternion: Quaternion;
  152686. /**
  152687. * The native hit test result
  152688. */
  152689. xrHitResult: XRHitTestResult;
  152690. }
  152691. /**
  152692. * The currently-working hit-test module.
  152693. * Hit test (or Ray-casting) is used to interact with the real world.
  152694. * For further information read here - https://github.com/immersive-web/hit-test
  152695. *
  152696. * Tested on chrome (mobile) 80.
  152697. */
  152698. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  152699. /**
  152700. * options to use when constructing this feature
  152701. */
  152702. readonly options: IWebXRHitTestOptions;
  152703. private _tmpMat;
  152704. private _tmpPos;
  152705. private _tmpQuat;
  152706. private _transientXrHitTestSource;
  152707. private _xrHitTestSource;
  152708. private initHitTestSource;
  152709. /**
  152710. * The module's name
  152711. */
  152712. static readonly Name: string;
  152713. /**
  152714. * The (Babylon) version of this module.
  152715. * This is an integer representing the implementation version.
  152716. * This number does not correspond to the WebXR specs version
  152717. */
  152718. static readonly Version: number;
  152719. /**
  152720. * When set to true, each hit test will have its own position/rotation objects
  152721. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  152722. * the developers will clone them or copy them as they see fit.
  152723. */
  152724. autoCloneTransformation: boolean;
  152725. /**
  152726. * Triggered when new babylon (transformed) hit test results are available
  152727. */
  152728. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  152729. /**
  152730. * Use this to temporarily pause hit test checks.
  152731. */
  152732. paused: boolean;
  152733. /**
  152734. * Creates a new instance of the hit test feature
  152735. * @param _xrSessionManager an instance of WebXRSessionManager
  152736. * @param options options to use when constructing this feature
  152737. */
  152738. constructor(_xrSessionManager: WebXRSessionManager,
  152739. /**
  152740. * options to use when constructing this feature
  152741. */
  152742. options?: IWebXRHitTestOptions);
  152743. /**
  152744. * attach this feature
  152745. * Will usually be called by the features manager
  152746. *
  152747. * @returns true if successful.
  152748. */
  152749. attach(): boolean;
  152750. /**
  152751. * detach this feature.
  152752. * Will usually be called by the features manager
  152753. *
  152754. * @returns true if successful.
  152755. */
  152756. detach(): boolean;
  152757. /**
  152758. * Dispose this feature and all of the resources attached
  152759. */
  152760. dispose(): void;
  152761. protected _onXRFrame(frame: XRFrame): void;
  152762. private _processWebXRHitTestResult;
  152763. }
  152764. }
  152765. declare module BABYLON {
  152766. /**
  152767. * Configuration options of the anchor system
  152768. */
  152769. export interface IWebXRAnchorSystemOptions {
  152770. /**
  152771. * a node that will be used to convert local to world coordinates
  152772. */
  152773. worldParentNode?: TransformNode;
  152774. /**
  152775. * If set to true a reference of the created anchors will be kept until the next session starts
  152776. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  152777. */
  152778. doNotRemoveAnchorsOnSessionEnded?: boolean;
  152779. }
  152780. /**
  152781. * A babylon container for an XR Anchor
  152782. */
  152783. export interface IWebXRAnchor {
  152784. /**
  152785. * A babylon-assigned ID for this anchor
  152786. */
  152787. id: number;
  152788. /**
  152789. * Transformation matrix to apply to an object attached to this anchor
  152790. */
  152791. transformationMatrix: Matrix;
  152792. /**
  152793. * The native anchor object
  152794. */
  152795. xrAnchor: XRAnchor;
  152796. /**
  152797. * if defined, this object will be constantly updated by the anchor's position and rotation
  152798. */
  152799. attachedNode?: TransformNode;
  152800. }
  152801. /**
  152802. * An implementation of the anchor system for WebXR.
  152803. * For further information see https://github.com/immersive-web/anchors/
  152804. */
  152805. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  152806. private _options;
  152807. private _lastFrameDetected;
  152808. private _trackedAnchors;
  152809. private _referenceSpaceForFrameAnchors;
  152810. private _futureAnchors;
  152811. /**
  152812. * The module's name
  152813. */
  152814. static readonly Name: string;
  152815. /**
  152816. * The (Babylon) version of this module.
  152817. * This is an integer representing the implementation version.
  152818. * This number does not correspond to the WebXR specs version
  152819. */
  152820. static readonly Version: number;
  152821. /**
  152822. * Observers registered here will be executed when a new anchor was added to the session
  152823. */
  152824. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  152825. /**
  152826. * Observers registered here will be executed when an anchor was removed from the session
  152827. */
  152828. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  152829. /**
  152830. * Observers registered here will be executed when an existing anchor updates
  152831. * This can execute N times every frame
  152832. */
  152833. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  152834. /**
  152835. * Set the reference space to use for anchor creation, when not using a hit test.
  152836. * Will default to the session's reference space if not defined
  152837. */
  152838. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  152839. /**
  152840. * constructs a new anchor system
  152841. * @param _xrSessionManager an instance of WebXRSessionManager
  152842. * @param _options configuration object for this feature
  152843. */
  152844. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  152845. private _tmpVector;
  152846. private _tmpQuaternion;
  152847. private _populateTmpTransformation;
  152848. /**
  152849. * Create a new anchor point using a hit test result at a specific point in the scene
  152850. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152851. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152852. *
  152853. * @param hitTestResult The hit test result to use for this anchor creation
  152854. * @param position an optional position offset for this anchor
  152855. * @param rotationQuaternion an optional rotation offset for this anchor
  152856. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152857. */
  152858. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  152859. /**
  152860. * Add a new anchor at a specific position and rotation
  152861. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  152862. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  152863. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152864. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152865. *
  152866. * @param position the position in which to add an anchor
  152867. * @param rotationQuaternion an optional rotation for the anchor transformation
  152868. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  152869. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152870. */
  152871. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  152872. /**
  152873. * detach this feature.
  152874. * Will usually be called by the features manager
  152875. *
  152876. * @returns true if successful.
  152877. */
  152878. detach(): boolean;
  152879. /**
  152880. * Dispose this feature and all of the resources attached
  152881. */
  152882. dispose(): void;
  152883. protected _onXRFrame(frame: XRFrame): void;
  152884. /**
  152885. * avoiding using Array.find for global support.
  152886. * @param xrAnchor the plane to find in the array
  152887. */
  152888. private _findIndexInAnchorArray;
  152889. private _updateAnchorWithXRFrame;
  152890. private _createAnchorAtTransformation;
  152891. }
  152892. }
  152893. declare module BABYLON {
  152894. /**
  152895. * Options used in the plane detector module
  152896. */
  152897. export interface IWebXRPlaneDetectorOptions {
  152898. /**
  152899. * The node to use to transform the local results to world coordinates
  152900. */
  152901. worldParentNode?: TransformNode;
  152902. /**
  152903. * If set to true a reference of the created planes will be kept until the next session starts
  152904. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  152905. */
  152906. doNotRemovePlanesOnSessionEnded?: boolean;
  152907. }
  152908. /**
  152909. * A babylon interface for a WebXR plane.
  152910. * A Plane is actually a polygon, built from N points in space
  152911. *
  152912. * Supported in chrome 79, not supported in canary 81 ATM
  152913. */
  152914. export interface IWebXRPlane {
  152915. /**
  152916. * a babylon-assigned ID for this polygon
  152917. */
  152918. id: number;
  152919. /**
  152920. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  152921. */
  152922. polygonDefinition: Array<Vector3>;
  152923. /**
  152924. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  152925. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  152926. */
  152927. transformationMatrix: Matrix;
  152928. /**
  152929. * the native xr-plane object
  152930. */
  152931. xrPlane: XRPlane;
  152932. }
  152933. /**
  152934. * The plane detector is used to detect planes in the real world when in AR
  152935. * For more information see https://github.com/immersive-web/real-world-geometry/
  152936. */
  152937. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  152938. private _options;
  152939. private _detectedPlanes;
  152940. private _enabled;
  152941. private _lastFrameDetected;
  152942. /**
  152943. * The module's name
  152944. */
  152945. static readonly Name: string;
  152946. /**
  152947. * The (Babylon) version of this module.
  152948. * This is an integer representing the implementation version.
  152949. * This number does not correspond to the WebXR specs version
  152950. */
  152951. static readonly Version: number;
  152952. /**
  152953. * Observers registered here will be executed when a new plane was added to the session
  152954. */
  152955. onPlaneAddedObservable: Observable<IWebXRPlane>;
  152956. /**
  152957. * Observers registered here will be executed when a plane is no longer detected in the session
  152958. */
  152959. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  152960. /**
  152961. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  152962. * This can execute N times every frame
  152963. */
  152964. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  152965. /**
  152966. * construct a new Plane Detector
  152967. * @param _xrSessionManager an instance of xr Session manager
  152968. * @param _options configuration to use when constructing this feature
  152969. */
  152970. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  152971. /**
  152972. * detach this feature.
  152973. * Will usually be called by the features manager
  152974. *
  152975. * @returns true if successful.
  152976. */
  152977. detach(): boolean;
  152978. /**
  152979. * Dispose this feature and all of the resources attached
  152980. */
  152981. dispose(): void;
  152982. protected _onXRFrame(frame: XRFrame): void;
  152983. private _init;
  152984. private _updatePlaneWithXRPlane;
  152985. /**
  152986. * avoiding using Array.find for global support.
  152987. * @param xrPlane the plane to find in the array
  152988. */
  152989. private findIndexInPlaneArray;
  152990. }
  152991. }
  152992. declare module BABYLON {
  152993. /**
  152994. * Options interface for the background remover plugin
  152995. */
  152996. export interface IWebXRBackgroundRemoverOptions {
  152997. /**
  152998. * Further background meshes to disable when entering AR
  152999. */
  153000. backgroundMeshes?: AbstractMesh[];
  153001. /**
  153002. * flags to configure the removal of the environment helper.
  153003. * If not set, the entire background will be removed. If set, flags should be set as well.
  153004. */
  153005. environmentHelperRemovalFlags?: {
  153006. /**
  153007. * Should the skybox be removed (default false)
  153008. */
  153009. skyBox?: boolean;
  153010. /**
  153011. * Should the ground be removed (default false)
  153012. */
  153013. ground?: boolean;
  153014. };
  153015. /**
  153016. * don't disable the environment helper
  153017. */
  153018. ignoreEnvironmentHelper?: boolean;
  153019. }
  153020. /**
  153021. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  153022. */
  153023. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  153024. /**
  153025. * read-only options to be used in this module
  153026. */
  153027. readonly options: IWebXRBackgroundRemoverOptions;
  153028. /**
  153029. * The module's name
  153030. */
  153031. static readonly Name: string;
  153032. /**
  153033. * The (Babylon) version of this module.
  153034. * This is an integer representing the implementation version.
  153035. * This number does not correspond to the WebXR specs version
  153036. */
  153037. static readonly Version: number;
  153038. /**
  153039. * registered observers will be triggered when the background state changes
  153040. */
  153041. onBackgroundStateChangedObservable: Observable<boolean>;
  153042. /**
  153043. * constructs a new background remover module
  153044. * @param _xrSessionManager the session manager for this module
  153045. * @param options read-only options to be used in this module
  153046. */
  153047. constructor(_xrSessionManager: WebXRSessionManager,
  153048. /**
  153049. * read-only options to be used in this module
  153050. */
  153051. options?: IWebXRBackgroundRemoverOptions);
  153052. /**
  153053. * attach this feature
  153054. * Will usually be called by the features manager
  153055. *
  153056. * @returns true if successful.
  153057. */
  153058. attach(): boolean;
  153059. /**
  153060. * detach this feature.
  153061. * Will usually be called by the features manager
  153062. *
  153063. * @returns true if successful.
  153064. */
  153065. detach(): boolean;
  153066. /**
  153067. * Dispose this feature and all of the resources attached
  153068. */
  153069. dispose(): void;
  153070. protected _onXRFrame(_xrFrame: XRFrame): void;
  153071. private _setBackgroundState;
  153072. }
  153073. }
  153074. declare module BABYLON {
  153075. /**
  153076. * Options for the controller physics feature
  153077. */
  153078. export class IWebXRControllerPhysicsOptions {
  153079. /**
  153080. * Should the headset get its own impostor
  153081. */
  153082. enableHeadsetImpostor?: boolean;
  153083. /**
  153084. * Optional parameters for the headset impostor
  153085. */
  153086. headsetImpostorParams?: {
  153087. /**
  153088. * The type of impostor to create. Default is sphere
  153089. */
  153090. impostorType: number;
  153091. /**
  153092. * the size of the impostor. Defaults to 10cm
  153093. */
  153094. impostorSize?: number | {
  153095. width: number;
  153096. height: number;
  153097. depth: number;
  153098. };
  153099. /**
  153100. * Friction definitions
  153101. */
  153102. friction?: number;
  153103. /**
  153104. * Restitution
  153105. */
  153106. restitution?: number;
  153107. };
  153108. /**
  153109. * The physics properties of the future impostors
  153110. */
  153111. physicsProperties?: {
  153112. /**
  153113. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  153114. * Note that this requires a physics engine that supports mesh impostors!
  153115. */
  153116. useControllerMesh?: boolean;
  153117. /**
  153118. * The type of impostor to create. Default is sphere
  153119. */
  153120. impostorType?: number;
  153121. /**
  153122. * the size of the impostor. Defaults to 10cm
  153123. */
  153124. impostorSize?: number | {
  153125. width: number;
  153126. height: number;
  153127. depth: number;
  153128. };
  153129. /**
  153130. * Friction definitions
  153131. */
  153132. friction?: number;
  153133. /**
  153134. * Restitution
  153135. */
  153136. restitution?: number;
  153137. };
  153138. /**
  153139. * the xr input to use with this pointer selection
  153140. */
  153141. xrInput: WebXRInput;
  153142. }
  153143. /**
  153144. * Add physics impostor to your webxr controllers,
  153145. * including naive calculation of their linear and angular velocity
  153146. */
  153147. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  153148. private readonly _options;
  153149. private _attachController;
  153150. private _controllers;
  153151. private _debugMode;
  153152. private _delta;
  153153. private _headsetImpostor?;
  153154. private _headsetMesh?;
  153155. private _lastTimestamp;
  153156. private _tmpQuaternion;
  153157. private _tmpVector;
  153158. /**
  153159. * The module's name
  153160. */
  153161. static readonly Name: string;
  153162. /**
  153163. * The (Babylon) version of this module.
  153164. * This is an integer representing the implementation version.
  153165. * This number does not correspond to the webxr specs version
  153166. */
  153167. static readonly Version: number;
  153168. /**
  153169. * Construct a new Controller Physics Feature
  153170. * @param _xrSessionManager the corresponding xr session manager
  153171. * @param _options options to create this feature with
  153172. */
  153173. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  153174. /**
  153175. * @hidden
  153176. * enable debugging - will show console outputs and the impostor mesh
  153177. */
  153178. _enablePhysicsDebug(): void;
  153179. /**
  153180. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  153181. * @param xrController the controller to add
  153182. */
  153183. addController(xrController: WebXRInputSource): void;
  153184. /**
  153185. * attach this feature
  153186. * Will usually be called by the features manager
  153187. *
  153188. * @returns true if successful.
  153189. */
  153190. attach(): boolean;
  153191. /**
  153192. * detach this feature.
  153193. * Will usually be called by the features manager
  153194. *
  153195. * @returns true if successful.
  153196. */
  153197. detach(): boolean;
  153198. /**
  153199. * Get the headset impostor, if enabled
  153200. * @returns the impostor
  153201. */
  153202. getHeadsetImpostor(): PhysicsImpostor | undefined;
  153203. /**
  153204. * Get the physics impostor of a specific controller.
  153205. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  153206. * @param controller the controller or the controller id of which to get the impostor
  153207. * @returns the impostor or null
  153208. */
  153209. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  153210. /**
  153211. * Update the physics properties provided in the constructor
  153212. * @param newProperties the new properties object
  153213. */
  153214. setPhysicsProperties(newProperties: {
  153215. impostorType?: number;
  153216. impostorSize?: number | {
  153217. width: number;
  153218. height: number;
  153219. depth: number;
  153220. };
  153221. friction?: number;
  153222. restitution?: number;
  153223. }): void;
  153224. protected _onXRFrame(_xrFrame: any): void;
  153225. private _detachController;
  153226. }
  153227. }
  153228. declare module BABYLON {
  153229. /**
  153230. * The motion controller class for all microsoft mixed reality controllers
  153231. */
  153232. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  153233. protected readonly _mapping: {
  153234. defaultButton: {
  153235. valueNodeName: string;
  153236. unpressedNodeName: string;
  153237. pressedNodeName: string;
  153238. };
  153239. defaultAxis: {
  153240. valueNodeName: string;
  153241. minNodeName: string;
  153242. maxNodeName: string;
  153243. };
  153244. buttons: {
  153245. "xr-standard-trigger": {
  153246. rootNodeName: string;
  153247. componentProperty: string;
  153248. states: string[];
  153249. };
  153250. "xr-standard-squeeze": {
  153251. rootNodeName: string;
  153252. componentProperty: string;
  153253. states: string[];
  153254. };
  153255. "xr-standard-touchpad": {
  153256. rootNodeName: string;
  153257. labelAnchorNodeName: string;
  153258. touchPointNodeName: string;
  153259. };
  153260. "xr-standard-thumbstick": {
  153261. rootNodeName: string;
  153262. componentProperty: string;
  153263. states: string[];
  153264. };
  153265. };
  153266. axes: {
  153267. "xr-standard-touchpad": {
  153268. "x-axis": {
  153269. rootNodeName: string;
  153270. };
  153271. "y-axis": {
  153272. rootNodeName: string;
  153273. };
  153274. };
  153275. "xr-standard-thumbstick": {
  153276. "x-axis": {
  153277. rootNodeName: string;
  153278. };
  153279. "y-axis": {
  153280. rootNodeName: string;
  153281. };
  153282. };
  153283. };
  153284. };
  153285. /**
  153286. * The base url used to load the left and right controller models
  153287. */
  153288. static MODEL_BASE_URL: string;
  153289. /**
  153290. * The name of the left controller model file
  153291. */
  153292. static MODEL_LEFT_FILENAME: string;
  153293. /**
  153294. * The name of the right controller model file
  153295. */
  153296. static MODEL_RIGHT_FILENAME: string;
  153297. profileId: string;
  153298. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153299. protected _getFilenameAndPath(): {
  153300. filename: string;
  153301. path: string;
  153302. };
  153303. protected _getModelLoadingConstraints(): boolean;
  153304. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153305. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153306. protected _updateModel(): void;
  153307. }
  153308. }
  153309. declare module BABYLON {
  153310. /**
  153311. * The motion controller class for oculus touch (quest, rift).
  153312. * This class supports legacy mapping as well the standard xr mapping
  153313. */
  153314. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  153315. private _forceLegacyControllers;
  153316. private _modelRootNode;
  153317. /**
  153318. * The base url used to load the left and right controller models
  153319. */
  153320. static MODEL_BASE_URL: string;
  153321. /**
  153322. * The name of the left controller model file
  153323. */
  153324. static MODEL_LEFT_FILENAME: string;
  153325. /**
  153326. * The name of the right controller model file
  153327. */
  153328. static MODEL_RIGHT_FILENAME: string;
  153329. /**
  153330. * Base Url for the Quest controller model.
  153331. */
  153332. static QUEST_MODEL_BASE_URL: string;
  153333. profileId: string;
  153334. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  153335. protected _getFilenameAndPath(): {
  153336. filename: string;
  153337. path: string;
  153338. };
  153339. protected _getModelLoadingConstraints(): boolean;
  153340. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153341. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153342. protected _updateModel(): void;
  153343. /**
  153344. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  153345. * between the touch and touch 2.
  153346. */
  153347. private _isQuest;
  153348. }
  153349. }
  153350. declare module BABYLON {
  153351. /**
  153352. * The motion controller class for the standard HTC-Vive controllers
  153353. */
  153354. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  153355. private _modelRootNode;
  153356. /**
  153357. * The base url used to load the left and right controller models
  153358. */
  153359. static MODEL_BASE_URL: string;
  153360. /**
  153361. * File name for the controller model.
  153362. */
  153363. static MODEL_FILENAME: string;
  153364. profileId: string;
  153365. /**
  153366. * Create a new Vive motion controller object
  153367. * @param scene the scene to use to create this controller
  153368. * @param gamepadObject the corresponding gamepad object
  153369. * @param handedness the handedness of the controller
  153370. */
  153371. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153372. protected _getFilenameAndPath(): {
  153373. filename: string;
  153374. path: string;
  153375. };
  153376. protected _getModelLoadingConstraints(): boolean;
  153377. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153378. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153379. protected _updateModel(): void;
  153380. }
  153381. }
  153382. declare module BABYLON {
  153383. /**
  153384. * A cursor which tracks a point on a path
  153385. */
  153386. export class PathCursor {
  153387. private path;
  153388. /**
  153389. * Stores path cursor callbacks for when an onchange event is triggered
  153390. */
  153391. private _onchange;
  153392. /**
  153393. * The value of the path cursor
  153394. */
  153395. value: number;
  153396. /**
  153397. * The animation array of the path cursor
  153398. */
  153399. animations: Animation[];
  153400. /**
  153401. * Initializes the path cursor
  153402. * @param path The path to track
  153403. */
  153404. constructor(path: Path2);
  153405. /**
  153406. * Gets the cursor point on the path
  153407. * @returns A point on the path cursor at the cursor location
  153408. */
  153409. getPoint(): Vector3;
  153410. /**
  153411. * Moves the cursor ahead by the step amount
  153412. * @param step The amount to move the cursor forward
  153413. * @returns This path cursor
  153414. */
  153415. moveAhead(step?: number): PathCursor;
  153416. /**
  153417. * Moves the cursor behind by the step amount
  153418. * @param step The amount to move the cursor back
  153419. * @returns This path cursor
  153420. */
  153421. moveBack(step?: number): PathCursor;
  153422. /**
  153423. * Moves the cursor by the step amount
  153424. * If the step amount is greater than one, an exception is thrown
  153425. * @param step The amount to move the cursor
  153426. * @returns This path cursor
  153427. */
  153428. move(step: number): PathCursor;
  153429. /**
  153430. * Ensures that the value is limited between zero and one
  153431. * @returns This path cursor
  153432. */
  153433. private ensureLimits;
  153434. /**
  153435. * Runs onchange callbacks on change (used by the animation engine)
  153436. * @returns This path cursor
  153437. */
  153438. private raiseOnChange;
  153439. /**
  153440. * Executes a function on change
  153441. * @param f A path cursor onchange callback
  153442. * @returns This path cursor
  153443. */
  153444. onchange(f: (cursor: PathCursor) => void): PathCursor;
  153445. }
  153446. }
  153447. declare module BABYLON {
  153448. /** @hidden */
  153449. export var blurPixelShader: {
  153450. name: string;
  153451. shader: string;
  153452. };
  153453. }
  153454. declare module BABYLON {
  153455. /** @hidden */
  153456. export var pointCloudVertexDeclaration: {
  153457. name: string;
  153458. shader: string;
  153459. };
  153460. }
  153461. // Mixins
  153462. interface Window {
  153463. mozIndexedDB: IDBFactory;
  153464. webkitIndexedDB: IDBFactory;
  153465. msIndexedDB: IDBFactory;
  153466. webkitURL: typeof URL;
  153467. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  153468. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  153469. WebGLRenderingContext: WebGLRenderingContext;
  153470. MSGesture: MSGesture;
  153471. CANNON: any;
  153472. AudioContext: AudioContext;
  153473. webkitAudioContext: AudioContext;
  153474. PointerEvent: any;
  153475. Math: Math;
  153476. Uint8Array: Uint8ArrayConstructor;
  153477. Float32Array: Float32ArrayConstructor;
  153478. mozURL: typeof URL;
  153479. msURL: typeof URL;
  153480. VRFrameData: any; // WebVR, from specs 1.1
  153481. DracoDecoderModule: any;
  153482. setImmediate(handler: (...args: any[]) => void): number;
  153483. }
  153484. interface HTMLCanvasElement {
  153485. requestPointerLock(): void;
  153486. msRequestPointerLock?(): void;
  153487. mozRequestPointerLock?(): void;
  153488. webkitRequestPointerLock?(): void;
  153489. /** Track wether a record is in progress */
  153490. isRecording: boolean;
  153491. /** Capture Stream method defined by some browsers */
  153492. captureStream(fps?: number): MediaStream;
  153493. }
  153494. interface CanvasRenderingContext2D {
  153495. msImageSmoothingEnabled: boolean;
  153496. }
  153497. interface MouseEvent {
  153498. mozMovementX: number;
  153499. mozMovementY: number;
  153500. webkitMovementX: number;
  153501. webkitMovementY: number;
  153502. msMovementX: number;
  153503. msMovementY: number;
  153504. }
  153505. interface Navigator {
  153506. mozGetVRDevices: (any: any) => any;
  153507. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153508. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153509. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153510. webkitGetGamepads(): Gamepad[];
  153511. msGetGamepads(): Gamepad[];
  153512. webkitGamepads(): Gamepad[];
  153513. }
  153514. interface HTMLVideoElement {
  153515. mozSrcObject: any;
  153516. }
  153517. interface Math {
  153518. fround(x: number): number;
  153519. imul(a: number, b: number): number;
  153520. }
  153521. interface WebGLRenderingContext {
  153522. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  153523. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  153524. vertexAttribDivisor(index: number, divisor: number): void;
  153525. createVertexArray(): any;
  153526. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  153527. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  153528. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  153529. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  153530. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  153531. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  153532. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  153533. // Queries
  153534. createQuery(): WebGLQuery;
  153535. deleteQuery(query: WebGLQuery): void;
  153536. beginQuery(target: number, query: WebGLQuery): void;
  153537. endQuery(target: number): void;
  153538. getQueryParameter(query: WebGLQuery, pname: number): any;
  153539. getQuery(target: number, pname: number): any;
  153540. MAX_SAMPLES: number;
  153541. RGBA8: number;
  153542. READ_FRAMEBUFFER: number;
  153543. DRAW_FRAMEBUFFER: number;
  153544. UNIFORM_BUFFER: number;
  153545. HALF_FLOAT_OES: number;
  153546. RGBA16F: number;
  153547. RGBA32F: number;
  153548. R32F: number;
  153549. RG32F: number;
  153550. RGB32F: number;
  153551. R16F: number;
  153552. RG16F: number;
  153553. RGB16F: number;
  153554. RED: number;
  153555. RG: number;
  153556. R8: number;
  153557. RG8: number;
  153558. UNSIGNED_INT_24_8: number;
  153559. DEPTH24_STENCIL8: number;
  153560. MIN: number;
  153561. MAX: number;
  153562. /* Multiple Render Targets */
  153563. drawBuffers(buffers: number[]): void;
  153564. readBuffer(src: number): void;
  153565. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  153566. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  153567. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  153568. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  153569. // Occlusion Query
  153570. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  153571. ANY_SAMPLES_PASSED: number;
  153572. QUERY_RESULT_AVAILABLE: number;
  153573. QUERY_RESULT: number;
  153574. }
  153575. interface WebGLProgram {
  153576. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  153577. }
  153578. interface EXT_disjoint_timer_query {
  153579. QUERY_COUNTER_BITS_EXT: number;
  153580. TIME_ELAPSED_EXT: number;
  153581. TIMESTAMP_EXT: number;
  153582. GPU_DISJOINT_EXT: number;
  153583. QUERY_RESULT_EXT: number;
  153584. QUERY_RESULT_AVAILABLE_EXT: number;
  153585. queryCounterEXT(query: WebGLQuery, target: number): void;
  153586. createQueryEXT(): WebGLQuery;
  153587. beginQueryEXT(target: number, query: WebGLQuery): void;
  153588. endQueryEXT(target: number): void;
  153589. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  153590. deleteQueryEXT(query: WebGLQuery): void;
  153591. }
  153592. interface WebGLUniformLocation {
  153593. _currentState: any;
  153594. }
  153595. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  153596. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  153597. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  153598. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153599. interface WebGLRenderingContext {
  153600. readonly RASTERIZER_DISCARD: number;
  153601. readonly DEPTH_COMPONENT24: number;
  153602. readonly TEXTURE_3D: number;
  153603. readonly TEXTURE_2D_ARRAY: number;
  153604. readonly TEXTURE_COMPARE_FUNC: number;
  153605. readonly TEXTURE_COMPARE_MODE: number;
  153606. readonly COMPARE_REF_TO_TEXTURE: number;
  153607. readonly TEXTURE_WRAP_R: number;
  153608. readonly HALF_FLOAT: number;
  153609. readonly RGB8: number;
  153610. readonly RED_INTEGER: number;
  153611. readonly RG_INTEGER: number;
  153612. readonly RGB_INTEGER: number;
  153613. readonly RGBA_INTEGER: number;
  153614. readonly R8_SNORM: number;
  153615. readonly RG8_SNORM: number;
  153616. readonly RGB8_SNORM: number;
  153617. readonly RGBA8_SNORM: number;
  153618. readonly R8I: number;
  153619. readonly RG8I: number;
  153620. readonly RGB8I: number;
  153621. readonly RGBA8I: number;
  153622. readonly R8UI: number;
  153623. readonly RG8UI: number;
  153624. readonly RGB8UI: number;
  153625. readonly RGBA8UI: number;
  153626. readonly R16I: number;
  153627. readonly RG16I: number;
  153628. readonly RGB16I: number;
  153629. readonly RGBA16I: number;
  153630. readonly R16UI: number;
  153631. readonly RG16UI: number;
  153632. readonly RGB16UI: number;
  153633. readonly RGBA16UI: number;
  153634. readonly R32I: number;
  153635. readonly RG32I: number;
  153636. readonly RGB32I: number;
  153637. readonly RGBA32I: number;
  153638. readonly R32UI: number;
  153639. readonly RG32UI: number;
  153640. readonly RGB32UI: number;
  153641. readonly RGBA32UI: number;
  153642. readonly RGB10_A2UI: number;
  153643. readonly R11F_G11F_B10F: number;
  153644. readonly RGB9_E5: number;
  153645. readonly RGB10_A2: number;
  153646. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  153647. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  153648. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  153649. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  153650. readonly DEPTH_COMPONENT32F: number;
  153651. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  153652. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  153653. 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;
  153654. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  153655. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  153656. readonly TRANSFORM_FEEDBACK: number;
  153657. readonly INTERLEAVED_ATTRIBS: number;
  153658. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  153659. createTransformFeedback(): WebGLTransformFeedback;
  153660. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  153661. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  153662. beginTransformFeedback(primitiveMode: number): void;
  153663. endTransformFeedback(): void;
  153664. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  153665. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153666. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153667. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153668. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  153669. }
  153670. interface ImageBitmap {
  153671. readonly width: number;
  153672. readonly height: number;
  153673. close(): void;
  153674. }
  153675. interface WebGLQuery extends WebGLObject {
  153676. }
  153677. declare var WebGLQuery: {
  153678. prototype: WebGLQuery;
  153679. new(): WebGLQuery;
  153680. };
  153681. interface WebGLSampler extends WebGLObject {
  153682. }
  153683. declare var WebGLSampler: {
  153684. prototype: WebGLSampler;
  153685. new(): WebGLSampler;
  153686. };
  153687. interface WebGLSync extends WebGLObject {
  153688. }
  153689. declare var WebGLSync: {
  153690. prototype: WebGLSync;
  153691. new(): WebGLSync;
  153692. };
  153693. interface WebGLTransformFeedback extends WebGLObject {
  153694. }
  153695. declare var WebGLTransformFeedback: {
  153696. prototype: WebGLTransformFeedback;
  153697. new(): WebGLTransformFeedback;
  153698. };
  153699. interface WebGLVertexArrayObject extends WebGLObject {
  153700. }
  153701. declare var WebGLVertexArrayObject: {
  153702. prototype: WebGLVertexArrayObject;
  153703. new(): WebGLVertexArrayObject;
  153704. };
  153705. // Type definitions for WebVR API
  153706. // Project: https://w3c.github.io/webvr/
  153707. // Definitions by: six a <https://github.com/lostfictions>
  153708. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153709. interface VRDisplay extends EventTarget {
  153710. /**
  153711. * Dictionary of capabilities describing the VRDisplay.
  153712. */
  153713. readonly capabilities: VRDisplayCapabilities;
  153714. /**
  153715. * z-depth defining the far plane of the eye view frustum
  153716. * enables mapping of values in the render target depth
  153717. * attachment to scene coordinates. Initially set to 10000.0.
  153718. */
  153719. depthFar: number;
  153720. /**
  153721. * z-depth defining the near plane of the eye view frustum
  153722. * enables mapping of values in the render target depth
  153723. * attachment to scene coordinates. Initially set to 0.01.
  153724. */
  153725. depthNear: number;
  153726. /**
  153727. * An identifier for this distinct VRDisplay. Used as an
  153728. * association point in the Gamepad API.
  153729. */
  153730. readonly displayId: number;
  153731. /**
  153732. * A display name, a user-readable name identifying it.
  153733. */
  153734. readonly displayName: string;
  153735. readonly isConnected: boolean;
  153736. readonly isPresenting: boolean;
  153737. /**
  153738. * If this VRDisplay supports room-scale experiences, the optional
  153739. * stage attribute contains details on the room-scale parameters.
  153740. */
  153741. readonly stageParameters: VRStageParameters | null;
  153742. /**
  153743. * Passing the value returned by `requestAnimationFrame` to
  153744. * `cancelAnimationFrame` will unregister the callback.
  153745. * @param handle Define the hanle of the request to cancel
  153746. */
  153747. cancelAnimationFrame(handle: number): void;
  153748. /**
  153749. * Stops presenting to the VRDisplay.
  153750. * @returns a promise to know when it stopped
  153751. */
  153752. exitPresent(): Promise<void>;
  153753. /**
  153754. * Return the current VREyeParameters for the given eye.
  153755. * @param whichEye Define the eye we want the parameter for
  153756. * @returns the eye parameters
  153757. */
  153758. getEyeParameters(whichEye: string): VREyeParameters;
  153759. /**
  153760. * Populates the passed VRFrameData with the information required to render
  153761. * the current frame.
  153762. * @param frameData Define the data structure to populate
  153763. * @returns true if ok otherwise false
  153764. */
  153765. getFrameData(frameData: VRFrameData): boolean;
  153766. /**
  153767. * Get the layers currently being presented.
  153768. * @returns the list of VR layers
  153769. */
  153770. getLayers(): VRLayer[];
  153771. /**
  153772. * Return a VRPose containing the future predicted pose of the VRDisplay
  153773. * when the current frame will be presented. The value returned will not
  153774. * change until JavaScript has returned control to the browser.
  153775. *
  153776. * The VRPose will contain the position, orientation, velocity,
  153777. * and acceleration of each of these properties.
  153778. * @returns the pose object
  153779. */
  153780. getPose(): VRPose;
  153781. /**
  153782. * Return the current instantaneous pose of the VRDisplay, with no
  153783. * prediction applied.
  153784. * @returns the current instantaneous pose
  153785. */
  153786. getImmediatePose(): VRPose;
  153787. /**
  153788. * The callback passed to `requestAnimationFrame` will be called
  153789. * any time a new frame should be rendered. When the VRDisplay is
  153790. * presenting the callback will be called at the native refresh
  153791. * rate of the HMD. When not presenting this function acts
  153792. * identically to how window.requestAnimationFrame acts. Content should
  153793. * make no assumptions of frame rate or vsync behavior as the HMD runs
  153794. * asynchronously from other displays and at differing refresh rates.
  153795. * @param callback Define the eaction to run next frame
  153796. * @returns the request handle it
  153797. */
  153798. requestAnimationFrame(callback: FrameRequestCallback): number;
  153799. /**
  153800. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  153801. * Repeat calls while already presenting will update the VRLayers being displayed.
  153802. * @param layers Define the list of layer to present
  153803. * @returns a promise to know when the request has been fulfilled
  153804. */
  153805. requestPresent(layers: VRLayer[]): Promise<void>;
  153806. /**
  153807. * Reset the pose for this display, treating its current position and
  153808. * orientation as the "origin/zero" values. VRPose.position,
  153809. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  153810. * updated when calling resetPose(). This should be called in only
  153811. * sitting-space experiences.
  153812. */
  153813. resetPose(): void;
  153814. /**
  153815. * The VRLayer provided to the VRDisplay will be captured and presented
  153816. * in the HMD. Calling this function has the same effect on the source
  153817. * canvas as any other operation that uses its source image, and canvases
  153818. * created without preserveDrawingBuffer set to true will be cleared.
  153819. * @param pose Define the pose to submit
  153820. */
  153821. submitFrame(pose?: VRPose): void;
  153822. }
  153823. declare var VRDisplay: {
  153824. prototype: VRDisplay;
  153825. new(): VRDisplay;
  153826. };
  153827. interface VRLayer {
  153828. leftBounds?: number[] | Float32Array | null;
  153829. rightBounds?: number[] | Float32Array | null;
  153830. source?: HTMLCanvasElement | null;
  153831. }
  153832. interface VRDisplayCapabilities {
  153833. readonly canPresent: boolean;
  153834. readonly hasExternalDisplay: boolean;
  153835. readonly hasOrientation: boolean;
  153836. readonly hasPosition: boolean;
  153837. readonly maxLayers: number;
  153838. }
  153839. interface VREyeParameters {
  153840. /** @deprecated */
  153841. readonly fieldOfView: VRFieldOfView;
  153842. readonly offset: Float32Array;
  153843. readonly renderHeight: number;
  153844. readonly renderWidth: number;
  153845. }
  153846. interface VRFieldOfView {
  153847. readonly downDegrees: number;
  153848. readonly leftDegrees: number;
  153849. readonly rightDegrees: number;
  153850. readonly upDegrees: number;
  153851. }
  153852. interface VRFrameData {
  153853. readonly leftProjectionMatrix: Float32Array;
  153854. readonly leftViewMatrix: Float32Array;
  153855. readonly pose: VRPose;
  153856. readonly rightProjectionMatrix: Float32Array;
  153857. readonly rightViewMatrix: Float32Array;
  153858. readonly timestamp: number;
  153859. }
  153860. interface VRPose {
  153861. readonly angularAcceleration: Float32Array | null;
  153862. readonly angularVelocity: Float32Array | null;
  153863. readonly linearAcceleration: Float32Array | null;
  153864. readonly linearVelocity: Float32Array | null;
  153865. readonly orientation: Float32Array | null;
  153866. readonly position: Float32Array | null;
  153867. readonly timestamp: number;
  153868. }
  153869. interface VRStageParameters {
  153870. sittingToStandingTransform?: Float32Array;
  153871. sizeX?: number;
  153872. sizeY?: number;
  153873. }
  153874. interface Navigator {
  153875. getVRDisplays(): Promise<VRDisplay[]>;
  153876. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  153877. }
  153878. interface Window {
  153879. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  153880. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  153881. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  153882. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153883. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153884. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  153885. }
  153886. interface Gamepad {
  153887. readonly displayId: number;
  153888. }
  153889. type XRSessionMode =
  153890. | "inline"
  153891. | "immersive-vr"
  153892. | "immersive-ar";
  153893. type XRReferenceSpaceType =
  153894. | "viewer"
  153895. | "local"
  153896. | "local-floor"
  153897. | "bounded-floor"
  153898. | "unbounded";
  153899. type XREnvironmentBlendMode =
  153900. | "opaque"
  153901. | "additive"
  153902. | "alpha-blend";
  153903. type XRVisibilityState =
  153904. | "visible"
  153905. | "visible-blurred"
  153906. | "hidden";
  153907. type XRHandedness =
  153908. | "none"
  153909. | "left"
  153910. | "right";
  153911. type XRTargetRayMode =
  153912. | "gaze"
  153913. | "tracked-pointer"
  153914. | "screen";
  153915. type XREye =
  153916. | "none"
  153917. | "left"
  153918. | "right";
  153919. type XREventType =
  153920. | "devicechange"
  153921. | "visibilitychange"
  153922. | "end"
  153923. | "inputsourceschange"
  153924. | "select"
  153925. | "selectstart"
  153926. | "selectend"
  153927. | "squeeze"
  153928. | "squeezestart"
  153929. | "squeezeend"
  153930. | "reset";
  153931. interface XRSpace extends EventTarget {
  153932. }
  153933. interface XRRenderState {
  153934. depthNear?: number;
  153935. depthFar?: number;
  153936. inlineVerticalFieldOfView?: number;
  153937. baseLayer?: XRWebGLLayer;
  153938. }
  153939. interface XRInputSource {
  153940. handedness: XRHandedness;
  153941. targetRayMode: XRTargetRayMode;
  153942. targetRaySpace: XRSpace;
  153943. gripSpace: XRSpace | undefined;
  153944. gamepad: Gamepad | undefined;
  153945. profiles: Array<string>;
  153946. }
  153947. interface XRSessionInit {
  153948. optionalFeatures?: string[];
  153949. requiredFeatures?: string[];
  153950. }
  153951. interface XRSession {
  153952. addEventListener: Function;
  153953. removeEventListener: Function;
  153954. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  153955. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  153956. requestAnimationFrame: Function;
  153957. end(): Promise<void>;
  153958. renderState: XRRenderState;
  153959. inputSources: Array<XRInputSource>;
  153960. // hit test
  153961. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  153962. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  153963. // legacy AR hit test
  153964. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153965. // legacy plane detection
  153966. updateWorldTrackingState(options: {
  153967. planeDetectionState?: { enabled: boolean; }
  153968. }): void;
  153969. }
  153970. interface XRReferenceSpace extends XRSpace {
  153971. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  153972. onreset: any;
  153973. }
  153974. type XRPlaneSet = Set<XRPlane>;
  153975. type XRAnchorSet = Set<XRAnchor>;
  153976. interface XRFrame {
  153977. session: XRSession;
  153978. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  153979. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  153980. // AR
  153981. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  153982. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  153983. // Anchors
  153984. trackedAnchors?: XRAnchorSet;
  153985. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  153986. // Planes
  153987. worldInformation: {
  153988. detectedPlanes?: XRPlaneSet;
  153989. };
  153990. }
  153991. interface XRViewerPose extends XRPose {
  153992. views: Array<XRView>;
  153993. }
  153994. interface XRPose {
  153995. transform: XRRigidTransform;
  153996. emulatedPosition: boolean;
  153997. }
  153998. interface XRWebGLLayerOptions {
  153999. antialias?: boolean;
  154000. depth?: boolean;
  154001. stencil?: boolean;
  154002. alpha?: boolean;
  154003. multiview?: boolean;
  154004. framebufferScaleFactor?: number;
  154005. }
  154006. declare var XRWebGLLayer: {
  154007. prototype: XRWebGLLayer;
  154008. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  154009. };
  154010. interface XRWebGLLayer {
  154011. framebuffer: WebGLFramebuffer;
  154012. framebufferWidth: number;
  154013. framebufferHeight: number;
  154014. getViewport: Function;
  154015. }
  154016. declare class XRRigidTransform {
  154017. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  154018. position: DOMPointReadOnly;
  154019. orientation: DOMPointReadOnly;
  154020. matrix: Float32Array;
  154021. inverse: XRRigidTransform;
  154022. }
  154023. interface XRView {
  154024. eye: XREye;
  154025. projectionMatrix: Float32Array;
  154026. transform: XRRigidTransform;
  154027. }
  154028. interface XRInputSourceChangeEvent {
  154029. session: XRSession;
  154030. removed: Array<XRInputSource>;
  154031. added: Array<XRInputSource>;
  154032. }
  154033. interface XRInputSourceEvent extends Event {
  154034. readonly frame: XRFrame;
  154035. readonly inputSource: XRInputSource;
  154036. }
  154037. // Experimental(er) features
  154038. declare class XRRay {
  154039. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  154040. origin: DOMPointReadOnly;
  154041. direction: DOMPointReadOnly;
  154042. matrix: Float32Array;
  154043. }
  154044. declare enum XRHitTestTrackableType {
  154045. "point",
  154046. "plane"
  154047. }
  154048. interface XRHitResult {
  154049. hitMatrix: Float32Array;
  154050. }
  154051. interface XRTransientInputHitTestResult {
  154052. readonly inputSource: XRInputSource;
  154053. readonly results: Array<XRHitTestResult>;
  154054. }
  154055. interface XRHitTestResult {
  154056. getPose(baseSpace: XRSpace): XRPose | undefined;
  154057. // When anchor system is enabled
  154058. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  154059. }
  154060. interface XRHitTestSource {
  154061. cancel(): void;
  154062. }
  154063. interface XRTransientInputHitTestSource {
  154064. cancel(): void;
  154065. }
  154066. interface XRHitTestOptionsInit {
  154067. space: XRSpace;
  154068. entityTypes?: Array<XRHitTestTrackableType>;
  154069. offsetRay?: XRRay;
  154070. }
  154071. interface XRTransientInputHitTestOptionsInit {
  154072. profile: string;
  154073. entityTypes?: Array<XRHitTestTrackableType>;
  154074. offsetRay?: XRRay;
  154075. }
  154076. interface XRAnchor {
  154077. anchorSpace: XRSpace;
  154078. delete(): void;
  154079. }
  154080. interface XRPlane {
  154081. orientation: "Horizontal" | "Vertical";
  154082. planeSpace: XRSpace;
  154083. polygon: Array<DOMPointReadOnly>;
  154084. lastChangedTime: number;
  154085. }